예제 #1
0
        public WorkflowTaskNode(object parent, SPWorkflowTask task)
        {
            this.Tag = task;
            this.SPParent = parent;

            Setup();
        }
예제 #2
0
        private static bool GetIsTaskAssignedToUserOrGroup(SPWorkflowTask task, int userId)
        {
            SPFieldLookupValue value2 = new SPFieldLookupValue(task[SPBuiltInFieldId.AssignedTo].ToString());
            int lookupId = value2.LookupId;

            return((lookupId == userId) || SPContext.Current.Web.IsCurrentUserMemberOfGroup(lookupId));
        }
예제 #3
0
        internal static SPWorkflowTask GetCurrentUserApprovalTask(SPListItem listItem)
        {
            SPWorkflowTask task           = null;
            SPUser         contextualUser = SPContext.Current.Web.CurrentUser;

            if ((contextualUser != null) && (listItem.ParentList.DefaultContentApprovalWorkflowId != Guid.Empty))
            {
                int iD = contextualUser.ID;
                foreach (SPWorkflow workflow in listItem.Workflows)
                {
                    if ((workflow.AssociationId == listItem.ParentList.DefaultContentApprovalWorkflowId) && ((workflow.InternalState & SPWorkflowState.Running) == SPWorkflowState.Running))
                    {
                        foreach (SPWorkflowTask task2 in workflow.Tasks)
                        {
                            if (!Convert.ToBoolean(task2[SPBuiltInFieldId.Completed]) && GetIsTaskAssignedToUserOrGroup(task2, iD))
                            {
                                task = task2;
                                break;
                            }
                        }
                        continue;
                    }
                }
            }
            return(task);
        }
예제 #4
0
        public WorkflowTaskNode(object parent, SPWorkflowTask task)
        {
            this.Tag      = task;
            this.SPParent = parent;

            Setup();
        }
예제 #5
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));
        }
예제 #6
0
        public SPWorkflowTaskInstance(ScriptEngine engine, SPWorkflowTask workflowTask)
            : base(new SPListItemInstance(engine, workflowTask))
        {
            this.m_workflowTask  = workflowTask;
            this.ListItem        = workflowTask;
            this.SecurableObject = workflowTask;

            this.PopulateFunctions(this.GetType(), BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
        }
        //Not finished, don't use in that way!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        public Hashtable CheckTasks(SPUserCodeWorkflowContext context, string id, string loginName)
        {
            Hashtable results = new Hashtable();

            results["result"] = string.Empty;
            try
            {
                using (SPSite site = new SPSite(context.CurrentWebUrl))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        int currentId;
                        if (int.TryParse(id, out currentId))
                        {
                            SPList source = web.Lists["Requirements"];

                            if (source != null)
                            {
                                SPListItem sourceItem = source.GetItemById(currentId);

                                if (sourceItem != null)
                                {
                                    CheckManager(sourceItem, loginName);

                                    SPWorkflowTask taskedit = null;


                                    //SPWorkflowTask task = sourceItem.Tasks[new Guid(taskId)];
                                    //taskedit = task;

                                    //if (taskedit != null)
                                    //{
                                    //    // alter the task
                                    //    Hashtable ht = new Hashtable();
                                    //    ht["TaskStatus"] = "#";    // Mark the entry as approved

                                    //    SPWorkflowTask.AlterTask((taskedit as SPListItem), ht, true);
                                    //}
                                    //results["result"] = GetCompletionStatus(web, sourceItem);
                                }
                            }
                        }
                    }
                }

                results["success"] = true;
            }
            catch (Exception e)
            {
                results            = new Hashtable();
                results["result"]  = e.ToString();
                results["success"] = false;
            }

            return(results);
        }
예제 #8
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));
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Hashtable hashTable = new Hashtable();

            hashTable["EstimatedCosts"]  = EstimatedCosts.Text;
            hashTable["_EstimatedCosts"] = EstimatedCosts.Text;
            hashTable["Outcome"]         = Outcome.SelectedValue;
            hashTable["_Outcome"]        = Outcome.SelectedValue;
            hashTable["TaskStatus"]      = "complete";
            hashTable["PercentComplete"] = "1";

            SPWorkflowTask.AlterTask(this._taskListItem, hashTable, true);
            this.Page.Response.Clear();
            this.Page.Response.Write(string.Format(CultureInfo.InvariantCulture, "<script type=\"text/javascript\">window.frameElement.commonModalDialogClose(1, '{0}');</script>", ""));
            this.Page.Response.End();
        }
예제 #10
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));
        }
