示例#1
0
文件: Logic.cs 项目: san90279/UK_OAS
        /// <summary>
        /// 取消通知
        /// </summary>
        /// <param name="flInstance">流程</param>
        /// <param name="currentFLActivity">当前Activity</param>
        /// <param name="flNotifyActivity">通知Activity</param>
        /// <param name="flInstanceParms">流程参数</param>
        /// <param name="keyValues">宿主表的筛选条件</param>
        /// <param name="clientInfo">ClientInfo</param>
        public static void InsertToDo4RejectNotify(FLInstance flInstance, IEventWaiting currentFLActivity, FLNotifyActivity flNotifyActivity, object[] flInstanceParms, object[] keyValues, object[] clientInfo)
        {
            string insertToDoListSQL4Notify = GetInsertToDoListSQL4RejectNotify(flInstance, currentFLActivity, flNotifyActivity, flInstanceParms, keyValues, clientInfo);

            string sql = insertToDoListSQL4Notify;
            EEPRemoteModule remoteModule = new EEPRemoteModule();
            String dbType = GetDBType(clientInfo);
            if (dbType == "3" && sql.EndsWith(";"))
                sql = "BEGIN " + sql + "END;";

            //object[] objs = remoteModule.ExecuteSql(clientInfo, "GLModule", "cmdWorkflow", sql, false);
            object[] objs = remoteModule.CallMethod(clientInfo, "GLModule", "UpdateWorkFlow", new object[] { sql });
            if (objs[0].ToString() == "1")
            {
                throw new FLException(objs[1].ToString());
            }
        }
示例#2
0
        private SendTo GetSendTo(IEventWaiting activity, SendTo from)
        {
            switch (activity.SendToKind)
            {
                //user
                case SendToKind.Applicate: return new SendTo(string.Empty, Instance.Creator);
                case SendToKind.User:
                    {
                        string user = string.IsNullOrEmpty(activity.SendToUser) ? string.Empty : activity.SendToUser.Split(';')[0].Trim();
                        return new SendTo(string.Empty, user);
                    }
                case SendToKind.RefUser:
                    {
                        string user = Instance._hostDataSet.Tables[0].Rows[0][activity.SendToField].ToString();
                        return new SendTo(string.Empty, user);
                    }
                case SendToKind.Role:
                    {
                        string role = string.IsNullOrEmpty(activity.SendToRole) ? string.Empty : activity.SendToRole.Split(';')[0].Trim();
                        return new SendTo(role, string.Empty);
                    }
                case SendToKind.RefRole:
                    {
                        string role = Instance._hostDataSet.Tables[0].Rows[0][activity.SendToField].ToString();
                        return new SendTo(role, string.Empty);
                    }
                case SendToKind.Manager:
                    {
                        string role = string.Empty;
                        if (activity is FLApproveBranchActivity && !string.IsNullOrEmpty(Instance.R))
                        {
                            role = Instance.R;
                        }
                        else
                        {
                            role = from.RoleID;
                        }
                        return GetManager(new SendTo(role, string.Empty));
                    }
                case SendToKind.RefManager:
                    {
                        string role = string.Empty;
                        if (activity is FLApproveBranchActivity && !string.IsNullOrEmpty(Instance.R))
                        {
                            role = Instance.R;
                        }
                        else
                        {
                            role = Instance._hostDataSet.Tables[0].Rows[0][activity.SendToField].ToString();
                        }
                        return GetManager(new SendTo(role, string.Empty));
                    }
                case SendToKind.ApplicateManager:
                    {
                        string role = string.Empty;
                        if (activity is FLApproveBranchActivity && !string.IsNullOrEmpty(Instance.R))
                        {
                            role = Instance.R;
                        }
                        else
                        {
                            role = Instance.CreateRole;
                        }
                        return GetManager(new SendTo(role, string.Empty));
                        //return GetManager(new SendTo(Instance.CreateRole, Instance.Creator));

                    }
            }
            return new SendTo(string.Empty, string.Empty);
        }
