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


C# IOrganizationService.GetEntities方法代码示例

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


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

示例1: UpdateViews

        private void UpdateViews(IOrganizationService service, AttributeMetadata from, AttributeMetadata to)
        {
            Trace("Retrieving Views");
            var queries = service.GetEntities<SavedQuery>(q => new { q.Id, q.Name, q.QueryType, q.FetchXml, q.LayoutXml },
                new ConditionExpression("fetchxml", ConditionOperator.Like, "%<entity name=\"" + from.EntityLogicalName + "\">%name=\"" + from.LogicalName + "\"%"),
                LogicalOperator.Or,
                new ConditionExpression("fetchxml", ConditionOperator.Like, "%<entity name=\"" + from.EntityLogicalName + "\">%attribute=\"" + from.LogicalName + "\"%"));

            foreach (var query in queries)
            {
                Trace("Updating View " + query.Name);
                query.FetchXml = query.FetchXml.Replace("name=\"" + from.LogicalName + "\"", "name=\"" + to.LogicalName + "\"");
                query.FetchXml = query.FetchXml.Replace("attribute=\"" + from.LogicalName + "\"", "attribute=\"" + to.LogicalName + "\"");
                if (query.LayoutXml != null)
                {
                    query.LayoutXml = query.LayoutXml.Replace("name=\"" + from.LogicalName + "\"", "name=\"" + to.LogicalName + "\"");
                }
                service.Update(query);
            }
        }
开发者ID:ganpathv,项目名称:DLaB.Xrm.XrmToolBoxTools,代码行数:20,代码来源:Logic.cs

示例2: UpdateCharts

        private void UpdateCharts(IOrganizationService service, AttributeMetadata from, AttributeMetadata to)
        {
            var fromValue = "name=\"" + from.LogicalName + "\"";
            var toValue = "name=\"" + to.LogicalName + "\"";
            var entityAttributeLikeExpression = $"%<entity name=\"{@from.EntityLogicalName}\">%{fromValue}%";

            Trace("Retrieving System Charts with cond: " + fromValue);
            var systemCharts = service.GetEntities<SavedQueryVisualization>(c => new { c.Id, c.DataDescription },
                new ConditionExpression(SavedQueryVisualization.Fields.DataDescription, ConditionOperator.Like, entityAttributeLikeExpression));

            foreach (var chart in systemCharts)
            {
                Trace("Updating Chart " + chart.Name);
                chart.DataDescription = chart.DataDescription.Replace(fromValue, toValue);
                service.Update(chart);
            }

            Trace("Retrieving User Charts with cond: " + fromValue);
            var userCharts = service.GetEntities<UserQueryVisualization>(c => new { c.Id, c.DataDescription },
                new ConditionExpression(UserQueryVisualization.Fields.DataDescription, ConditionOperator.Like, entityAttributeLikeExpression));

            foreach (var chart in userCharts)
            {
                Trace("Updating Chart " + chart.Name);
                chart.DataDescription = chart.DataDescription.Replace(fromValue, toValue);
                service.Update(chart);
            }
        }
开发者ID:ganpathv,项目名称:DLaB.Xrm.XrmToolBoxTools,代码行数:28,代码来源:Logic.cs

示例3: UpdateForms

        private void UpdateForms(IOrganizationService service, AttributeMetadata from, AttributeMetadata to)
        {
            Trace("Retrieving Forms");
            var forms = service.GetEntities<SystemForm>(
                "objecttypecode", from.EntityLogicalName,
                new ConditionExpression("formxml", ConditionOperator.Like, "%<control id=\"" + from.LogicalName + "\"%"));

            foreach (var form in forms)
            {
                Trace("Updating Form " + form.Name);
                form.FormXml = form.FormXml.Replace("<control id=\"" + from.LogicalName + "\"", "<control id=\"" + to.LogicalName + "\"").
                    Replace("datafieldname=\"" + from.LogicalName + "\"", "datafieldname=\"" + to.LogicalName + "\"");
                service.Update(form);
            }
        }
开发者ID:ganpathv,项目名称:DLaB.Xrm.XrmToolBoxTools,代码行数:15,代码来源:Logic.cs

