Step 2: Create a Repository and Map the Data Source to the Repository
- Last UpdatedJun 10, 2024
- 2 minute read
The below code creates a repository entry, during creation of repository only the default data source providers can be configured. To set the custom data source provider we need to update the repository which will be done later.
PROCEDURE
The AssemblyResolve (System.AppDomain.CurrentDomain.AssemblyResolve) event, reference and namespace used in the previous example [Step 1: Create Data Source for the Repository] are required in this sample as well.
Try the following code in a console application:
HandleSkeltaFarm handlerSkeltaFarm = new HandleSkeltaFarm();
HandleSkeltaFarm.RepositoryDetails repositoryDetails = new HandleSkeltaFarm.RepositoryDetails();
repositoryDetails.Name = "Telematics HR Repository";
repositoryDetails.Description = "Telematics HR Process Repository";
repositoryDetails.DisplayName = "Telematics HR Repository";
// Name of the data source created in the previous step
repositoryDetails.Datasource = "SkeltaDatasource";
repositoryDetails.IsHidden = false;
repositoryDetails.Sourceelements = "WORKFLOWELEMENTS\\Default";
//Enter the email id to which exception emails must be sent.
//These exception emails will be generated from the engine when the activity execution fails.
repositoryDetails.Fromemail = "admin@domain.com";
repositoryDetails.Toemail = "admin@domain.com";
repositoryDetails.Alertuser = true;
// Select servers and repository mapping.
Dictionary<Guid, Server> serversmapped = new Dictionary<Guid, Server>();
// To select all servers/clients of current farm,
// ServerCollection servers = new ServerCollection(Farm.Local);
// To select servers only
ServerCollection servers = new ServerCollection(Farm.Local);
foreach (Server server in servers.Items)
serversmapped.Add(server.Id, server);
repositoryDetails.ServersMapped = serversmapped;
List<Guid> enterpriseConsoles = new List<Guid>();
// This code returns all EnterpriseConsole sites in the Farm.
// Ignore this part if you have not installed enterprise consoles.
WebSiteCollection websites = new WebSiteCollection("EC");
foreach (WebSite website in websites.Items)
enterpriseConsoles.Add(website.Id);
repositoryDetails.EnterpriseConsoles = enterpriseConsoles;
repositoryDetails.Provider = HandleSkeltaFarm.RepositoryProviders.SkeltaList;
handlerSkeltaFarm.RepositorySettings = repositoryDetails;
handlerSkeltaFarm.ManageRepository();
Verification:
The above code creates a repository named Telematics HR Repository. The entry in Farm DB can be verified in the database by running the query Select * from SKRepository Where Name=Telematics HR Repository'. The same can be verified in the Enterprise Console repository list page.