本文整理汇总了C#中ClientContext.ExecuteQueryWithTrace方法的典型用法代码示例。如果您正苦于以下问题:C# ClientContext.ExecuteQueryWithTrace方法的具体用法?C# ClientContext.ExecuteQueryWithTrace怎么用?C# ClientContext.ExecuteQueryWithTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClientContext
的用法示例。
在下文中一共展示了ClientContext.ExecuteQueryWithTrace方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCurrentWebWorkflowSubscriptioBySourceId
protected WorkflowSubscription GetCurrentWebWorkflowSubscriptioBySourceId(
object host,
ClientContext hostclientContext,
Web web,
Guid eventSourceId,
SP2013WorkflowSubscriptionDefinition workflowSubscriptionModel)
{
var context = web.Context;
var workflowServiceManager = new WorkflowServicesManager(hostclientContext, web);
context.Load(web);
context.Load(web);
context.ExecuteQueryWithTrace();
hostclientContext.Load(workflowServiceManager);
hostclientContext.ExecuteQueryWithTrace();
var workflowSubscriptionService = workflowServiceManager.GetWorkflowSubscriptionService();
var subscriptions = workflowSubscriptionService.EnumerateSubscriptionsByEventSource(eventSourceId);
hostclientContext.Load(subscriptions);
hostclientContext.ExecuteQueryWithTrace();
return subscriptions.FirstOrDefault(s => s.Name == workflowSubscriptionModel.Name);
}
示例2: GetTypedFields
protected override IEnumerable<Field> GetTypedFields(ClientContext context, FieldCollection items)
{
var typedFields = context.LoadQuery(items.Where(i => i.TypeAsString == BuiltInFieldTypes.TaxonomyFieldType));
context.ExecuteQueryWithTrace();
var result = new List<Field>();
result.AddRange(typedFields);
typedFields = context.LoadQuery(items.Where(i => i.TypeAsString == BuiltInFieldTypes.TaxonomyFieldTypeMulti));
context.ExecuteQueryWithTrace();
result.AddRange(typedFields);
return result;
}
示例3: GetTypedFields
protected override IEnumerable<Field> GetTypedFields(ClientContext context, FieldCollection items)
{
var typedFields = context.LoadQuery(items.Where(i => i.FieldTypeKind == FieldType.User));
context.ExecuteQueryWithTrace();
return typedFields;
}
示例4: GetTypedFields
protected virtual IEnumerable<Field> GetTypedFields(ClientContext context, FieldCollection items)
{
context.Load(items);
context.ExecuteQueryWithTrace();
return items.ToArray();
}
示例5: PreloadProperties
private static void PreloadProperties(ClientContext clientContext)
{
var needQuery = false;
if (!clientContext.Site.IsPropertyAvailable("ServerRelativeUrl"))
{
clientContext.Load(clientContext.Site, s => s.ServerRelativeUrl);
clientContext.ExecuteQueryWithTrace();
}
if (!clientContext.Web.IsPropertyAvailable("ServerRelativeUrl"))
{
clientContext.Load(clientContext.Web, w => w.ServerRelativeUrl);
clientContext.ExecuteQueryWithTrace();
}
}
示例6: GetTypedFields
protected override IEnumerable<Field> GetTypedFields(ClientContext context, FieldCollection items)
{
var typedFields = context.LoadQuery(items.Where(i => i.TypeAsString == BuiltInPublishingFieldTypes.HTML));
context.ExecuteQueryWithTrace();
return typedFields;
}
示例7: GetTypedFields
protected override IEnumerable<Field> GetTypedFields(ClientContext context, FieldCollection items)
{
var typedFields = context.LoadQuery(
items.Where(i => i.FieldTypeKind == FieldType.Number)
.IncludeWithDefaultProperties());
context.ExecuteQueryWithTrace();
return typedFields;
}
示例8: RetractModel
public override void RetractModel(object modelHost, DefinitionBase model)
{
// TODO, should be better behavior with try/catch or "Ensure" methods
var webModelHost = modelHost.WithAssertAndCast<WebModelHost>("modelHost", value => value.RequireNotNull());
var webModel = model.WithAssertAndCast<WebDefinition>("model", value => value.RequireNotNull());
var parentWeb = GetParentWeb(webModelHost);
var context = parentWeb.Context;
context.Load(parentWeb, w => w.RootFolder);
context.Load(parentWeb, w => w.ServerRelativeUrl);
context.ExecuteQueryWithTrace();
var currentWebUrl = GetCurrentWebUrl(context, parentWeb, webModel);
try
{
using (var webContext = new ClientContext(currentWebUrl))
{
webContext.Credentials = context.Credentials;
var tmpWeb = webContext.Web;
webContext.Load(tmpWeb);
tmpWeb.DeleteObject();
webContext.ExecuteQueryWithTrace();
}
}
catch (ClientRequestException)
{
// TODO, chekc is web exists
}
}
示例9: GetWorkflowDefinition
protected WorkflowDefinition GetWorkflowDefinition(object host,
ClientContext hostclientContext,
Web web,
SP2013WorkflowSubscriptionDefinition workflowSubscriptionModel)
{
TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Resolving workflow definition by DisplayName: [{0}]", workflowSubscriptionModel.WorkflowDisplayName);
var context = hostclientContext;
//var web = list.ParentWeb;
var workflowServiceManager = new WorkflowServicesManager(hostclientContext, web);
//context.Load(web);
//context.Load(list);
context.ExecuteQueryWithTrace();
hostclientContext.Load(workflowServiceManager);
hostclientContext.ExecuteQueryWithTrace();
var workflowSubscriptionService = workflowServiceManager.GetWorkflowSubscriptionService();
var workflowDeploymentService = workflowServiceManager.GetWorkflowDeploymentService();
var tgtwis = workflowServiceManager.GetWorkflowInstanceService();
hostclientContext.Load(workflowSubscriptionService);
hostclientContext.Load(workflowDeploymentService);
hostclientContext.Load(tgtwis);
hostclientContext.ExecuteQueryWithTrace();
var publishedWorkflows = workflowDeploymentService.EnumerateDefinitions(true);
hostclientContext.Load(publishedWorkflows);
hostclientContext.ExecuteQueryWithTrace();
var result = publishedWorkflows.FirstOrDefault(w => w.DisplayName == workflowSubscriptionModel.WorkflowDisplayName);
if (result == null)
{
TraceService.ErrorFormat((int)LogEventId.ModelProvisionCoreCall,
"Cannot find workflow definition with DisplayName: [{0}]. Provision might break.",
workflowSubscriptionModel.WorkflowDisplayName);
}
return result;
}
示例10: DeployListWorkflowSubscriptionDefinition
private void DeployListWorkflowSubscriptionDefinition(
object host,
ClientContext hostclientContext, List list, SP2013WorkflowSubscriptionDefinition workflowSubscriptionModel)
{
// hostclientContext - it must be clientContext, not ClientRuntimeContext - won't work and would give some weirs error with wg publishing
// use only clientContext instance for the workflow publishing, not ClientRuntimeContext
var context = list.Context;
var web = list.ParentWeb;
//This WorkflowServiceManager object is created for current web from client context,
//but actually it has to be created for parent web of current web.
//Otherwise it uses wrong web for provisions with multiple webs
//var workflowServiceManager = new WorkflowServicesManager(hostclientContext, hostclientContext.Web);
context.Load(web);
context.Load(list);
context.ExecuteQueryWithTrace();
//This is creation of WorkflowServiceManager with right web
var workflowServiceManager = new WorkflowServicesManager(hostclientContext, web);
hostclientContext.Load(workflowServiceManager);
hostclientContext.ExecuteQueryWithTrace();
var workflowSubscriptionService = workflowServiceManager.GetWorkflowSubscriptionService();
var workflowDeploymentService = workflowServiceManager.GetWorkflowDeploymentService();
var tgtwis = workflowServiceManager.GetWorkflowInstanceService();
hostclientContext.Load(workflowSubscriptionService);
hostclientContext.Load(workflowDeploymentService);
hostclientContext.Load(tgtwis);
hostclientContext.ExecuteQueryWithTrace();
var publishedWorkflows = workflowDeploymentService.EnumerateDefinitions(true);
hostclientContext.Load(publishedWorkflows);
hostclientContext.ExecuteQueryWithTrace();
var currentWorkflowDefinition = publishedWorkflows.FirstOrDefault(w => w.DisplayName == workflowSubscriptionModel.WorkflowDisplayName);
if (currentWorkflowDefinition == null)
throw new Exception(string.Format("Cannot lookup workflow definition with display name: [{0}] on web:[{1}]", workflowSubscriptionModel.WorkflowDisplayName, web.Url));
var subscriptions = workflowSubscriptionService.EnumerateSubscriptionsByEventSource(list.Id);
hostclientContext.Load(subscriptions);
hostclientContext.ExecuteQueryWithTrace();
var currentSubscription = subscriptions.FirstOrDefault(s => s.Name == workflowSubscriptionModel.Name);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioning,
Object = currentSubscription,
ObjectType = typeof(WorkflowSubscription),
ObjectDefinition = workflowSubscriptionModel,
ModelHost = host
});
if (currentSubscription == null)
{
var taskList = GetTaskList(web, workflowSubscriptionModel);
var historyList = GetHistoryList(web, workflowSubscriptionModel);
TraceService.Information((int)LogEventId.ModelProvisionProcessingNewObject, "Processing new SP2013 workflow subscription");
var newSubscription = new WorkflowSubscription(hostclientContext);
TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Setting subscription properties");
newSubscription.Name = workflowSubscriptionModel.Name;
newSubscription.DefinitionId = currentWorkflowDefinition.Id;
newSubscription.EventTypes = workflowSubscriptionModel.EventTypes;
newSubscription.EventSourceId = list.Id;
newSubscription.SetProperty("HistoryListId", historyList.Id.ToString());
newSubscription.SetProperty("TaskListId", taskList.Id.ToString());
newSubscription.SetProperty("ListId", list.Id.ToString());
newSubscription.SetProperty("Microsoft.SharePoint.ActivationProperties.ListId", list.Id.ToString());
MapProperties(currentSubscription, workflowSubscriptionModel);
InvokeOnModelEvent(this, new ModelEventArgs
{
CurrentModelNode = null,
Model = null,
EventType = ModelEventType.OnProvisioned,
Object = newSubscription,
ObjectType = typeof(WorkflowSubscription),
ObjectDefinition = workflowSubscriptionModel,
ModelHost = host
});
TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Calling PublishSubscription()");
//.........这里部分代码省略.........