コード例 #1
0
        public static WFEvent CreateLinkedWorkItem(string sourceWorkItemID, string workToPerform,
                                                   string userID, WFTimeDuration duration, string clientData)
        {
            IWFWorkflowService svc = Common.GetWorkFlowAPI();
            // get existing work item
            string  workItemID = sourceWorkItemID;// for example,"90CF843AC57644058A391FBFA030F607"
            WFEvent evt        = null;

            try
            {
                // Get the source WFManualWorkItem object
                //WFManualWorkItem sourceWorkItem = svc.GetWorkItem(workItemID);
                //string workToPerform = sourceWorkItem.Name; //different workToPerform can be used if desired
                //WFTimeDuration duration = new WFTimeDuration();
                //duration.Length = "15"; //for example, 15 days
                //duration.Unit = WFTimeUnit.DAY;
                //string user = @"[DOMAIN NAME]\username"; //the participant of the linked work item
                evt = svc.CreateLinkedWorkItem(workItemID, workToPerform, userID, duration, clientData);
            }

            catch (Exception ex)
            {
            }
            return(evt);
        }
コード例 #2
0
        public static WFEvent CreatePseudoWorkItem(string sourceWorkItemID, string workToPerform, string userID,
                                                   WFTimeDuration duration, string clientData, bool reserved)
        {
            IWFWorkflowService svc = Common.GetWorkFlowAPI();
            WFEvent            evt = null;

            try
            {
                evt = svc.CreatePseudoWorkItem(sourceWorkItemID, workToPerform, userID, duration, clientData, false);
            }
            catch (Exception ex)
            {
            }
            return(evt);
        }
コード例 #3
0
        public static WFEvent CreateLinkedWorkItemEx(string sourceWorkItemID, string workToPerform,
                                                     string userID, WFTimeDuration duration, string clientData, bool bDependent)
        {
            IWFWorkflowService svc = Common.GetWorkFlowAPI();
            WFEvent            evt = null;

            try
            {
                evt = svc.CreateLinkedWorkItemEx(sourceWorkItemID, workToPerform, userID, duration, null, true);
            }
            catch (Exception ex)
            {
            }
            return(evt);
        }
コード例 #4
0
        public static WFEvent CreateWorkItem(string activityInstanceID, string workToPerform, string userID,
                                             WFTimeDuration duration, string clientData)
        {
            IWFWorkflowService svc = Common.GetWorkFlowAPI();
            string             ActivityInstanceID = activityInstanceID; // for example, "0172460E0AF943C6A6520044452BCAB3";
            string             WorkToPerform      = workToPerform;      // for example, "SubmitRequest";
            //different workToPerform can be used if desired
            WFEvent evt = null;

            //WFTimeDuration duration = new WFTimeDuration("15", WFTimeUnit.DAY, true );// business time
            string user = userID; //the participant of the linked work item

            try
            {
                evt = svc.CreateWorkItem(activityInstanceID,
                                         workToPerform, user, duration, null);
            }
            catch (Exception ex)
            {
            }
            return(evt);
        }
コード例 #5
0
ファイル: APHelper.cs プロジェクト: hijoy/CPL_ERS
        //如是最后一个节点 则创建一个任务
        public bool LastCreateWorkItem(string processInstanceID, int positionID, ref string approve)
        {
            try {
                string admin = (String)ConfigurationManager.AppSettings["APAdmin"];
                APWorkFlowTableAdapters.StuffUserTableAdapter TAStuffUser = new APWorkFlowTableAdapters.StuffUserTableAdapter();
                APWorkFlowTableAdapters.StuffUserAndPositionTableAdapter TAUserAndPosition = new APWorkFlowTableAdapters.StuffUserAndPositionTableAdapter();
                APWorkFlowTableAdapters.ProcessLastNameTableAdapter TAProcessLastName = new APWorkFlowTableAdapters.ProcessLastNameTableAdapter();
                APWorkFlow.StuffUserAndPositionDataTable dtStuffUserAndPosition = TAUserAndPosition.GetDataByPositionId(positionID);
                if (dtStuffUserAndPosition.Rows.Count == 0) {
                    return false;
                }
                string lastName = "";
                WFBaseProcessInstance pi = api.GetProcInst(processInstanceID);
                WFManualWorkItem wi = getNextNode(processInstanceID);
                WFBaseActivityInstance ai = api.GetActivityInst(wi.ActivityInstID);
                APWorkFlow.ProcessLastNameDataTable dtProcessLastName = TAProcessLastName.GetDataByTName(pi.DefName);
                if (dtProcessLastName.Rows.Count > 0) {
                    lastName = dtProcessLastName[0].lastName;
                    if (ai.DisplayName == lastName) {
                        WFTimeDuration td = new WFTimeDuration();
                        td.BusinessTime = false;
                        td.Length = "7";
                        td.Unit = WFTimeUnit.DAY;
                        foreach (APWorkFlow.StuffUserAndPositionRow drStuffUserAndPosition in dtStuffUserAndPosition.Rows) {
                            //获取审批人
                            approve += "P" + drStuffUserAndPosition.StuffUserId + "P";
                            //APWorkFlow.StuffUserDataTable dtUser=TAStuffUser.GetDataByID(drStuffUserAndPosition.StuffUserId);
                        }
                        WFEvent evt = api.CreateLinkedWorkItem(wi.WorkItemID, wi.Name, approve, td, wi.ClientData);
                        evt = getFullEvent(evt);
                        APWorkFlow.NodeStatusDataTable dt = new APWorkFlow.NodeStatusDataTable();
                        APWorkFlow.NodeStatusRow dr = dt.NewNodeStatusRow();

                        dr.STATUS = FlowNodeStatus.ASSIGNED;
                        dr.PARTICIPANT = approve;
                        //dr.AcceptChanges();
                        dt.AddNodeStatusRow(dr);
                        dt.AcceptChanges();
                        StringWriter sw = new StringWriter();
                        dt.WriteXml(sw);
                        string clientData = sw.ToString();

                        System.Collections.ArrayList attrList = new System.Collections.ArrayList();
                        attrList.Add(new NameValue("UserID", dr.PARTICIPANT));//更新该步骤的userid
                        attrList.Add(new NameValue("CLIENT_DATA", clientData));
                        NameValue[] attributes = (NameValue[])attrList.ToArray(typeof(NameValue));
                        api.UpdateWorkItem(evt.WorkItemID, attributes);
                        api.GetWorkItem(evt.WorkItemID).DisplayName = "总经理审批";
                        if (string.IsNullOrEmpty(evt.Error))
                            return true;
                        return false;
                    }
                }
                return false;
            } catch {
                return false;
            }
        }