Пример #1
0
        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"]));
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
 public void CreateMergedSolution(Guid solutionId, List <MergedInSolutionComponent> components)
 {
     foreach (var item in components.OrderBy(k => k.GetOrderWeight()))
     {
         CrmProvider.AddComponentToSolution(_service, solutionId, item);
     }
 }
Пример #4
0
        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);
            }
        }
Пример #5
0
        public void RemoveSolution(string uniqueName)
        {
            var solution = GetSolution(uniqueName);

            if (solution != null)
            {
                CrmProvider.RemoveSolution(_service, solution.Id);
            }
        }
Пример #6
0
        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);
            }
        }
Пример #7
0
        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());
        }
Пример #8
0
        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);
        }
Пример #9
0
        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);
        }
Пример #10
0
        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);
        }
Пример #11
0
        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);
        }
Пример #12
0
        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);
        }
Пример #13
0
 public void SetDependenciesKOForWorkSolution(Guid id, string error)
 {
     CrmProvider.UpdateWorkSolutionDependenciesCheck(_service, id, false, error);
 }
Пример #14
0
 public void RemoveWorkSolution(Guid id)
 {
     CrmProvider.RemoveWorkSolution(_service, id);
 }
Пример #15
0
 public void RemoveAggregatedSolution(Guid id)
 {
     CrmProvider.RemoveAggregatedSolution(_service, id);
 }
Пример #16
0
 public void SetMergedWithSupersolutionFlagInAggregatedSolution(Guid aggregatedId)
 {
     CrmProvider.UpdateAggregatedSolutionMergedWithSupersolutionFlag(_service, aggregatedId, true);
 }
Пример #17
0
 public Guid CreateAggregatedSolution(string name, AggregatedSolution.AggregatedSolutionType type)
 {
     return(CrmProvider.CreateAggregatedSolution(_service, name, type));
 }
Пример #18
0
 public void SetNotReadyWorkSolution(Guid id)
 {
     CrmProvider.UpdateWorkSolutionStatus(_service, id, WorkSolution.WorkSolutionStatus.Development);
 }
Пример #19
0
 public List <AggregatedSolution> GetAggregatedSolutions()
 {
     return(CrmProvider.GetAgregatedSolutions(this._service));
 }
Пример #20
0
 public List <WorkSolution> GetWorkSolutions(Guid aggregatedSolutionId)
 {
     return(CrmProvider.GetWorkSolutions(this._service, aggregatedSolutionId));
 }
Пример #21
0
 public List <EntityReference> GetPublishers()
 {
     return(CrmProvider.GetPublishers(_service));
 }
Пример #22
0
 public Solution GetSolution(Guid id)
 {
     return(CrmProvider.GetSolution(this._service, id));
 }
Пример #23
0
 public Solution GetSolution(string uniqueName)
 {
     return(CrmProvider.GetSolution(this._service, uniqueName));
 }
Пример #24
0
 public void SetDependenciesOKForWorkSolution(Guid id)
 {
     CrmProvider.UpdateWorkSolutionDependenciesCheck(_service, id, true);
 }
Пример #25
0
 public void SetReadyWorkSolution(Guid id)
 {
     CrmProvider.UpdateWorkSolutionStatus(_service, id, WorkSolution.WorkSolutionStatus.ReadyToInt);
 }
Пример #26
0
        public List <SolutionComponentBase> GetSolutionComponents(Guid solutionId, bool expandDefinition = false)
        {
            bool expand = !ExpandDefinition ? ExpandDefinition : expandDefinition;

            return(CrmProvider.GetSolutionComponents(this._service, solutionId, expand));
        }
Пример #27
0
 public void AssignWorkSolutionToAggregatedSolution(Guid aggregatedSolutionId, Guid workSolutionId)
 {
     CrmProvider.AssignWorkSolutionToAggregatedSolution(_service, aggregatedSolutionId, workSolutionId);
 }
Пример #28
0
 public void UpdatedJustCreatedAggregatedSolution(Guid aggregatedId, string uniqueName, string displayName)
 {
     CrmProvider.UpdatedJustCreatedAggregatedSolution(_service, aggregatedId, uniqueName, displayName);
 }
Пример #29
0
 public List <WorkSolution> GetAllOpenWorkSolutions()
 {
     return(CrmProvider.GetAllOpenWorkSolutions(this._service));
 }
Пример #30
0
 public void SetStatusAggregatedSolution(Guid aggregatedId, AggregatedSolution.AggregatedSolutionStatus status)
 {
     CrmProvider.UpdateAggregatedSolutionStatus(_service, aggregatedId, status);
 }