本文整理汇总了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)
});
}
}
}
}
示例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)
});
}
}
}
示例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)
});
}
}
}
}