Exemplo n.º 1
0
 public PredictByReferenceRequest()
 {
     this.RequestName    = "PredictByReference";
     this.version        = default(string);
     this.targetRecordId = default(string);
     this.Target         = default(Microsoft.Xrm.Sdk.EntityReference);
 }
        public void Delete(Microsoft.Xrm.Sdk.EntityReference target)
        {
            try
            {
                var key = target.LogicalName + target.Id.ToString();
                if (!entities.ContainsKey(key))
                {
                    throw new Exceptions.EntityNotFoundException(target.LogicalName, target.Id);
                }

                this.ExecuteStep(target, 10, "Delete", false, null, OnValidation);
                this.ExecuteStep(target, 20, "Delete", false, () =>
                {
                    ((Repository.IEntityShadow) this).Delete(target.LogicalName, target.Id);
                    ((Repository.IEntityShadow) this).Commit();
                }, OnPre);
                this.ExecuteStep(target, 40, "Delete", false, () =>
                {
                    ((Repository.IEntityShadow) this).Commit();
                }, OnPost);
                this.ExecuteStep(target, 40, "Delete", true, () =>
                {
                    ((Repository.IEntityShadow) this).Commit();
                }, OnPostAsync);
            }
            catch (Exception)
            {
                ((IEntityShadow)this).Rollback();
                throw;
            }
        }
 public ScheduleRetrainRequest()
 {
     this.RequestName = "ScheduleRetrain";
     this.recurrence  = default(string);
     this.version     = default(string);
     this.Target      = default(Microsoft.Xrm.Sdk.EntityReference);
 }
Exemplo n.º 4
0
 public PvaAuthorizeRequest()
 {
     this.RequestName     = "PvaAuthorize";
     this.Users           = default(Microsoft.Xrm.Sdk.EntityCollection);
     this.SharingRoleType = default(Microsoft.Xrm.Sdk.OptionSetValue);
     this.ShareOrUnshare  = default(bool);
     this.Target          = default(Microsoft.Xrm.Sdk.EntityReference);
 }
 public TargetReference(Microsoft.Xrm.Sdk.EntityReference target)
 {
     if (target.LogicalName != this._logicalName)
     {
         throw new ArgumentException($"Target reference does not match this type, expected {_logicalName} got {target.LogicalName }");
     }
     this.target = target;
 }