예제 #11
0
    public XmlDocument GetWFTasks(string sSiteURL, string sDocLibName, string sFolder, string sDocName, string sUser)
    {
        //temp debugging code:
        if (sUser.ToLower() == @"basexp\admin")
        {
            sUser = @"mossrtm\administrator";
        }
        sUser = @"mossrtm\administrator";
        //end temp debugging code

        string      sTaskName = string.Empty;
        string      sTaskURL  = string.Empty;
        XmlDocument xDoc      = new XmlDocument();
        XmlElement  xElem     = null;
        XmlText     xText     = null;
        XmlNode     xNode     = null;
        //SPUser usr = new SPUser(
        //this.User.
        SPSite            site   = new SPSite(sSiteURL);
        SPWeb             web    = site.OpenWeb();
        SPDocumentLibrary doclib = (SPDocumentLibrary)web.Lists[sDocLibName];
        SPListItem        item   = null;

        foreach (SPListItem itemTemp in doclib.Items)
        {
            if (sFolder == string.Empty)
            {
                if (itemTemp.File.Name.ToLower() == sDocName.ToLower())
                {
                    item = itemTemp;
                    break;
                }
            }
            else
            {
                if ((itemTemp.Folder.Name == sFolder) &&
                    (itemTemp.File.Name.ToLower() == sDocName.ToLower())
                    )
                {
                    item = itemTemp;
                    break;
                }
            }
        }
        //string sCurrentUser = this.User.Identity.Name.ToLower();

        string sTaskAssignedTo = string.Empty;

        for (int i = 0; i < item.Workflows.Count; i++)
        {
            SPWorkflow wf = item.Workflows[i];
            if (!wf.IsCompleted)
            {
                wf.TaskFilter = new SPWorkflowFilter(SPWorkflowState.Running, SPWorkflowState.None);
                for (int j = 0; j < wf.Tasks.Count; j++)
                {
                    SPWorkflowTask task = item.Workflows[i].Tasks[j];
                    sTaskAssignedTo = task["AssignedTo"].ToString();
                    sTaskAssignedTo = sTaskAssignedTo.Substring(sTaskAssignedTo.IndexOf('#') + 1);
                    if (sUser.ToLower() == sTaskAssignedTo.ToLower())
                    {
                        sTaskName = task.DisplayName;

                        sTaskURL = sSiteURL.TrimEnd('/') + "/Lists/" + wf.TaskList.Title + "/DispForm.aspx?ID=" + task.ID.ToString();
                        break;
                    }
                }
            }
        }

        xNode = xDoc.CreateNode(XmlNodeType.XmlDeclaration, string.Empty, string.Empty);
        xDoc.AppendChild(xNode);
        xElem = xDoc.CreateElement("WorkFlowTask");
        xDoc.AppendChild(xElem);
        xElem = xDoc.CreateElement("TaskName");
        xText = xDoc.CreateTextNode(sTaskName);
        xElem.AppendChild(xText);
        xDoc.ChildNodes.Item(1).AppendChild(xElem);
        xElem = xDoc.CreateElement("TaskURL");
        xText = xDoc.CreateTextNode(sTaskURL);
        xElem.AppendChild(xText);
        xDoc.ChildNodes.Item(1).AppendChild(xElem);

        return(xDoc);
    }
        private bool GetSpecificTaskItem(SPWorkflowTask newWorkflowTask, List<WorkflowTask> oldTasks, string eventDriven, out Hashtable hash)
        {
            bool isSpecific = false;
            hash = new Hashtable();

            SPFieldUserValue newTaskUserValue = new SPFieldUserValue(newWorkflowTask.Web, newWorkflowTask[SPBuiltInFieldId.AssignedTo].AsString());

            foreach (WorkflowTask oldTask in oldTasks)
            {
                SPFieldUserValue oldTaskUserValue = new SPFieldUserValue(newWorkflowTask.Web, oldTask[WorkflowTaskFieldName.AssignedTo].AsString());
                if (newTaskUserValue.User.ID.Equals(oldTaskUserValue.User.ID)
                    && oldTask[WorkflowTaskFieldName.Status] == "Completed")
                {
                    string outCome = oldTask[WorkflowTaskFieldName.Outcome].AsString();
                    CancelTask_StartDate = oldTask[WorkflowTaskFieldName.StartDate].AsString();
                    CancelTask_EndDate = oldTask[WorkflowTaskFieldName.CompleteDate].AsString();

                    hash.Add("__TaskOutcome", outCome);
                    hash.Add("__Action", "Commit");
                    hash.Add("__WorkflowVaribales", eventDriven);
                    hash.Add("StartDate", oldTask[WorkflowTaskFieldName.StartDate].AsString());
                    hash.Add("DueDate", oldTask[WorkflowTaskFieldName.CompleteDate].AsString());
                    hash.Add("Body", oldTask[WorkflowTaskFieldName.Comments].AsString());
                    //hash.Add("AssignedTo", oldTaskUserValue.User);

                    isSpecific = true;

                    oldTasks.Remove(oldTask);
                    break;
                }
            }

            return isSpecific;
        }
예제 #13
0
파일: WF.cs 프로젝트: porter1130/MyTest
        private bool GetSpecificTaskItem(SPWorkflowTask newWorkflowTask, List<SPWorkflowTask> oldTasks, string eventDriven, out Hashtable hash)
        {
            bool isSpecific = false;
            hash = new Hashtable();

            SPFieldUserValue newTaskUserValue = new SPFieldUserValue(newWorkflowTask.Web, newWorkflowTask[SPBuiltInFieldId.AssignedTo].AsString());

            foreach (SPWorkflowTask oldTask in oldTasks)
            {
                SPFieldUserValue oldTaskUserValue = new SPFieldUserValue(newWorkflowTask.Web, oldTask[SPBuiltInFieldId.AssignedTo].AsString());
                if (newTaskUserValue.User.ID.Equals(oldTaskUserValue.User.ID))
                {
                    string outCome = oldTask[SPBuiltInFieldId.WorkflowOutcome].AsString();
                    hash.Add("__TaskOutcome", outCome);
                    hash.Add("__Action", "Commit");
                    hash.Add("__WorkflowVaribales", eventDriven);
                    //hash.Add("AssignedTo", oldTaskUserValue.User);

                    isSpecific = true;

                    oldTasks.Remove(oldTask);
                    break;
                }
            }

            return isSpecific;
        }
예제 #14
0
파일: WF.cs 프로젝트: porter1130/MyTest
        private void AddExceptionList(string key, SPWorkflowTaskCollection tasks)
        {
            SPWorkflowTask[] taskArray = new SPWorkflowTask[tasks.Count];
            tasks.CopyTo(taskArray, 0);

            if (!exceptionDict.ContainsKey(key))
            {
                exceptionDict.Add(key, taskArray);
            }
        }