예제 #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));
        }
예제 #2
0
        public SPWorkflowCollectionInstance GetItemWorkflows(SPListItemInstance item, object filter)
        {
            if (item == null)
            {
                throw new JavaScriptException(this.Engine, "Error",
                                              "An instance of a SPListItem object must be supplied as the first argument.");
            }

            SPWorkflowCollection result;

            if (filter == Undefined.Value)
            {
                result = m_workflowManager.GetItemWorkflows(item.ListItem);
            }
            else
            {
                var wf = filter as SPWorkflowFilterInstance;
                if (wf == null)
                {
                    throw new JavaScriptException(this.Engine, "Error",
                                                  "An instance of a SPWorkflowFilter object must be supplied as the second argument.");
                }
                result = m_workflowManager.GetItemWorkflows(item.ListItem, wf.SPWorkflowFilter);
            }

            return(result == null
                ? null
                : new SPWorkflowCollectionInstance(this.Engine.Object.InstancePrototype, result));
        }
예제 #3
0
        public string GetWorkflowData(SPListItemInstance task)
        {
            if (task == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A task must be specified.");
            }

            return(SPWorkflowTask.GetWorkflowData(task.ListItem));
        }
예제 #4
0
        public SPWorkflowTaskCollectionInstance GetWorkflowAvailableRunCount(SPListItemInstance listItem, object guidOrWorkflow, object filter)
        {
            if (listItem == null)
            {
                throw new JavaScriptException(this.Engine, "Error",
                                              "An instance of a SPListItem object must be supplied as the first argument.");
            }

            SPWorkflowTaskCollection result;

            if (guidOrWorkflow is SPWorkflowInstance)
            {
                if (filter == Undefined.Value)
                {
                    result = m_workflowManager.GetWorkflowTasks(listItem.ListItem,
                                                                (guidOrWorkflow as SPWorkflowInstance).SPWorkflow);
                }
                else
                {
                    var wf = filter as SPWorkflowFilterInstance;
                    if (wf == null)
                    {
                        throw new JavaScriptException(this.Engine, "Error",
                                                      "An instance of a SPWorkflowFilter object must be supplied as the second argument.");
                    }
                    result = m_workflowManager.GetWorkflowTasks(listItem.ListItem,
                                                                (guidOrWorkflow as SPWorkflowInstance).SPWorkflow, wf.SPWorkflowFilter);
                }
            }
            else
            {
                var guid = GuidInstance.ConvertFromJsObjectToGuid(guidOrWorkflow);
                if (filter == Undefined.Value)
                {
                    result = m_workflowManager.GetWorkflowTasks(listItem.ListItem,
                                                                guid);
                }
                else
                {
                    var wf = filter as SPWorkflowFilterInstance;
                    if (wf == null)
                    {
                        throw new JavaScriptException(this.Engine, "Error",
                                                      "An instance of a SPWorkflowFilter object must be supplied as the second argument.");
                    }
                    result = m_workflowManager.GetWorkflowTasks(listItem.ListItem,
                                                                guid, wf.SPWorkflowFilter);
                }
            }

            return(result == null
                ? null
                : new SPWorkflowTaskCollectionInstance(this.Engine.Object.InstancePrototype, result));
        }
예제 #5
0
        public HashtableInstance GetExtendedPropertiesAsHashtable(SPListItemInstance task)
        {
            if (task == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A task must be specified.");
            }

            var result = SPWorkflowTask.GetExtendedPropertiesAsHashtable(task.ListItem);

            return(result == null
                ? null
                : new HashtableInstance(this.Engine.Object.InstancePrototype, result));
        }
        public SPWorkflowAssociationInstance GetWorkflowAssociationByName(SPListItemInstance listItem, object id)
        {
            if (listItem == null)
            {
                throw new JavaScriptException(Engine, "Error", "ListItem must be specified as the first argument.");
            }

            var guidId = GuidInstance.ConvertFromJsObjectToGuid(id);
            var result = SPWorkflowAssociationCollection.GetAssociationForListItemById(listItem.ListItem, guidId);

            return(result == null
                ? null
                : new SPWorkflowAssociationInstance(Engine.Object.InstancePrototype, result));
        }