Exemplo n.º 6
0
 public msdyn_SendEmailFromTemplateRequest()
 {
     this.RequestName = "msdyn_SendEmailFromTemplate";
     this.From        = default(Microsoft.Xrm.Sdk.EntityReference);
     this.To          = default(Microsoft.Xrm.Sdk.EntityCollection);
     this.Regarding   = default(Microsoft.Xrm.Sdk.EntityReference);
     this.Template    = default(Microsoft.Xrm.Sdk.EntityReference);
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="target">The target reference</param>
        /// <param name="stage">10=validate,20=pre,40=post</param>
        /// <param name="message">Create,Update,Delete,??</param>
        /// <param name="isAsync">false or true, only apply to stage 40</param>
        /// <param name="finalize">Will be executed end of step, regardless of any plugin execution</param>
        /// <param name="onDone">the valide method provided by the test library</param>
        private void ExecuteStep(Microsoft.Xrm.Sdk.EntityReference target, int stage, string message, bool isAsync, Action finalize, Action onDone)
        {
            if (stage == 10)
            {
                var key = target.LogicalName + target.Id.ToString();
                this.preImage = this.entities[key].Clone();
            }

            var methods = this.pluginMethodCache.ForPlugin(this.plugin.GetType(), stage, message, target.LogicalName, isAsync, false);

            if (methods.Length > 0)
            {
                var pluginExecutionContext = new Services.PluginExecutionContext(stage, 1, message, target.LogicalName, target.Id, isAsync);
                pluginExecutionContext.InputParameters.Add("Target", target);

                var imagePre = this.ResolveImage(target.LogicalName, target.Id, 1, methods, preImage);
                if (imagePre != null)
                {
                    var imgName = Kipon.Fake.Xrm.Reflection.PluginMethod.ImageSuffixFor(1, stage, isAsync);
                    pluginExecutionContext.PreEntityImages.Add(imgName, imagePre);
                }

                if (stage == 40 && message != "Delete")
                {
                    var imagePost = this.ResolveImage(target.LogicalName, target.Id, 2, methods, null);
                    if (imagePost != null)
                    {
                        var imgName = Kipon.Fake.Xrm.Reflection.PluginMethod.ImageSuffixFor(2, stage, isAsync);
                        pluginExecutionContext.PostEntityImages.Add(imgName, imagePost);
                    }
                }

                var serviceProvider = new Services.ServiceProvider(pluginExecutionContext, this, this.plugin.GetType().Assembly);
                this.plugin.Execute(serviceProvider);

                finalize?.Invoke();

                onDone?.Invoke();
            }
            else
            {
                if (onDone != null)
                {
                    throw new Exceptions.UnexpectedEventListenerException(plugin.GetType(), message, stage);
                }
                else
                {
                    finalize?.Invoke();
                }
            }
        }
Exemplo n.º 8
0
        public void ConvertTest()
        {
            {
                var id = Guid.NewGuid();
                var re = new Microsoft.Xrm.Sdk.EntityReference("some", id);
                Assert.AreEqual(id, re.ConvertValueTo <Guid>(out bool r));
            }

            {
                var no = 234;
                var os = new Microsoft.Xrm.Sdk.OptionSetValue(no);
                Assert.AreEqual(no, os.ConvertValueTo <int>(out bool r));
            }
        }
Exemplo n.º 9
0
        public void EqualTest()
        {
            {
                var ent1 = new Microsoft.Xrm.Sdk.EntityReference(Entities.Account.EntityLogicalName, Guid.NewGuid());
                var ent2 = new Microsoft.Xrm.Sdk.EntityReference(Entities.Account.EntityLogicalName, ent1.Id);

                Assert.IsTrue(ent1.Equals(ent2));
            }
            {
                object value  = "equaltest";
                var    filter = new Microsoft.Xrm.Sdk.Query.ConditionExpression("value", Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, "equalTEST");
                Assert.IsTrue(value.Equal(filter.Values));
            }

            {
                object value  = 10;
                var    filter = new Microsoft.Xrm.Sdk.Query.ConditionExpression("value", Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, 10);
                Assert.IsTrue(value.Equal(filter.Values));
            }

            {
                object value  = new Microsoft.Xrm.Sdk.Money(10M);
                var    filter = new Microsoft.Xrm.Sdk.Query.ConditionExpression("value", Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, 10M);
                Assert.IsTrue(value.Equal(filter.Values));
            }

            {
                var value  = new Microsoft.Xrm.Sdk.EntityReference(Entities.Contact.EntityLogicalName, Guid.NewGuid());
                var filter = new Microsoft.Xrm.Sdk.Query.ConditionExpression("value", Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, value.Id);
                Assert.IsTrue(value.Equal(filter.Values));
            }

            {
                var value  = new Microsoft.Xrm.Sdk.EntityReference(Entities.Contact.EntityLogicalName, Guid.NewGuid());
                var v2     = new Microsoft.Xrm.Sdk.EntityReference(Entities.Contact.EntityLogicalName, value.Id);
                var filter = new Microsoft.Xrm.Sdk.Query.ConditionExpression("value", Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, v2);
                Assert.IsTrue(value.Equal(filter.Values));
            }

            {
                var value  = new Microsoft.Xrm.Sdk.EntityReference(Entities.Contact.EntityLogicalName, Guid.NewGuid());
                var v2     = new Microsoft.Xrm.Sdk.EntityReference(Entities.Account.EntityLogicalName, value.Id);
                var filter = new Microsoft.Xrm.Sdk.Query.ConditionExpression("value", Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, v2);
                Assert.IsFalse(value.Equal(filter.Values));
            }
        }
Exemplo n.º 10
0
        internal static Microsoft.Xrm.Sdk.Entity ToCrmEntity <T>(this T crmPlusPlusEntity) where T : CrmPlusPlusEntity, new()
        {
            var entity = new Microsoft.Xrm.Sdk.Entity(EntityNameAttribute.GetFromType <T>(), crmPlusPlusEntity.Id);

            foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(typeof(T)))
            {
                var attributes = property.Attributes.AsEnumerable();

                var propertyNameAttr = attributes.SingleOrDefault(attr => attr.GetType() == typeof(PropertyNameAttribute));
                var propertyInfoAttr = attributes.SingleOrDefault(attr => attr.GetType() == typeof(PropertyInfoAttribute));
                var typeInfoAttr     = attributes
                                       .SingleOrDefault(attr => (attr.GetType() == typeof(BooleanAttribute) && property.PropertyType == typeof(bool)) ||
                                                        (attr.GetType() == typeof(DateTimeAttribute) && property.PropertyType == typeof(DateTime)) ||
                                                        (attr.GetType() == typeof(DecimalAttribute) && property.PropertyType == typeof(decimal)) ||
                                                        (attr.GetType() == typeof(DoubleAttribute) && property.PropertyType == typeof(double)) ||
                                                        (attr.GetType() == typeof(IntegerAttribute) && property.PropertyType == typeof(int)) ||
                                                        (attr.GetType() == typeof(StringAttribute) && property.PropertyType == typeof(string)) ||
                                                        (attr.GetType() == typeof(LookupAttribute) && property.PropertyType.IsGenericType && property.PropertyType.GetGenericTypeDefinition() == typeof(EntityReference <>)) ||
                                                        (attr.GetType() == typeof(OptionSetAttribute) && property.PropertyType.IsEnum));

                if (propertyNameAttr != null && propertyInfoAttr != null && typeInfoAttr != null)
                {
                    var propertyName = ((PropertyNameAttribute)propertyNameAttr).PropertyName;
                    var value        = property.GetValue(crmPlusPlusEntity);

                    if (value != null)
                    {
                        if (value.GetType().IsGenericType&& value.GetType().GetGenericTypeDefinition() == typeof(EntityReference <>))
                        {
                            var entityReferenceType = property.PropertyType.GetGenericArguments().Single();
                            var entityName          = EntityNameAttribute.GetFromType(entityReferenceType);

                            value = new Microsoft.Xrm.Sdk.EntityReference(entityName, ((dynamic)value).Id);
                        }
                        else if (value.GetType().IsEnum)
                        {
                            value = new Microsoft.Xrm.Sdk.OptionSetValue((int)value);
                        }

                        entity[propertyName] = value;
                    }
                }
            }

            return(entity);
        }
        public void PreValueOfTest()
        {
            var ctx = new Kipon.Solid.Plugin.UnitTests.Mocks.PluginExecutionContext
            {
                PreEntityImages = new Microsoft.Xrm.Sdk.EntityImageCollection()
            };

            var account = new Microsoft.Xrm.Sdk.Entity(Kipon.Solid.Plugin.Entities.Account.EntityLogicalName, Guid.NewGuid());

            account["accountcategorycode"] = new Microsoft.Xrm.Sdk.OptionSetValue(1);
            account["name"] = "Kipon ApS";
            var parent = new Microsoft.Xrm.Sdk.EntityReference("account", new Guid());

            account["parentaccountid"] = parent;
            ctx.PreEntityImages.Add("animage", account);

            var enumValue = ctx.PreValueOf <Kipon.Solid.Plugin.Entities.Account.AnEnum?>(nameof(Kipon.Solid.Plugin.Entities.Account.AnEnumValue));

            Assert.AreEqual(Kipon.Solid.Plugin.Entities.Account.AnEnum.Value1, enumValue);
            Assert.AreEqual(account["name"], ctx.PreValueOf <string>(nameof(Kipon.Solid.Plugin.Entities.Account.Name)));

            Assert.AreEqual(parent, ctx.PreValueOf <Microsoft.Xrm.Sdk.EntityReference>(nameof(Kipon.Solid.Plugin.Entities.Account.ParentAccountId)));

            account.Attributes.Remove("accountcategorycode");
            enumValue = ctx.PreValueOf <Kipon.Solid.Plugin.Entities.Account.AnEnum?>(nameof(Kipon.Solid.Plugin.Entities.Account.AnEnumValue));
            Assert.IsNull(enumValue);

            {
                var ex = Assert.ThrowsException <Microsoft.Xrm.Sdk.InvalidPluginExecutionException>(() =>
                {
                    ctx.PreValueOf <string>("NoneExistingProperty");
                });

                Assert.AreEqual(string.Format(Kipon.Xrm.Extensions.Sdk.KiponSdkGeneratedExtensionMethods.UNDEFINED_ATTRIBUTE_MESSAGE, "account", "NoneExistingProperty"), ex.Message);
            }

            {
                var ex = Assert.ThrowsException <Microsoft.Xrm.Sdk.InvalidPluginExecutionException>(() =>
                {
                    ctx.PreValueOf <string>(nameof(Kipon.Solid.Plugin.Entities.Account.NoDecorationProperty));
                });

                Assert.AreEqual(string.Format(Kipon.Xrm.Extensions.Sdk.KiponSdkGeneratedExtensionMethods.MISSING_DECORATION_ATTRIBUTE_MESSAGE, "account", nameof(Kipon.Solid.Plugin.Entities.Account.NoDecorationProperty)), ex.Message);
            }
        }
        public void TestForeignKeyQueryTest()
        {
            using (var ctx = PluginExecutionFakeContext.ForType <Kipon.Solid.Plugin.Plugins.Account.AccountCreatePlugin>())
            {
                var id = Guid.NewGuid();
                var primaryContactId = new Microsoft.Xrm.Sdk.EntityReference {
                    LogicalName = Entities.Contact.EntityLogicalName, Id = Guid.NewGuid()
                };
                ctx.AddEntity(new Entities.Account {
                    AccountId = id, Name = "Kurt", PrimaryContactId = primaryContactId
                });

                var accountQuery = ctx.GetQuery <Entities.Account>();
                var kurt         = (from a in accountQuery where a.PrimaryContactId.Id == primaryContactId.Id select a).Single();

                Assert.AreEqual("Kurt", kurt.Name);

                kurt = (from a in accountQuery where a.PrimaryContactId == primaryContactId select a).Single();

                Assert.AreEqual("Kurt", kurt.Name);
            }
        }
