예제 #1
0
        private AttributeTypeCode?GetAttributeType(IExecutionContainer container, string attribute, string entityName)
        {
            container.StartSection(MethodBase.GetCurrentMethod().Name + " " + entityName + "." + attribute);
            AttributeTypeCode?type = null;
            var eqe = new EntityQueryExpression
            {
                Properties = new MetadataPropertiesExpression()
            };

            eqe.Properties.PropertyNames.Add("Attributes");
            eqe.Criteria.Conditions.Add(new MetadataConditionExpression("LogicalName", MetadataConditionOperator.Equals, entityName));
            var aqe = new AttributeQueryExpression
            {
                Properties = new MetadataPropertiesExpression("LogicalName", "AttributeType")
            };

            eqe.AttributeQuery = aqe;
            var req = new RetrieveMetadataChangesRequest()
            {
                Query = eqe,
                ClientVersionStamp = null
            };
            var resp = (RetrieveMetadataChangesResponse)container.Execute(req);

            if (resp.EntityMetadata.Count == 1)
            {
                foreach (var attr in resp.EntityMetadata[0].Attributes)
                {
                    if (attr.LogicalName == attribute)
                    {
                        type = attr.AttributeType;
                        break;
                    }
                }
            }
            container.Log($"Type: {type}");
            container.EndSection();
            return(type);
        }
 public static void PublishDuplicateRule(this IExecutionContainer container, Entity duplicateRule) => container.Execute(new PublishDuplicateRuleRequest {
     DuplicateRuleId = duplicateRule.Id
 });
예제 #3
0
        private void ExportSolutionBlock(IExecutionContainer container, SolutionBlock block)
        {
            container.StartSection("ExportSolutionBlock");
            var name = block.Name;

            container.Log("Block: {0}", name);
            var path = block.Path;
            var file = block.File;

            if (string.IsNullOrWhiteSpace(path) && !string.IsNullOrWhiteSpace(definitionpath))
            {
                path  = definitionpath;
                path += path.EndsWith("\\") ? "" : "\\";
            }
            if (string.IsNullOrWhiteSpace(file))
            {
                file = name;
            }
            if (block.Export != null)
            {
                var type          = block.Export.Type;
                var setversion    = block.Export.SetVersion;
                var publish       = block.Export.PublishBeforeExport;
                var targetversion = block.Export.TargetVersion;

                var cdSolution     = GetAndVerifySolutionForExport(name);
                var currentversion = new Version(cdSolution.GetAttribute("version", "1.0.0.0"));

                SendLine(container, "Solution: {0} {1}", name, currentversion);

                if (!string.IsNullOrWhiteSpace(setversion))
                {
                    SetNewSolutionVersion(container, setversion, cdSolution, currentversion);
                }

                if (publish)
                {
                    SendLine(container, "Publishing customizations");
                    container.Execute(new PublishAllXmlRequest());
                }

                var req = new ExportSolutionRequest()
                {
                    SolutionName = name
                };
#if Crm8
                if (!string.IsNullOrWhiteSpace(targetversion))
                {
                    req.TargetVersion = targetversion;
                }
#endif
                if (block.Export.Settings != null)
                {
                    req.ExportAutoNumberingSettings          = block.Export.Settings.AutoNumbering;
                    req.ExportCalendarSettings               = block.Export.Settings.Calendar;
                    req.ExportCustomizationSettings          = block.Export.Settings.Customization;
                    req.ExportEmailTrackingSettings          = block.Export.Settings.EmailTracking;
                    req.ExportGeneralSettings                = block.Export.Settings.General;
                    req.ExportMarketingSettings              = block.Export.Settings.Marketing;
                    req.ExportOutlookSynchronizationSettings = block.Export.Settings.OutlookSync;
                    req.ExportRelationshipRoles              = block.Export.Settings.RelationshipRoles;
                    req.ExportIsvConfig = block.Export.Settings.IsvConfig;
                }

                if (type == SolutionTypes.Managed || type == SolutionTypes.Both)
                {
                    var filename = path + file + "_managed.zip";
                    SendLine(container, "Exporting solution to: {0}", filename);
                    req.Managed = true;
                    var exportSolutionResponse = (ExportSolutionResponse)container.Execute(req);
                    var exportXml = exportSolutionResponse.ExportSolutionFile;
                    File.WriteAllBytes(filename, exportXml);
                }
                if (type == SolutionTypes.Unmanaged || type == SolutionTypes.Both)
                {
                    var filename = path + file + ".zip";
                    SendLine(container, $"Exporting solution to: {filename}");
                    req.Managed = false;
                    var exportSolutionResponse = (ExportSolutionResponse)container.Execute(req);
                    var exportXml = exportSolutionResponse.ExportSolutionFile;
                    File.WriteAllBytes(filename, exportXml);
                }
            }
            container.EndSection();
        }