当前位置: 首页>>代码示例>>C#>>正文


C# IOrganizationService.Execute方法代码示例

本文整理汇总了C#中IOrganizationService.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# IOrganizationService.Execute方法的具体用法?C# IOrganizationService.Execute怎么用?C# IOrganizationService.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IOrganizationService的用法示例。


在下文中一共展示了IOrganizationService.Execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PreValidateContactCreate

        /// <summary>
        /// Pre-Validation method will default the values of contact preference fields
        /// </summary>
        private static void PreValidateContactCreate(IPluginExecutionContext context, IOrganizationService service)
        {
            Entity contactEntity = (Entity)context.InputParameters["Target"];
            OptionSetValue doNotAllow = new OptionSetValue(1);

            contactEntity.SetAttribute("donotemail", doNotAllow);
            contactEntity.SetAttribute("donotpostalmail", doNotAllow);
            contactEntity.SetAttribute("donotbulkemail", doNotAllow);
            contactEntity.SetAttribute("donotfax", doNotAllow);

            // Get a count of child phone call entities associated with this Contact
            QueryExpression query = new QueryExpression();
            query.EntityName = "phonecall";
            query.ColumnSet = new ColumnSet(allColumns: true);
            query.Criteria = new FilterExpression();
            query.Criteria.AddCondition(new ConditionExpression("regardingobjectid", ConditionOperator.Equal, context.PrimaryEntityId));

            RetrieveMultipleRequest request = new RetrieveMultipleRequest();
            request.Query = query;
            IEnumerable<Entity> results = ((RetrieveMultipleResponse)service.Execute(request)).EntityCollection.Entities;
            if (results.Any())
            {
                // Do not default contact preference for phone if there are already some associated phone calls
                // Why? Because! Testing!
                contactEntity.SetAttribute("donotphone", doNotAllow);
            }
        }
开发者ID:tswann,项目名称:CrmPluginTesting,代码行数:30,代码来源:ContactPlugin.cs