Exemplo n.º 13
0
 public opc_complaintcheckcomplainantrequiresprivilegedcorrespondenceRequest()
 {
     this.RequestName = "opc_complaintcheckcomplainantrequiresprivilegedcorrespondence";
     this.Target      = default(Microsoft.Xrm.Sdk.EntityReference);
 }
 public PublishAIConfigurationRequest()
 {
     this.RequestName = "PublishAIConfiguration";
     this.version     = default(string);
     this.Target      = default(Microsoft.Xrm.Sdk.EntityReference);
 }
 public msdyn_IoTGetEditablePropertiesMetadataRequest()
 {
     this.RequestName    = "msdyn_IoTGetEditablePropertiesMetadata";
     this.DeviceCategory = default(Microsoft.Xrm.Sdk.EntityReference);
 }
 public new_ApplyCreditLimitRequest()
 {
     this.RequestName          = "new_ApplyCreditLimit";
     this.RequestedCreditLimit = default(Microsoft.Xrm.Sdk.Money);
     this.Target = default(Microsoft.Xrm.Sdk.EntityReference);
 }
Exemplo n.º 17
0
 public QuickTestRequest()
 {
     this.RequestName = "QuickTest";
     this.version     = default(string);
     this.Target      = default(Microsoft.Xrm.Sdk.EntityReference);
 }
 public tc_TcCompensationEmailPaymentTypesRequest()
 {
     this.RequestName = "tc_TcCompensationEmailPaymentTypes";
     this.Target      = default(Microsoft.Xrm.Sdk.EntityReference);
 }