예제 #7
0
        public SPWorkflowCollectionInstance CreateWorkflowFromListItem(SPListItemInstance listItem, object inclusiveFilterStates,
                                                                       object exclusiveFilterStates, object rowCountLimit, object ascending)
        {
            if (listItem == null)
            {
                throw new JavaScriptException(Engine, "Error", "A listItem must be supplied.");
            }

            SPWorkflowCollection result;

            if (inclusiveFilterStates == Undefined.Value && exclusiveFilterStates == Undefined.Value &&
                rowCountLimit == Undefined.Value && ascending == Undefined.Value)
            {
                result = new SPWorkflowCollection(listItem.ListItem);
            }
            else if (rowCountLimit == Undefined.Value && ascending == Undefined.Value)
            {
                SPWorkflowState wsInclusiveFilterStates;
                if (!TypeConverter.ToString(inclusiveFilterStates).TryParseEnum(true, out wsInclusiveFilterStates))
                {
                    throw new JavaScriptException(Engine, "Error", "inclusiveFilerStates argument must be a valid SPWorkflowState.");
                }

                SPWorkflowState wsExclusiveFilterStates;
                if (!TypeConverter.ToString(exclusiveFilterStates).TryParseEnum(true, out wsExclusiveFilterStates))
                {
                    throw new JavaScriptException(Engine, "Error", "exclusiveFilterStates argument must be a valid SPWorkflowState.");
                }

                result = new SPWorkflowCollection(listItem.ListItem, wsInclusiveFilterStates, wsExclusiveFilterStates);
            }
            else
            {
                SPWorkflowState wsInclusiveFilterStates;
                if (!TypeConverter.ToString(inclusiveFilterStates).TryParseEnum(true, out wsInclusiveFilterStates))
                {
                    throw new JavaScriptException(Engine, "Error", "inclusiveFilerStates argument must be a valid SPWorkflowState.");
                }

                SPWorkflowState wsExclusiveFilterStates;
                if (!TypeConverter.ToString(exclusiveFilterStates).TryParseEnum(true, out wsExclusiveFilterStates))
                {
                    throw new JavaScriptException(Engine, "Error", "exclusiveFilterStates argument must be a valid SPWorkflowState.");
                }

                result = new SPWorkflowCollection(listItem.ListItem, wsInclusiveFilterStates, wsExclusiveFilterStates, TypeConverter.ToInteger(rowCountLimit), TypeConverter.ToBoolean(ascending));
            }

            return(new SPWorkflowCollectionInstance(Engine.Object.InstancePrototype, result));
        }
예제 #8
0
        public SPWorkflowCollectionInstance GetItemActiveWorkflows(SPListItemInstance item)
        {
            if (item == null)
            {
                throw new JavaScriptException(this.Engine, "Error",
                                              "An instance of a SPListItem object must be supplied as the first argument.");
            }

            var result = m_workflowManager.GetItemActiveWorkflows(item.ListItem);

            return(result == null
                ? null
                : new SPWorkflowCollectionInstance(this.Engine.Object.InstancePrototype, result));
        }
예제 #9
0
        public bool AlterTask(SPListItemInstance task, object htData, bool synchronous)
        {
            if (task == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A task must be specified.");
            }

            if (htData == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A hashtable of data must be specified.");
            }

            Hashtable ht;

            if (htData is HashtableInstance)
            {
                var temp = (htData as HashtableInstance).Hashtable;
                ht = new Hashtable();
                foreach (var key in temp.Keys)
                {
                    if (key is GuidInstance)
                    {
                        ht.Add((key as GuidInstance).Value, temp[key]);
                    }
                    else
                    {
                        ht.Add(TypeConverter.ToObject(this.Engine, key), TypeConverter.ToObject(this.Engine, temp[key]));
                    }
                }
            }
            else if (htData is ObjectInstance)
            {
                ht = new Hashtable();
                foreach (var prop in (htData as ObjectInstance).Properties)
                {
                    ht.Add(prop.Name, prop.Value);
                }
            }
            else
            {
                throw new JavaScriptException(this.Engine, "Error",
                                              "htData argument must either be a hashtable instance, or a js hashtable");
            }

            return(SPWorkflowTask.AlterTask(task.ListItem, ht, synchronous));
        }