Beispiel #1
0
        ////
        /// <summary>
        /// 把用户字符串转换成用户列表
        /// </summary>
        /// <param name="dbsource"></param>
        /// <param name="userlist">用户列表,格式:"用户代码1__用户名1,用户代码2__用户名2。。。"</param>
        /// <returns></returns>
        public static Group StrToGroup(DBSource dbsource, string userlist)
        {
            AVEVA.CDMS.Server.Group userGroup = new AVEVA.CDMS.Server.Group();
            try
            {
                string[] strArray = (string.IsNullOrEmpty(userlist) ? "" : userlist).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string struser in strArray)
                {
                    Object objuser = dbsource.GetObjectByKeyWord(struser);

                    if (objuser == null)
                    {
                        break;
                    }
                    if (objuser is User)
                    {
                        userGroup.AddUser(objuser as User);
                        // userList.Add(user);
                    }
                }
            }
            catch { }
            return(userGroup);
        }
Beispiel #2
0
        /// <summary>
        /// 创建发文单后,发起发文流程
        /// </summary>
        /// <param name="sid"></param>
        /// <param name="docKeyword"></param>
        /// <param name="DocList"></param>
        /// <returns></returns>
        public static JObject RecognitionStartWorkFlow(string sid, string docKeyword, string DocList, string UserList)
        {
            ExReJObject reJo = new ExReJObject();

            try
            {
                User curUser = DBSourceController.GetCurrentUser(sid);
                if (curUser == null)
                {
                    reJo.msg = "登录验证失败!请尝试重新登录!";
                    return(reJo.Value);
                }

                DBSource dbsource = curUser.dBSource;
                if (dbsource == null)
                {
                    reJo.msg = "登录验证失败!请尝试重新登录!";
                    return(reJo.Value);
                }

                Doc doc = dbsource.GetDocByKeyWord(docKeyword);
                if (doc == null)
                {
                    reJo.msg = "错误的文档操作信息!指定的文档不存在!";
                    return(reJo.Value);
                }

                #region 获取下一状态用户
                string[] userArray = (string.IsNullOrEmpty(UserList) ? "" : UserList).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                Server.Group group = new Server.Group();
                //List<User> m_UserList = new List<User>();
                //启动工作流程
                //反转列表
                //m_UserList.Reverse();
                foreach (string strObj in userArray)
                {
                    object obj = dbsource.GetObjectByKeyWord(strObj);

                    if (obj is User)
                    {
                        //m_UserList.Add((User)obj);
                        group.AddUser((User)obj);
                    }
                }
                if (group.UserList.Count <= 0)
                {
                    reJo.msg = "获取下一流程状态用户错误,自动启动流程失败!请手动启动流程";
                    return(reJo.Value);
                }
                #endregion

                {
                    #region 获取文档列表
                    string[] strArray = (string.IsNullOrEmpty(DocList) ? "" : DocList).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                    List <Doc> m_DocList = new List <Doc>();
                    //启动工作流程
                    m_DocList.Reverse();
                    foreach (string strObj in strArray)
                    {
                        object obj = dbsource.GetObjectByKeyWord(strObj);

                        if (obj is Doc)
                        {
                            m_DocList.Add((Doc)obj);
                        }
                    }
                    #endregion

                    WorkFlow flow = dbsource.NewWorkFlow(m_DocList, "RECOGNITION");
                    //if (flow == null || flow.CuWorkState == null || flow.CuWorkState.workStateBranchList == null || (flow.CuWorkState.workStateBranchList.Count <= 0))
                    if (flow == null)
                    {
                        reJo.msg = "自动启动流程失败!请手动启动";
                        return(reJo.Value);
                    }



                    //获取下一状态
                    //me.approvpathdata = [{ text: "二级-编批", value: "二级-编批" }, { text: "三级-编审批", value: "三级-编审批" },
                    //{ text: "四级-编审定批", value: "四级-编审定批" }, { text: "五级-编校审定批", value: "五级-编校审定批" }];

                    WorkState ws = new WorkState();

                    DefWorkState dws = flow.DefWorkFlow.DefWorkStateList.Find(s => s.KeyWord == "APPROV");// CHECK");
                    ws.DefWorkState = dws;

                    //if (ApprovPath == "二级-编批")
                    //{
                    //    DefWorkState dws = flow.DefWorkFlow.DefWorkStateList.Find(s => s.KeyWord == "APPROV");// CHECK");
                    //    ws.DefWorkState = dws;
                    //}
                    //else if (ApprovPath == "三级-编审批" || ApprovPath == "四级-编审定批")
                    //{
                    //    DefWorkState dws = flow.DefWorkFlow.DefWorkStateList.Find(s => s.KeyWord == "AUDIT");// CHECK");
                    //    ws.DefWorkState = dws;
                    //}
                    //else if (ApprovPath == "五级-编校审定批")
                    //{
                    //    DefWorkState dws = flow.DefWorkFlow.DefWorkStateList.Find(s => s.KeyWord == "CHECK");// CHECK");
                    //    ws.DefWorkState = dws;

                    //}
                    //else
                    //{
                    //    flow.Delete();
                    //    flow.Delete();

                    //    reJo.msg = "审批路径参数错误,自动启动流程失败!请手动启动流程";
                    //    return reJo.Value;
                    //}

                    //foreach (User user in group.UserList)
                    //{
                    //    ws.group.AddUser(user);
                    //}
                    //flow.WorkStateList.Add(ws);
                    //flow.Modify();


                    ////启动流程
                    WorkStateBranch branch = flow.CuWorkState.workStateBranchList[0];
                    branch.NextStateAddGroup(group);

                    ExReJObject GotoNextReJo = WebWorkFlowEvent.GotoNextStateAndSelectUser(flow.CuWorkState.workStateBranchList[0]);

                    if (!GotoNextReJo.success)
                    {
                        //  doc.dBSource.ProgramRun = false;
                        flow.Delete();
                        flow.Delete();

                        reJo.msg = "自动启动流程失败!请手动启动流程";
                        return(reJo.Value);
                    }

                    DBSourceController.RefreshDBSource(sid);

                    return(GotoNextReJo.Value);
                }
            }
            catch (Exception exception)
            {
                WebApi.CommonController.WebWriteLog(exception.Message + "\r\n" + exception.Source + "\r\n" + exception.StackTrace);
                reJo.msg = "启动流程失败!" + exception.Message + "\r\n" + exception.Source + "\r\n" + exception.StackTrace;
            }
            return(reJo.Value);
        }