Exemplo n.º 19
0
 public PvaCreateBotComponentsRequest()
 {
     this.RequestName   = "PvaCreateBotComponents";
     this.BotComponents = default(Microsoft.Xrm.Sdk.EntityCollection);
     this.Target        = default(Microsoft.Xrm.Sdk.EntityReference);
 }
Exemplo n.º 20
0
 public PvaCreateContentSnapshotRequest()
 {
     this.RequestName = "PvaCreateContentSnapshot";
     this.Target      = default(Microsoft.Xrm.Sdk.EntityReference);
 }
 public UnschedulePredictionRequest()
 {
     this.RequestName = "UnschedulePrediction";
     this.version     = default(string);
     this.Target      = default(Microsoft.Xrm.Sdk.EntityReference);
 }
 public CancelTrainingRequest()
 {
     this.RequestName = "CancelTraining";
     this.version     = default(string);
     this.Target      = default(Microsoft.Xrm.Sdk.EntityReference);
 }
Exemplo n.º 23
0
        public static object GetAttributeValueFromString(Microsoft.Xrm.Sdk.IOrganizationService service, string entityName, string attribute, string value)

        {
            object retVal = null;



            var attributeRequest = new Microsoft.Xrm.Sdk.Messages.RetrieveAttributeRequest

            {
                EntityLogicalName = entityName,

                LogicalName = attribute,

                RetrieveAsIfPublished = true
            };

            Microsoft.Xrm.Sdk.Messages.RetrieveAttributeResponse attributeResponse = (Microsoft.Xrm.Sdk.Messages.RetrieveAttributeResponse)service.Execute(attributeRequest);

            Microsoft.Xrm.Sdk.Metadata.AttributeMetadata attrMetadata = (Microsoft.Xrm.Sdk.Metadata.AttributeMetadata)attributeResponse.AttributeMetadata;



            switch (attrMetadata.AttributeType.ToString())

            {
            case "Status":     //Status



                //Microsoft.Xrm.Sdk.Metadata.StatusAttributeMetadata tmp = new Microsoft.Xrm.Sdk.Metadata.StatusAttributeMetadata();

                //tmp.DefaultFormValue = int.Parse(value);

                //retVal = tmp;

                retVal = int.Parse(value);

                break;

            case "Picklist":     //Picklist



                retVal = int.Parse(value);

                break;

            case "State":     //State



                retVal = int.Parse(value);

                break;

            case "Decimal":     //Decimal



                retVal = decimal.Parse(value);

                break;

            case "Enum":     //Enum



                retVal = int.Parse(value);

                break;

            case "Memo":     //Memo

                retVal = value;

                break;

            case "Money":     //Money



                retVal = decimal.Parse(value);

                break;

            case "Lookup":

            {
                //    attrMetadata

                string[] strs = value.Split('\\');

                //Microsoft.Xrm.Sdk.EntityReference er = new Microsoft.Xrm.Sdk.EntityReference();

                //    er.LogicalName = ((Microsoft.Xrm.Sdk.Metadata.LookupAttributeMetadata) attrMetadata).Targets[0];
                //    er.Id = Guid.Parse(strs[0]);

                if (strs.Length > 1)
                {
                    retVal = Guid.Parse(strs[1]);
                }
                else if (strs.Length == 1)
                {
                    retVal = Guid.Parse(strs[0]);
                }
            }

            break;

            case "Integer":



                retVal = int.Parse(value);

                break;

            case "Owner":

            {
                string[] strs = value.Split('\\');

                Microsoft.Xrm.Sdk.EntityReference er = new Microsoft.Xrm.Sdk.EntityReference();

                er.LogicalName = strs[0];

                er.Id = Guid.Parse(strs[1]);

                retVal = er;
            }

            break;

            case "DateTime":     //DateTime



                retVal = DateTime.Parse(value);

                break;

            case "Boolean":     //Boolean

                retVal = bool.Parse(value);

                break;

            case "String":     //String

                retVal = value;

                break;

            case "Double":     //Double

                retVal = Double.Parse(value);

                break;

            case "EntityName":     //Entity Name

                retVal = value;

                break;

            case "Image":     //Image, it will return image name.

                retVal = value;

                break;

            case "BigInt":

                break;

            case "ManagedProperty":

                break;

            case "Uniqueidentifier":

                retVal = Guid.Parse(value);

                break;

            case "Virtual":

                break;

            default:

                //TODO: Write Err Exception

                break;
            }

            return(retVal);
        }
 public msdyn_IoTNewPrimaryAlertRequest()
 {
     this.RequestName  = "msdyn_IoTNewPrimaryAlert";
     this.PrimaryAlert = default(Microsoft.Xrm.Sdk.EntityReference);
 }