示例#3
0
文件: Logic.cs 项目: san90279/UK_OAS
        /// <summary>
        /// 取得取消通知时要插入ToDoList的SQL语句
        /// </summary>
        /// <param name="flInstance">流程</param>
        /// <param name="currentFLActivity">当前Activity</param>
        /// <param name="notifyActivity">通知Activity</param>
        /// <param name="flInstanceParms">流程参数</param>
        /// <param name="keyValues">宿主表的筛选条件</param>
        /// <param name="clientInfo">ClientInfo</param>
        /// <returns></returns>
        private static string GetInsertToDoListSQL4RejectNotify(FLInstance flInstance, IEventWaiting currentFLActivity, IFLNotifyActivity notifyActivity, object[] flInstanceParms, object[] keyValues, object[] clientInfo)
        {
            Guid flInstanceId = flInstance.FLInstanceId;
            Guid flDefinitionId = flInstance.FLDefinitionId;
            string tableName = ((IFLRootActivity)flInstance.RootFLActivity).TableName;
            string orgKind = ((IFLRootActivity)flInstance.RootFLActivity).OrgKind;

            List<string> sendToIds = new List<string>();
            if (notifyActivity != null)
            {
                if (notifyActivity.SendToKind == SendToKind.AllRoles)
                {
                    List<string> list = new List<string>();
                    foreach (string q in flInstance.RL)
                    {
                        if (string.IsNullOrEmpty(q)) continue;
                        string[] qq = q.Split(":".ToCharArray());
                        if (qq[0] == "R")
                        {
                            list.AddRange(Global.GetUsersIdsByRoleId(qq[1].Trim(), clientInfo));
                        }
                        else
                        {
                            list.Add(qq[1].Trim());
                        }
                    }
                    list.Add(flInstance.Creator);

                    foreach (string u in list)
                    {
                        if (sendToIds.Contains(u))
                        {
                            continue;
                        }

                        sendToIds.Add(u);
                    }
                }
            }

            string flowDesc = ((IFLRootActivity)flInstance.RootFLActivity).Description;
            string sUserId = ((object[])clientInfo[0])[1].ToString();
            string sUserName = Global.GetUserName(sUserId, clientInfo);
            string email = Global.GetUserEmail(((object[])clientInfo[0])[1].ToString(), clientInfo);
            string sql = string.Empty;

            string presentFields = ((IFLRootActivity)flInstance.RootFLActivity).PresentFields;
            string keys = keyValues[0].ToString();
            string presenation = keyValues[1].ToString();
            string presenationCT = GetFormPresentCT(flInstance, keys, presenation, presentFields, clientInfo);

            foreach (string id in sendToIds)
            {
                string sendToKind = "2";
                string status = "F";
                string sendToName = Global.GetUserName(id, clientInfo);

                DateTime now = DateTime.Now;
                string remark = "Reject(system)";

                List<object> list = new List<object>();
                list.Add(flInstanceId.ToString());                                                                      // LISTID;    0
                list.Add(flDefinitionId.ToString());                                                                    // FLOW_ID;         1
                list.Add(flowDesc);                                                                                     // FLOW_DESC;     2
                list.Add(sUserId);                                                                                      // S_USER_ID;      3
                list.Add(currentFLActivity == null ? null : currentFLActivity.Name);                                    // S_STEP_ID;     4
                list.Add(currentFLActivity == null ? null : currentFLActivity.Description);                             // S_STEP_DESC;   5
                list.Add(notifyActivity.Name);                                                                          // D_STEP_ID;      6
                list.Add(notifyActivity.Description);                                                                   // D_STEP_DESC;     7
                list.Add(notifyActivity.ExpTime);                                                                       // EXP_TIME;       8
                list.Add(notifyActivity.UrgentTime);                                                                    // URGENT_TIME;     9
                list.Add(notifyActivity.TimeUnit);                                                                      // TIME_UNIT;     10
                list.Add(sUserName);                                                                                    // USERNAME
                list.Add(string.IsNullOrEmpty(notifyActivity.FormName)
                    ? ((IFLRootActivity)flInstance.RootFLActivity).FormName
                    : notifyActivity.FormName);                                                                         // FORM_NAME;
                list.Add(0);                                                                                            // NAVIGATOR_MODE;
                list.Add(3);                                                                                            // FLNAVIGATOR_MODE;
                list.Add(notifyActivity.Parameters);                                                                    // PARAMETERS;
                list.Add(sendToKind);                                                                                   // SENDTO_KIND;
                list.Add(id);                                                                                           // SENDTO_ID;
                list.Add(0);                                                                                            // FLOWIMPORTANT;
                list.Add(0);                                                                                            // FLOWURGENT;
                list.Add(status);                                                                                       // STATUS;              // 先不管
                list.Add(tableName);                                                                                    // FORM_TABLE;
                list.Add(keys);                                                                                         // FORM_KEYS
                list.Add(presenation);                                                                                  // FORM_PRESENTATION;
                list.Add(presenationCT);                                                                                // FORM_PRESENT_CT;
                list.Add(remark);                                                                                       // REMARK;
                list.Add(flInstanceParms[3].ToString());                                                                // PROVIDER_NAME;       // 先不管
                list.Add(null);                                                                                         // VERSION;             // 先不管
                list.Add(email);                                                                                        // EMAIL_ADD;
                list.Add(null);                                                                                         // EMAIL_STATUS;
                list.Add(flInstance.Solution);                                                                          // VDSNAME;
                list.Add(null);                                                                                         // SENDBACKSTEP;        // 先不管
                list.Add(null);                                                                                         // LEVEL_NO
                list.Add(string.IsNullOrEmpty(notifyActivity.WebFormName)
                    ? ((IFLRootActivity)flInstance.RootFLActivity).WebFormName
                    : notifyActivity.WebFormName);                                                                      // WEBFORM_NAME;
                list.Add(flInstance.Creator);                                                                           // APPLICANT
                list.Add(Guid.NewGuid().ToString() + ";" + currentFLActivity.Name);                                     // FLOWPATH
                list.Add(now.ToString("yyyy-MM-dd"));                                                                   // UPDATE_DATE
                list.Add(now.ToString("HH:mm:ss"));                                                                     // UPDATE_TIME
                list.Add(null);                                                                                         // PLUSAPPROVE
                list.Add(null);                                                                                         // PLUSROLES
                list.Add("0");                                                                                          // MULTISTEPRETURN
                list.Add(sendToName);                                                                                   // SENDTO_NAME
                list.Add(null);                                                                                         // ATTACHMENTFILES
                list.Add(GetNvarcharMark(clientInfo));
            #if CreateTime
            list.Add(flInstance.CreatedTime.ToString("yyyy-MM-dd HH:mm:ss"));
            #endif

                string insertSql = string.Format(INSERT_TODOLIST, list.ToArray());
                sql = sql + insertSql + ";";
            }

            return sql;
        }
