public override void Execute(IOrganizationService service)
        {
            if (!this.Validate())
            {
                throw new ArgumentNullException(nameof(this.FileName));
            }

            using (var crm = new CrmOrganization(service))
            {
                using (FileStream zip = File.Open(Path.Combine(_solutionsDirectory, this.FileName), FileMode.Open))
                {
                    Logger.Log($"Starting with import of {this.FileName}", LogLevel.Info);
                    var message = new ImportSolutionMessage(crm)
                    {
                        SolutionFileStream               = zip,
                        HoldingSolution                  = this.HoldingSolution,
                        OverwriteIfSameVersionExists     = this.OverwriteIfSameVersionExists,
                        OverwriteUnmanagedCustomizations = this.OverwriteUnmanagedCustomizations,
                        PublishWorkflows                 = this.PublishWorkflows,
                        SkipProductUpdateDependencies    = this.SkipProductDependencies,
                    };

                    crm.Execute(message);
                }
            }
        }
        public override void Execute(IOrganizationService service)
        {
            if (!this.Validate())
            {
                throw new ArgumentNullException(nameof(this.UniqueName));
            }

            using (var crm = new CrmOrganization(service))
            {
                var message = new DeleteSolutionMessage(crm)
                {
                    UniqueName = this.UniqueName,
                };

                crm.Execute(message);
            }
        }
        public override void Execute(IOrganizationService service)
        {
            using (var crm = new CrmOrganization(service))
            {
                List <string> entities = this.EntityLogicalNames.Split(',').ToList();

                foreach (var entity in entities)
                {
                    var message = new EnableEntityChangeTrackingMessage(crm)
                    {
                        EntityLogicalName    = entity,
                        EnableChangeTracking = this.EnableChangeTracking,
                    };

                    crm.Execute(message);
                }
            }
        }
Esempio n. 4
0
        public override void Execute(IOrganizationService service)
        {
            if (!this.Validate())
            {
                throw new ArgumentNullException($"SystemUserId {this.SystemUserId} could not be parsed to a valid Guid.");
            }

            Logger.Log($"Changing the owner of workflows to {SystemUserGuid}. Activating workflows: {ActivateAllWorkflows}.", LogLevel.Info);

            using (var crm = new CrmOrganization(service))
            {
                var message = new ChangeOwnerOfAllWorkflowsMessage(crm)
                {
                    SystemUserId         = this.SystemUserGuid,
                    ActivateAllWorkflows = this.ActivateAllWorkflows
                };

                crm.Execute(message);
            }
        }
        public override void Execute(IOrganizationService service)
        {
            if (!this.Validate())
            {
                throw new ArgumentNullException($"Either {nameof(this.UniqueName)} or {nameof(this.WriteToZipFile)} where not filled in.");
            }

            Logger.Log($"Exporting solution {this.UniqueName}.", LogLevel.Info);
            var writeToFile = Path.Combine(_solutionsDirectory, this.WriteToZipFile);

            using (var crm = new CrmOrganization(service))
            {
                var message = new ExportSolutionMessage(crm)
                {
                    UniqueName      = this.UniqueName,
                    ExportAsManaged = this.ExportAsManaged,
                    OutputFile      = writeToFile,
                };

                crm.Execute(message);
            }
        }
        protected override void ProcessRecord()
        {
            Logger.Log(ObjectLogger.GetLogFor(this), LogLevel.Info);

            var crm = new CrmOrganization(this.OrganizationService);

            using (FileStream solution = File.Open(this.SolutionFile, FileMode.Open))
            {
                var message = new ImportSolutionMessage(crm)
                {
                    SolutionFileStream           = solution,
                    OverwriteIfSameVersionExists = this.OverwriteIfSameVersionExists,
                    HoldingSolution  = this.HoldingSolution,
                    PublishWorkflows = this.PublishWorkflows,
                    ConvertToManaged = this.ConvertToManaged,
                    OverwriteUnmanagedCustomizations = this.OverwriteUnmanagedCustomizations,
                    SkipProductUpdateDependencies    = this.SkipProductUpdateDependencies,
                };

                var result = (ImportSolutionResult)crm.Execute(message);
                WriteObject(result);
            }
        }