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


C# IOrganizationService.GetEntitiesById方法代码示例

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


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

示例1: UpdateWorkflows

        private void UpdateWorkflows(IOrganizationService service, AttributeMetadata att)
        {
            Trace("Checking for Workflow Dependencies");
            var depends = ((RetrieveDependenciesForDeleteResponse)service.Execute(new RetrieveDependenciesForDeleteRequest
            {
                ComponentType = (int)ComponentType.Attribute,
                ObjectId = att.MetadataId.GetValueOrDefault()
            })).EntityCollection.ToEntityList<Dependency>().Where(d => d.DependentComponentTypeEnum == ComponentType.Workflow).ToList();

            if (!depends.Any())
            {
                Trace("No Workflow Dependencies Found");
                return;
            }

            foreach (var workflow in service.GetEntitiesById<Workflow>(depends.Select(d => d.DependentComponentObjectId.GetValueOrDefault())))
            {
                Trace("Updating {0} - {1} ({2})", workflow.CategoryEnum.ToString(), workflow.Name, workflow.Id);
                workflow.Xaml = RemoveParentXmlNodesWithTagValue(workflow.Xaml, "mxswa:ActivityReference AssemblyQualifiedName=\"Microsoft.Crm.Workflow.Activities.StepComposite,", "mcwb:Control", "DataFieldName", att.LogicalName, "mxswa:ActivityReference");
                var unsupportedXml = RemoveXmlNodesWithTagValue(workflow.Xaml, "mxswa:GetEntityProperty", "Attribute", att.LogicalName);
                if (workflow.Xaml != unsupportedXml)
                {
                    throw new NotImplementedException("Attribute is used in a Business Rules Get Entity Property.  This is unsupported for manual deletion.  Delete the Business Rule " + workflow.Name + " manually to be able to delete the attribute.");
                }
                
                var activate = workflow.StateCode == WorkflowState.Activated;
                if (activate)
                {
                    service.Execute(new SetStateRequest
                    {
                        EntityMoniker = workflow.ToEntityReference(),
                        State = new OptionSetValue((int)WorkflowState.Draft),
                        Status = new OptionSetValue((int)Workflow_StatusCode.Draft)
                    });
                }
                try
                {
                    var triggers = service.GetEntities<ProcessTrigger>(ProcessTrigger.Fields.ProcessId,
                        workflow.Id,
                        ProcessTrigger.Fields.ControlName,
                        att.LogicalName);

                    foreach (var trigger in triggers)
                    {
                        Trace("Deleting Trigger {0} for Workflow", trigger.Id);
                        service.Delete(ProcessTrigger.EntityLogicalName, trigger.Id);
                    }

                    service.Update(workflow);
                }
                finally
                {
                    if (activate)
                    {
                        service.Execute(new SetStateRequest()
                        {
                            EntityMoniker = workflow.ToEntityReference(),
                            State = new OptionSetValue((int) WorkflowState.Activated),
                            Status = new OptionSetValue((int) Workflow_StatusCode.Activated)
                        });
                    }
                }

            }
        }
开发者ID:daryllabar,项目名称:DLaB.Xrm.XrmToolBoxTools,代码行数:65,代码来源:DeleteLogic.cs

示例2: UpdateWorkflows

        private void UpdateWorkflows(IOrganizationService service, AttributeMetadata from, AttributeMetadata to)
        {
            Trace("Checking for Workflow Dependencies");
            var depends = ((RetrieveDependenciesForDeleteResponse)service.Execute(new RetrieveDependenciesForDeleteRequest
            {
                ComponentType = (int)componenttype.Attribute,
                ObjectId = from.MetadataId.GetValueOrDefault()
            })).EntityCollection.ToEntityList<Dependency>().Where(d => d.DependentComponentTypeEnum == componenttype.Workflow).ToList();

            if (!depends.Any())
            {
                Trace("No Workflow Dependencies Found");
                return;
            }

            foreach (var workflow in service.GetEntitiesById<Workflow>(depends.Select(d => d.DependentComponentObjectId.GetValueOrDefault())))
            {
                workflow.Xaml = workflow.Xaml.Replace("\"" + from.LogicalName + "\"", "\"" + to.LogicalName + "\"");
                var activate = workflow.StateCode.Value == WorkflowState.Activated;
                if (activate)
                {
                    service.Execute(new SetStateRequest()
                    {
                        EntityMoniker = workflow.ToEntityReference(),
                        State = new OptionSetValue((int) WorkflowState.Draft),
                        Status = new OptionSetValue((int) workflow_statuscode.Draft)
                    });
                }
                service.Update(workflow);
                if (activate)
                {
                    service.Execute(new SetStateRequest()
                    {
                        EntityMoniker = workflow.ToEntityReference(),
                        State = new OptionSetValue((int)WorkflowState.Activated),
                        Status = new OptionSetValue((int)workflow_statuscode.Activated)
                    });
                }
            }
        }
开发者ID:ganpathv,项目名称:DLaB.Xrm.XrmToolBoxTools,代码行数:40,代码来源:Logic.cs

示例3: UpdateWorkflows

        private void UpdateWorkflows(IOrganizationService service, AttributeMetadata att, AttributeMetadata to)
        {
            Trace("Checking for Workflow Dependencies");
            var depends = ((RetrieveDependenciesForDeleteResponse) service.Execute(new RetrieveDependenciesForDeleteRequest
            {
                ComponentType = (int) ComponentType.Attribute,
                ObjectId = att.MetadataId.GetValueOrDefault()
            })).EntityCollection.ToEntityList<Dependency>().Where(d => d.DependentComponentTypeEnum == ComponentType.Workflow).ToList();

            if (!depends.Any())
            {
                Trace("No Workflow Dependencies Found");
                return;
            }

            foreach (var workflow in service.GetEntitiesById<Workflow>(depends.Select(d => d.DependentComponentObjectId.GetValueOrDefault())))
            {
                Trace("Updating {0} - {1} ({2})", workflow.CategoryEnum.ToString(), workflow.Name, workflow.Id);
                var xml = UpdateBusinessProcessFlowClassId(workflow.Xaml, att, to);
                workflow.Xaml = xml.Replace("\"" + att.LogicalName + "\"", "\"" + to.LogicalName + "\"");
                var activate = workflow.StateCode == WorkflowState.Activated;
                if (activate)
                {
                    service.Execute(new SetStateRequest()
                    {
                        EntityMoniker = workflow.ToEntityReference(),
                        State = new OptionSetValue((int) WorkflowState.Draft),
                        Status = new OptionSetValue((int) Workflow_StatusCode.Draft)
                    });
                }

                try
                {
                    var triggers = service.GetEntities<ProcessTrigger>(ProcessTrigger.Fields.ProcessId,
                        workflow.Id,
                        ProcessTrigger.Fields.ControlName,
                        att.LogicalName);

                    foreach (var trigger in triggers)
                    {
                        Trace("Updating Trigger {0} for Workflow", trigger.Id);
                        service.Update(new ProcessTrigger
                        {
                            Id = trigger.Id,
                            ControlName = to.LogicalName
                        });
                    }

                    service.Update(workflow);
                }
                finally
                {
                    if (activate)
                    {
                        service.Execute(new SetStateRequest()
                        {
                            EntityMoniker = workflow.ToEntityReference(),
                            State = new OptionSetValue((int) WorkflowState.Activated),
                            Status = new OptionSetValue((int) Workflow_StatusCode.Activated)
                        });
                    }
                }
            }
        }
开发者ID:daryllabar,项目名称:DLaB.Xrm.XrmToolBoxTools,代码行数:64,代码来源:Logic.cs


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