示例#4
0
文件: Logic.cs 项目: san90279/UK_OAS
        /// <summary>
        /// 取得通知时要插入ToDoList的SQL语句
        /// </summary>
        /// <param name="flInstance">流程</param>
        /// <param name="currentFLActivity">当前Activity</param>
        /// <param name="notifyActivity">通知Activity</param>
        /// <param name="flInstanceParms">流程参数</param>
        /// <param name="keyValues">宿主表的筛选条件</param>
        /// <param name="clientInfo">ClientInfo</param>
        /// <returns></returns>
        private static string GetInsertToDoListSQL4Notify(FLInstance flInstance, IEventWaiting currentFLActivity, IFLNotifyActivity notifyActivity, object[] flInstanceParms, object[] keyValues, object[] clientInfo)
        {
            Guid flInstanceId = flInstance.FLInstanceId;
            Guid flDefinitionId = flInstance.FLDefinitionId;
            string tableName = ((IFLRootActivity)flInstance.RootFLActivity).TableName;
            string orgKind = ((IFLRootActivity)flInstance.RootFLActivity).OrgKind;

            List<string> sendToIds = new List<string>();
            if (notifyActivity != null)
            {
                string id = string.Empty;
                if (notifyActivity.SendToKind == SendToKind.Role)
                {
                    string q = notifyActivity.SendToRole;
                    if (string.IsNullOrEmpty(q))
                    {
                        string message = SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(clientInfo[0]))[0]), "FLRuntime", "Logic", "SendToIdNotSet");
                        throw new FLException(2, message);
                    }
                    string[] qq = q.Split(";".ToCharArray());
                    id = qq[0].Trim();
                    sendToIds.AddRange(Global.GetUsersIdsByRoleId(id, clientInfo));
                }
                else if (notifyActivity.SendToKind == SendToKind.RefRole)
                {
                    string values = keyValues[1].ToString();
                    string sendToField = notifyActivity.SendToField;
                    id = Global.GetRoleIdByRefRole(flInstance, sendToField, tableName, values, clientInfo);

                    sendToIds.AddRange(Global.GetUsersIdsByRoleId(id, clientInfo));
                }

                else if (notifyActivity.SendToKind == SendToKind.User)
                {
                    string q = notifyActivity.SendToUser;
                    if (string.IsNullOrEmpty(q))
                    {
                        string message = SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(clientInfo[0]))[0]), "FLRuntime", "Logic", "SendToIdNotSet");
                        throw new FLException(2, message);
                    }
                    string[] users = q.Split(';');
                    foreach (string user in users)
                    {
                        if (user.Trim().Length > 0)
                        {
                            sendToIds.Add(user.Trim());
                        }
                    }
                }
                else if (notifyActivity.SendToKind == SendToKind.RefUser)
                {
                    string values = keyValues[1].ToString();
                    string sendToField = notifyActivity.SendToField;
                    id = Global.GetRoleIdByRefRole(flInstance, sendToField, tableName, values, clientInfo, true);//取出RefUser 方法一样就不重写了
                    if (!string.IsNullOrEmpty(id))
                    {
                        string[] users = id.Split(';');
                        foreach (string user in users)
                        {
                            if (user.Trim().Length > 0)
                            {
                                sendToIds.Add(user.Trim());
                            }
                        }
                    }
                }
                else if (notifyActivity.SendToKind == SendToKind.RefManager)
                {
                    string values = keyValues[1].ToString();
                    string sendToField = notifyActivity.SendToField;
                    id = Global.GetRoleIdByRefRole(flInstance, sendToField, tableName, values, clientInfo);
                    id = Global.GetManagerRoleId(flInstanceParms[5].ToString(), orgKind, clientInfo);
                    sendToIds.AddRange(Global.GetUsersIdsByRoleId(id, clientInfo));
                }
                else if (notifyActivity.SendToKind == SendToKind.Manager)
                {
                    if (flInstance.IsReturn)
                    {
                        id = notifyActivity.RoleId;
                    }
                    {
                        id = Global.GetManagerRoleId(flInstanceParms[5].ToString(), orgKind, clientInfo);
                    }
                    sendToIds.AddRange(Global.GetUsersIdsByRoleId(id, clientInfo));
                }
                else if (notifyActivity.SendToKind == SendToKind.Applicate)
                {
                    sendToIds.Add(flInstance.Creator);
                }
                else if (notifyActivity.SendToKind == SendToKind.ApplicateManager)
                {

                    if (!string.IsNullOrEmpty(flInstance.CreateRole))
                    {
                        id = Global.GetManagerRoleId(flInstance.CreateRole, orgKind, clientInfo);
                        sendToIds.AddRange(Global.GetUsersIdsByRoleId(id, clientInfo));
                    }
                    else
                    {
                        List<string> roleIds = Global.GetRoleIdsByUserId(flInstance.Creator, clientInfo);
                        if (roleIds.Count > 0)
                        {
                            id = Global.GetManagerRoleId(roleIds[0], orgKind, clientInfo);
                            sendToIds.AddRange(Global.GetUsersIdsByRoleId(id, clientInfo));
                        }
                    }
                }

                else if (notifyActivity.SendToKind == SendToKind.AllRoles)
                {
                    List<string> list = new List<string>();
                    foreach (string q in flInstance.RL)
                    {
                        if (string.IsNullOrEmpty(q)) continue;
                        string[] qq = q.Split(":".ToCharArray());
                        if (qq[0] == "R")
                        {
                            list.AddRange(Global.GetUsersIdsByRoleId(qq[1].Trim(), clientInfo));
                        }
                        else
                        {
                            list.Add(qq[1].Trim());
                        }
                    }
                    list.Add(flInstance.Creator);

                    foreach (string u in list)
                    {
                        if (sendToIds.Contains(u))
                        {
                            continue;
                        }

                        sendToIds.Add(u);
                    }
                }
                else if (notifyActivity.SendToKind == SendToKind.LastUser)
                {
                    List<string> list = new List<string>();
                    if (flInstance.RL.Count > 0)
                    {
                        for (int i = flInstance.RL.Count - 1; i >= 0; i--)
                        {
                            string q = flInstance.RL[i];
                            if (string.IsNullOrEmpty(q)) continue;
                            string[] qq = q.Split(":".ToCharArray());
                            if (qq[0] == "R")
                            {
                                list.AddRange(Global.GetUsersIdsByRoleId(qq[1].Trim(), clientInfo));
                            }
                            else
                            {
                                list.Add(qq[1].Trim());
                            }
                            break;
                        }
                    }
                    else
                    {
                        list.Add(flInstance.Creator);
                    }

                    foreach (string u in list)
                    {
                        if (sendToIds.Contains(u))
                        {
                            continue;
                        }

                        sendToIds.Add(u);
                    }
                }
            }
            else
            {
                string s = flInstanceParms[8].ToString();
                string[] ss = s.Split(';');
                foreach (string id in ss)
                {
                    if (id != null && id != string.Empty)
                    {
                        string[] ss1 = id.Split(':');
                        if (ss1.Length > 1)
                        {
                            if (ss1[ss1.Length - 1].Trim().ToLower() == "userid")
                            {
                                sendToIds.Add(ss1[0]);
                            }
                            else
                            {

                                sendToIds.AddRange(Global.GetUsersIdsByRoleId(ss1[0], clientInfo));
                            }
                        }
                        else
                        {
                            List<string> userofrole = Global.GetUsersIdsByRoleId(id, clientInfo);
                            if (userofrole.Count > 0)
                            {
                                string agent = Global.GetAgent(id, userofrole[0], flInstance.RootFLActivity.Description, clientInfo);
                                if (!string.IsNullOrEmpty(agent))
                                {
                                    object parAgent = Global.GetPARAGENT(flInstance.RootFLActivity.Description, agent, clientInfo);
                                    if (parAgent != null && Convert.ToBoolean(parAgent))
                                    {
                                        sendToIds.AddRange(userofrole);
                                    }
                                    sendToIds.Add(agent);
                                }
                                else
                                {
                                    sendToIds.AddRange(userofrole);
                                }
                            }
                        }
                    }
                }
            }

            var flowPath = notifyActivity == null ? Guid.NewGuid().ToString() + ";" + currentFLActivity.Name : currentFLActivity.Name + ";" + notifyActivity.Name;

            IEventWaiting nextFLActivity = currentFLActivity;

            string flowDesc = ((IFLRootActivity)flInstance.RootFLActivity).Description;
            string sUserId = ((object[])clientInfo[0])[1].ToString();
            string sUserName = Global.GetUserName(sUserId, clientInfo);
            string email = Global.GetUserEmail(((object[])clientInfo[0])[1].ToString(), clientInfo);
            string sql = string.Empty;

            string presentFields = ((IFLRootActivity)flInstance.RootFLActivity).PresentFields;
            string keys = keyValues[0].ToString();
            string presenation = keyValues[1].ToString();
            string presenationCT = GetFormPresentCT(flInstance, keys, presenation, presentFields, clientInfo);

            int plusApprove = 0;
            if (nextFLActivity is IFLStandActivity)
            {
                plusApprove = Convert.ToInt32(((IFLStandActivity)nextFLActivity).PlusApprove);
            }
            else if (nextFLActivity is IFLApproveActivity)
            {
                plusApprove = Convert.ToInt32(((IFLApproveActivity)nextFLActivity).PlusApprove);
            }

            // scheduling
            string delayAutoApprove = null;
            if ((nextFLActivity is IFLStandActivity && ((IFLStandActivity)nextFLActivity).DelayAutoApprove)
                || (nextFLActivity is IFLApproveActivity && ((IFLApproveActivity)nextFLActivity).DelayAutoApprove))
                delayAutoApprove = "AUTO";

            foreach (string id in sendToIds)
            {
                if (currentFLActivity is IFLApproveBranchActivity)
                {
                    string parentName = ((IFLApproveBranchActivity)currentFLActivity).ParentActivity;
                    currentFLActivity = (IEventWaiting)flInstance.RootFLActivity.GetFLActivityByName(parentName);
                }

                IEventWaiting nextFLActivity2 = null;
                if (nextFLActivity is IFLApproveBranchActivity)
                {
                    string parentName = ((IFLApproveBranchActivity)nextFLActivity).ParentActivity;
                    nextFLActivity2 = (IEventWaiting)flInstance.RootFLActivity.GetFLActivityByName(parentName);
                }
                else
                {
                    nextFLActivity2 = nextFLActivity;
                }

                string sendToKind = "2";
                string status = "F";
                string sendToName = Global.GetUserName(id, clientInfo);

                DateTime now = DateTime.Now;
                string remark = flInstance.IsReturn == true ? "Return(system)" : (flInstanceParms[4] == null ? string.Empty : flInstanceParms[4].ToString().Replace("'", "''"));

                List<object> list = new List<object>();
                list.Add(flInstanceId.ToString());                                                                      // LISTID;    0
                list.Add(flDefinitionId.ToString());                                                                    // FLOW_ID;         1
                list.Add(flowDesc);                                                                                     // FLOW_DESC;     2
                list.Add(sUserId);                                                                                      // S_USER_ID;      3
                list.Add(currentFLActivity == null ? null : currentFLActivity.Name);                                    // S_STEP_ID;     4
                list.Add(currentFLActivity == null ? null : currentFLActivity.Description);                             // S_STEP_DESC;   5
                list.Add(notifyActivity != null ? notifyActivity.Name : nextFLActivity2.Name);                          // D_STEP_ID;      6
                list.Add(notifyActivity != null ? notifyActivity.Description : nextFLActivity2.Description);            // D_STEP_DESC;     7
                list.Add(notifyActivity != null ? notifyActivity.ExpTime : nextFLActivity2.ExpTime);                    // EXP_TIME;       8
                list.Add(notifyActivity != null ? notifyActivity.UrgentTime : nextFLActivity2.UrgentTime);              // URGENT_TIME;     9
                list.Add(notifyActivity != null ? notifyActivity.TimeUnit : nextFLActivity2.TimeUnit);                  // TIME_UNIT;     10
                list.Add(sUserName);                                                                                    // USERNAME
                list.Add(notifyActivity != null && !string.IsNullOrEmpty(notifyActivity.FormName)
                    ? notifyActivity.FormName
                    : (
                        nextFLActivity2 != null && !string.IsNullOrEmpty(nextFLActivity2.FormName)
                        ? nextFLActivity2.FormName : ((IFLRootActivity)flInstance.RootFLActivity).FormName)
                    );                                                                                                  // FORM_NAME;
                list.Add(0);                                                                                            // NAVIGATOR_MODE;
                list.Add(3);                                                                                            // FLNAVIGATOR_MODE;
                list.Add(notifyActivity != null ? notifyActivity.Parameters : nextFLActivity2.Parameters);              // PARAMETERS;
                list.Add(sendToKind);                                                                                   // SENDTO_KIND;
                list.Add(id);                                                                                           // SENDTO_ID;
                list.Add(flInstanceParms[2]);                                                                           // FLOWIMPORTANT;
                list.Add(flInstanceParms[3]);                                                                           // FLOWURGENT;
                list.Add(status);                                                                                       // STATUS;              // 先不管
                list.Add(tableName);                                                                                    // FORM_TABLE;
                list.Add(keys);                                                                                         // FORM_KEYS
                list.Add(presenation);                                                                                  // FORM_PRESENTATION;
                list.Add(presenationCT);                                                                                // FORM_PRESENT_CT;
                list.Add(remark);                                                                                       // REMARK;
                list.Add(flInstanceParms[6].ToString());                                                                // PROVIDER_NAME;       // 先不管
                list.Add(null);                                                                                         // VERSION;             // 先不管
                list.Add(email);                                                                                        // EMAIL_ADD;
                list.Add(null);                                                                                         // EMAIL_STATUS;
                list.Add(flInstance.Solution);                                                                          // VDSNAME;
                list.Add(null);                                                                                         // SENDBACKSTEP;        // 先不管
                list.Add(delayAutoApprove);                                                                             // LEVEL_NO
                list.Add(notifyActivity != null && !string.IsNullOrEmpty(notifyActivity.WebFormName)
                    ? notifyActivity.WebFormName
                    : (
                        nextFLActivity2 != null && !string.IsNullOrEmpty(nextFLActivity2.WebFormName)
                        ? nextFLActivity2.WebFormName : ((IFLRootActivity)flInstance.RootFLActivity).WebFormName)
                    );                                                                                                  // WEBFORM_NAME;
                list.Add(flInstance.Creator);                                                                           // APPLICANT
                list.Add(flowPath);                                     // FLOWPATH
                list.Add(now.ToString("yyyy-MM-dd"));                                                                   // UPDATE_DATE
                list.Add(now.ToString("HH:mm:ss"));                                                                     // UPDATE_TIME
                list.Add(plusApprove);                                                                                  // PLUSAPPROVE
                list.Add(null);                                                                                         // PLUSROLES
                list.Add(flInstance.GetMultiStepReturn((FLActivity)nextFLActivity2) ? "1" : "0");                       // MULTISTEPRETURN
                list.Add(sendToName);                                                                                   // SENDTO_NAME
                list.Add(flInstanceParms[9] == null ? null : flInstanceParms[9].ToString());                                                                // ATTACHMENTFILES
                list.Add(GetNvarcharMark(clientInfo));

            #if CreateTime
            list.Add(flInstance.CreatedTime.ToString("yyyy-MM-dd HH:mm:ss"));
            #endif

                string insertSql = string.Format(INSERT_TODOLIST, list.ToArray());
                sql = sql + insertSql + ";";
            }

            return sql;
        }