Exemplo n.º 25
0
        private async Task <string> CheckMailMergeTemplates()
        {
            StringBuilder content = new StringBuilder();

            await _comparerSource.InitializeConnection(_iWriteToOutput, content);

            string operation = string.Format(Properties.OperationNames.CheckingMailMergeTemplatesFormat2, Connection1.Name, Connection2.Name);

            content.AppendLine(_iWriteToOutput.WriteToOutputStartOperation(null, operation));

            Task <List <MailMergeTemplate> > task1 = _comparerSource.GetMailMergeTemplate1Async();
            Task <List <MailMergeTemplate> > task2 = _comparerSource.GetMailMergeTemplate2Async();

            List <MailMergeTemplate> list1 = await task1;

            content.AppendLine(_iWriteToOutput.WriteToOutput(null, "Mail Merge Templates in {0}: {1}", Connection1.Name, list1.Count()));

            List <MailMergeTemplate> list2 = await task2;

            content.AppendLine(_iWriteToOutput.WriteToOutput(null, "Mail Merge Templates in {0}: {1}", Connection2.Name, list2.Count()));

            if (list1.Count == 0 && list2.Count == 0)
            {
                _iWriteToOutput.WriteToOutput(null, Properties.OrganizationComparerStrings.ThereIsNothingToCompare);
                _iWriteToOutput.WriteToOutputEndOperation(null, operation);
                return(null);
            }

            FormatTextTableHandler tableOnlyExistsIn1 = new FormatTextTableHandler();

            tableOnlyExistsIn1.SetHeader("AssociatedEntity", "Name", "Language", "File Name", "Mail Merge Type", "Viewable By", "Owner", "Id");

            FormatTextTableHandler tableOnlyExistsIn2 = new FormatTextTableHandler();

            tableOnlyExistsIn2.SetHeader("AssociatedEntity", "Name", "Language", "File Name", "Mail Merge Type", "Viewable By", "Owner", "Id");

            Dictionary <Tuple <string, string, string, string>, List <string> > dictDifference = new Dictionary <Tuple <string, string, string, string>, List <string> >();

            foreach (MailMergeTemplate template1 in list1)
            {
                {
                    MailMergeTemplate template2 = list2.FirstOrDefault(template => template.Id == template1.Id);

                    if (template2 != null)
                    {
                        continue;
                    }
                }

                string name1       = template1.Name;
                string entityName1 = template1.TemplateTypeCode;
                int    language1   = template1.LanguageCode.Value;

                string filename   = template1.FileName;
                string reportType = template1.FormattedValues.ContainsKey(MailMergeTemplate.Schema.Attributes.mailmergetype) ? template1.FormattedValues[MailMergeTemplate.Schema.Attributes.mailmergetype] : string.Empty;

                Microsoft.Xrm.Sdk.EntityReference ownerRef = template1.OwnerId;
                string owner = string.Empty;

                if (ownerRef != null)
                {
                    owner = ownerRef.Name;
                }

                string ispersonal = template1.FormattedValues.ContainsKey(MailMergeTemplate.Schema.Attributes.ispersonal) ? template1.FormattedValues[MailMergeTemplate.Schema.Attributes.ispersonal] : string.Empty;

                tableOnlyExistsIn1.AddLine(entityName1, name1, LanguageLocale.GetLocaleName(language1), filename, reportType, ispersonal, owner, template1.Id.ToString());

                this.ImageBuilder.AddComponentSolution1((int)ComponentType.MailMergeTemplate, template1.Id);
            }

            foreach (MailMergeTemplate template2 in list2)
            {
                {
                    MailMergeTemplate template1 = list1.FirstOrDefault(template => template.Id == template2.Id);

                    if (template1 != null)
                    {
                        continue;
                    }
                }

                string name2       = template2.Name;
                string entityName2 = template2.TemplateTypeCode;
                int    language2   = template2.LanguageCode.Value;

                string filename     = template2.FileName;
                string templateType = template2.FormattedValues.ContainsKey(MailMergeTemplate.Schema.Attributes.mailmergetype) ? template2.FormattedValues[MailMergeTemplate.Schema.Attributes.mailmergetype] : string.Empty;

                Microsoft.Xrm.Sdk.EntityReference ownerRef = template2.OwnerId;
                string owner = string.Empty;

                if (ownerRef != null)
                {
                    owner = ownerRef.Name;
                }

                string ispersonal = template2.FormattedValues.ContainsKey(MailMergeTemplate.Schema.Attributes.ispersonal) ? template2.FormattedValues[MailMergeTemplate.Schema.Attributes.ispersonal] : string.Empty;

                tableOnlyExistsIn2.AddLine(entityName2, name2, LanguageLocale.GetLocaleName(language2), filename, templateType, ispersonal, owner, template2.Id.ToString());

                this.ImageBuilder.AddComponentSolution2((int)ComponentType.MailMergeTemplate, template2.Id);
            }

            foreach (MailMergeTemplate template1 in list1)
            {
                MailMergeTemplate template2 = list2.FirstOrDefault(template => template.Id == template1.Id);

                if (template2 == null)
                {
                    continue;
                }

                FormatTextTableHandler tabDiff = new FormatTextTableHandler();
                tabDiff.SetHeader("Attribute", "Organization", "Value");

                foreach (string fieldName in _fieldsToCompareMailMergeTemplateOrdinal)
                {
                    if (ContentCoparerHelper.IsEntityDifferentInField(template1, template2, fieldName))
                    {
                        string str1 = EntityDescriptionHandler.GetAttributeString(template1, fieldName, Connection1);
                        string str2 = EntityDescriptionHandler.GetAttributeString(template2, fieldName, Connection2);

                        tabDiff.AddLine(fieldName, Connection1.Name, str1);
                        tabDiff.AddLine(fieldName, Connection2.Name, str2);
                    }
                }

                foreach (string fieldName in _fieldsToCompareMailMergeTemplateXml)
                {
                    string xml1 = template1.GetAttributeValue <string>(fieldName) ?? string.Empty;
                    string xml2 = template2.GetAttributeValue <string>(fieldName) ?? string.Empty;

                    if (!ContentCoparerHelper.CompareXML(xml1, xml2).IsEqual)
                    {
                        string reason = string.Empty;

                        ContentCopareResult compare = ContentCoparerHelper.CompareXML(xml1.ToLower(), xml2.ToLower(), true);

                        if (!compare.IsEqual)
                        {
                            reason = "InCase";
                        }
                        else
                        {
                            reason = compare.GetCompareDescription();
                        }

                        tabDiff.AddLine(fieldName, string.Empty, string.Format(Properties.OrganizationComparerStrings.FieldDifferenceReasonFormat3, Connection1.Name, Connection2.Name, reason));
                    }
                }

                if (tabDiff.Count > 0)
                {
                    string name1       = template1.Name;
                    string entityName1 = template1.TemplateTypeCode;
                    int    language1   = template1.LanguageCode.Value;

                    var diff = tabDiff.GetFormatedLines(false);
                    this.ImageBuilder.AddComponentDifferent((int)ComponentType.MailMergeTemplate, template1.Id, template2.Id, string.Join(Environment.NewLine, diff));

                    dictDifference.Add(Tuple.Create(entityName1, name1, LanguageLocale.GetLocaleName(language1), template1.Id.ToString()), diff);
                }
            }

            if (tableOnlyExistsIn1.Count > 0)
            {
                content
                .AppendLine()
                .AppendLine()
                .AppendLine()
                .AppendLine(new string('-', 150))
                .AppendLine()
                .AppendLine();

                content.AppendLine().AppendLine().AppendFormat("Mail Merge Templates ONLY EXISTS in {0}: {1}", Connection1.Name, tableOnlyExistsIn1.Count);

                tableOnlyExistsIn1.GetFormatedLines(true).ForEach(e => content.AppendLine().Append((tabSpacer + e).TrimEnd()));
            }

            if (tableOnlyExistsIn2.Count > 0)
            {
                content
                .AppendLine()
                .AppendLine()
                .AppendLine()
                .AppendLine(new string('-', 150))
                .AppendLine()
                .AppendLine();

                content.AppendLine().AppendLine().AppendFormat("Mail Merge Templates ONLY EXISTS in {0}: {1}", Connection2.Name, tableOnlyExistsIn2.Count);

                tableOnlyExistsIn2.GetFormatedLines(true).ForEach(e => content.AppendLine().Append((tabSpacer + e).TrimEnd()));
            }

            if (dictDifference.Count > 0)
            {
                content
                .AppendLine()
                .AppendLine()
                .AppendLine()
                .AppendLine(new string('-', 150))
                .AppendLine()
                .AppendLine();

                content.AppendLine().AppendLine().AppendFormat("Mail Merge Templates DIFFERENT in {0} and {1}: {2}", Connection1.Name, Connection2.Name, dictDifference.Count);

                FormatTextTableHandler tableDifference = new FormatTextTableHandler();
                tableDifference.SetHeader("AssociatedEntity", "Name", "Language", "Id");

                foreach (KeyValuePair <Tuple <string, string, string, string>, List <string> > template in dictDifference)
                {
                    tableDifference.CalculateLineLengths(template.Key.Item1, template.Key.Item2, template.Key.Item3, template.Key.Item4);
                }

                foreach (KeyValuePair <Tuple <string, string, string, string>, List <string> > template in dictDifference
                         .OrderBy(w => w.Key.Item1)
                         .ThenBy(w => w.Key.Item2)
                         .ThenBy(w => w.Key.Item3)
                         .ThenBy(w => w.Key.Item4)
                         )
                {
                    content.AppendLine().Append(tabSpacer + tableDifference.FormatLine(template.Key.Item1, template.Key.Item2, template.Key.Item3, template.Key.Item4));

                    foreach (string str in template.Value)
                    {
                        content.AppendLine().Append(tabSpacer + tabSpacer + str);
                    }
                }
            }

            if (tableOnlyExistsIn2.Count == 0 &&
                tableOnlyExistsIn1.Count == 0 &&
                dictDifference.Count == 0
                )
            {
                content.AppendLine("No difference in Mail Merge Templates.");
            }

            content.AppendLine().AppendLine().AppendLine(_iWriteToOutput.WriteToOutputEndOperation(null, operation));

            string fileName = EntityFileNameFormatter.GetDifferenceConnectionsForFieldFileName(_OrgOrgName, "Mail Merge Templates");

            string filePath = Path.Combine(_folder, FileOperations.RemoveWrongSymbols(fileName));

            File.WriteAllText(filePath, content.ToString(), new UTF8Encoding(false));

            await SaveOrganizationDifferenceImage();

            return(filePath);
        }
Exemplo n.º 26
0
 public ccllc_BTF_CanNavigateForwardRequest()
 {
     this.RequestName = "ccllc_BTF_CanNavigateForward";
     this.Target      = default(Microsoft.Xrm.Sdk.EntityReference);
 }
 public tc_TcFootersSetBrandBasedRequest()
 {
     this.RequestName = "tc_TcFootersSetBrandBased";
     this.Target      = default(Microsoft.Xrm.Sdk.EntityReference);
 }
 public msdyn_GetIoTCommandMetadataRequest()
 {
     this.RequestName          = "msdyn_GetIoTCommandMetadata";
     this.IoTCommandDefinition = default(Microsoft.Xrm.Sdk.EntityReference);
 }
 public msdyn_GDPROptoutLeadRequest()
 {
     this.RequestName = "msdyn_GDPROptoutLead";
     this.optout      = default(bool);
     this.Target      = default(Microsoft.Xrm.Sdk.EntityReference);
 }
Exemplo n.º 30
0
 public PvaDeleteBotRequest()
 {
     this.RequestName = "PvaDeleteBot";
     this.Target      = default(Microsoft.Xrm.Sdk.EntityReference);
 }