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


C# WorkflowServicesManager类代码示例

本文整理汇总了C#中WorkflowServicesManager的典型用法代码示例。如果您正苦于以下问题:C# WorkflowServicesManager类的具体用法?C# WorkflowServicesManager怎么用?C# WorkflowServicesManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GetWorkflowSubscription

 /// <summary>
 /// Returns a workflow subscription (associations) for a list
 /// </summary>
 /// <param name="list"></param>
 /// <param name="name"></param>
 /// <returns></returns>
 public static WorkflowSubscription GetWorkflowSubscription(this List list, string name)
 {
     var servicesManager = new WorkflowServicesManager(list.Context, list.ParentWeb);
     var subscriptionService = servicesManager.GetWorkflowSubscriptionService();
     var subscriptions = subscriptionService.EnumerateSubscriptionsByList(list.Id);
     var subscriptionQuery = from sub in subscriptions where sub.Name == name select sub;
     var subscriptionResults = list.Context.LoadQuery(subscriptionQuery);
     list.Context.ExecuteQueryRetry();
     var subscription = subscriptionResults.FirstOrDefault();
     return subscription;
 }
开发者ID:ipbhattarai,项目名称:PnP,代码行数:17,代码来源:WorkflowExtensions.cs

示例2: 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);
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:28,代码来源:SP2013WorkflowSubscriptionDefinitionModelHandler.cs

示例3: AddWorkflowDefinition

        public static Guid AddWorkflowDefinition(this Web web, WorkflowDefinition definition, bool publish = true)
        {
            var servicesManager = new WorkflowServicesManager(web.Context, web);
            var deploymentService = servicesManager.GetWorkflowDeploymentService();

            WorkflowDefinition def = new WorkflowDefinition(web.Context);
            def.AssociationUrl = definition.AssociationUrl;
            def.Description = definition.Description;
            def.DisplayName = definition.DisplayName;
            def.DraftVersion = definition.DraftVersion;
            def.FormField = definition.FormField;
            def.Id = definition.Id != Guid.Empty ? definition.Id : Guid.NewGuid();
            foreach (var prop in definition.Properties)
            {
                def.SetProperty(prop.Key,prop.Value);
            }
            def.RequiresAssociationForm = definition.RequiresAssociationForm;
            def.RequiresInitiationForm = definition.RequiresInitiationForm;
            def.RestrictToScope = definition.RestrictToScope;
            def.RestrictToType = definition.RestrictToType;
            def.Xaml = definition.Xaml;

            var result = deploymentService.SaveDefinition(def);

            web.Context.ExecuteQueryRetry();

            if (publish)
            {
                deploymentService.PublishDefinition(result.Value);
                web.Context.ExecuteQueryRetry();
            }
            return result.Value;
        }
开发者ID:rroman81,项目名称:PnP-Sites-Core,代码行数:33,代码来源:WorkflowExtensions.cs

