Exemplo n.º 1
0
        public SPWorkflowInstance StartWorkflow(SPListItemInstance listItem, SPWorkflowAssociationInstance association, object eventData, object isAutoStart)
        {
            if (listItem == null)
            {
                throw new JavaScriptException(this.Engine, "Error",
                                              "An instance of a SPListItem object must be supplied as the first argument.");
            }

            if (association == null)
            {
                throw new JavaScriptException(this.Engine, "Error",
                                              "An instance of a SPWorkflowAssociation object must be supplied as the second argument.");
            }

            var assData = association.SPWorkflowAssociation.AssociationData;

            if (eventData != Undefined.Value)
            {
                assData = TypeConverter.ToString(eventData);
            }

            var result = isAutoStart == Undefined.Value
                ? m_workflowManager.StartWorkflow(listItem.ListItem, association.SPWorkflowAssociation, assData)
                : m_workflowManager.StartWorkflow(listItem.ListItem, association.SPWorkflowAssociation, assData, TypeConverter.ToBoolean(isAutoStart));

            return(result == null
                ? null
                : new SPWorkflowInstance(this.Engine.Object.InstancePrototype, result));
        }
        public void Update(SPWorkflowAssociationInstance workflowAssociation)
        {
            if (workflowAssociation == null)
            {
                throw new JavaScriptException(Engine, "Error", "Workflow Association must be supplied as first argument.");
            }

            m_workflowAssociationCollection.Update(workflowAssociation.SPWorkflowAssociation);
        }
Exemplo n.º 3
0
        public int CountWorkflowsByAssociation(SPWorkflowAssociationInstance association)
        {
            if (association == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "An instance of a SPWorkflowAssociation object must be supplied as the first argument.");
            }

            return(m_workflowManager.CountWorkflows(association.SPWorkflowAssociation));
        }
Exemplo n.º 4
0
        public SPWorkflowInstance StartWorkflowWithContext(object context, SPWorkflowAssociationInstance association, object eventData, object runOptions)
        {
            if (association == null)
            {
                throw new JavaScriptException(this.Engine, "Error",
                                              "An instance of a SPWorkflowAssociation object must be supplied as the second argument.");
            }

            var wfRunOptions = SPWorkflowRunOptions.Synchronous;

            if (runOptions != Undefined.Value)
            {
                SPWorkflowRunOptions tmpOptions;
                if (TypeConverter.ToString(runOptions).TryParseEnum(true, out tmpOptions))
                {
                    wfRunOptions = tmpOptions;
                }
            }

            var assData = association.SPWorkflowAssociation.AssociationData;

            if (eventData != Undefined.Value)
            {
                assData = TypeConverter.ToString(eventData);
            }

            object localContext = null;

            if (context is SPListItemInstance)
            {
                localContext = (context as SPListItemInstance).ListItem;
            }
            else if (context is SPSiteInstance)
            {
                localContext = (context as SPSiteInstance).Site;
            }
            else if (context is SPListInstance)
            {
                localContext = (context as SPListInstance).List;
            }
            else if (context is SPContentTypeInstance)
            {
                localContext = (context as SPContentTypeInstance).ContentType;
            }

            var result = m_workflowManager.StartWorkflow(localContext,
                                                         association.SPWorkflowAssociation, assData, wfRunOptions);

            return(result == null
                ? null
                : new SPWorkflowInstance(this.Engine.Object.InstancePrototype, result));
        }
        public SPWorkflowAssociationInstance Add(SPWorkflowAssociationInstance workflowAssociation)
        {
            if (workflowAssociation == null)
            {
                throw new JavaScriptException(Engine, "Error", "Workflow Association must be supplied as first argument.");
            }

            var result = m_workflowAssociationCollection.Add(workflowAssociation.SPWorkflowAssociation);

            return(result == null
                ? null
                : new SPWorkflowAssociationInstance(Engine.Object.InstancePrototype, result));
        }