Beispiel #1
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            switch (ParameterSetName)
            {
            case TestUninstallSolutionParameterSet:
                string solutionUniqueName1 = SolutionManagementHelper.GetSolutionUniqueName(_repository, Solution);
                ExecuteTestUninstall(solutionUniqueName1);
                break;

            case TestDependenciesSolutionParameterSet:
                string solutionUniqueName2 = SolutionManagementHelper.GetSolutionUniqueName(_repository, Solution);
                ExecuteTestDependencies(solutionUniqueName2);
                break;

            case TestMissingSolutionParameterSet:
                byte[] content = File.ReadAllBytes(LiteralPath);
                ExecuteTestMissing(content);
                break;

            default:
                break;
            }
        }
Beispiel #2
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            string solutionUniqueName = SolutionManagementHelper.GetSolutionUniqueName(_repository, Solution, false);

            int componentTypeValue = 0;

            if (int.TryParse(Type, out int typeAsInt) && _validComponentTypes.ContainsKey(typeAsInt))
            {
                componentTypeValue = typeAsInt;
            }
            else if (_validComponentTypes.Any(v => v.Value.Equals(Type, StringComparison.InvariantCultureIgnoreCase)))
            {
                componentTypeValue = _validComponentTypes.First(v => v.Value.Equals(Type, StringComparison.InvariantCultureIgnoreCase)).Key;
            }
            else
            {
                throw new NotSupportedException(string.Format("ComponentType '{0}' is not supported.", Type));
            }

            OrganizationRequest request = new OrganizationRequest("RemoveSolutionComponent")
            {
                Parameters = new ParameterCollection()
                {
                    { "SolutionUniqueName", solutionUniqueName },
                    { "ComponentType", componentTypeValue },
                    { "ComponentId", ComponentId }
                }
            };

            OrganizationResponse response = _repository.Execute(request);
        }
Beispiel #3
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            Hashtable requestParameters = new Hashtable()
            {
                { "SolutionName", SolutionManagementHelper.GetSolutionUniqueName(_repository, Id, false) },
                { "ExportAutoNumberingSettings", AutoNumberingSettings.ToBool() },
                { "ExportCalendarSettings", CalendarSettings.ToBool() },
                { "ExportCustomizationSettings", CustomizationSettings.ToBool() },
                { "ExportEmailTrackingSettings", EmailTrackingSettings.ToBool() },
                { "ExportGeneralSettings", GeneralSettings.ToBool() },
                { "ExportIsvConfig", IsvConfig.ToBool() },
                { "ExportMarketingSettings", MarketingSettings.ToBool() },
                { "ExportOutlookSynchronizationSettings", OutlookSynchronizationSettings.ToBool() },
                { "ExportRelationshipRoles", RelationshipRoles.ToBool() },
                { "Managed", Managed.ToBool() }
            };

            if (_context != null)
            {
                _context.SetParametersOnRequest(requestParameters);
            }

            OrganizationResponse response = _repository.Execute("ExportSolution", requestParameters);

            File.WriteAllBytes(Path, (byte[])response.Results["ExportSolutionFile"]);
        }
Beispiel #4
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            OrganizationResponse response = _repository.Execute("ExportTranslation", new Hashtable()
            {
                { "SolutionName", SolutionManagementHelper.GetSolutionUniqueName(_repository, Solution, false) }
            });

            File.WriteAllBytes(Path, (byte[])response.Results["ExportTranslationFile"]);
        }
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            foreach (Guid id in Solution)
            {
                string solutionUniqueName = SolutionManagementHelper.GetSolutionUniqueName(_repository, id);

                int?componentTypeValue = null;
                if (!string.IsNullOrWhiteSpace(Type))
                {
                    if (int.TryParse(Type, out int typeAsInt) && _validComponentTypes.ContainsKey(typeAsInt))
                    {
                        componentTypeValue = typeAsInt;
                    }
                    else if (_validComponentTypes.Any(v => v.Value.Equals(Type, StringComparison.InvariantCultureIgnoreCase)))
                    {
                        componentTypeValue = _validComponentTypes.First(v => v.Value.Equals(Type, StringComparison.InvariantCultureIgnoreCase)).Key;
                    }
                    else
                    {
                        throw new NotSupportedException(string.Format("ComponentType '{0}' is not supported.", Type));
                    }
                }

                QueryExpression query = GetSolutionComponentQuery(id, componentTypeValue);

                if (PagingParameters.IncludeTotalCount)
                {
                    int count = _repository.GetRowCount(query, out double accuracy);
                    WriteObject(PagingParameters.NewTotalCount(Convert.ToUInt64(count), accuracy));
                }

                IEnumerable <Entity> result = _repository.Get(query, this.PagingParameters.First, this.PagingParameters.Skip);

                var groupedResult = result.GroupBy(k =>
                {
                    var keyAttribute = k.GetAttributeValue <AliasedValue>("dependency.requiredcomponentobjectid");
                    if (keyAttribute == null)
                    {
                        return(k.GetAttributeValue <Guid>("objectid"));
                    }
                    else
                    {
                        return((Guid)keyAttribute.Value);
                    }
                });

                foreach (var groupResult in groupedResult)
                {
                    WriteObject(groupResult.OrderBy(e => e.GetAttributeValue <OptionSetValue>("componenttype").Value), true);
                }
            }
        }
Beispiel #6
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            if (Solution.HasValue && Solution.Value != Guid.Empty)
            {
                CrmContext.ActiveSolution = SolutionManagementHelper.GetSolutionUniqueName(_repository, Solution.Value, false);
            }
            else
            {
                CrmContext.ActiveSolution = null;
            }
        }