示例4: GetCurrentWorkflowDefinition

        protected WorkflowDefinition GetCurrentWorkflowDefinition(SPWeb web,
            SP2013WorkflowDefinition workflowDefinitionModel)
        {
            var workflowServiceManager = new WorkflowServicesManager(web);
            var workflowDeploymentService = workflowServiceManager.GetWorkflowDeploymentService();

            var publishedWorkflows = workflowDeploymentService.EnumerateDefinitions(false);
            return publishedWorkflows.FirstOrDefault(w => w.DisplayName == workflowDefinitionModel.DisplayName);
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:9,代码来源:SP2013WorkflowDefinitionHandler.cs

示例5: GetWorkflowSubscriptions

        /// <summary>
        /// Returns all the workflow subscriptions (associations) for the web and the lists of that web
        /// </summary>
        /// <param name="web">The target Web</param>
        /// <returns></returns>
        public static WorkflowSubscription[] GetWorkflowSubscriptions(this Web web)
        {
            // Get a reference to infrastructural services
            var servicesManager = new WorkflowServicesManager(web.Context, web);
            var subscriptionService = servicesManager.GetWorkflowSubscriptionService();

            // Retrieve all the subscriptions (site and lists)
            var subscriptions = subscriptionService.EnumerateSubscriptions();
            web.Context.Load(subscriptions);
            web.Context.ExecuteQueryRetry();
            return subscriptions.ToArray();
        }
开发者ID:LiyeXu,项目名称:PnP-Sites-Core,代码行数:17,代码来源:WorkflowExtensions.cs

示例6: GetCurrentWebWorkflowSubscriptioBySourceId

        protected WorkflowSubscription GetCurrentWebWorkflowSubscriptioBySourceId(
             object host,
             SPWeb web,
             Guid eventSourceId,
             SP2013WorkflowSubscriptionDefinition workflowSubscriptionModel)
        {
            var workflowServiceManager = new WorkflowServicesManager(web);
            var workflowSubscriptionService = workflowServiceManager.GetWorkflowSubscriptionService();
            var subscriptions = workflowSubscriptionService.EnumerateSubscriptionsByEventSource(eventSourceId);

            return subscriptions.FirstOrDefault(s => s.Name == workflowSubscriptionModel.Name);
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:12,代码来源:SP2013WorkflowSubscriptionDefinitionModelHandler.cs

示例7: ExecuteCmdlet

        protected override void ExecuteCmdlet()
        {
            if (string.IsNullOrEmpty(Name))
            {
                var servicesManager = new WorkflowServicesManager(ClientContext, SelectedWeb);
                var deploymentService = servicesManager.GetWorkflowDeploymentService();
                var definitions = deploymentService.EnumerateDefinitions(PublishedOnly);

                ClientContext.Load(definitions);

                ClientContext.ExecuteQueryRetry();
                WriteObject(definitions, true);
            }
            else
            {
                WriteObject(SelectedWeb.GetWorkflowDefinition(Name, PublishedOnly));
            }
        }
开发者ID:johnnygoodey,项目名称:PnP-PowerShell,代码行数:18,代码来源:GetWorkflowDefinition.cs

示例8: GetCurrentWorkflowDefinition

        protected WorkflowDefinition GetCurrentWorkflowDefinition(Web web, SP2013WorkflowDefinition workflowDefinitionModel)
        {
            TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Resolving workflow definition by DisplayName: [{0}]", workflowDefinitionModel.DisplayName);

            var clientContext = web.Context;

            var workflowServiceManager = new WorkflowServicesManager(clientContext, web);
            var workflowDeploymentService = workflowServiceManager.GetWorkflowDeploymentService();

            var publishedWorkflows = workflowDeploymentService.EnumerateDefinitions(false);
            clientContext.Load(publishedWorkflows, c => c.Include(
                        w => w.DisplayName,
                        w => w.Id,
                        w => w.Published
                        ));
            clientContext.ExecuteQueryWithTrace();

            return publishedWorkflows.FirstOrDefault(w => w.DisplayName == workflowDefinitionModel.DisplayName);

        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:20,代码来源:SP2013WorkflowDefinitionHandler.cs

示例9: ExecuteCmdlet

        protected override void ExecuteCmdlet()
        {
            if (List != null)
            {
                var list = SelectedWeb.GetList(List);

                if (string.IsNullOrEmpty(Name))
                {
                    var servicesManager = new WorkflowServicesManager(ClientContext, SelectedWeb);
                    var subscriptionService = servicesManager.GetWorkflowSubscriptionService();
                    var subscriptions = subscriptionService.EnumerateSubscriptionsByList(list.Id);

                    ClientContext.Load(subscriptions);

                    ClientContext.ExecuteQueryRetry();
                    WriteObject(subscriptions, true);
                }
                else
                {
                    WriteObject(list.GetWorkflowSubscription(Name));
                }
            }
            else
            {
                if (string.IsNullOrEmpty(Name))
                {
                    var servicesManager = new WorkflowServicesManager(ClientContext, SelectedWeb);
                    var subscriptionService = servicesManager.GetWorkflowSubscriptionService();
                    var subscriptions = subscriptionService.EnumerateSubscriptions();

                    ClientContext.Load(subscriptions);

                    ClientContext.ExecuteQueryRetry();
                    WriteObject(subscriptions, true);
                }
                else
                {
                    WriteObject(SelectedWeb.GetWorkflowSubscription(Name));
                }
            }
        }
开发者ID:ivanvagunin,项目名称:PnP,代码行数:41,代码来源:GetWorkflowSubscription.cs

示例10: ProcessOneWayEvent

        public void ProcessOneWayEvent(SPRemoteEventProperties properties)
        {
            if (properties.EventType != SPRemoteEventType.ItemAdded)
            return;

              // build client context using S2S
              using (ClientContext context = TokenHelper.CreateRemoteEventReceiverClientContext(properties)) {
            Web web = context.Web;

            // create a collection of name/value pairs to pass to the workflow upon starting
            var args = new Dictionary<string, object>();
            args.Add("RemoteEventReceiverPassedValue", "Hello from the Remote Event Receiver! - " + DateTime.Now.ToString());

            // get reference to Workflow Service Manager (WSM) in SP...
            WorkflowServicesManager wsm = new WorkflowServicesManager(context, web);
            context.Load(wsm);
            context.ExecuteQuery();

            // get reference to subscription service
            WorkflowSubscriptionService subscriptionService = wsm.GetWorkflowSubscriptionService();
            context.Load(subscriptionService);
            context.ExecuteQuery();

            // get the only workflow association on item's list
            WorkflowSubscription association = subscriptionService.EnumerateSubscriptionsByList(properties.ItemEventProperties.ListId).FirstOrDefault();

            // get reference to instance service (to start a new workflow)
            WorkflowInstanceService instanceService = wsm.GetWorkflowInstanceService();
            context.Load(instanceService);
            context.ExecuteQuery();

            // start the workflow
            instanceService.StartWorkflowOnListItem(association, properties.ItemEventProperties.ListItemId, args);

            // execute the CSOM request
            context.ExecuteQuery();
              }
        }
开发者ID:zohaib01khan,项目名称:Sharepoint-training-for-Learning,代码行数:38,代码来源:RemoteEventReceiver.svc.cs

示例11: GetWorkflowDefinition

        protected WorkflowDefinition GetWorkflowDefinition(object host,
            SPWeb web,
            SP2013WorkflowSubscriptionDefinition workflowSubscriptionModel)
        {
            TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Resolving workflow definition by DisplayName: [{0}]", workflowSubscriptionModel.WorkflowDisplayName);
            var workflowServiceManager = new WorkflowServicesManager(web);

            var workflowSubscriptionService = workflowServiceManager.GetWorkflowSubscriptionService();
            var workflowDeploymentService = workflowServiceManager.GetWorkflowDeploymentService();
            var tgtwis = workflowServiceManager.GetWorkflowInstanceService();

            var publishedWorkflows = workflowDeploymentService.EnumerateDefinitions(true);

            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;
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:24,代码来源:SP2013WorkflowSubscriptionDefinitionModelHandler.cs

示例12: Delete

        /// <summary>
        /// Deletes the subscription
        /// </summary>
        /// <param name="subscription"></param>
        public static void Delete(this WorkflowSubscription subscription)
        {
            var clientContext = subscription.Context as ClientContext;
            var servicesManager = new WorkflowServicesManager(clientContext, clientContext.Web);

            var subscriptionService = servicesManager.GetWorkflowSubscriptionService();

            subscriptionService.DeleteSubscription(subscription.Id);

            clientContext.ExecuteQueryRetry();
        }
开发者ID:xaviayala,项目名称:Birchman,代码行数:15,代码来源:WorkflowExtensions.cs

示例13: ProvisionObjects

        public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
        {
            using (var scope = new PnPMonitoredScope(this.Name))
            {
                // Get a reference to infrastructural services
                WorkflowServicesManager servicesManager = null;

                try
                {
                    servicesManager = new WorkflowServicesManager(web.Context, web);
                }
                catch (ServerException)
                {
                    // If there is no workflow service present in the farm this method will throw an error.
                    // Swallow the exception
                }

                if (servicesManager != null)
                {
                    var deploymentService = servicesManager.GetWorkflowDeploymentService();
                    var subscriptionService = servicesManager.GetWorkflowSubscriptionService();

                    // Pre-load useful properties
                    web.EnsureProperty(w => w.Id);

                    // Provision Workflow Definitions
                    foreach (var definition in template.Workflows.WorkflowDefinitions)
                    {
                        // Load the Workflow Definition XAML
                        Stream xamlStream = template.Connector.GetFileStream(definition.XamlPath);
                        System.Xml.Linq.XElement xaml = System.Xml.Linq.XElement.Load(xamlStream);

                        // Create the WorkflowDefinition instance
                        Microsoft.SharePoint.Client.WorkflowServices.WorkflowDefinition workflowDefinition =
                            new Microsoft.SharePoint.Client.WorkflowServices.WorkflowDefinition(web.Context)
                            {
                                AssociationUrl = definition.AssociationUrl,
                                Description = definition.Description,
                                DisplayName = definition.DisplayName,
                                FormField = definition.FormField,
                                DraftVersion = definition.DraftVersion,
                                Id = definition.Id,
                                InitiationUrl = definition.InitiationUrl,
                                RequiresAssociationForm = definition.RequiresAssociationForm,
                                RequiresInitiationForm = definition.RequiresInitiationForm,
                                RestrictToScope = parser.ParseString(definition.RestrictToScope),
                                RestrictToType = definition.RestrictToType != "Universal" ? definition.RestrictToType : null,
                                Xaml = xaml.ToString(),
                            };

                        //foreach (var p in definition.Properties)
                        //{
                        //    workflowDefinition.SetProperty(p.Key, parser.ParseString(p.Value));
                        //}

                        // Save the Workflow Definition
                        var definitionId = deploymentService.SaveDefinition(workflowDefinition);
                        web.Context.Load(workflowDefinition);
                        web.Context.ExecuteQueryRetry();

                        // Let's publish the Workflow Definition, if needed
                        if (definition.Published)
                        {
                            deploymentService.PublishDefinition(definitionId.Value);
                        }
                    }

                    // get existing subscriptions
                    var existingWorkflowSubscriptions = web.GetWorkflowSubscriptions();

                    foreach (var subscription in template.Workflows.WorkflowSubscriptions)
                    {
                        // Check if the subscription already exists before adding it, and
                        // if already exists a subscription with the same name and with the same DefinitionId,
                        // it is a duplicate
                        string subscriptionName;
                        if (subscription.PropertyDefinitions.TryGetValue("SharePointWorkflowContext.Subscription.Name", out subscriptionName) &&
                            existingWorkflowSubscriptions.Any(s => s.PropertyDefinitions["SharePointWorkflowContext.Subscription.Name"] == subscriptionName && s.DefinitionId == subscription.DefinitionId))
                            {
                                // Thus, skip it!
                                WriteWarning(string.Format("Workflow Subscription '{0}' already exists. Skipping...", subscription.Name), ProvisioningMessageType.Warning);
                                continue;
                            }
            #if CLIENTSDKV15
                    // Create the WorkflowDefinition instance
                    Microsoft.SharePoint.Client.WorkflowServices.WorkflowSubscription workflowSubscription =
                        new Microsoft.SharePoint.Client.WorkflowServices.WorkflowSubscription(web.Context)
                        {
                            DefinitionId = subscription.DefinitionId,
                            Enabled = subscription.Enabled,
                            EventSourceId = (!String.IsNullOrEmpty(subscription.EventSourceId)) ? Guid.Parse(parser.ParseString(subscription.EventSourceId)) : web.Id,
                            EventTypes = subscription.EventTypes,
                            ManualStartBypassesActivationLimit =  subscription.ManualStartBypassesActivationLimit,
                            Name =  subscription.Name,
                            StatusFieldName = subscription.StatusFieldName,
                        };
            #else
                        // Create the WorkflowDefinition instance
                        Microsoft.SharePoint.Client.WorkflowServices.WorkflowSubscription workflowSubscription =
                            new Microsoft.SharePoint.Client.WorkflowServices.WorkflowSubscription(web.Context)
//.........这里部分代码省略.........
开发者ID:biste5,项目名称:PnP-Sites-Core,代码行数:101,代码来源:ObjectWorkflows.cs

示例14: StartWorkflowInstance

        /// <summary>
        /// Starts a new instance of a workflow definition against the current item
        /// </summary>
        /// <param name="item">The target item</param>
        /// <param name="subscriptionId">The ID of the workflow subscription to start</param>
        /// <param name="payload">Any input argument for the workflow instance</param>
        public static void StartWorkflowInstance(this ListItem item, Guid subscriptionId, IDictionary<String, Object> payload)
        {
            var parentList = item.EnsureProperty(i => i.ParentList);

            var clientContext = item.Context as ClientContext;
            var servicesManager = new WorkflowServicesManager(clientContext, clientContext.Web);

            var workflowSubscriptionService = servicesManager.GetWorkflowSubscriptionService();
            var subscriptions = workflowSubscriptionService.EnumerateSubscriptionsByList(parentList.Id);

            clientContext.Load(subscriptions, subs => subs.Where(sub => sub.Id == subscriptionId));
            clientContext.ExecuteQueryRetry();

            var subscription = subscriptions.FirstOrDefault();
            if (subscription != null)
            {
                var workflowInstanceService = servicesManager.GetWorkflowInstanceService();
                workflowInstanceService.StartWorkflowOnListItem(subscription, item.Id, payload);
                clientContext.ExecuteQueryRetry();
            }
        }
开发者ID:rroman81,项目名称:PnP-Sites-Core,代码行数:27,代码来源:WorkflowExtensions.cs

示例15: GetWorkflowDefinitions

        /// <summary>
        /// Returns all the workflow definitions
        /// </summary>
        /// <param name="web">The target Web</param>
        /// <param name="publishedOnly">Defines whether to include only published definition, or all the definitions</param>
        /// <returns></returns>
        public static WorkflowDefinition[] GetWorkflowDefinitions(this Web web, Boolean publishedOnly)
        {
            // Get a reference to infrastructural services
            var servicesManager = new WorkflowServicesManager(web.Context, web);
            var deploymentService = servicesManager.GetWorkflowDeploymentService();

            var definitions = deploymentService.EnumerateDefinitions(publishedOnly);
            web.Context.Load(definitions);
            web.Context.ExecuteQueryRetry();
            return definitions.ToArray();
        }
开发者ID:rroman81,项目名称:PnP-Sites-Core,代码行数:17,代码来源:WorkflowExtensions.cs


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