示例2: ApplyImagesToEntities

        public static void ApplyImagesToEntities(List<EntityImageMap> mappings, IOrganizationService service)
        {
            foreach (var mapping in mappings)
            {
                if (mapping.ImageSize == 16)
                {
                    mapping.Entity.IconSmallName = mapping.WebResourceName;
                }
                else
                {
                    mapping.Entity.IconMediumName = mapping.WebResourceName;
                }

                var request = new UpdateEntityRequest { Entity = mapping.Entity };
                service.Execute(request);
            }

            string parameter = mappings.Aggregate(string.Empty, (current, mapping) => current + ("<entity>" + mapping.Entity.LogicalName + "</entity>"));

            string parameterXml = string.Format("<importexportxml ><entities>{0}</entities></importexportxml>",
                                                parameter);

            var publishRequest = new PublishXmlRequest { ParameterXml = parameterXml };
            service.Execute(publishRequest);
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:25,代码来源:MetadataManager.cs

示例3: UpdateRank

        public static int UpdateRank(IOrganizationService service, Entity workflow)
        {
            var wf = service.Retrieve("workflow", workflow.Id, new ColumnSet("statecode"));
            if (wf.GetAttributeValue<OptionSetValue>("statecode").Value != 0)
            {
                service.Execute(new SetStateRequest
                {
                    EntityMoniker = wf.ToEntityReference(),
                    State = new OptionSetValue(0),
                    Status = new OptionSetValue(-1)
                });
            }

            workflow.Attributes.Remove("statecode");
            workflow.Attributes.Remove("statuscode");
            service.Update(workflow);

            if (wf.GetAttributeValue<OptionSetValue>("statecode").Value != 0)
            {
                service.Execute(new SetStateRequest
                {
                    EntityMoniker = wf.ToEntityReference(),
                    State = new OptionSetValue(1),
                    Status = new OptionSetValue(-1)
                });
            }
            return workflow.GetAttributeValue<int>("rank");
        }
开发者ID:RazDynamics,项目名称:XrmToolBox,代码行数:28,代码来源:WorkflowHelper.cs

示例4: Import

        public void Import(ExcelWorksheet sheet, List<EntityMetadata> emds, IOrganizationService service)
        {
            var rmds = new List<OneToManyRelationshipMetadata>();

            foreach (var row in sheet.Rows.Where(r => r.Index != 0).OrderBy(r => r.Index))
            {
                var rmd = rmds.FirstOrDefault(r => r.MetadataId == new Guid(row.Cells[1].Value.ToString()));
                if (rmd == null)
                {
                    var currentEntity = emds.FirstOrDefault(e => e.LogicalName == row.Cells[0].Value.ToString());
                    if (currentEntity == null)
                    {
                        var request = new RetrieveEntityRequest
                        {
                            LogicalName = row.Cells[0].Value.ToString(),
                            EntityFilters = EntityFilters.Relationships
                        };

                        var response = ((RetrieveEntityResponse) service.Execute(request));
                        currentEntity = response.EntityMetadata;

                        emds.Add(currentEntity);
                    }

                    rmd =
                        currentEntity.OneToManyRelationships.FirstOrDefault(
                            r => r.SchemaName == row.Cells[2].Value.ToString());
                    if (rmd == null)
                    {
                        rmd =
                            currentEntity.ManyToOneRelationships.FirstOrDefault(
                                r => r.SchemaName == row.Cells[2].Value.ToString());
                    }

                    rmds.Add(rmd);
                }

                int columnIndex = 4;

                rmd.AssociatedMenuConfiguration.Label = new Label();

                while (row.Cells[columnIndex].Value != null)
                {
                    rmd.AssociatedMenuConfiguration.Label.LocalizedLabels.Add(
                        new LocalizedLabel(row.Cells[columnIndex].Value.ToString(),
                            int.Parse(sheet.Cells[0, columnIndex].Value.ToString())));

                    columnIndex++;
                }
            }

            foreach (var rmd in rmds)
            {
                var request = new UpdateRelationshipRequest
                {
                    Relationship = rmd,
                };
                service.Execute(request);
            }
        }
开发者ID:NielsMinnee,项目名称:XrmToolBox,代码行数:60,代码来源:RelationshipTranslation.cs

示例5: ResetIcons

        public static void ResetIcons(EntityMetadata emd, IOrganizationService service)
        {
            emd.IconSmallName = "";
            emd.IconMediumName = "";
            emd.IconLargeName = "";
            var request = new UpdateEntityRequest { Entity = emd };
            service.Execute(request);

            string parameterXml = string.Format("<importexportxml ><entities><entity>{0}</entity></entities></importexportxml>",
                                                emd.LogicalName);

            var publishRequest = new PublishXmlRequest { ParameterXml = parameterXml };
            service.Execute(publishRequest);
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:14,代码来源:MetadataManager.cs

示例6: OrganizationData

        public OrganizationData(IOrganizationService orgService)
        {
            var optionSetRequest = new RetrieveAllOptionSetsRequest();
            var entityRequest = new RetrieveAllEntitiesRequest
            {
                EntityFilters = EntityFilters.Entity | EntityFilters.Attributes,
                RetrieveAsIfPublished = false
            };

            OptionSets = ((RetrieveAllOptionSetsResponse)orgService.Execute(optionSetRequest))
                .OptionSetMetadata.OrderBy(o => o.Name).ToArray();

            Entities = ((RetrieveAllEntitiesResponse)orgService.Execute(entityRequest))
                .EntityMetadata.OrderBy(e => e.LogicalName).ToArray();
        }
开发者ID:aytacozkan,项目名称:crm-mobilesdk-tool-svcutil,代码行数:15,代码来源:OrganizationData.cs

示例7: ExportSolution

        /// <summary>
        /// Экспортируем решение
        /// </summary>
        /// <param name="uniquename"></param>
        /// <param name="service"></param>
        /// <param name="enviroment"></param>
        public static void ExportSolution(string uniquename, IOrganizationService service, string enviroment)
        {
            ExportSolutionRequest request = new ExportSolutionRequest
            {
                Managed = false,
                SolutionName = uniquename
            };
            ExportSolutionResponse response = (ExportSolutionResponse)service.Execute(request);

            byte[] exportXml = response.ExportSolutionFile;

            string filename = string.Empty;
            switch (enviroment)
            {
                case "Customization":
                    filename = uniquename + ".zip";
                    break;
                case "Import":
                    filename = uniquename + enviroment + ".zip";
                    break;
            }

            DirectoryHandler.SetZipPath(DirectoryHandler.TempPath + "\\" + filename, enviroment);

            File.WriteAllBytes(DirectoryHandler.CurrentBackupPath + "\\" + filename, exportXml);
            File.WriteAllBytes(DirectoryHandler.TempPath + "\\" + filename, exportXml);
        }
开发者ID:helekon,项目名称:MergeCustomization,代码行数:33,代码来源:DataHandler.cs

示例8: GetOptionsSetTextOnValue

        private string GetOptionsSetTextOnValue(IOrganizationService service, string entityName, string attributeName, int selectedValue, int LanCode)
        {
            RetrieveAttributeRequest retrieveAttributeRequest = new
            RetrieveAttributeRequest
            {

                EntityLogicalName = entityName,
                LogicalName = attributeName,
                RetrieveAsIfPublished = true
            };
            RetrieveAttributeResponse retrieveAttributeResponse = (RetrieveAttributeResponse)service.Execute(retrieveAttributeRequest);
            PicklistAttributeMetadata retrievedPicklistAttributeMetadata = (PicklistAttributeMetadata)retrieveAttributeResponse.AttributeMetadata;
            OptionMetadata[] optionList = retrievedPicklistAttributeMetadata.OptionSet.Options.ToArray();

            string selectedOptionLabel = string.Empty;
            foreach (OptionMetadata oMD in optionList)
            {
                if (oMD.Value == selectedValue)
                {
                    foreach (var item in oMD.Label.LocalizedLabels)
                    {
                        if (item.LanguageCode == LanCode)
                        {
                            selectedOptionLabel = item.Label;
                        }
                    }
                }
            }
            return selectedOptionLabel;
        }
开发者ID:e-safarzadeh,项目名称:Raybod.MSCRM.KandooWebSite,代码行数:30,代码来源:TuitionList.aspx.cs

示例9: Main

        public static void Main(IOrganizationService service)
        {
            var request = new RetrieveVersionRequest();
            var response = (RetrieveVersionResponse)service.Execute(request);
            var version = new Version(response.Version);

            Console.WriteLine("CRM Version is: {0}", version);
        }
开发者ID:BISmb,项目名称:Projects,代码行数:8,代码来源:GetXrmVersion.cs

示例10: ServiceContextBase

        public ServiceContextBase(IOrganizationService service)
        {
            LogHelper = new LogHelper(Console.WriteLine);
            AdminOrganizationService = service;
            OrganizationService = service;

            var response = (WhoAmIResponse)service.Execute(new WhoAmIRequest());
            UserId = response.UserId;
            InitiatingUserId = response.UserId;
            BusinessUnitRef = new EntityReference(BusinessUnitDefinition.EntityName, response.BusinessUnitId);
        }
开发者ID:cgoconseils,项目名称:XrmFramework,代码行数:11,代码来源:ServiceContextBase.cs

示例11: GetEntitiesMetadata

        /// <summary>
        /// Gets all entities metadata with specified informations
        /// </summary>
        /// <param name="service">Organization service</param>
        /// <param name="filters">Information to retrieve</param>
        /// <returns>List of entities metadata</returns>
        public static List<EntityMetadata> GetEntitiesMetadata(IOrganizationService service, EntityFilters filters)
        {
            var request = new RetrieveAllEntitiesRequest
            {
                EntityFilters = filters
            };

            var response = (RetrieveAllEntitiesResponse)service.Execute(request);

            return response.EntityMetadata.ToList();
        }
开发者ID:NielsMinnee,项目名称:XrmToolBox,代码行数:17,代码来源:MetadataHelper.cs

示例12: RetrieveEntities

        /// <summary>
        /// Gets the list of entities metadata (only Entity Items)
        /// </summary>
        /// <returns>List of entities metadata</returns>
        public static List<EntityMetadata> RetrieveEntities(IOrganizationService oService)
        {
            var request = new RetrieveAllEntitiesRequest
            {
                EntityFilters = EntityFilters.Entity | EntityFilters.Attributes
            };

            var response = (RetrieveAllEntitiesResponse)oService.Execute(request);

            return response.EntityMetadata.ToList();
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:15,代码来源:MetadataHelper.cs

示例13: GetEntitiesList

        /// <summary>
        /// Recupere la liste des EntityMetadata presente dans la CRM
        /// </summary>
        /// <param name="service">CRM Service</param>
        /// <returns>Liste des entites retrouvees</returns>
        public static List<EntityMetadata> GetEntitiesList(IOrganizationService service)
        {
            var req = new RetrieveAllEntitiesRequest
            {
                EntityFilters = EntityFilters.Entity
            };

            var resp = (RetrieveAllEntitiesResponse)service.Execute(req);
            //resp.EntityMetadata[0].icon

            return resp.EntityMetadata.Where(ent => ent.IsCustomEntity != null && (ent.DisplayName.UserLocalizedLabel != null && ent.IsCustomEntity.Value)).ToList();
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:17,代码来源:MetadataManager.cs

示例14: RetrieveEntities

        /// <summary>
        /// Gets the list of entities metadata (only Entity Items)
        /// </summary>
        /// <returns>List of entities metadata</returns>
        public static List<EntityMetadata> RetrieveEntities(IOrganizationService oService)
        {
            var response = (RetrieveAllEntitiesResponse)oService.Execute(new RetrieveAllEntitiesRequest
            {
                EntityFilters = EntityFilters.Entity | EntityFilters.Attributes
            });

            return
                response.EntityMetadata.Where(
                    emd => emd.DisplayName.UserLocalizedLabel != null &&
                           (emd.IsCustomizable.Value || emd.IsManaged.HasValue && emd.IsManaged.Value == false))
                    .ToList();
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:17,代码来源:MetadataHelper.cs

示例15: LoadEntities

 public static RetrieveMetadataChangesResponse LoadEntities(IOrganizationService service)
 {
     if (service == null)
     {
         return null;
     }
     var eqe = new EntityQueryExpression();
     eqe.Properties = new MetadataPropertiesExpression(entityProperties);
     var req = new RetrieveMetadataChangesRequest()
     {
         Query = eqe,
         ClientVersionStamp = null
     };
     return service.Execute(req) as RetrieveMetadataChangesResponse;
 }
开发者ID:Innofactor,项目名称:CRMWinForm,代码行数:15,代码来源:MetadataHelper.cs


注:本文中的IOrganizationService.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。