public override void Execute(List <CommandParameter> parameters) { var stringConnection = GetStringParameterValue(parameters, CommandStringConnectionParameter.Name); var assemblyId = GetGuidParameterValue(parameters, CommandAssemblyIdParameter.Name); var assemblyName = GetStringParameterValue(parameters, CommandAssemblyNameParameter.Name); IOrganizationService service = CrmProvider.GetService(stringConnection); Guid id = Guid.Empty; if (assemblyId != Guid.Empty) { id = assemblyId; } else if (!string.IsNullOrEmpty(assemblyName)) { QueryByAttribute qe = new QueryByAttribute("pluginassembly"); qe.AddAttributeValue("name", assemblyName); var response = service.RetrieveMultiple(qe); if (response.Entities.Count == 0) { throw new Exception($"Can't find any assembly with name '{assemblyName}'"); } id = response.Entities[0].Id; } var assembly = service.Retrieve("pluginassembly", id, new ColumnSet("name", "content")); var path = $"{assembly["name"]}.dll"; FileService.WriteAllBytes(path, Convert.FromBase64String((string)assembly["content"])); }
public override void Execute(List <CommandParameter> parameters) { var stringConnectionFrom = GetStringParameterValue(parameters, CommandStringConnectionFromMasterParameter.Name); var stringConnectionTo = GetStringParameterValue(parameters, CommandStringConnectionFromSlaveParameter.Name); var includeOptions = GetBoolParameterValue(parameters, CommandIncludeOptionsParameter.Name, false); var composedTo = $"{stringConnectionTo};RequireNewInstance=true"; var composedFrom = $"{stringConnectionFrom};RequireNewInstance=true"; var serviceFrom = CrmProvider.GetService(composedFrom); var serviceTo = CrmProvider.GetService(composedTo); var displayFrom = CrmProvider.GetServiceDisplayName(composedFrom); var displayTo = CrmProvider.GetServiceDisplayName(composedTo); ConsoleService.WriteLine($"You are cloning USD configuration from '{displayFrom}' to '{displayTo}'. The configuration in '{displayTo}' will be modified and the operation cannot be undone. Confirm? (Y/N)"); var response = ConsoleService.ReadLine(); if (!string.IsNullOrEmpty(response)) { var input = response.ToLowerInvariant(); if (input == "y" || input == "yes") { CrmProvider.CloneUsdConfiguration((string text) => { ConsoleService.WriteLine(text); }, serviceFrom, serviceTo, includeOptions); } } }
public void CreateMergedSolution(Guid solutionId, List <MergedInSolutionComponent> components) { foreach (var item in components.OrderBy(k => k.GetOrderWeight())) { CrmProvider.AddComponentToSolution(_service, solutionId, item); } }
public override void Execute(List <CommandParameter> parameters) { var stringConnection = GetStringParameterValue(parameters, CommandStringConnectionParameter.Name); var solutionPath = GetStringParameterValue(parameters, CommandPathParameter.Name); if (!FileService.ExistsFile(solutionPath)) { throw new PathNotFoundException(solutionPath); } IOrganizationService service = CrmProvider.GetService(stringConnection); var completePath = FileService.GetAbsoluteCurrentPath(solutionPath); var data = FileService.ReadAllBytes(completePath); bool migrateAsHold = GetBoolParameterValue(parameters, CommandMigrateAsHoldParameter.Name, false); bool overwriteUnmanagedCustomizations = GetBoolParameterValue(parameters, CommandOverwriteUnmanagedCustomizationsParameter.Name, true); bool publishWorkflows = GetBoolParameterValue(parameters, CommandPublishWorkflowsParameter.Name, true); bool async = GetBoolParameterValue(parameters, ImportAsyncParameter.Name, false); if (async) { CrmProvider.ImportSolutionsAsync(service, data, overwriteUnmanagedCustomizations, migrateAsHold, publishWorkflows); } else { CrmProvider.ImportSolutions(service, data, overwriteUnmanagedCustomizations, migrateAsHold, publishWorkflows); } }
public void RemoveSolution(string uniqueName) { var solution = GetSolution(uniqueName); if (solution != null) { CrmProvider.RemoveSolution(_service, solution.Id); } }
public override void Execute(List <CommandParameter> parameters) { var stringConnection = GetStringParameterValue(parameters, CommandStringConnectionParameter.Name); var assemblyId = GetGuidParameterValue(parameters, CommandWorkflowIdParameter.Name); var assemblyName = GetStringParameterValue(parameters, CommandWorkflowNameParameter.Name); var fetchFile = GetStringParameterValue(parameters, FetchFilePathParameter.Name); var period = GetIntParameterValue(parameters, PeriodParameter.Name); Log("Retrieving organization service..."); IOrganizationService service = CrmProvider.GetService(stringConnection); Guid id = Guid.Empty; if (assemblyId != Guid.Empty) { id = assemblyId; } else if (!string.IsNullOrEmpty(assemblyName)) { QueryByAttribute qe = new QueryByAttribute("workflow"); qe.AddAttributeValue("name", assemblyName); qe.AddAttributeValue("type", 1); var response = service.RetrieveMultiple(qe); if (response.Entities.Count == 0) { throw new Exception($"Can't find any assembly with name '{assemblyName}'"); } id = response.Entities[0].Id; } var existsFile = FileService.ExistsFile(fetchFile); if (!existsFile) { throw new Exception($"Can't find file with path '{fetchFile}'"); } var fetch = FileService.ReadAllText(fetchFile); Log("Loaded fetch in file:"); Log(fetch); while (true) { var records = CrmProvider.GetIdsFromFetch(service, fetch); Log($"Retrieved {records.Count} from fetch"); foreach (var recordId in records) { var incidentId = CrmProvider.GetRegardingQueueItemIncidentId(service, recordId); CrmProvider.ExecuteWorkflowOnRecord(service, id, incidentId); Log($"Executed workflow for incidentId={incidentId}"); } Log($"Waiting {period} seconds..."); System.Threading.Thread.Sleep(period * 1000); } }
public void IncreaseSolutionRevisionVersion(Guid solutionId) { var solution = CrmProvider.GetSolution(_service, solutionId); var version = solution.Version; var versioned = new Version(version); var newVersion = new Version(versioned.Major, versioned.Minor, versioned.Build, versioned.Revision + 1); CrmProvider.UpdateSolutionVersion(_service, solutionId, newVersion.ToString()); }
public void ExportSolution(ContextService context, string id, ExportSolutionReq request) { var operationEventArgs = new OperationEventArgs(OperationType.ExportSolution, id); OnOperationStarted? .Invoke(this, operationEventArgs); CrmProvider.ExportSolution(Service, request.Managed, request.UniqueName, request.Path); OnOperationCompleted? .Invoke(this, operationEventArgs); }
public override void Execute(List <CommandParameter> parameters) { var stringConnection = GetStringParameterValue(parameters, CommandStringConnectionParameter.Name); var clientId = GetStringParameterValue(parameters, CommandClientIdParameter.Name); var crmServiceClient = CrmProvider.GetCrmServiceClient(stringConnection); var proxy = crmServiceClient.OrganizationServiceProxy; var username = proxy.ClientCredentials.UserName.UserName; var password = proxy.ClientCredentials.UserName.Password; var host = $"https://{crmServiceClient.CrmConnectOrgUriActual.Host}/"; var token = CrmProvider.GetCrmToken(username, password, host, clientId); Log(token); }
public void ImportSolution( string path, bool overwriteUnmanagedCustomizations = true, bool migrateAsHold = false, bool publishWorkflows = true) { var data = File.ReadAllBytes(path); CrmProvider .ImportSolution( _service, data, overwriteUnmanagedCustomizations, migrateAsHold, publishWorkflows); }
public void ImportSolutionsAsync(ContextService context, string id, ImportSolutionReq request) { var operationEventArgs = new OperationEventArgs(OperationType.ImportSolutionAsync, id); OnOperationStarted? .Invoke(this, operationEventArgs); var data = File.ReadAllBytes(request.Path); var jobId = CrmProvider .ImportSolutionAsync( Service, data, request.OverwriteUnmanagedCustomizations, request.MigrateAsHold, request.PublishWorkflows); WaitAsnycOperation(jobId); OnOperationCompleted? .Invoke(this, operationEventArgs); }
public override void Execute(List <CommandParameter> parameters) { var stringConnection = GetStringParameterValue(parameters, CommandStringConnectionParameter.Name); var resourcePath = GetStringParameterValue(parameters, CommandPathParameter.Name); var resourceName = GetStringParameterValue(parameters, CommandResourceName.Name); if (!FileService.ExistsFile(resourcePath)) { throw new PathNotFoundException(resourcePath); } Log("Connecting to CRM..."); IOrganizationService service = CrmProvider.GetService(stringConnection) ?? throw new Exception("Can't connect to CRM with given string connection"); var completePath = FileService.GetAbsoluteCurrentPath(resourcePath); var data = FileService.ReadAllBytes(completePath); Log("Uploading webresource..."); var id = CrmProvider.UploadWebResource(service, data, resourceName); Log("Publishing webresource..."); CrmProvider.PublishWebResouce(service, id); }
public void SetDependenciesKOForWorkSolution(Guid id, string error) { CrmProvider.UpdateWorkSolutionDependenciesCheck(_service, id, false, error); }
public void RemoveWorkSolution(Guid id) { CrmProvider.RemoveWorkSolution(_service, id); }
public void RemoveAggregatedSolution(Guid id) { CrmProvider.RemoveAggregatedSolution(_service, id); }
public void SetMergedWithSupersolutionFlagInAggregatedSolution(Guid aggregatedId) { CrmProvider.UpdateAggregatedSolutionMergedWithSupersolutionFlag(_service, aggregatedId, true); }
public Guid CreateAggregatedSolution(string name, AggregatedSolution.AggregatedSolutionType type) { return(CrmProvider.CreateAggregatedSolution(_service, name, type)); }
public void SetNotReadyWorkSolution(Guid id) { CrmProvider.UpdateWorkSolutionStatus(_service, id, WorkSolution.WorkSolutionStatus.Development); }
public List <AggregatedSolution> GetAggregatedSolutions() { return(CrmProvider.GetAgregatedSolutions(this._service)); }
public List <WorkSolution> GetWorkSolutions(Guid aggregatedSolutionId) { return(CrmProvider.GetWorkSolutions(this._service, aggregatedSolutionId)); }
public List <EntityReference> GetPublishers() { return(CrmProvider.GetPublishers(_service)); }
public Solution GetSolution(Guid id) { return(CrmProvider.GetSolution(this._service, id)); }
public Solution GetSolution(string uniqueName) { return(CrmProvider.GetSolution(this._service, uniqueName)); }
public void SetDependenciesOKForWorkSolution(Guid id) { CrmProvider.UpdateWorkSolutionDependenciesCheck(_service, id, true); }
public void SetReadyWorkSolution(Guid id) { CrmProvider.UpdateWorkSolutionStatus(_service, id, WorkSolution.WorkSolutionStatus.ReadyToInt); }
public List <SolutionComponentBase> GetSolutionComponents(Guid solutionId, bool expandDefinition = false) { bool expand = !ExpandDefinition ? ExpandDefinition : expandDefinition; return(CrmProvider.GetSolutionComponents(this._service, solutionId, expand)); }
public void AssignWorkSolutionToAggregatedSolution(Guid aggregatedSolutionId, Guid workSolutionId) { CrmProvider.AssignWorkSolutionToAggregatedSolution(_service, aggregatedSolutionId, workSolutionId); }
public void UpdatedJustCreatedAggregatedSolution(Guid aggregatedId, string uniqueName, string displayName) { CrmProvider.UpdatedJustCreatedAggregatedSolution(_service, aggregatedId, uniqueName, displayName); }
public List <WorkSolution> GetAllOpenWorkSolutions() { return(CrmProvider.GetAllOpenWorkSolutions(this._service)); }
public void SetStatusAggregatedSolution(Guid aggregatedId, AggregatedSolution.AggregatedSolutionStatus status) { CrmProvider.UpdateAggregatedSolutionStatus(_service, aggregatedId, status); }