示例#5
0
文件: Logic.cs 项目: san90279/UK_OAS
        /// <summary>
        /// 取得插入ToDoList的SQL语句
        /// </summary>
        /// <param name="flInstance">流程</param>
        /// <param name="flInstanceParms">流程参数</param>
        /// <param name="keyValues">宿主表的筛选条件</param>
        /// <param name="clientInfo">ClientInfo</param>
        /// <param name="nextFLActivity">下一Activity</param>
        /// <returns></returns>
        private static string GetInsertToDoListSQL(FLInstance flInstance, object[] flInstanceParms, object[] keyValues, object[] clientInfo, IEventWaiting nextFLActivity)
        {
            Guid flInstanceId = flInstance.FLInstanceId;
            Guid flDefinitionId = flInstance.FLDefinitionId;

            IEventWaiting currentFLActivity = (IEventWaiting)flInstance.CurrentFLActivity;
            List<FLActivity> s = flInstance.NextFLActivities;

            string orgKind = ((IFLRootActivity)flInstance.RootFLActivity).OrgKind;
            string tableName = ((IFLRootActivity)flInstance.RootFLActivity).TableName;
            string flowDesc = ((IFLRootActivity)flInstance.RootFLActivity).Description;
            string sUserId = ((object[])clientInfo[0])[1].ToString();
            string sUserName = Global.GetUserName(sUserId, clientInfo);
            string email = Global.GetUserEmail(((object[])clientInfo[0])[1].ToString(), clientInfo);

            string flowPath = (currentFLActivity == null ? string.Empty : currentFLActivity.Name) + ";" + nextFLActivity.Name;

            IEventWaiting currentFLActivity2 = null;
            if (currentFLActivity is IFLApproveBranchActivity)
            {
                string parentName = ((IFLApproveBranchActivity)currentFLActivity).ParentActivity;
                currentFLActivity2 = (IEventWaiting)flInstance.RootFLActivity.GetFLActivityByName(parentName);
            }
            else
            {
                currentFLActivity2 = currentFLActivity;
            }

            IEventWaiting nextFLActivity2 = null;
            if (nextFLActivity is IFLApproveBranchActivity)
            {
                string parentName = ((IFLApproveBranchActivity)nextFLActivity).ParentActivity;
                nextFLActivity2 = (IEventWaiting)flInstance.RootFLActivity.GetFLActivityByName(parentName);
                ((IEventWaitingExecute)nextFLActivity2).UserId = ((IEventWaitingExecute)nextFLActivity).UserId;
                ((IEventWaitingExecute)nextFLActivity2).RoleId = ((IEventWaitingExecute)nextFLActivity).RoleId;
            }
            else
            {
                nextFLActivity2 = nextFLActivity;
            }

            int plusApprove = 0;
            if (nextFLActivity2 is IFLStandActivity)
            {
                plusApprove = Convert.ToInt32(((IFLStandActivity)nextFLActivity2).PlusApprove);
            }
            else if (nextFLActivity2 is IFLApproveActivity)
            {
                plusApprove = Convert.ToInt32(((IFLApproveActivity)nextFLActivity2).PlusApprove);
            }

            // scheduling
            string delayAutoApprove = null;
            if ((nextFLActivity2 is IFLStandActivity && ((IFLStandActivity)nextFLActivity2).DelayAutoApprove)
                || (nextFLActivity2 is IFLApproveActivity && ((IFLApproveActivity)nextFLActivity2).DelayAutoApprove))
                delayAutoApprove = "AUTO";

            string sendToId = string.Empty;
            string sendToName = string.Empty;
            string sendToKind = "1";
            if (nextFLActivity2.SendToKind == SendToKind.Role)
            {
                string q = nextFLActivity2.SendToRole;
                if (string.IsNullOrEmpty(q))
                {
                    string message = SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(clientInfo[0]))[0]), "FLRuntime", "Logic", "SendToIdNotSet");
                    throw new FLException(2, message);
                }
                string[] qq = q.Split(";".ToCharArray());

                sendToId = qq[0].Trim();
                flInstance.RL.Add(string.Format("R:{0}", sendToId));
            }
            else if (nextFLActivity2.SendToKind == SendToKind.RefRole)
            {
                string sendToField = nextFLActivity2.SendToField;
                string values = keyValues[1].ToString();

                if (nextFLActivity is FLStandActivity && ((ISupportFLDetailsActivity)nextFLActivity).SendToId2 != string.Empty)
                {
                    sendToId = ((ISupportFLDetailsActivity)nextFLActivity).SendToId2;
                }
                else
                {
                    sendToId = Global.GetRoleIdByRefRole(flInstance, sendToField, tableName, values, clientInfo);
                }
                flInstance.RL.Add(string.Format("R:{0}", sendToId));
            }
            else if (nextFLActivity2.SendToKind == SendToKind.Applicate)
            {
                sendToId = flInstance.Creator;
                sendToKind = "2";
                flInstance.RL.Add(string.Format("U:{0}", sendToId));
            }
            else if (nextFLActivity2.SendToKind == SendToKind.User)
            {
                string q = nextFLActivity2.SendToUser;
                if (string.IsNullOrEmpty(q))
                {
                    string message = SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(clientInfo[0]))[0]), "FLRuntime", "Logic", "SendToIdNotSet");
                    throw new FLException(2, message);
                }
                sendToId = q.Split(';')[0];
                sendToKind = "2";
                flInstance.RL.Add(string.Format("U:{0}", sendToId));
            }
            else if (nextFLActivity2.SendToKind == SendToKind.RefUser)
            {
                string sendToField = nextFLActivity2.SendToField;
                string values = keyValues[1].ToString();
                sendToId = Global.GetRoleIdByRefRole(flInstance, sendToField, tableName, values, clientInfo, true);
                sendToKind = "2";
                flInstance.RL.Add(string.Format("U:{0}", sendToId));
            }

            else
            {
                if (flInstance.IsRetake)
                {
                    sendToId = flInstanceParms[5].ToString();
                }
                else
                {
                    if (flInstance.FLDirection == FLDirection.GoToBack)
                    {
                        sendToId = ((IEventWaitingExecute)nextFLActivity2).RoleId;
                    }
                    else
                    {
                        if (nextFLActivity2.SendToKind == SendToKind.Manager)
                        {
                            if (string.IsNullOrEmpty(flInstance.R))
                            {
                                sendToId = Global.GetManagerRoleId(flInstanceParms[5].ToString(), orgKind, clientInfo);
                            }
                            else
                            {
                                sendToId = Global.GetManagerRoleId(flInstance.R.ToString(), orgKind, clientInfo);
                            }
                        }
                        else if (nextFLActivity2.SendToKind == SendToKind.RefManager)
                        {
                            if (nextFLActivity2 is IFLApproveActivity && !string.IsNullOrEmpty(flInstance.R))
                            {
                                sendToId = Global.GetManagerRoleId(flInstance.R.ToString(), orgKind, clientInfo);
                            }
                            else
                            {
                                string sendToField = nextFLActivity2.SendToField;
                                string values = keyValues[1].ToString();

                                string roleId = Global.GetRoleIdByRefRole(flInstance, sendToField, tableName, values, clientInfo);
                                sendToId = Global.GetManagerRoleId(roleId.ToString(), orgKind, clientInfo);
                            }
                        }
                        else if (nextFLActivity2.SendToKind == SendToKind.ApplicateManager)
                        {
                            if (nextFLActivity2 is IFLApproveActivity && !string.IsNullOrEmpty(flInstance.R))
                            {
                                sendToId = Global.GetManagerRoleId(flInstance.R.ToString(), orgKind, clientInfo);
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(flInstance.CreateRole))
                                {
                                    sendToId = Global.GetManagerRoleId(flInstance.CreateRole, orgKind, clientInfo);
                                    flInstance.RL.Add(string.Format("R:{0}", sendToId));
                                }
                                else
                                {
                                    List<string> roleIds = Global.GetRoleIdsByUserId(flInstance.Creator, clientInfo);
                                    if (roleIds.Count > 0)
                                    {
                                        sendToId = Global.GetManagerRoleId(roleIds[0], orgKind, clientInfo);
                                        flInstance.RL.Add(string.Format("R:{0}", sendToId));
                                    }
                                }
                            }

                        }
                        flInstance.RL.Add(string.Format("R:{0}", sendToId));
                    }
                }
            }

            if (sendToKind == "1")
            {
                sendToName = Global.GetGroupName(sendToId, clientInfo);
            }
            else
            {
                sendToName = Global.GetUserName(sendToId, clientInfo);
            }

            if (sendToId == null || sendToId == string.Empty)
            {
                String message = SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(clientInfo[0]))[0]), "FLRuntime", "Logic", "SendToIdIsNull");
                throw new FLException(message);
            }

            // 判断代理 移到InsertToDoAndCallMethod中
            bool parAgentNotify = false;
            //string sSendToId = currentFLActivity == null ? string.Empty : currentFLActivity.SendToId;
            //SendToKind sSendToKind = currentFLActivity2 == null ? SendToKind.Role : currentFLActivity2.SendToKind;
            //if ((sSendToId != null && sSendToId != string.Empty) && sSendToKind != SendToKind.Applicate && sSendToKind != SendToKind.User && sSendToKind != SendToKind.RefUser)
            //{
            //    List<string> userRoleIds = Global.GetRoleIdsByUserId(sUserId, clientInfo);
            //    if (!userRoleIds.Contains(sSendToId))
            //    {
            //        object parAgent = Global.GetPARAGENT(flowDesc, sUserId, clientInfo);
            //        if (parAgent != null && Convert.ToBoolean(parAgent))
            //        {
            //            // 添加一个Notify
            //            parAgentNotify = true;
            //        }
            //    }
            //}

            string presentFields = ((IFLRootActivity)flInstance.RootFLActivity).PresentFields;
            string keys = keyValues[0].ToString();
            string presenation = keyValues[1].ToString();
            string presenationCT = GetFormPresentCT(flInstance, keys, presenation, presentFields, clientInfo);

            nextFLActivity.SendToId = sendToId;

            string status = "N";
            if (nextFLActivity2 is IFLNotifyActivity)
            {
                status = "F";
            }
            //else if (flInstance.RootFLActivity.ChildFLActivities[0].Name == nextFLActivity2.Name)
            //{
            if (flInstance.IsRetake || flInstance.IsPause)
            {
                status = "NF";
            }
            else if (flInstance.IsReturn)  // 把Return都归为此类
            {
                status = "NR";
            }
            //}

            int navigatorMode = 0;
            if ((flInstance.IsRetake || flInstance.IsReturn || flInstance.IsPause || !flInstance.V))
            {
                navigatorMode = (flInstance.RootFLActivity.ChildFLActivities[0].Name == nextFLActivity.Name)/*取得是否取回或退回到第一个activity*/ ? 2 : (int)nextFLActivity.NavigatorMode;
            }
            else
            {
                navigatorMode = (int)nextFLActivity2.NavigatorMode;
            }
            //if (status == "NR")
            //{
            //    navigatorMode = 2;
            //}

            bool isUrgent = (flInstanceParms[3] != null && flInstanceParms[3].ToString() == "1") ? true : false;
            IFLRootActivity rootActivity = ((IFLRootActivity)flInstance.RootFLActivity);
            DateTime now = DateTime.Now;

            decimal expTime = -1;
            decimal urgentTime = -1;
            TimeUnit timeUnit = TimeUnit.Hour;

            decimal rExpTime = rootActivity.ExpTime;
            decimal rUrgentTime = rootActivity.UrgentTime;

            if (!string.IsNullOrEmpty(rootActivity.ExpTimeField))
            {
                DataSet dataset = HostTable.GetHostDataSet(flInstance, keyValues, clientInfo);
                if (dataset.Tables.Count > 0 && dataset.Tables[0].Rows.Count > 0)
                {
                    object value = dataset.Tables[0].Rows[0][rootActivity.ExpTimeField];
                    if (!value.Equals(DBNull.Value))
                    {
                        decimal.TryParse(value.ToString(), out rExpTime);
                        decimal.TryParse(value.ToString(), out rUrgentTime);
                    }
                }
            }

            decimal nExpTime = nextFLActivity2.ExpTime;
            decimal nUrgentTime = nextFLActivity2.UrgentTime;
            if (rootActivity.TimeUnit == TimeUnit.Day)
            {
                rExpTime *= 8;
                rUrgentTime *= 8;
            }
            if (nextFLActivity2.TimeUnit == TimeUnit.Day)
            {
                nExpTime *= 8;
                nUrgentTime *= 8;
            }

            decimal timeSpanr = isUrgent ? rUrgentTime : rExpTime;
            decimal timeSpann = isUrgent ? nUrgentTime : nExpTime;

            if (timeSpanr <= 0)//如果没有设置root取next
            {
                expTime = nExpTime;
                urgentTime = nUrgentTime;
            }
            else
            {
                //decimal usedHours = new decimal((now - flInstance.CreatedTime).TotalHours);
                decimal usedDays = WorkTimeSpan(now.Date, flInstance.CreatedTime.Date, true, null).Days;
                decimal usedHours = usedDays * 8 + now.Hour - flInstance.CreatedTime.Hour;

                if (timeSpanr - usedHours > 0)
                {
                    rExpTime -= usedHours;
                    rUrgentTime -= usedHours;
                    if (timeSpann <= 0)
                    {
                        expTime = rExpTime;
                        urgentTime = rUrgentTime;
                    }
                    else
                    {
                        expTime = Math.Min(rExpTime, nExpTime);
                        urgentTime = Math.Min(rUrgentTime, nUrgentTime);
                    }
                }
            }

            List<object> list = new List<object>();
            list.Add(flInstanceId.ToString());                                                                      // LISTID;    0
            list.Add(flDefinitionId.ToString());                                                                    // FLOW_ID;         1
            list.Add(flowDesc);                                                                                     // FLOW_DESC;     2
            list.Add(sUserId);                                                                                      // S_USER_ID;      3
            list.Add(currentFLActivity2 == null ? null : currentFLActivity2.Name);                                  // S_STEP_ID;     4
            list.Add(currentFLActivity2 == null ? null : currentFLActivity2.Description);                           // S_STEP_DESC;   5
            list.Add(nextFLActivity2.Name);                                                                         // D_STEP_ID;      6
            list.Add(nextFLActivity2.Description);                                                                  // D_STEP_DESC;     7
            list.Add(expTime);                                                                                      // EXP_TIME;       8
            list.Add(urgentTime);                                                                                   // URGENT_TIME;     9
            list.Add(timeUnit);                                                                                     // TIME_UNIT;     10
            list.Add(sUserName);                                                                                    // USERNAME
            list.Add(nextFLActivity2 == null || string.IsNullOrEmpty(nextFLActivity2.FormName)
                ? ((IFLRootActivity)flInstance.RootFLActivity).FormName : nextFLActivity2.FormName);                // FORM_NAME
            list.Add(navigatorMode);                                                                                // NAVIGATOR_MODE;
            list.Add((int)nextFLActivity2.FLNavigatorMode);                                                         // FLNAVIGATOR_MODE;
            list.Add(nextFLActivity2.Parameters);                                                                   // PARAMETERS;
            list.Add(sendToKind);                                                                                   // SENDTO_KIND;
            list.Add(sendToId);                                                                                     // SENDTO_ID;
            list.Add(flInstanceParms[2]);                                                                           // FLOWIMPORTANT;
            list.Add(flInstanceParms[3]);                                                                           // FLOWURGENT;
            list.Add(status);                                                                                       // STATUS;              // 先不管
            list.Add(tableName);                                                                                    // FORM_TABLE;
            list.Add(keys);                                                                                         // FORM_KEYS
            list.Add(presenation);                                                                                  // FORM_PRESENTATION;
            list.Add(presenationCT);                                                                                // FORM_PRESENT_CT;
            list.Add(flInstanceParms[4] == null ? string.Empty : flInstanceParms[4].ToString().Replace("'", "''")); // REMARK;
            list.Add(flInstanceParms[6].ToString());                                                                // PROVIDER_NAME;       // 先不管
            list.Add(null);                                                                                         // VERSION;             // 先不管
            list.Add(email);                                                                                        // EMAIL_ADD;
            list.Add(null);                                                                                         // EMAIL_STATUS;
            list.Add(flInstance.Solution);                                                                          // VDSNAME;
            list.Add(null);                                                                                         // SENDBACKSTEP;        // 先不管
            list.Add(delayAutoApprove);                                                                             // LEVEL_NO
            list.Add(nextFLActivity2 == null || string.IsNullOrEmpty(nextFLActivity2.WebFormName)
                ? ((IFLRootActivity)flInstance.RootFLActivity).WebFormName : nextFLActivity2.WebFormName);          // WEBFORM_NAME
            list.Add(flInstance.Creator);                                                                           // APPLICANT
            list.Add(flowPath);                                                                                     // FLOWPATH
            list.Add(now.ToString("yyyy-MM-dd"));                                                                   // UPDATE_DATE
            list.Add(now.ToString("HH:mm:ss"));                                                                     // UPDATE_TIME
            list.Add(plusApprove);                                                                                  // PLUSAPPROVE
            list.Add(null);                                                                                         // PLUSROLES
            list.Add(flInstance.GetMultiStepReturn((FLActivity)nextFLActivity2) ? "1" : "0");                       // MULTISTEPRETURN
            list.Add(sendToName);                                                                                   // SENDTO_NAME
            list.Add(flInstanceParms[9] == null ? null : flInstanceParms[9].ToString());                                                                // ATTACHMENTFILES
            list.Add(GetNvarcharMark(clientInfo));

            #if CreateTime
            list.Add(flInstance.CreatedTime.ToString("yyyy-MM-dd HH:mm:ss"));
            #endif

            //if (!parAgentNotify)
            //{
            return string.Format(INSERT_TODOLIST, list.ToArray()); ;
            //}
            //else
            //{
            //    List<object> flInstanceParms2 = new List<object>(flInstanceParms);
            //    if (flInstanceParms2.Count >= 9)
            //    {
            //        flInstanceParms2[8] = sSendToId;
            //    }
            //    else
            //    {
            //        int count = flInstanceParms2.Count;
            //        for (int i = 0; i < 8 - count; i++)
            //        {
            //            flInstanceParms2.Add(null);
            //        }
            //        flInstanceParms2.Add(sSendToId);
            //    }

            //    string parAgentNotifySQL = GetInsertToDoListSQL4Notify(flInstance, currentFLActivity2, null, flInstanceParms2.ToArray(), keyValues, clientInfo);
            //    return string.Format(INSERT_TODOLIST, list.ToArray()) + ";" + parAgentNotifySQL;
            //}
        }
