static public BaseSolution CreateSolution(BaseSolution solutionDescription) { BaseSolution result = (BaseSolution)Activator.CreateInstance(solutionDescription.GetType()); result.Name = solutionDescription.Id; return(result); }
protected void OnStepped(BaseSolution <double> solution, int step) { if (Stepped != null) { Stepped(solution, step); } }
protected void OnSolutionUpdated(BaseSolution <double> best_solution, int step) { if (SolutionUpdated != null) { SolutionUpdated(best_solution, step); } }
public override void DoAction(BaseSolution solution) { ActionStarted(); DynamicsSolution ds = (DynamicsSolution)solution; ds.Service.SetFieldPermission(FieldSecurityProfileId, EntityName, AttributeName, CanRead, CanCreate, CanUpdate); ActionCompleted(); }
public override void SetDefaults(Projectile projectile) { if (projectile.modProjectile != null && projectile.modProjectile is BaseSolution) { BaseSolution bs = projectile.modProjectile as BaseSolution; bs.toChange = true; } }
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(); string path = ((DynamicsSolution)solution).GetActionsDataFolder(this); System.IO.Directory.CreateDirectory(path); System.IO.File.Copy(FileName, System.IO.Path.Combine(path, System.IO.Path.GetFileName(FileName))); 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(); }
static public List <BaseAction> GetActionList(BaseSolution sln) { if (actionList == null) { GetActionList(); } List <BaseAction> result = new List <BaseAction>(); foreach (var x in actionList) { if (x.SupportedSolutionTypes.IndexOf(sln.GetType()) > -1) { result.Add(x); } } return(result); }
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 bool PreAI(Projectile projectile) { if (projectile.modProjectile != null && projectile.modProjectile is BaseSolution) { BaseSolution bs = projectile.modProjectile as BaseSolution; if (bs.toChange) { SolutionsPlayer p = Main.player[projectile.owner].GetModPlayer <SolutionsPlayer>(); if (p.solTimesFour) { bs.maxTime *= 4; } if (p.solTimesTwo) { bs.maxTime *= 2; } if (p.solTimesOneThird) { bs.maxTime /= 3; } if (p.solTimesOneFifth) { bs.maxTime /= 5; } projectile.timeLeft = bs.maxTime; if (p.solRadiusDouble) { bs.radius *= 2; } if (p.solRadiusHalf) { bs.radius /= 2; } if (p.lightless) { bs.dustType = dustToLightless[bs.dustType]; } bs.toChange = false; } } return(base.PreAI(projectile)); }
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(); }
private void NewSolution() { ItemSelector selector = new ItemSelector(); selector.Initialize(SolutionFactory.GetSolutionList(Package).ToList <object>(), "Solution Type"); if (selector.ShowIfMultiple() == DialogResult.OK && selector.SelectedItem != null) { BaseSolution sln = SolutionFactory.CreateSolution((BaseSolution)selector.SelectedItem); sln.Package = Package; ComponentControl ac = new ComponentControl(); ac.Setup(sln, "Solution Properties"); if (ac.ShowDialog() == DialogResult.OK) { ac.UpdateComponent(sln); Package.HasUnsavedChanges = true; Package.Solutions.Add(sln); lbSolutions.Items.Add(sln); lbSolutions.SelectedIndex = lbSolutions.Items.Count - 1; ResetActions(); } } }
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 virtual string XML { get; set; } virtual public void DoAction(BaseSolution solution) { }
public FSPSolution(BaseSolution origin) : base(origin) { }
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(); }
public Harmony(BaseSolution origin) : base(origin) { }