示例4: UpdateMappings

        private void UpdateMappings(IOrganizationService service, AttributeMetadata att)
        {
            Trace("Looking up Mappings");
            var mappings = service.GetEntities<AttributeMap>(AttributeMap.Fields.SourceAttributeName,
                att.LogicalName,
                LogicalOperator.Or,
                AttributeMap.Fields.TargetAttributeName,
                att.LogicalName);
            foreach (var mapping in mappings.Where(m => !m.IsManaged.GetValueOrDefault() && !m.IsSystem.GetValueOrDefault()))
            {
                Trace("Deleting Attribute Mapping: " + mapping.Id);
                service.Delete(mapping.LogicalName, mapping.Id);
            }

            if (mappings.Count == 0)
            {
                Trace("No Mappings Found");
            }
        }
开发者ID:daryllabar,项目名称:DLaB.Xrm.XrmToolBoxTools,代码行数:19,代码来源:DeleteLogic.cs

示例5: 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

示例6: GetViewsWithAttribute

        private List<SavedQuery> GetViewsWithAttribute(IOrganizationService service, AttributeMetadata @from)
        {
            var qe = QueryExpressionFactory.Create<SavedQuery>(q => new
            {
                q.Id,
                q.Name,
                q.QueryType,
                q.FetchXml,
                q.LayoutXml
            });

            AddFetchXmlCriteria(qe, SavedQuery.Fields.FetchXml, @from.EntityLogicalName, @from.LogicalName);

            Trace("Retrieving Views with Query: " + qe.GetSqlStatement());
            var views = service.GetEntities(qe);
            return views;
        }
开发者ID:daryllabar,项目名称:DLaB.Xrm.XrmToolBoxTools,代码行数:17,代码来源:Logic.cs

示例7: 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

示例8: UpdatePluginStepImages

        private void UpdatePluginStepImages(IOrganizationService service, AttributeMetadata att, AttributeMetadata to)
        {
            var qe = QueryExpressionFactory.Create<SdkMessageProcessingStepImage>();
            qe.AddLink<SdkMessageFilter>(SdkMessageFilter.Fields.SdkMessageFilterId)
                .WhereEqual(SdkMessageFilter.Fields.PrimaryObjectTypeCode, att.EntityLogicalName);
            AddConditionsForValueInCsv(qe.Criteria, qe.EntityName, SdkMessageProcessingStepImage.Fields.Attributes1, att.LogicalName);

            Trace("Checking for Plugin Registration Step Images Attribute Dependencies with Query: " + qe.GetSqlStatement());

            foreach (var step in service.GetEntities(qe))
            {
                var filter = ReplaceCsvValues(step.Attributes1, att.LogicalName, to.LogicalName);
                Trace("Updating {0} - \"{1}\" to \"{2}\"", step.Name, step.Attributes1, filter);
                service.Update(new SdkMessageProcessingStepImage
                {
                    Id = step.Id,
                    Attributes1 = filter
                });
            }
        }
开发者ID:daryllabar,项目名称:DLaB.Xrm.XrmToolBoxTools,代码行数:20,代码来源:Logic.cs

示例9: GetFormsWithAttribute

        private List<SystemForm> GetFormsWithAttribute(IOrganizationService service, AttributeMetadata att)
        {
            var qe = QueryExpressionFactory.Create<SystemForm>(q => new
            {
                q.Id,
                q.Name,
                q.FormXml
            },
                SystemForm.Fields.ObjectTypeCode, att.EntityLogicalName,
                new ConditionExpression("formxml", ConditionOperator.Like, "%<control %datafieldname=\"" + att.LogicalName + "\"%"));

            Trace("Retrieving Forms with Query: " + qe.GetSqlStatement());
            return service.GetEntities(qe);
        }
开发者ID:daryllabar,项目名称:DLaB.Xrm.XrmToolBoxTools,代码行数:14,代码来源:Logic.cs

示例10: GetUserChartsWithAttribute

        private List<UserQueryVisualization> GetUserChartsWithAttribute(IOrganizationService service, AttributeMetadata from)
        {
            var qe = QueryExpressionFactory.Create<UserQueryVisualization>(q => new
            {
                q.Id,
                q.DataDescription
            });

            AddFetchXmlCriteria(qe, UserQueryVisualization.Fields.DataDescription, from.EntityLogicalName, from.LogicalName);

            Trace("Retrieving System Charts with Query: " + qe.GetSqlStatement());
            return service.GetEntities(qe);
        }
开发者ID:daryllabar,项目名称:DLaB.Xrm.XrmToolBoxTools,代码行数:13,代码来源:Logic.cs


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