public ActionResult CancelTask(string id) { if (id != null) { TaskManagerClient client = new TaskManagerClient(); client.CancelTask(ObjectId.Parse(id)); return RedirectToAction("UserTasks", "Home"); } _logger.Trace("Task cancellation by ID"); return RedirectToAction("UserTasks", "Home"); }
public ActionResult DeleteTask(string id) { if (id == null) { _logger.Trace("Task deleting by ID: id == null" ); MessageOnPage msg = new MessageOnPage("Task ID is null"); return RedirectToAction("MessagePage", "Home", msg); } TaskManagerClient client = new TaskManagerClient(); client.CancelTask(ObjectId.Parse(id)); //If task is run we have to cancel it first var filter = Builders<GaTask>.Filter.Eq(s => s.Id, ObjectId.Parse(id)); _dbContext.CoursesCreatingTasks.DeleteOneAsync(filter); _logger.Trace("Task deleting by ID: "); return RedirectToAction("UserTasks", "Home"); }
protected void Page_Load(object sender, EventArgs e) { ContextBusClient cbClient = new ContextBusClient(); //Get Employee definition from adventure works: ConnectionParam[] parameters = cbClient.LoadConnection("advworks", AdvWorksConnectorId); cbClient.Login(parameters, AdvWorksConnectorId); FlyweightObjectDefinition flyweight = new FlyweightObjectDefinition() { Id = "HumanResources.Employee" }; ObjectDefinition employeeObjDef = cbClient.GetObjectDefinitionList(new FlyweightObjectDefinition[] { flyweight }, AdvWorksConnectorId).First(); //Get Team definition from Sharepoint parameters = cbClient.LoadConnection("Sharepoint-Team", "SharePoint"); cbClient.Login(parameters, "SharePoint"); flyweight = new FlyweightObjectDefinition() { Id = "SP|List|/sites/SiteCollection1|Team" }; ObjectDefinition sharepointObjDef = cbClient.GetObjectDefinitionList(new FlyweightObjectDefinition[] { flyweight }, "SharePoint").First(); //build the workflow. TaskManagerClient taskClient = new TaskManagerClient(); //1. Create login task LoginTask login = taskClient.CreateLoginTask(AdvWorksConnectorId, "advworks"); //2. Create Mapping Task MappingTask map = taskClient.CreateMappingTask(sharepointObjDef, employeeObjDef); MappableField field = map.TargetFields.SingleOrDefault(f => f.Id == "p.BusinessEntityID"); field.Mapping.MappingType = MappingType.ConstMapping; field.Mapping.Value = 1; field = map.TargetFields.SingleOrDefault(f => f.Id == "p.EmailPromotion"); field.Mapping.MappingType = MappingType.ConstMapping; field.Mapping.Value = 0; field = map.TargetFields.SingleOrDefault(f => f.Id == "p.Demographics"); field.Mapping.MappingType = MappingType.ConstMapping; field.Mapping.Value = ""; field = map.TargetFields.SingleOrDefault(f => f.Id == "p.NameStyle"); field.Mapping.MappingType = MappingType.ConstMapping; field.Mapping.Value = false; field = map.TargetFields.SingleOrDefault(f => f.Id == "p.PersonType"); field.Mapping.MappingType = MappingType.ConstMapping; field.Mapping.Value = "EM"; field = map.TargetFields.SingleOrDefault(f => f.Id == "p.FirstName"); field.Mapping.MappingType = MappingType.FieldMapping; field.Mapping.Value = "First_x0020_Name"; field = map.TargetFields.SingleOrDefault(f => f.Id == "p.LastName"); field.Mapping.MappingType = MappingType.FieldMapping; field.Mapping.Value = "Last_x0020_Name"; field = map.TargetFields.SingleOrDefault(f => f.Id == "e.JobTitle"); field.Mapping.MappingType = MappingType.FieldMapping; field.Mapping.Value = "Title"; //3. Save Task SaveObjectInstanceTask saveSharepointToEktron = taskClient.CreateSaveObjectTask(AdvWorksConnectorId); //4. Logout Task LogoutTask logout = taskClient.CreateLogoutTask(AdvWorksConnectorId); //5. Assemble and save workflow string workflowName = string.Concat("My Test Workflow"); Workflow workflow = taskClient.CreateWorkflow(workflowName); List<ContextBusTask> tasks = new List<ContextBusTask>(); tasks.Add(login); tasks.Add(map); tasks.Add(saveSharepointToEktron); tasks.Add(logout); workflow.Tasks = tasks.ToArray(); taskClient.SaveWorkflow(workflow); //3. Create associated Event Definitions for workflow. EventManagerClient eventClient = new EventManagerClient(); EventDefinition eventDef = new EventDefinition() { Id = workflowName, Payload = map.SourceObject }; eventClient.AssociateWorkflowsToEvent(new string[] { workflow.WorkflowName }, eventDef); // //Now raise the event to perform the workflow! // //first get sharpeoint item ObjectInstanceCriteriaFilter criteria = new ObjectInstanceCriteriaFilter(); criteria.Filters = new CriteriaFilter[0]; ObjectInstanceList sharepointObjInstance = cbClient.GetObjectInstanceList(sharepointObjDef, criteria, "SharePoint"); //create event instance with sharepoint item EventInstance itemEvent = new EventInstance() { Id = workflowName, Payload = sharepointObjInstance.Results.First() }; //raise the event. eventClient.RaiseEvent(itemEvent); }
public ActionResult NewTask(GaTask task) { if (ModelState.IsValid) { User currentUser = null; var obj = ViewData["CustomUser"]; if (obj != null) { currentUser = obj as User; } if (currentUser == null) { MessageOnPage msg = new MessageOnPage("Error with user identification"); return RedirectToAction("MessagePage", "Home", msg); } var loList = _dbContext.LOs.Find(x => true).ToListAsync().Result; task.SourceLearningObjects = new LearningObject[loList.Count]; for (int i = 0; i < loList.Count; i++) { task.SourceLearningObjects[i] = loList[i]; } task.CreatigTime = DateTime.Now; task.AuthorEmail = currentUser.Email; TaskManagerClient client = new TaskManagerClient(); client.TaskRunAsync(task); _logger.Trace("Course creating task launching."); return RedirectToAction("UserTasks", "Home"); } else { _logger.Trace("Course creating task launching. Attempt to launch. User is unregistered"); return View(task); } }
protected void Page_Load(object sender, EventArgs e) { ContextBusClient cbClient = new ContextBusClient(); //Get Employee definition from adventure works: ConnectionParam[] parameters = cbClient.LoadConnection("advworks", AdvWorksConnectorId); cbClient.Login(parameters, AdvWorksConnectorId); FlyweightObjectDefinition flyweight = new FlyweightObjectDefinition() { Id = "HumanResources.Employee" }; ObjectDefinition employeeObjDef = cbClient.GetObjectDefinitionList(new FlyweightObjectDefinition[] { flyweight }, AdvWorksConnectorId).First(); //Get Team definition from Sharepoint parameters = cbClient.LoadConnection("Sharepoint-Team", "SharePoint"); cbClient.Login(parameters, "SharePoint"); flyweight = new FlyweightObjectDefinition() { Id = "SP|List|/sites/SiteCollection1|Team" }; ObjectDefinition sharepointObjDef = cbClient.GetObjectDefinitionList(new FlyweightObjectDefinition[] { flyweight }, "SharePoint").First(); //build the workflow. TaskManagerClient taskClient = new TaskManagerClient(); //1. Create login task LoginTask login = taskClient.CreateLoginTask(AdvWorksConnectorId, "advworks"); //2. Create Mapping Task MappingTask map = taskClient.CreateMappingTask(sharepointObjDef, employeeObjDef); MappableField field = map.TargetFields.SingleOrDefault(f => f.Id == "p.BusinessEntityID"); field.Mapping.MappingType = MappingType.ConstMapping; field.Mapping.Value = 1; field = map.TargetFields.SingleOrDefault(f => f.Id == "p.EmailPromotion"); field.Mapping.MappingType = MappingType.ConstMapping; field.Mapping.Value = 0; field = map.TargetFields.SingleOrDefault(f => f.Id == "p.Demographics"); field.Mapping.MappingType = MappingType.ConstMapping; field.Mapping.Value = ""; field = map.TargetFields.SingleOrDefault(f => f.Id == "p.NameStyle"); field.Mapping.MappingType = MappingType.ConstMapping; field.Mapping.Value = false; field = map.TargetFields.SingleOrDefault(f => f.Id == "p.PersonType"); field.Mapping.MappingType = MappingType.ConstMapping; field.Mapping.Value = "EM"; field = map.TargetFields.SingleOrDefault(f => f.Id == "p.FirstName"); field.Mapping.MappingType = MappingType.FieldMapping; field.Mapping.Value = "First_x0020_Name"; field = map.TargetFields.SingleOrDefault(f => f.Id == "p.LastName"); field.Mapping.MappingType = MappingType.FieldMapping; field.Mapping.Value = "Last_x0020_Name"; field = map.TargetFields.SingleOrDefault(f => f.Id == "e.JobTitle"); field.Mapping.MappingType = MappingType.FieldMapping; field.Mapping.Value = "Title"; //3. Save Task SaveObjectInstanceTask saveSharepointToEktron = taskClient.CreateSaveObjectTask(AdvWorksConnectorId); //4. Logout Task LogoutTask logout = taskClient.CreateLogoutTask(AdvWorksConnectorId); //5. Assemble and save workflow string workflowName = string.Concat("My Test Workflow"); Workflow workflow = taskClient.CreateWorkflow(workflowName); List <ContextBusTask> tasks = new List <ContextBusTask>(); tasks.Add(login); tasks.Add(map); tasks.Add(saveSharepointToEktron); tasks.Add(logout); workflow.Tasks = tasks.ToArray(); taskClient.SaveWorkflow(workflow); //3. Create associated Event Definitions for workflow. EventManagerClient eventClient = new EventManagerClient(); EventDefinition eventDef = new EventDefinition() { Id = workflowName, Payload = map.SourceObject }; eventClient.AssociateWorkflowsToEvent(new string[] { workflow.WorkflowName }, eventDef); // //Now raise the event to perform the workflow! // //first get sharpeoint item ObjectInstanceCriteriaFilter criteria = new ObjectInstanceCriteriaFilter(); criteria.Filters = new CriteriaFilter[0]; ObjectInstanceList sharepointObjInstance = cbClient.GetObjectInstanceList(sharepointObjDef, criteria, "SharePoint"); //create event instance with sharepoint item EventInstance itemEvent = new EventInstance() { Id = workflowName, Payload = sharepointObjInstance.Results.First() }; //raise the event. eventClient.RaiseEvent(itemEvent); }
public ActionResult CourseCompiler(GaTask gaTask) { if (ModelState.IsValid) { var client = new TaskManagerClient(); client.TaskRun(gaTask); return View("UserTasks"); } return View(gaTask); }
protected void Page_Load(object sender, EventArgs e) { ContextBusClient cbClient = new ContextBusClient(); ConnectionParam[] parameters = cbClient.LoadConnection("Advworks", AdvWorksConnectorId); cbClient.Login(parameters, AdvWorksConnectorId); FlyweightObjectDefinition[] flyweights = cbClient.GetObjectDefinitionNameList(AdvWorksConnectorId); lvObjects.DataSource = flyweights; lvObjects.DataBind(); List<ObjectDefinition> objDefList = cbClient.GetObjectDefinitionList(flyweights, AdvWorksConnectorId).ToList(); ObjectInstanceCriteriaFilter criteria = new ObjectInstanceCriteriaFilter(); ObjectInstanceList objectInstanceReturn = cbClient.GetObjectInstanceList(objDefList.First(), criteria, AdvWorksConnectorId); lvObjectInstances.DataSource = objectInstanceReturn.Results; lvObjectInstances.DataBind(); //Lets map a sharepoint object to AdventureWorks //Get Sharepoint ObjectDefinition FlyweightObjectDefinition flyweight = new FlyweightObjectDefinition() { Id = "SP|List|/sites/SiteCollection1|Team"}; ObjectDefinition sharepointObjDef= cbClient.GetObjectDefinitionList(new FlyweightObjectDefinition[] { flyweight }, "SharePoint").First(); //Get Employee definition from adventure works: ObjectDefinition employeeObjDef = objDefList.Find(d => d.DisplayName == "Employee"); //build the workflow. TaskManagerClient taskClient = new TaskManagerClient(); //1. Create login task LoginTask login = taskClient.CreateLoginTask(AdvWorksConnectorId, ""); //2. Create Mapping Task MappingTask map = taskClient.CreateMappingTask(sharepointObjDef, employeeObjDef); MappableField field = map.TargetFields.SingleOrDefault(f => f.Id == "BusinessEntityID"); field.Mapping.MappingType = MappingType.ConstMapping; field.Mapping.Value = 1; field = map.TargetFields.SingleOrDefault(f => f.Id == "PersonType"); field.Mapping.MappingType = MappingType.ConstMapping; field.Mapping.Value = "EM"; field = map.TargetFields.SingleOrDefault(f => f.Id == "FirstName"); field.Mapping.MappingType = MappingType.FieldMapping; field.Mapping.Value = map.SourceObject.Fields.SingleOrDefault(f => f.Id == "First_x0020_Name"); field = map.TargetFields.SingleOrDefault(f => f.Id == "LastName"); field.Mapping.MappingType = MappingType.FieldMapping; field.Mapping.Value = map.SourceObject.Fields.SingleOrDefault(f => f.Id == "last_x0020_name"); field = map.TargetFields.SingleOrDefault(f => f.Id == "JobTitle"); field.Mapping.MappingType = MappingType.FieldMapping; field.Mapping.Value = map.SourceObject.Fields.SingleOrDefault(f => f.Id == "Title"); //3. Save Task SaveObjectInstanceTask saveSharepointToEktron = taskClient.CreateSaveObjectTask(AdvWorksConnectorId); //4. Logout Task LogoutTask logout = taskClient.CreateLogoutTask(AdvWorksConnectorId); }
protected void Page_Load(object sender, EventArgs e) { ContextBusClient cbClient = new ContextBusClient(); ConnectionParam[] parameters = cbClient.LoadConnection("Advworks", AdvWorksConnectorId); cbClient.Login(parameters, AdvWorksConnectorId); FlyweightObjectDefinition[] flyweights = cbClient.GetObjectDefinitionNameList(AdvWorksConnectorId); lvObjects.DataSource = flyweights; lvObjects.DataBind(); List <ObjectDefinition> objDefList = cbClient.GetObjectDefinitionList(flyweights, AdvWorksConnectorId).ToList(); ObjectInstanceCriteriaFilter criteria = new ObjectInstanceCriteriaFilter(); ObjectInstanceList objectInstanceReturn = cbClient.GetObjectInstanceList(objDefList.First(), criteria, AdvWorksConnectorId); lvObjectInstances.DataSource = objectInstanceReturn.Results; lvObjectInstances.DataBind(); //Lets map a sharepoint object to AdventureWorks //Get Sharepoint ObjectDefinition FlyweightObjectDefinition flyweight = new FlyweightObjectDefinition() { Id = "SP|List|/sites/SiteCollection1|Team" }; ObjectDefinition sharepointObjDef = cbClient.GetObjectDefinitionList(new FlyweightObjectDefinition[] { flyweight }, "SharePoint").First(); //Get Employee definition from adventure works: ObjectDefinition employeeObjDef = objDefList.Find(d => d.DisplayName == "Employee"); //build the workflow. TaskManagerClient taskClient = new TaskManagerClient(); //1. Create login task LoginTask login = taskClient.CreateLoginTask(AdvWorksConnectorId, ""); //2. Create Mapping Task MappingTask map = taskClient.CreateMappingTask(sharepointObjDef, employeeObjDef); MappableField field = map.TargetFields.SingleOrDefault(f => f.Id == "BusinessEntityID"); field.Mapping.MappingType = MappingType.ConstMapping; field.Mapping.Value = 1; field = map.TargetFields.SingleOrDefault(f => f.Id == "PersonType"); field.Mapping.MappingType = MappingType.ConstMapping; field.Mapping.Value = "EM"; field = map.TargetFields.SingleOrDefault(f => f.Id == "FirstName"); field.Mapping.MappingType = MappingType.FieldMapping; field.Mapping.Value = map.SourceObject.Fields.SingleOrDefault(f => f.Id == "First_x0020_Name"); field = map.TargetFields.SingleOrDefault(f => f.Id == "LastName"); field.Mapping.MappingType = MappingType.FieldMapping; field.Mapping.Value = map.SourceObject.Fields.SingleOrDefault(f => f.Id == "last_x0020_name"); field = map.TargetFields.SingleOrDefault(f => f.Id == "JobTitle"); field.Mapping.MappingType = MappingType.FieldMapping; field.Mapping.Value = map.SourceObject.Fields.SingleOrDefault(f => f.Id == "Title"); //3. Save Task SaveObjectInstanceTask saveSharepointToEktron = taskClient.CreateSaveObjectTask(AdvWorksConnectorId); //4. Logout Task LogoutTask logout = taskClient.CreateLogoutTask(AdvWorksConnectorId); }
private static void LoadManagerFromFile(FrmMain uiform) { IFormatter formatter = new BinaryFormatter(); try { Stream stream = new FileStream("SlowAndSteadyParser.store", FileMode.Open, FileAccess.Read, FileShare.Read); try { LocalStorage store = (LocalStorage)formatter.Deserialize(stream); ms_tmc = store.CurrentTaskManager; DomainManager.DomainList = store.DomainList; ms_c = store.Configuration; } catch (SerializationException e) { log.Warn("本地数据文件格式错误", e); } finally { stream.Close(); } } catch (System.IO.FileNotFoundException e) { log.Warn("未找到本地数据文件", e); } finally { if (ms_tmc == null) ms_tmc = new TaskManagerClient(); RecheckConfiguration(); SetConfigurationToServerInfo(); SetConfigurationToManager(); SetConfigurationToPerformanceBalancer(); SetConfigurationToADSL(); } }
public void ImportListToFolder(string ektronConnectionId, string sharepointConnectionId, long folderId, MappingTask map, bool isDeleteallowed, int languageid) { Log.WriteVerbose(string.Format(BeginLogMessage, CLASS_NAME, "ImportListToFolder(string ektronConnectionId, string sharepointConnectionId, string objectDefinitionId, long folderId, List<ObjectInstance> objectinstancelist, Dictionary<string, string> SharePointFieldToMetaId = null)")); TaskManagerClient taskClient = new TaskManagerClient(); EventManagerClient eventClient = new EventManagerClient(); string workflowName = string.Empty; if (isDeleteallowed) workflowName = string.Concat("SharepointDeleteAllowed|Ektron|", map.SourceObject.Id, "|", folderId, "|ListDependant;" + languageid); else workflowName = string.Concat("Sharepoint|Ektron|", map.SourceObject.Id, "|", folderId, "|ListDependant;" + languageid); //check workflow and delete if it already exists. DxhWorkflow workflow = taskClient.GetWorkflow(workflowName); if (workflow != null) { taskClient.DeleteWorkflow(workflowName); } //1. Create workflow tasks LoginTask login = taskClient.CreateLoginTask("Ektron", ektronConnectionId); SaveObjectInstanceTask saveSharepointToEktron = taskClient.CreateSaveObjectTask("Ektron"); LogoutTask logout = taskClient.CreateLogoutTask("Ektron"); //2. Assemble and save workflow workflow = taskClient.CreateWorkflow(workflowName); ((ICollection<ContextBusTask>)workflow.Tasks).Add(login); ((ICollection<ContextBusTask>)workflow.Tasks).Add(map); ((ICollection<ContextBusTask>)workflow.Tasks).Add(saveSharepointToEktron); ((ICollection<ContextBusTask>)workflow.Tasks).Add(logout); taskClient.SaveWorkflow(workflow); DxHUtils.SaveMapping(AdapterName, sharepointConnectionId, map, workflow, Ektron.Cms.Common.EkEnumeration.CMSObjectTypes.Folder, folderId, "", languageid); //3. Create associated Event Defintions for workflow. EventDefinition eventDef = new EventDefinition() { Id = workflowName, Payload = map.SourceObject }; eventClient.AssociateWorkflowsToEvent(new List<string> { workflow.WorkflowName }, eventDef); if (this.GetListType(map.SourceObject.Id).ToLower() == "list") { eventDef = new EventDefinition() { Id = string.Concat("SP|List|SPReceiverEvent|", this.GetSiteUrlandListTitle(map.SourceObject.Id)), Payload = map.SourceObject }; eventClient.AssociateWorkflowsToEvent(new List<string> { workflow.WorkflowName }, eventDef); eventDef = new EventDefinition() { Id = string.Concat("SP|ListItemAttachment|SPReceiverEvent|", this.GetSiteUrlandListTitle(map.SourceObject.Id)), Payload = map.SourceObject }; eventClient.AssociateWorkflowsToEvent(new List<string> { workflow.WorkflowName }, eventDef); } else if (this.GetListType(map.SourceObject.Id).ToLower() == "documentlibrary") { eventDef = new EventDefinition() { Id = string.Concat("SP|DocumentLibrary|SPReceiverEvent|", this.GetSiteUrlandListTitle(map.SourceObject.Id)), Payload = map.SourceObject }; eventClient.AssociateWorkflowsToEvent(new List<string> { workflow.WorkflowName }, eventDef); } if (isDeleteallowed) { string deleteworkflowname = string.Concat("SharepointDelete|Ektron|", map.SourceObject.Id, "|", folderId, "|ListDependant;" + languageid); DxhWorkflow deleteworkflow = taskClient.GetWorkflow(deleteworkflowname); if (deleteworkflow != null) { taskClient.DeleteWorkflow(deleteworkflowname); } // Create Delete Workflow Tasks LoginTask deletelogin = taskClient.CreateLoginTask("Ektron", ektronConnectionId); DeleteObjectInstanceTask deleteObjecttask = taskClient.CreateDeleteObjectTask("Ektron"); LogoutTask deletelogout = taskClient.CreateLogoutTask("Ektron"); //Assemble the Workflow deleteworkflow = taskClient.CreateWorkflow(deleteworkflowname); ((ICollection<ContextBusTask>)deleteworkflow.Tasks).Add(deletelogin); ((ICollection<ContextBusTask>)deleteworkflow.Tasks).Add(map); ((ICollection<ContextBusTask>)deleteworkflow.Tasks).Add(deleteObjecttask); ((ICollection<ContextBusTask>)deleteworkflow.Tasks).Add(deletelogout); taskClient.SaveWorkflow(deleteworkflow); eventDef = new EventDefinition() { Id = string.Concat("SPReceiverEvent|Delete|", this.GetSiteUrlandListTitle(map.SourceObject.Id)), Payload = map.SourceObject }; eventClient.AssociateWorkflowsToEvent(new List<string> { deleteworkflow.WorkflowName }, eventDef); } ////4. Retrieve Sharepoint items and raise event for each one. SharePointClientImportHelper.GetInstance().StartImport(sharepointConnectionId, AdapterName, workflowName, map.SourceObject); Log.WriteVerbose(string.Format(FinishLogMessage, CLASS_NAME, "ImportListToFolder(string ektronConnectionId, string sharepointConnectionId, string objectDefinitionId, long folderId, List<ObjectInstance> objectinstancelist, Dictionary<string, string> SharePointFieldToMetaId = null)")); }
public void ImportItemsToFolderWithOutListDependency(string ektronConnectionId, string sharepointConnectionId, string objectDefinitionId, long folderId, ConcurrentDictionary<int, MappingTask> listIdWithMappingTask, bool isDeleteallowed, int languageid) { Log.WriteVerbose(string.Format(BeginLogMessage, CLASS_NAME, "ImportItemsToFolderWithOutListDependency(string ektronConnectionId, string sharepointConnectionId, string objectDefinitionId, long folderId, IEnumerable<int> objectsharepointIdList)")); foreach (var listAndMapping in listIdWithMappingTask) { List<ObjectInstance> objectinstancelist = this.GetFilteredObjectInstanceList(sharepointConnectionId, listAndMapping.Value.SourceObject, new List<int>() { listAndMapping.Key }); TaskManagerClient taskClient = new TaskManagerClient(); EventManagerClient eventClient = new EventManagerClient(); foreach (ObjectInstance item in objectinstancelist) { string id = item.Fields.Single(p => p.Id.ToLower().Equals("id")).Value.ToString(); string workflowName = string.Empty; if (isDeleteallowed) workflowName = string.Concat("SharepointDeleteAllowed|Ektron|", objectDefinitionId, "|", folderId, "|ItemDependant|" + id + ";" + languageid); else workflowName = string.Concat("Sharepoint|Ektron|", objectDefinitionId, "|", folderId, "|ItemDependant|" + id + ";" + languageid); //check workflow and delete if it already exists. DxhWorkflow workflow = taskClient.GetWorkflow(workflowName); if (workflow != null) { taskClient.DeleteWorkflow(workflowName); } //1. Create workflow tasks LoginTask login = taskClient.CreateLoginTask("Ektron", ektronConnectionId); SaveObjectInstanceTask saveSharepointToEktron = taskClient.CreateSaveObjectTask("Ektron"); LogoutTask logout = taskClient.CreateLogoutTask("Ektron"); //2. Assemble and save workflow workflow = taskClient.CreateWorkflow(workflowName); ((ICollection<ContextBusTask>)workflow.Tasks).Add(login); ((ICollection<ContextBusTask>)workflow.Tasks).Add(listAndMapping.Value); ((ICollection<ContextBusTask>)workflow.Tasks).Add(saveSharepointToEktron); ((ICollection<ContextBusTask>)workflow.Tasks).Add(logout); taskClient.SaveWorkflow(workflow); DxHUtils.SaveMapping(AdapterName, sharepointConnectionId, listAndMapping.Value, workflow, Ektron.Cms.Common.EkEnumeration.CMSObjectTypes.Folder, folderId, "", languageid); //3. Create associated Event Defintions for workflow. EventDefinition eventDef = new EventDefinition() { Id = workflowName, Payload = listAndMapping.Value.SourceObject }; eventClient.AssociateWorkflowsToEvent(new List<string> { workflow.WorkflowName }, eventDef); if (this.GetListType(objectDefinitionId).ToLower() == "list") { eventDef = new EventDefinition() { Id = string.Concat("SP|List|SPReceiverEvent|", this.GetSiteUrlandListTitle(objectDefinitionId)), Payload = listAndMapping.Value.SourceObject }; eventClient.AssociateWorkflowsToEvent(new List<string> { workflow.WorkflowName }, eventDef); eventDef = new EventDefinition() { Id = string.Concat("SP|ListItemAttachment|SPReceiverEvent|", this.GetSiteUrlandListTitle(objectDefinitionId)), Payload = listAndMapping.Value.SourceObject }; eventClient.AssociateWorkflowsToEvent(new List<string> { workflow.WorkflowName }, eventDef); } else if (this.GetListType(objectDefinitionId).ToLower() == "documentlibrary") { eventDef = new EventDefinition() { Id = string.Concat("SP|DocumentLibrary|SPReceiverEvent|", this.GetSiteUrlandListTitle(objectDefinitionId)), Payload = listAndMapping.Value.SourceObject }; eventClient.AssociateWorkflowsToEvent(new List<string> { workflow.WorkflowName }, eventDef); } if (isDeleteallowed) { string deleteworkflowname = string.Concat("SharepointDelete|Ektron|", objectDefinitionId, "|", folderId, "|ItemDependant|" + id + ";" + languageid); DxhWorkflow deleteworkflow = taskClient.GetWorkflow(deleteworkflowname); if (deleteworkflow != null) { taskClient.DeleteWorkflow(deleteworkflowname); } // Create Delete Workflow Tasks LoginTask deletelogin = taskClient.CreateLoginTask("Ektron", ektronConnectionId); DeleteObjectInstanceTask deleteObjecttask = taskClient.CreateDeleteObjectTask("Ektron"); LogoutTask deletelogout = taskClient.CreateLogoutTask("Ektron"); //Assemble the Workflow deleteworkflow = taskClient.CreateWorkflow(deleteworkflowname); ((ICollection<ContextBusTask>)deleteworkflow.Tasks).Add(deletelogin); ((ICollection<ContextBusTask>)deleteworkflow.Tasks).Add(listAndMapping.Value); ((ICollection<ContextBusTask>)deleteworkflow.Tasks).Add(deleteObjecttask); ((ICollection<ContextBusTask>)deleteworkflow.Tasks).Add(deletelogout); taskClient.SaveWorkflow(deleteworkflow); eventDef = new EventDefinition() { Id = string.Concat("SPReceiverEvent|Delete|", this.GetSiteUrlandListTitle(objectDefinitionId)), Payload = listAndMapping.Value.SourceObject }; eventClient.AssociateWorkflowsToEvent(new List<string> { deleteworkflow.WorkflowName }, eventDef); } item.Fields.Where(p => p.Id.Equals("DxHSource")).FirstOrDefault().Value = "FromEktron"; EventInstance itemEvent = new EventInstance() { Id = workflowName, Payload = item }; eventClient.RaiseEvent(itemEvent); } Log.WriteVerbose(string.Format(FinishLogMessage, CLASS_NAME, "ImportItemsToFolderWithOutListDependency(string ektronConnectionId, string sharepointConnectionId, string objectDefinitionId, long folderId, IEnumerable<int> objectsharepointIdList)")); } }