示例#1
0
        /// <summary>
        /// 获取安装单详情
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public async Task <CrmEntity> GetInstallationorderDetail(string guid)
        {
            try
            {
                var userInfo      = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo);
                var fetchString   = _InstallationRepository.GetInstallationorderDetail(Guid.Parse(guid));
                var fetchXdoc     = XDocument.Parse(fetchString);
                var fetchResponse = await helper.ExecuteAsync(_crmService, "mcs_installationorder", fetchXdoc);

                if (fetchResponse != null && fetchResponse.Results.Count > 0)
                {
                    var item      = fetchResponse.Results[0];
                    var crmEntity = new CrmEntity(item.EntityName, item.Id);
                    crmEntity.Attributes = item.Attributes;
                    crmEntity.IsActivity = item.IsActivity;
                    crmEntity.Version    = item.Version;
                    return(crmEntity);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private static string BuildFetchXml(CrmRelationship relationship, CrmEntity entity, List <IMappingFetchCreator> mappingFetchCreators)
        {
            StringBuilder fetchXML = new StringBuilder();

            fetchXML.AppendLine("<fetch version=\"1.0\" output-format=\"xml - platform\" mapping=\"logical\" distinct=\"false\">");
            fetchXML.AppendLine("<entity name=\"" + relationship.RelatedEntityName + "\">");

            fetchXML.AppendLine("<attribute name=\"" + entity.PrimaryIdField + "\" />");
            fetchXML.AppendLine("<attribute name=\"" + relationship.TargetEntityPrimaryKey + "\" />");

            var aplicableFetchCreators = mappingFetchCreators.Where(mr => mr.UseForEntity(relationship.RelatedEntityName)).ToList();

            foreach (var rule in aplicableFetchCreators)
            {
                fetchXML.Append(rule.GetExportFetchXML(relationship.RelatedEntityName, new CrmField()
                {
                    LookupType = entity.Name, FieldName = entity.PrimaryIdField
                }));
            }

            foreach (var rule in aplicableFetchCreators)
            {
                fetchXML.Append(rule.GetExportFetchXML(relationship.RelatedEntityName, new CrmField()
                {
                    LookupType = relationship.TargetEntityName, FieldName = relationship.TargetEntityPrimaryKey
                }));
            }

            fetchXML.AppendLine("</entity>");
            fetchXML.AppendLine("</fetch>");

            return(fetchXML.ToString());
        }
示例#3
0
        /// <summary>
        /// 用户消息新增编辑
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <ValidateResult <CrmEntity> > AddAndEdit(UserMsgequest request)
        {
            var validateResult  = new ValidateResult <CrmEntity>();
            var reusetCrmEntity = new CrmEntity("mcs_user_msg", new Guid());

            //新增
            if (string.IsNullOrWhiteSpace(request.mcs_user_msgid))
            {
                var createEntity = new CrmExecuteEntity("mcs_user_msg", Guid.NewGuid());
                BasicAssignment(createEntity, request);
                var reuset = await _crmService.Create(createEntity);

                reusetCrmEntity.Id = createEntity.Id;
            }
            //编辑
            if (!string.IsNullOrWhiteSpace(request.mcs_user_msgid))
            {
                var updateEntity = new CrmExecuteEntity("mcs_user_msg", Guid.Parse(request.mcs_user_msgid));
                BasicAssignment(updateEntity, request);
                await _crmService.Update(updateEntity);

                reusetCrmEntity.Id = updateEntity.Id;
            }
            validateResult.Data        = reusetCrmEntity;
            validateResult.Result      = true;
            validateResult.Description = "操作成功";
            return(validateResult);
        }
        private static CrmSchemaConfiguration GetSchema()
        {
            CrmSchemaConfiguration schemaConfig = new CrmSchemaConfiguration();
            List <CrmEntity>       entities     = new List <CrmEntity>();
            CrmEntity contact = new CrmEntity
            {
                Name           = "contact",
                PrimaryIdField = "contactid"
            };

            List <CrmField> fields = new List <CrmField>
            {
                new CrmField {
                    FieldName = "contactid", FieldType = "guid"
                },
                new CrmField {
                    FieldName = "firstname", FieldType = "string"
                },
                new CrmField {
                    FieldName = "lastname", FieldType = "string"
                }
            };

            contact.CrmFields.AddRange(fields);

            entities.Add(contact);
            schemaConfig.Entities.AddRange(entities);

            return(schemaConfig);
        }
        public void StoreCrmEntityData()
        {
            var entityLogicalName = "contact";
            var attributeSet      = new HashSet <string>()
            {
                "contactId", "firstname", "lastname"
            };

            inputEntityAttributes.Add(entityLogicalName, attributeSet);
            var inputAttributeMapping = new AttributeTypeMapping();

            var entityMetadata = InstantiateEntityMetaData(entityLogicalName);

            InsertAttributeList(entityMetadata, new List <string> {
                "contactId", "firstname", "lastname"
            });

            var crmEntity     = new CrmEntity();
            var crmEntityList = new List <CrmEntity>();

            FluentActions.Invoking(() => systemUnderTest.StoreCrmEntityData(crmEntity, entityMetadata, crmEntityList, inputEntityRelationships, inputEntityAttributes, inputAttributeMapping, NotificationServiceMock.Object))
            .Should()
            .NotThrow();

            crmEntityList.Count.Should().Be(1);
        }
        public void CollectCrmEntityRelationShip(EntityMetadata sourceList, CrmEntity crmEntity, Dictionary <string, HashSet <string> > inputEntityRelationships)
        {
            var manyToManyRelationship = sourceList.ManyToManyRelationships;
            var relationshipList       = new List <CrmRelationship>();

            if (manyToManyRelationship != null)
            {
                foreach (var relationship in manyToManyRelationship)
                {
                    if (inputEntityRelationships.ContainsKey(sourceList.LogicalName))
                    {
                        foreach (var relationshipName in inputEntityRelationships[sourceList.LogicalName])
                        {
                            if (relationshipName == relationship.IntersectEntityName)
                            {
                                StoreCrmEntityRelationShipData(crmEntity, relationship, relationshipList);
                            }
                        }
                    }
                }
            }

            crmEntity.CrmRelationships.Clear();
            crmEntity.CrmRelationships.AddRange(relationshipList);
        }
        public bool AreCrmEntityFieldsSelected(HashSet <string> inputCheckedEntity, Dictionary <string, HashSet <string> > inputEntityRelationships, Dictionary <string, HashSet <string> > inputEntityAttributes, AttributeTypeMapping inputAttributeMapping, ServiceParameters serviceParameters)
        {
            var fieldsSelected = false;

            if (inputCheckedEntity.Count > 0)
            {
                var crmEntityList = new List <CrmEntity>();

                foreach (var item in inputCheckedEntity)
                {
                    var crmEntity  = new CrmEntity();
                    var sourceList = serviceParameters.MetadataService.RetrieveEntities(item, serviceParameters.OrganizationService, serviceParameters.ExceptionService);
                    StoreCrmEntityData(crmEntity, sourceList, crmEntityList, inputEntityRelationships, inputEntityAttributes, inputAttributeMapping, serviceParameters.NotificationService);

                    if (crmEntity.CrmFields != null && crmEntity.CrmFields.Any())
                    {
                        fieldsSelected = true;
                    }
                    else
                    {
                        fieldsSelected = false;
                        break;
                    }
                }
            }

            return(fieldsSelected);
        }
示例#8
0
        public async Task <ValidateResult> AddAnswercontent(QuestionAddRequest model)
        {
            ValidateResult ts = await _appQuestion.AddAnswercontent(model);

            CrmEntity ent = await _appQuestion.GetUserToCode(model.mcs_answername);

            //await _appUser.IntegralCreate(IntegralQuestion_Key, ent.Id.ToString());
            return(ts);
        }
示例#9
0
        public void GenerateCSharpClass(CrmEntity crmEntity)
        {
            if (string.IsNullOrWhiteSpace(CacheManager.Namespace))
            {
                CacheManager.Namespace = ControlMod.InputBox("", "Please enter a namespace", CacheManager.Namespace);
            }

            Manager.GenerateCSharpClass(ClassOptions.FromCrmEntity(crmEntity, CacheManager.Namespace));
        }
 private static void ExtractRelationships(CrmEntity entities, HashSet <string> relationShipSet)
 {
     if (entities.CrmRelationships != null)
     {
         foreach (var relationship in entities.CrmRelationships)
         {
             relationShipSet.Add(relationship.RelationshipName);
         }
     }
 }
 private static void ExtractAttributes(CrmEntity entities, HashSet <string> attributeSet)
 {
     if (entities.CrmFields != null)
     {
         foreach (var attributes in entities.CrmFields)
         {
             attributeSet.Add(attributes.FieldName);
         }
     }
 }
示例#12
0
文件: CrmService.cs 项目: mluvii/dots
        private async Task <CrmEntity> GetCustomerDetail(HttpClient client, string personId, CultureInfo culture)
        {
            CrmEntity           customer = null;
            HttpResponseMessage response = await client.GetAsync(crmUrl + $"/GetCustomerDetailById/{personId}?lang={culture.TwoLetterISOLanguageName}");

            if (response.IsSuccessStatusCode)
            {
                customer = await response.Content.ReadAsAsync <CrmEntity>();
            }

            return(customer);
        }
        public void StoreCrmEntityData(CrmEntity crmEntity, EntityMetadata sourceList, List <CrmEntity> crmEntityList, Dictionary <string, HashSet <string> > inputEntityRelationships, Dictionary <string, HashSet <string> > inputEntityAttributes, AttributeTypeMapping inputAttributeMapping, INotificationService notificationService)
        {
            crmEntity.Name = sourceList.LogicalName;

            crmEntity.DisplayName = sourceList.DisplayName?.UserLocalizedLabel == null ? string.Empty : sourceList.DisplayName.UserLocalizedLabel.Label;

            crmEntity.EntityCode       = sourceList.ObjectTypeCode.ToString();
            crmEntity.PrimaryIdField   = sourceList.PrimaryIdAttribute;
            crmEntity.PrimaryNameField = sourceList.PrimaryNameAttribute;
            CollectCrmEntityRelationShip(sourceList, crmEntity, inputEntityRelationships);
            CollectCrmAttributesFields(sourceList, crmEntity, inputEntityAttributes, inputAttributeMapping, notificationService);
            crmEntityList.Add(crmEntity);
        }
        public void Setup()
        {
            InitializeProperties();
            var entity = new CrmEntity
            {
                Name           = "contact",
                PrimaryIdField = "contactid"
            };

            crmSchemaConfiguration = new CrmSchemaConfiguration();
            crmSchemaConfiguration.Entities.Add(entity);

            systemUnderTest = new DataFileStoreWriterCsv(MockLogger.Object, FilePrefix, TestResultFolder, ExcludedFields, crmSchemaConfiguration);
        }
        public void StoreCrmEntityRelationShipData(CrmEntity crmEntity, ManyToManyRelationshipMetadata relationship, List <CrmRelationship> relationshipList)
        {
            var crmRelationShip = new CrmRelationship
            {
                RelatedEntityName      = relationship.IntersectEntityName,
                ManyToMany             = true,
                IsReflexive            = relationship.IsCustomizable.Value,
                TargetEntityPrimaryKey = crmEntity.PrimaryIdField == relationship.Entity2IntersectAttribute ? relationship.Entity1IntersectAttribute : relationship.Entity2IntersectAttribute,
                TargetEntityName       = crmEntity.Name == relationship.Entity2LogicalName ? relationship.Entity1LogicalName : relationship.Entity2LogicalName,
                RelationshipName       = relationship.IntersectEntityName
            };

            relationshipList.Add(crmRelationShip);
        }
示例#16
0
文件: MainDialog.cs 项目: mluvii/dots
        public async Task StartAsync(IDialogContext context)
        {
            var culture = Thread.CurrentThread.CurrentCulture;

            if (personId == null)
            {
                personId = Customer.DefaultPersonId;
            }
            if (crmEntity == null)
            {
                crmEntity = await crmService.GetCrmData(personId, culture);
            }
            if (crmEntity != null)
            {
                SetCallParams(context);
                var reply = context.MakeMessage();
                reply.AddThumbnailCard(
                    crmEntity.Product?.ProductName,
                    (crmEntity.Product?.ProductPrice ?? 0).ToString("C"),
                    string.Format(Resources.WelcomeMessage_prompt, crmEntity.Salutation ?? crmEntity.Customer.FullName, $"<b>{crmEntity.Product?.ProductName}</b>"),
                    new[]
                {
                    Resources.WelcomeMessage_operator,
                    Resources.MluviiDialog_virtual_assistant
                },
                    crmEntity.Product?.ProductPhotoUrl);
                await context.PostAsync(reply);

                context.Wait(MessageReceivedAsync);

                return;
            }

            await context.SayAsync(Resources.CrmQueryFailed);

            var endreply = context.MakeMessage();

            endreply.AddHeroCard(
                "",
                "",
                string.Format(Resources.goodbye, crmEntity.Customer.Email, crmEntity.Product.ProductName),
                new[]
            {
                Resources.HelpDialog_end,
            });
            await context.PostAsync(endreply);

            context.Wait(onFinished);
        }
示例#17
0
        public async Task <CrmEntity> QueryById(Guid entityId)
        {
            try
            {
                CrmEntity entity   = null;
                var       userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo);
                entity = await _crmService.Retrieve(EntityName, entityId, "", userInfo != null?userInfo.systemuserid : null);

                return(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#18
0
        /// <summary>
        /// 预约记录明细
        /// </summary>
        /// <param name="entityid"></param>
        /// <returns></returns>
        public async Task <CrmEntity> QueryDetail(string entityid)
        {
            try
            {
                var       fetchString = _appointmentInfoRepository.QueryDetail(entityid);
                CrmEntity entity      = null;
                entity = await _crmService.Retrieve("mcs_appointmentinfo", Guid.Parse(entityid), fetchString, null, dicHead);

                return(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#19
0
        public async Task <CrmEntity> Retrieve(ICrmService crmService, string entityName, Guid id, Guid?userId = null)
        {
            var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo);
            var dicHead  = new Dictionary <string, IEnumerable <string> >();

            dicHead.Add("Prefer", new List <string>()
            {
                "odata.include-annotations=\"*\""
            });
            CrmEntity entity = null;

            entity = await crmService.Retrieve(entityName, id, "", userInfo?.systemuserid, dicHead);

            return(entity);
        }
        public void CreateEmailRelationshipOrFail(string emailId, CrmEntity entity)
        {
            var success = clsSuiteCRMHelper.SetRelationship(
                new eSetRelationshipValue
            {
                module2    = "emails",
                module2_id = emailId,
                module1    = entity.ModuleName,
                module1_id = entity.EntityId,
            });

            if (!success)
            {
                throw new CrmSaveDataException($"Cannot create email relationship with {entity.ModuleName} ('set_relationship' failed)");
            }
        }
        public void CreateEmailRelationshipOrFail(string emailId, CrmEntity entity)
        {
            var success = RestAPIWrapper.TrySetRelationship(
                new SetRelationshipParams
            {
                module2    = "emails",
                module2_id = emailId,
                module1    = entity.ModuleName,
                module1_id = entity.EntityId,
            }, Objective.Email);

            if (!success)
            {
                throw new CrmSaveDataException($"Cannot create email relationship with {entity.ModuleName} ('set_relationship' failed)");
            }
        }
        private List <string> GetHeader(CrmExportedDataStore store)
        {
            store.ThrowArgumentNullExceptionIfNull(nameof(store));

            var           ent    = store.ExportedEntities.FirstOrDefault();
            List <string> header = new List <string>();

            if (!ent.IsManyToMany)
            {
                CrmEntity entity = schemaConfig.Entities.FirstOrDefault(p => p.Name == ent.LogicalName);

                var fields = entity.CrmFields.Where(p => p.FieldName != entity.PrimaryIdField).Select(p => p.FieldName).ToList();

                AddFieldWithCheck(header, entity.PrimaryIdField);

                if (fields != null)
                {
                    foreach (var field in fields)
                    {
                        AddFieldWithCheck(header, field);
                    }
                }
            }
            else
            {
                CrmEntity entity = schemaConfig.Entities
                                   .First(r => r.CrmRelationships.Select(a => a.RelatedEntityName == ent.LogicalName).Any());

                CrmRelationship rel = entity.CrmRelationships.FirstOrDefault(a => a.RelatedEntityName == ent.LogicalName);

                AddFieldWithCheck(header, $"{rel.RelationshipName}id");
                AddFieldWithCheck(header, entity.PrimaryIdField);
                AddFieldWithCheck(header, rel.TargetEntityPrimaryKey);
            }

            foreach (var item in store.ExportedEntities)
            {
                var mapAtr = item.Attributes.Where(p => p.AttributeType == "Microsoft.Xrm.Sdk.AliasedValue" && !header.Contains(p.AttributeName)).Select(p => p.AttributeName).ToList();

                foreach (var field in mapAtr)
                {
                    AddFieldWithCheck(header, field);
                }
            }

            return(header);
        }
        public void CollectCrmEntityFields(HashSet <string> inputCheckedEntity, CrmSchemaConfiguration schemaConfiguration, Dictionary <string, HashSet <string> > inputEntityRelationships, Dictionary <string, HashSet <string> > inputEntityAttributes, AttributeTypeMapping inputAttributeMapping, ServiceParameters serviceParameters)
        {
            if (inputCheckedEntity.Count > 0)
            {
                var crmEntityList = new List <CrmEntity>();

                foreach (var item in inputCheckedEntity)
                {
                    var crmEntity  = new CrmEntity();
                    var sourceList = serviceParameters.MetadataService.RetrieveEntities(item, serviceParameters.OrganizationService, serviceParameters.ExceptionService);
                    StoreCrmEntityData(crmEntity, sourceList, crmEntityList, inputEntityRelationships, inputEntityAttributes, inputAttributeMapping, serviceParameters.NotificationService);
                }

                schemaConfiguration.Entities.Clear();
                schemaConfiguration.Entities.AddRange(crmEntityList);
            }
        }
示例#24
0
        /// <summary>
        /// 预约单创建与修改(包括取消预约)
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <ValidateResult <CrmEntity> > AddOrEdit(AppointmentInfoAddOrEditRequest request)
        {
            var userInfo = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo);

            if (userInfo != null && !string.IsNullOrWhiteSpace(userInfo.mcs_dealerid))
            {
                request.appointmentinfo.mcs_dealerid = Guid.Parse(userInfo.mcs_dealerid);
            }
            if (userInfo != null && userInfo.systemuserid != null)
            {
                request.appointmentinfo.mcs_serviceadvisorid = userInfo.systemuserid;
            }
            var validateResult  = new ValidateResult <CrmEntity>();
            var reusetCrmEntity = new CrmEntity("mcs_appointmentinfo", new Guid());

            //新增预约单
            if (request.appointmentinfo.mcs_appointmentinfoid == null)
            {
                var createEntity = new CrmExecuteEntity("mcs_appointmentinfo", Guid.NewGuid());
                //预约状态 创建默认是待跟进
                createEntity.Attributes.Add("mcs_status", 10);
                BasicAssignment(createEntity, request);
                var reuset = await _crmService.Create(createEntity, userInfo?.systemuserid);

                reusetCrmEntity.Id = createEntity.Id;
            }
            //编辑预约单
            if (request.appointmentinfo.mcs_appointmentinfoid != null)
            {
                var updateEntity = new CrmExecuteEntity("mcs_appointmentinfo", (Guid)request.appointmentinfo.mcs_appointmentinfoid);
                //预约状态
                if (request.appointmentinfo.mcs_status != null)
                {
                    updateEntity.Attributes.Add("mcs_status", request.appointmentinfo.mcs_status);
                }
                BasicAssignment(updateEntity, request);
                await _crmService.Update(updateEntity, userInfo?.systemuserid);

                reusetCrmEntity.Id = (Guid)request.appointmentinfo.mcs_appointmentinfoid;
            }
            validateResult.Data        = reusetCrmEntity;
            validateResult.Result      = true;
            validateResult.Description = "操作成功";
            return(validateResult);
        }
        public void CollectCrmAttributesFields(EntityMetadata sourceList, CrmEntity crmEntity, Dictionary <string, HashSet <string> > inputEntityAttributes, AttributeTypeMapping inputAttributeMapping, INotificationService notificationService)
        {
            if (inputEntityAttributes != null)
            {
                var attributes = sourceList.Attributes.ToArray();

                var primaryAttribute = sourceList.PrimaryIdAttribute;
                if (sourceList.LogicalName != null && inputEntityAttributes.ContainsKey(sourceList.LogicalName))
                {
                    var crmFieldList = new List <CrmField>();
                    foreach (AttributeMetadata attribute in attributes)
                    {
                        StoreAttributeMetadata(attribute, sourceList, primaryAttribute, crmFieldList, inputEntityAttributes, inputAttributeMapping, notificationService);
                    }

                    crmEntity.CrmFields.Clear();
                    crmEntity.CrmFields.AddRange(crmFieldList);
                }
            }
        }
示例#26
0
 public int GetCrmEntityType(string entityName)
 {
     if (string.IsNullOrEmpty(entityName))
     {
         return(0);
     }
     if (!crmEntityDict.ContainsKey(entityName))
     {
         CrmEntity crmEntity = crmEntityList.Where(p => p.Name == entityName).FirstOrDefault();
         crmEntityDict.GetOrAdd(entityName, crmEntity != null && crmEntity.Id > 0 ? crmEntity : null);
     }
     if (crmEntityDict.ContainsKey(entityName))
     {
         CrmEntity crmEntity = crmEntityDict[entityName];
         if (crmEntity != null)
         {
             return(crmEntity.Type);
         }
     }
     return(0);
 }
示例#27
0
        /// <summary>
        /// 唯一线索详情查询
        /// </summary>
        /// <param name="entityid"></param>
        /// <returns></returns>
        public async Task <CrmEntity> GetOnlyLeadDetail(string entityid)
        {
            try
            {
                var dicHead = new Dictionary <string, IEnumerable <string> >();
                dicHead.Add("Prefer", new List <string>()
                {
                    "odata.include-annotations=\"*\""
                });

                //var fetchString = _onlyLeadRepository.GetOnlyLeadDetail(entityid);
                CrmEntity entity = null;
                entity = await _crmService.Retrieve("mcs_onlylead", Guid.Parse(entityid), "", null, dicHead);

                return(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#28
0
        /// <summary>
        /// 唯一线索编辑
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <ValidateResult <CrmEntity> > Edit(OnlyLeadEditRequest request)
        {
            var validateResult  = new ValidateResult <CrmEntity>();
            var userInfo        = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo);
            var reusetCrmEntity = new CrmEntity("mcs_onlylead", request.onlylead.mcs_onlyleadid);

            //编辑
            if (request.onlylead.mcs_onlyleadid != null)
            {
                var updateEntity = new CrmExecuteEntity("mcs_onlylead", request.onlylead.mcs_onlyleadid);

                BasicAssignment(updateEntity, request);
                await _crmService.Update(updateEntity, userInfo?.systemuserid);

                reusetCrmEntity.Id = updateEntity.Id;
            }

            validateResult.Data        = reusetCrmEntity;
            validateResult.Result      = true;
            validateResult.Description = "操作成功";
            return(validateResult);
        }
        private static string BuildFetchXml(CrmEntity entity, bool onlyActiveRecords, Dictionary <string, string> fetchXmlFilters, List <IMappingFetchCreator> mappingFetchCreators)
        {
            StringBuilder fetchXML = new StringBuilder();

            fetchXML.AppendLine("<fetch version=\"1.0\" output-format=\"xml - platform\" mapping=\"logical\" distinct=\"false\">");
            fetchXML.AppendLine("<entity name=\"" + entity.Name + "\">");

            var aplicableFetchCreators = mappingFetchCreators.Where(mr => mr.UseForEntity(entity.Name)).ToList();

            foreach (var field in entity.CrmFields)
            {
                fetchXML.AppendLine("<attribute name=\"" + field.FieldName + "\" />");

                if (field.FieldType.Equals("entityreference", StringComparison.InvariantCulture) || field.PrimaryKey)
                {
                    foreach (var rule in aplicableFetchCreators)
                    {
                        fetchXML.AppendLine(rule.GetExportFetchXML(entity.Name, field));
                    }
                }
            }

            if (onlyActiveRecords)
            {
                fetchXML.AppendLine("<filter type=\"and\" >");
                fetchXML.AppendLine($"      <condition attribute=\"{EntityFields.StateCode}\" operator=\"eq\" value=\"0\" />");
                fetchXML.AppendLine("</filter>");
            }
            else if (fetchXmlFilters != null && fetchXmlFilters.ContainsKey(entity.Name))
            {
                fetchXML.AppendLine(fetchXmlFilters[entity.Name]);
            }

            fetchXML.AppendLine("</entity>");
            fetchXML.AppendLine("</fetch>");

            return(fetchXML.ToString());
        }
示例#30
0
文件: MainDialog.cs 项目: mluvii/dots
        public async Task StartAsync(IDialogContext context)
        {
            if (personId == null)
            {
                personId = Customer.DefaultPersonId;
            }
            if (crmEntity == null)
            {
                crmEntity = await crmService.GetCrmData(personId, Thread.CurrentThread.CurrentCulture);
            }
            if (crmEntity != null)
            {
                SetCallParams(context);
                await PostWelcomeCard(context);

                context.Wait(MessageReceivedAsync);

                return;
            }

            await context.SayAsync(Resources.CrmQueryFailed);

            var endreply = context.MakeMessage();

            endreply.AddHeroCard(
                "",
                "",
                string.Format(Resources.goodbye),
                new[]
            {
                Resources.HelpDialog_end
            });
            await context.PostAsync(endreply);

            context.Wait(onFinished);
        }