示例#6
0
文件: Email.cs 项目: san90279/UK_OAS
 private static bool IsSendToSelf(IEventWaiting activity, object[] clientInfo)
 {
     string userId = ((object[])clientInfo[0])[1].ToString();
     if (activity.SendToKind == SendToKind.Applicate || activity.SendToKind == SendToKind.RefUser || activity.SendToKind == SendToKind.User)
     {
         return userId == activity.SendToId;
     }
     else
     {
         List<string> users = Global.GetUsersIdsByRoleId(activity.SendToId, clientInfo);
         return  users.Contains(userId);
     }
 }
示例#7
0
文件: Email.cs 项目: san90279/UK_OAS
        private static string GetButtons(FLInstance flInstance, object[] clientInfo, EmailSetting setting, string userID, IEventWaiting nextFLActivity)
        {
            var buttons = new StringBuilder();
            string webUrl = flInstance.GetWebUrl();
            if (webUrl != null && webUrl != "0" && webUrl.IndexOf("/MainPage_Flow.aspx") > 0)
            {
                var databaseType = Srvtools.DbConnectionSet.GetDbConn((string)((object[])clientInfo[0])[2]).DbType.ToString().Replace("ct", string.Empty);
                webUrl = webUrl.Substring(0, webUrl.IndexOf("/MainPage_Flow.aspx")) + "/FlowEmail.aspx";
                var key = Srvtools.PublicKey.GetEncryptKey(userID, Global.GetUserName(userID, clientInfo), (string)((object[])clientInfo[0])[2], (string)((object[])clientInfo[0])[6], databaseType, (string)((object[])clientInfo[0])[5]);

                buttons.Append("<br/>");
                var listID = flInstance.FLInstanceId.ToString();
                IEventWaiting currentFLActivity = (IEventWaiting)flInstance.CurrentFLActivity;
                string flowPath = (currentFLActivity == null ? string.Empty : currentFLActivity.Name) + ";" + nextFLActivity.Name;
                var titles = SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(clientInfo[0]))[0]), "FLClientControls", "FLNavigator", "NavText").Split(';');
                if (setting.ButtonApprove)
                {
                    var param = EncryptParameters(string.Format("{{\"listID\":\"{0}\", \"type\":\"{1}\", \"flowPath\":\"{2}\"}}", listID, "approve", flowPath), key);
                    buttons.Append(string.Format("<a href='{0}?key={1}&param={2}' style='margin:15px 15px 15px 5px'  target='_blank'>{3}</a>", webUrl, HttpUtility.UrlEncode(key), HttpUtility.UrlEncode(param), titles[17]));
                }
                if (setting.ButtonReturn)
                {
                    var param = EncryptParameters(string.Format("{{\"listID\":\"{0}\", \"type\":\"{1}\", \"flowPath\":\"{2}\"}}", listID, "return", flowPath), key);
                    buttons.Append(string.Format("<a href='{0}?key={1}&param={2}' style='margin:15px'  target='_blank'>{3}</a>", webUrl, HttpUtility.UrlEncode(key), HttpUtility.UrlEncode(param), titles[18]));
                }
                if (setting.ButtonReject)
                {
                    if (nextFLActivity.FLNavigatorMode == FLNavigatorMode.Submit)
                    {
                        var param = EncryptParameters(string.Format("{{\"listID\":\"{0}\", \"type\":\"{1}\", \"flowPath\":\"{2}\"}}", listID, "reject", flowPath), key);
                        buttons.Append(string.Format("<a href='{0}?key={1}&param={2}' style='margin:15px'  target='_blank'>{3}</a>", webUrl, HttpUtility.UrlEncode(key), HttpUtility.UrlEncode(param), titles[19]));
                    }
                }
            }

            return buttons.ToString();
        }