public override void DoAction(BaseSolution solution) { ActionStarted(); DynamicsSolution ds = (DynamicsSolution)solution; ds.Service.SetFieldPermission(FieldSecurityProfileId, EntityName, AttributeName, CanRead, CanCreate, CanUpdate); ActionCompleted(); }
public override void DoAction(BaseSolution solution) { ActionStarted(); DynamicsSolution ds = (DynamicsSolution)solution; ds.ImportSolution(); ActionCompleted(); }
public override void DoAction(BaseSolution solution) { ActionStarted(); DynamicsSolution ds = (DynamicsSolution)solution; RetrievePrivilegeSetResponse r; //AddPrivilegesRoleRequest apr = new AddPrivilegesRoleRequest(); //apr.Privileges[0] = new RolePrivilege() // ds.Service.SetFieldPermission(FieldSecurityProfileId, EntityName, AttributeName, CanRead, CanCreate, CanUpdate); ActionCompleted(); }
public override void DoAction(BaseSolution solution) { ActionStarted(); DynamicsSolution ds = (DynamicsSolution)solution; var results = ds.Service.Service.RetrieveMultiple(new FetchExpression(UnescapeXML(XML))); var list = results.Entities.ToList(); var json = ItAintBoring.EZChange.Core.Dynamics.Common.SerializeEntityList(list, ((DynamicsSolution)solution).GuidShift); ds.SaveActionData(this, json); ActionCompleted(); }
public override void DoAction(BaseSolution solution) { ActionStarted(); DynamicsSolution ds = (DynamicsSolution)solution; try { ds.Service.SetMessageStepStatus(StepName, Activate); } catch (Exception ex) { throw new Exception("Error setting SDK step status " + Name + ". " + ex.Message); } ActionCompleted(); }
public override void DoAction(BaseSolution solution) { ActionStarted(); DynamicsSolution ds = (DynamicsSolution)solution; if (!String.IsNullOrEmpty(FetchXml) && !String.IsNullOrEmpty(WorkflowId)) { var results = ds.Service.Service.RetrieveMultiple(new FetchExpression(FetchXml)); foreach (var r in results.Entities) { ExecuteWorkflowRequest ewr = new ExecuteWorkflowRequest(); ewr.EntityId = r.Id; ewr.WorkflowId = Guid.Parse(WorkflowId); ds.Service.Service.Execute(ewr); } } ActionCompleted(); }
public override void DoAction(BaseSolution solution) { ActionStarted(); var exportAction = Solution.Package.FindAction(ExportActionId); DynamicsSolution ds = (DynamicsSolution)solution; string json = ds.LoadActionData(this, ds.GetActionFileName(exportAction, null)); if (json != null) { try { var list = ItAintBoring.EZChange.Core.Dynamics.Common.DeSerializeEntityList(ds.Service.Service, json, ((DynamicsSolution)solution).GuidShift); ds.Service.DeserializeData(list, CreateOnly); } catch (Exception ex) { throw new Exception("Error deserializing data for " + Name + ". " + ex.Message); } } ActionCompleted(); }
public override void DoAction(BaseSolution solution) { ActionStarted(); DynamicsSolution ds = (DynamicsSolution)solution; if (!String.IsNullOrEmpty(FetchXml)) { var results = ds.Service.Service.RetrieveMultiple(new FetchExpression(FetchXml)); foreach (Entity r in results.Entities) { var activateRequest = new SetStateRequest { EntityMoniker = r.ToEntityReference(), State = new OptionSetValue(0), Status = new OptionSetValue(1) }; LogInfo("Deactivating process: " + r.Id.ToString()); ds.Service.Service.Execute(activateRequest); } } ActionCompleted(); }
public override void DoAction(BaseSolution solution) { ActionStarted(); DynamicsSolution ds = (DynamicsSolution)solution; ds.Service.PublishAll(); XmlDocument doc = new XmlDocument(); doc.LoadXml(XML); var actions = doc.GetElementsByTagName("action"); foreach (XmlNode a in actions) { try { switch (a.Attributes["target"].Value) { case "attribute": DeleteAttributeRequest dar = new DeleteAttributeRequest(); dar.EntityLogicalName = a.Attributes["entity"].Value; dar.LogicalName = a.Attributes["attribute"].Value; ds.Service.Service.Execute(dar); break; case "entity": DeleteEntityRequest der = new DeleteEntityRequest(); der.LogicalName = a.Attributes["entity"].Value; ds.Service.Service.Execute(der); break; case "pluginstep": break; case "plugin": break; case "businessrule": case "workflow": try { SetStateRequest deactivateRequest = new SetStateRequest { EntityMoniker = new EntityReference("workflow", Guid.Parse(a.Attributes["recordid"].Value)), State = new OptionSetValue(0), Status = new OptionSetValue(1) }; ds.Service.Service.Execute(deactivateRequest); ds.Service.Service.Delete("workflow", Guid.Parse(a.Attributes["recordid"].Value)); } catch (Exception ex) { if (!ex.Message.ToUpper().Contains(a.Attributes["recordid"].Value.ToUpper())) { throw; } //Ignore if the ID is there - likely "does not exist" error //May need an extra attribute to decide if to ignore or not } break; case "webresource": ds.Service.Service.Delete("webresrouce", Guid.Parse(a.Attributes["recordid"].Value)); break; case "record": ds.Service.Service.Delete(a.Attributes["entity"].Value, Guid.Parse(a.Attributes["recordid"].Value)); break; case "globaloptionset": ds.Service.Service.Execute(new DeleteOptionSetRequest { Name = a.Attributes["name"].Value }); break; case "globaloptionsetvalue": ds.Service.Service.Execute(new DeleteOptionValueRequest { OptionSetName = a.Attributes["name"].Value, Value = int.Parse(a.Attributes["value"].Value) }); break; case "optionsetvalue": ds.Service.Service.Execute(new DeleteOptionValueRequest { EntityLogicalName = a.Attributes["entity"].Value, AttributeLogicalName = a.Attributes["attribute"].Value, Value = int.Parse(a.Attributes["value"].Value) }); break; } } catch (Exception ex) { if (ex.Message.ToLower().Contains("could not find") || ex.Message.ToLower().Contains("does not exist")) { if (a.Attributes["errorIfMissing"] == null || a.Attributes["errorIfMissing"].Value == "true") { throw; } } else { throw; } } } ActionCompleted(); }
public override void DoAction(BaseSolution solution) { ActionStarted(); DynamicsSolution ds = (DynamicsSolution)solution; ds.Service.PublishAll(); if (!String.IsNullOrEmpty(FetchXml) && !String.IsNullOrEmpty(WorkflowId)) { // get all lines of fetch var fetchLines = FetchXml.Split('<'); //replace first line <fetch.... with <fetch {0}> for (int i = 0; i < fetchLines.Length; i++) { if (fetchLines[i].Contains("fetch")) { fetchLines[i] = "fetch {0}>"; break; } } FetchXml = String.Join("<", fetchLines); bool moreRecords; int page = 1; string cookie = string.Empty; int totalRecords = 0; int batch = 1000;//int.Parse(ConfigurationManager.AppSettings["batch"]); ExecuteMultipleRequest emr = new ExecuteMultipleRequest() { Requests = new OrganizationRequestCollection(), Settings = new ExecuteMultipleSettings() { ContinueOnError = false, ReturnResponses = false } }; do { var xml = string.Format(FetchXml, cookie); var results = ds.Service.Service.RetrieveMultiple(new FetchExpression(xml)); totalRecords += results.Entities.Count; foreach (var r in results.Entities) { if (emr.Requests.Count == batch) { ds.Service.Service.Execute(emr); emr = new ExecuteMultipleRequest() { Requests = new OrganizationRequestCollection(), Settings = new ExecuteMultipleSettings() { ContinueOnError = false, ReturnResponses = false } }; } emr.Requests.Add(new ExecuteWorkflowRequest { EntityId = r.Id, WorkflowId = Guid.Parse(WorkflowId) }); } if (emr.Requests.Any()) { ds.Service.Service.Execute(emr); emr = new ExecuteMultipleRequest() { Requests = new OrganizationRequestCollection(), Settings = new ExecuteMultipleSettings() { ContinueOnError = false, ReturnResponses = false } }; } moreRecords = results.MoreRecords; if (moreRecords) { page++; cookie = string.Format("paging-cookie='{0}' page='{1}'", System.Security.SecurityElement.Escape(results.PagingCookie), page); } }while (moreRecords); LogInfo($"Processed {totalRecords} records"); } ActionCompleted(); }