Esempio n. 1
0
        /// <summary>
        /// 登录.
        /// </summary>
        /// <returns></returns>
        public string Login_Submit()
        {
            string userNo = this.GetRequestVal("TB_No");

            if (userNo == null)
            {
                userNo = this.GetRequestVal("TB_UserNo");
            }

            string pass = this.GetRequestVal("TB_PW");

            if (pass == null)
            {
                pass = this.GetRequestVal("TB_Pass");
            }

            BP.Port.Emp emp = new Emp();
            emp.No = userNo;
            if (emp.RetrieveFromDBSources() == 0)
            {
                if (DBAccess.IsExitsTableCol("Port_Emp", "NikeName") == true)
                {
                    /*如果包含昵称列,就检查昵称是否存在.*/
                    Paras ps = new Paras();
                    ps.SQL = "SELECT No FROM Port_Emp WHERE NikeName=" + SystemConfig.AppCenterDBVarStr + "NikeName";
                    ps.Add("NikeName", userNo);
                    string no = DBAccess.RunSQLReturnStringIsNull(ps, null);
                    if (no == null)
                    {
                        return("err@用户名或者密码错误.");
                    }

                    emp.No = no;
                    int i = emp.RetrieveFromDBSources();
                    if (i == 0)
                    {
                        return("err@用户名或者密码错误.");
                    }
                }
                else
                {
                    return("err@用户名或者密码错误.");
                }
            }

            if (emp.CheckPass(pass) == false)
            {
                return("err@用户名或者密码错误.");
            }

            //调用登录方法.
            BP.WF.Dev2Interface.Port_Login(emp.No, emp.Name, emp.FK_Dept, emp.FK_DeptText);

            return("登录成功.");
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            switch (this.DoType)
            {
            case "CheckPower":
                this.CheckPower();
                break;

            case "GetNewMsg":
                this.GetNewMsg();
                break;

            case "OpenWork":
                Emp emp = new Emp(this.UserNo);
                emp.No = this.UserNo;
                emp.RetrieveFromDBSources();

                BP.Web.WebUser.SignInOfGenerLang(emp, this.Lang);
                this.Response.Redirect("../MyFlow.aspx?OID=" + this.Request.QueryString["WorkID"] + "&FK_Flow=" + this.Request.QueryString["FK_Flow"], true);
                return;

            default:
                throw new Exception("错误的标记:" + this.DoType);
            }
        }
Esempio n. 3
0
    //登录方法
    private void Login()
    {
        string user = TB_No.Text.Trim();
        string pass = TB_Pass.Text.Trim();

        //判断是否是记住密码
        if (hidIsRememberedPass.Value == "1")
        {
            pass = Emp.DecryptPass(pass);
        }

        try
        {
            if (WebUser.No != null)
            {
                WebUser.Exit();
            }

            if (user.ToLower() == "guest")
            {
                this.Alert("guest 用户不能登录内部用户的处理程序. ");
                return;
            }

            Emp em = new Emp();
            em.No = user;
            if (em.RetrieveFromDBSources() == 0)
            {
                this.Alert("用户名密码错误,注意密码区分大小写,请检查是否按下了CapsLock.。");
                return;
            }

            if (em.CheckPass(pass))
            {
                //bool bl = this.IsRemember.Checked;

                //WebUser.SignInOfGenerLang(em, WebUser.SysLang, bl);
                //if (this.Request.RawUrl.ToLower().Contains("wap"))
                //    WebUser.IsWap = true;
                //else
                //    WebUser.IsWap = false;
                //WebUser.Token = this.Session.SessionID;

                //调用登录接口,让BP框架登录.
                BP.WF.Dev2Interface.Port_Login(em.No, this.IsRemember.Checked);

                Response.Redirect("Default.aspx", false);
                return;
            }
            this.Alert("用户名密码错误,注意密码区分大小写,请检查是否按下了CapsLock.。");
        }
        catch (System.Exception ex)
        {
            this.Alert("@用户名密码错误!@检查是否按下了CapsLock.@更详细的信息:" + ex.Message);
        }
    }
Esempio n. 4
0
        public string DoType(string doType, string v1, string v2, string v3, string v4, string v5)
        {
            try
            {
                switch (doType)
                {
                case "AdminLogin":
                    try
                    {
                        Emp emp = new Emp();
                        emp.No = v1;
                        emp.RetrieveFromDBSources();
                        if (emp.Pass == v2)
                        {
                            return(null);
                        }
                        return("error password.");
                    }
                    catch (Exception ex)
                    {
                        return(ex.Message);
                    }

                case "DeleteFrmSort":
                    FrmSort fs = new FrmSort();
                    fs.No = v1;
                    fs.Delete();
                    return(null);

                case "DeleteFrm":
                case "DelFrm":
                    MapData md = new MapData();
                    md.No = v1;
                    md.Delete();
                    return(null);

                case "InitDesignerXml":
                    string  path = BP.SystemConfig.PathOfData + "\\Xml\\Designer.xml";
                    DataSet ds   = new DataSet();
                    ds.ReadXml(path);
                    ds = this.TurnXmlDataSet2SLDataSet(ds);
                    return(Connector.ToXml(ds));

                default:
                    throw new Exception("没有判断的,功能编号" + doType);
                }
            }
            catch (Exception ex)
            {
                BP.DA.Log.DefaultLogWriteLineError("执行错误,功能编号" + doType + " error:" + ex.Message);
                throw new Exception("执行错误,功能编号" + doType + " error:" + ex.Message);
            }
        }
Esempio n. 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region 检查是否是安装了ccflow如果没有就让其安装.
            try
            {
                //如果没有Port_Dept 表就可能没有安装ccflow.
                DBAccess.RunSQL("SELECT * FROM Port_Dept WHERE 1=2");
            }
            catch
            {
                /*数据库链接不通或者有异常,说明没有安装.*/
                this.Response.Redirect("../DBInstall.aspx", true);
                return;
            }
            #endregion 检查是否是安装了ccflow如果没有就让其安装.

            #region 执行admin登陆.
            Emp emp = new Emp();
            emp.No = "admin";
            if (emp.RetrieveFromDBSources() == 1)
            {
                BP.Web.WebUser.SignInOfGener(emp, true);
            }
            else
            {
                emp.No      = "admin";
                emp.Name    = "admin";
                emp.FK_Dept = "01";
                emp.Pass    = "******";
                emp.Insert();
                BP.Web.WebUser.SignInOfGener(emp, true);
                //throw new Exception("admin 用户丢失,请注意大小写。");
            }
            #endregion 执行admin登陆.

            // 执行升级, 现在升级代码移动到 Glo 里面了。
            string str = BP.WF.Glo.UpdataCCFlowVer(); //执行升级.
            if (str != null)
            {
                //   this.Response.Write(str);
                if (str == "0")
                {
                    BP.Sys.PubClass.Alert("系统升级错误,请查看日志文件\\DataUser/\\log");
                }
                else
                {
                    BP.Sys.PubClass.Alert("系统成功升级到:" + str + " ,系统升级不会破坏现有的数据。");
                }
            }
        }
Esempio n. 6
0
    private void Login()
    {
        string user = TB_No.Text.Trim();
        string pass = TB_Pass.Text.Trim();

        try
        {
            //关闭已登录用户
            if (WebUser.No != null)
            {
                WebUser.Exit();
            }

            Emp em = new Emp();
            em.No = user;
            if (em.RetrieveFromDBSources() == 0)
            {
                //  this.TB_No.Text = "";
                return;
            }


            if (em.CheckPass(pass))
            {
                bool bl = this.IsRemember.Checked;
                WebUser.SignInOfGenerLang(em, WebUser.SysLang, bl);

                if (this.Request.RawUrl.ToLower().Contains("wap"))
                {
                    WebUser.IsWap = true;
                }
                else
                {
                    WebUser.IsWap = false;
                }

                WebUser.Token = this.Session.SessionID;

                Response.Redirect("Default.aspx", false);
                return;
            }
            this.Alert("用户名密码错误,注意密码区分大小写,请检查是否按下了CapsLock.。");
        }
        catch (System.Exception ex)
        {
            this.Alert("@用户名密码错误!@检查是否按下了CapsLock.@更详细的信息:" + ex.Message);
        }
    }
Esempio n. 7
0
        public void CheckPower()
        {
            Emp emp = new Emp();

            emp.No = this.UserNo;
            if (emp.RetrieveFromDBSources() == 0)
            {
                this.Response.Write("");
                return;
            }

            if (emp.Pass == this.UserPass)
            {
                this.Response.Write("1");
            }
        }
        void btn_Click(object sender, EventArgs e)
        {
            string user = this.Pub1.GetTextBoxByID("TB_User").Text.Trim();
            string pass = this.Pub1.GetTextBoxByID("TB_Pass").Text;

            try
            {
                Emp em = new Emp();
                em.No = user;
                if (em.RetrieveFromDBSources() == 0)
                {
                    this.Alert("用户名或密码错误,注意两者区分大小写,请检查是否按下了CapsLock。");
                    return;
                }
                if (em.CheckPass(pass))
                {
                    // 执行登陆.
                    WebUser.SignInOfGenerLang(em, this.Lang);
                    if (this.Request.RawUrl.ToLower().Contains("wap"))
                    {
                        WebUser.IsWap = true;
                    }
                    else
                    {
                        WebUser.IsWap = false;
                    }

                    WebUser.Token = this.Session.SessionID;
                    string script = "<script language=JavaScript>window.control.returnLogin(" + user + ");</script>";
                    if (WebUser.IsWap)
                    {
                        System.Web.HttpContext.Current.Response.Write(script);
                        Response.Redirect("Home.aspx", true);
                        return;
                    }

                    System.Web.HttpContext.Current.Response.Write(script);
                    Response.Redirect(this.ToWhere, false);
                    return;
                }
                this.Alert("用户名或密码错误,注意两者区分大小写,请检查是否按下了CapsLock。");
            }
            catch (System.Exception ex)
            {
                this.Response.Write("<font color=red ><b>@用户名密码错误!@检查是否按下了CapsLock.@更详细的信息:" + ex.Message + "</b></font>");
            }
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region 检查是否是安装了ccflow如果没有就让其安装.
            /*数据库链接不通或者有异常,说明没有安装.*/
            if (BP.DA.DBAccess.IsExitsObject("WF_Emp") == false)
            {
                this.Response.Redirect("../DBInstall.aspx", true);
                return;
            }
            #endregion 检查是否是安装了ccflow如果没有就让其安装.

            #region 执行admin登陆.
            Emp emp = new Emp();
            emp.No = "admin";
            if (emp.RetrieveFromDBSources() == 1)
            {
                BP.Web.WebUser.SignInOfGener(emp, true);
            }
            else
            {
                emp.No      = "admin";
                emp.Name    = "admin";
                emp.FK_Dept = "01";
                emp.Pass    = "******";
                emp.Insert();
                BP.Web.WebUser.SignInOfGener(emp, true);
                //throw new Exception("admin 用户丢失,请注意大小写。");
            }
            #endregion 执行admin登陆.

            // 执行升级, 现在升级代码移动到 Glo 里面了。
            string str = BP.WF.Glo.UpdataCCFlowVer(); //执行升级.
            if (str != null)
            {
                //   this.Response.Write(str);
                if (str == "0")
                {
                    BP.Sys.PubClass.Alert("系统升级错误,请查看日志文件\\DataUser\\log");
                }
                else
                {
                    BP.Sys.PubClass.Alert("系统成功升级到:" + str + " ,系统升级不会破坏现有的数据,ccbpm6的升级都是保证向下兼容的。");
                }
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        string strNo      = "";
        string strPs      = "";
        string isRemember = "";

        if (this.Request.QueryString["DoType"] == "Logout")
        {
            BP.Web.WebUser.Exit();
        }

        if (IsPostBack == false)
        {
            if (Request.QueryString["username"] != null)//判断是否是从其他页面跳转
            {
                strNo = Request.QueryString["username"].ToString();

                if (Request.QueryString["password"] != null)
                {
                    strPs = Request.QueryString["password"].ToString();
                    Login(strNo, strPs);
                }
            }
            else
            {
                if (this.Request.Browser.Cookies == true) //获取cookie
                {
                    if (Request.Cookies["CCS"] != null)
                    {
                        strNo = Convert.ToString(Request.Cookies["CCS"].Values["No"]);
                        if (strNo != "")
                        {
                            strPs      = Convert.ToString(Request.Cookies["CCS"].Values["Pass"]);
                            isRemember = Request.Cookies["CCS"].Values["IsRememberMe"].ToString();
                            //获取cookie中的用户名和密码,并判断是否一致
                            Emp em = new Emp(strNo);
                            em.No = strNo;
                            if (em.RetrieveFromDBSources() == 0)
                            {
                                return;
                            }

                            if (em.CheckPass(strPs))
                            {
                                WebUser.SignInOfGenerLang(em, WebUser.SysLang, isRemember == "0" ? false : true);
                                if (isRemember == "1")
                                {
                                    if (this.Request.RawUrl.ToLower().Contains("wap"))
                                    {
                                        WebUser.IsWap = true;
                                    }
                                    else
                                    {
                                        WebUser.IsWap = false;
                                    }

                                    WebUser.Token = this.Session.SessionID;

                                    Response.Redirect("Default.aspx", false);
                                    return;
                                }
                                else
                                {
                                    this.TB_No.Text = strNo;
                                }
                            }
                            else
                            {
                                this.TB_No.Text = strNo;
                            }
                        }
                    }
                }
            }
            this.Page.RegisterStartupScript("event_handler", "<script>document.body.onkeypress = keyPressed;</script>");
            this.Page.RegisterClientScriptBlock("default_button", "<script> function keyPressed() { if(window.event.keyCode == 13) { document.getElementById(\""
                                                + this.Btn1.ClientID + "\").click(); } } </script>");
            if (WebUser.No != null)
            {
                TB_No.Text = WebUser.No;
            }
        }
    }
Esempio n. 11
0
        /// <summary>
        /// 通用的登陆
        /// </summary>
        /// <param name="guestNo">客户编号</param>
        /// <param name="guestName">客户名称</param>
        /// <param name="deptNo">部门编号</param>
        /// <param name="deptName">部门名称</param>
        /// <param name="lang">语言</param>
        /// <param name="isRememberMe">是否记忆我</param>
        public static void SignInOfGener(string guestNo, string guestName, string deptNo,
                                         string deptName, string lang, bool isRememberMe)
        {
            if (System.Web.HttpContext.Current == null)
            {
                SystemConfig.IsBSsystem = false;
            }
            else
            {
                SystemConfig.IsBSsystem = true;
            }

            //记录客人信息.
            GuestUser.No       = guestNo;
            GuestUser.Name     = guestName;
            GuestUser.DeptNo   = deptNo;
            GuestUser.DeptName = deptName;


            //记录内部客户信息.
            BP.Port.Emp em = new Emp();
            em.No = "Guest";
            if (em.RetrieveFromDBSources() == 0)
            {
                em.Name = "客人";
                em.Insert();
            }
            WebUser.No          = em.No;
            WebUser.Name        = em.Name;
            WebUser.FK_Dept     = em.FK_Dept;
            WebUser.FK_DeptName = em.FK_DeptText;
            WebUser.HisStations = null;
            WebUser.SysLang     = lang;
            if (BP.Sys.SystemConfig.IsBSsystem)
            {
                // Guest  信息.
                HttpCookie cookie = new HttpCookie("CCSGuest");
                //cookie.Expires = DateTime.Now.AddMonths(10);
                cookie.Expires = DateTime.Now.AddDays(2);
                cookie.Values.Add("GuestNo", guestNo);
                cookie.Values.Add("GuestName", HttpUtility.UrlEncode(guestName));
                cookie.Values.Add("DeptNo", deptNo);
                cookie.Values.Add("DeptName", HttpUtility.UrlEncode(deptName));
                System.Web.HttpContext.Current.Response.AppendCookie(cookie); //加入到会话。


                HttpCookie cookie2 = new HttpCookie("CCS");
                cookie2.Expires = DateTime.Now.AddDays(2);
                // Guest  信息.
                cookie2.Values.Add("GuestNo", guestNo);
                cookie2.Values.Add("GuestName", HttpUtility.UrlEncode(guestName));

                cookie2.Values.Add("DeptNo", deptNo);
                cookie2.Values.Add("DeptName", HttpUtility.UrlEncode(deptName));

                cookie2.Values.Add("No", "Guest");
                cookie2.Values.Add("Name", HttpUtility.UrlEncode(em.Name));

                if (isRememberMe)
                {
                    cookie2.Values.Add("IsRememberMe", "1");
                }
                else
                {
                    cookie2.Values.Add("IsRememberMe", "0");
                }

                cookie2.Values.Add("FK_Dept", em.FK_Dept);
                cookie2.Values.Add("FK_DeptName", HttpUtility.UrlEncode(em.FK_DeptText));

                cookie2.Values.Add("Token", System.Web.HttpContext.Current.Session.SessionID);
                cookie2.Values.Add("SID", System.Web.HttpContext.Current.Session.SessionID);

                cookie2.Values.Add("Lang", lang);
                cookie2.Values.Add("Style", "0");
                cookie2.Values.Add("Auth", ""); //授权人.
                System.Web.HttpContext.Current.Response.AppendCookie(cookie2);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// 生成数据
        /// </summary>
        /// <returns></returns>
        public DataTable GenerWorkerOfDataTable()
        {
            DataTable dt = new DataTable();

            // 首先判断第一类别
            switch (this.SortVal0)
            {
            case "ByDept":
                return(this.GenerByDept());

            case "Leader":
            case "SpecEmps":

                #region   首先找到2级参数,就是当事人是谁?
                string empNo   = null;
                string empDept = null;
                switch (this.HisFindLeaderType)
                {
                case FindLeaderType.Submiter:         // 当前提交人的直线领导
                    empNo   = BP.Web.WebUser.No;
                    empDept = BP.Web.WebUser.FK_Dept;
                    break;

                case FindLeaderType.SpecNodeSubmiter:         // 指定节点提交人的直线领导.
                    sql = "SELECT FK_Emp,FK_Dept FROM WF_GenerWorkerlist WHERE WorkID=" + this.WorkID + " AND FK_Node=" + this.TagVal1;
                    dt  = BP.DA.DBAccess.RunSQLReturnTable(sql);
                    if (dt.Rows.Count == 0)
                    {
                        throw new Exception("@没有找到指定节点数据,请反馈给系统管理员,技术信息:" + sql);
                    }
                    empNo   = dt.Rows[0][0] as string;
                    empDept = dt.Rows[0][1] as string;
                    break;

                case FindLeaderType.BySpecField:         //指定节点字段人员的直接领导..
                    sql   = " SELECT " + this.TagVal1 + " FROM " + this.HisNode.HisFlow.PTable + " WHERE OID=" + this.WorkID;
                    dt    = BP.DA.DBAccess.RunSQLReturnTable(sql);
                    empNo = dt.Rows[0][0] as string;
                    if (string.IsNullOrEmpty(empNo))
                    {
                        throw new Exception("@指定的节点字段(" + this.TagVal1 + ")的值为空.");
                    }
                    //指定它
                    Emp emp = new Emp();
                    emp.No = empNo;
                    if (emp.RetrieveFromDBSources() == 0)
                    {
                        throw new Exception("@指定的节点字段(" + this.TagVal1 + ")的值(" + empNo + ")是非法的人员编号...");
                    }
                    empDept = emp.FK_Dept;
                    break;

                default:
                    throw new Exception("@尚未处理的Case:" + this.HisFindLeaderType);
                    break;
                }
                if (string.IsNullOrEmpty(empNo))
                {
                    throw new Exception("@遗漏的判断步骤,没有找到指定的工作人员.");
                }
                #endregion

                if (this.SortVal0 == "Leader")
                {
                    return(GenerHisLeader(empNo, empDept));    // 产生他的领导并返回.
                }
                else
                {
                    return(GenerHisSpecEmps(empNo, empDept));    // 产生他的特定的同事并返回.
                }

            default:
                break;
            }
            return(null);
        }
Esempio n. 13
0
        /// <summary>
        /// 初始化界面.
        /// </summary>
        /// <returns></returns>
        public string TestFlow_Init()
        {
            //清除缓存.
            BP.Sys.SystemConfig.DoClearCash();

            if (1 == 2 && BP.Web.WebUser.IsAdmin == false)
            {
                return("err@您不是管理员,无法执行该操作.");
            }

            // 让admin 登录.
            //   BP.WF.Dev2Interface.Port_Login("admin");

            if (this.RefNo != null)
            {
                Emp emp = new Emp(this.RefNo);
                BP.Web.WebUser.SignInOfGener(emp);
                context.Session["FK_Flow"] = this.FK_Flow;
                return("url@../MyFlow.htm?FK_Flow=" + this.FK_Flow);
            }

            FlowExt fl = new FlowExt(this.FK_Flow);

            if (1 == 2 && BP.Web.WebUser.No != "admin" && fl.Tester.Length <= 1)
            {
                string msg = "err@二级管理员[" + BP.Web.WebUser.Name + "]您好,您尚未为该流程配置测试人员.";
                msg += "您需要在流程属性里的底部[设置流程发起测试人]的属性里,设置可以发起的测试人员,多个人员用逗号分开.";
                return(msg);
            }

            /* 检查是否设置了测试人员,如果设置了就按照测试人员身份进入
             * 设置测试人员的目的是太多了人员影响测试效率.
             * */
            if (fl.Tester.Length > 2)
            {
                // 构造人员表.
                DataTable dtEmps = new DataTable();
                dtEmps.Columns.Add("No");
                dtEmps.Columns.Add("Name");
                dtEmps.Columns.Add("FK_DeptText");

                string[] strs = fl.Tester.Split(',');
                foreach (string str in strs)
                {
                    if (DataType.IsNullOrEmpty(str) == true)
                    {
                        continue;
                    }

                    Emp emp = new Emp();
                    emp.SetValByKey("No", str);
                    int i = emp.RetrieveFromDBSources();
                    if (i == 0)
                    {
                        continue;
                    }

                    DataRow dr = dtEmps.NewRow();
                    dr["No"]          = emp.No;
                    dr["Name"]        = emp.Name;
                    dr["FK_DeptText"] = emp.FK_DeptText;
                    dtEmps.Rows.Add(dr);
                }
                return(BP.Tools.Json.ToJson(dtEmps));
            }



            //fl.DoCheck();

            int       nodeid = int.Parse(this.FK_Flow + "01");
            DataTable dt     = null;
            string    sql    = "";

            BP.WF.Node nd = new BP.WF.Node(nodeid);

            if (nd.IsGuestNode)
            {
                /*如果是guest节点,就让其跳转到 guest登录界面,让其发起流程。*/
                //这个地址需要配置.
                return("url@/SDKFlowDemo/GuestApp/Login.aspx?FK_Flow=" + this.FK_Flow);
            }

            try
            {
                switch (nd.HisDeliveryWay)
                {
                case DeliveryWay.ByStation:
                case DeliveryWay.ByStationOnly:

                    sql = "SELECT Port_Emp.No  FROM Port_Emp LEFT JOIN Port_Dept   Port_Dept_FK_Dept ON  Port_Emp.FK_Dept=Port_Dept_FK_Dept.No  join Port_DeptEmpStation on (fk_emp=Port_Emp.No)   join WF_NodeStation on (WF_NodeStation.fk_station=Port_DeptEmpStation.fk_station) WHERE (1=1) AND  FK_Node=" + nd.NodeID;
                    // emps.RetrieveInSQL_Order("select fk_emp from Port_Empstation WHERE fk_station in (select fk_station from WF_NodeStation WHERE FK_Node=" + nodeid + " )", "FK_Dept");
                    break;

                case DeliveryWay.ByDept:
                    sql = "select No,Name from Port_Emp where FK_Dept in (select FK_Dept from WF_NodeDept where FK_Node='" + nodeid + "') ";
                    //emps.RetrieveInSQL("");
                    break;

                case DeliveryWay.ByBindEmp:
                    sql = "select No,Name from Port_Emp where No in (select FK_Emp from WF_NodeEmp where FK_Node='" + nodeid + "') ";
                    //emps.RetrieveInSQL("select fk_emp from wf_NodeEmp WHERE fk_node=" + int.Parse(this.FK_Flow + "01") + " ");
                    break;

                case DeliveryWay.ByDeptAndStation:
                    //added by liuxc,2015.6.30.
                    //区别集成与BPM模式
                    if (BP.WF.Glo.OSModel == BP.Sys.OSModel.OneOne)
                    {
                        sql  = "SELECT No FROM Port_Emp WHERE No IN ";
                        sql += "(SELECT No as FK_Emp FROM Port_Emp WHERE FK_Dept IN ";
                        sql += "( SELECT FK_Dept FROM WF_NodeDept WHERE FK_Node=" + nodeid + ")";
                        sql += ")";
                        sql += "AND No IN ";
                        sql += "(";
                        sql += "SELECT FK_Emp FROM " + BP.WF.Glo.EmpStation + " WHERE FK_Station IN ";
                        sql += "( SELECT FK_Station FROM WF_NodeStation WHERE FK_Node=" + nodeid + ")";
                        sql += ") ORDER BY No ";
                    }
                    else
                    {
                        sql = "SELECT pdes.FK_Emp AS No"
                              + " FROM   Port_DeptEmpStation pdes"
                              + "        INNER JOIN WF_NodeDept wnd"
                              + "             ON  wnd.FK_Dept = pdes.FK_Dept"
                              + "             AND wnd.FK_Node = " + nodeid
                              + "        INNER JOIN WF_NodeStation wns"
                              + "             ON  wns.FK_Station = pdes.FK_Station"
                              + "             AND wnd.FK_Node =" + nodeid
                              + " ORDER BY"
                              + "        pdes.FK_Emp";
                    }
                    break;

                case DeliveryWay.BySelected:     //所有的人员多可以启动, 2016年11月开始约定此规则.
                    sql = "SELECT No as FK_Emp FROM Port_Emp ";
                    dt  = BP.DA.DBAccess.RunSQLReturnTable(sql);
                    if (dt.Rows.Count > 300)
                    {
                        if (SystemConfig.AppCenterDBType == BP.DA.DBType.MSSQL)
                        {
                            sql = "SELECT top 300 No as FK_Emp FROM Port_Emp ";
                        }

                        if (SystemConfig.AppCenterDBType == BP.DA.DBType.Oracle)
                        {
                            sql = "SELECT  No as FK_Emp FROM Port_Emp WHERE ROWNUM <300 ";
                        }

                        if (SystemConfig.AppCenterDBType == BP.DA.DBType.MySQL)
                        {
                            sql = "SELECT  No as FK_Emp FROM Port_Emp WHERE limit 0,300 ";
                        }
                    }
                    break;

                case DeliveryWay.BySQL:
                    if (DataType.IsNullOrEmpty(nd.DeliveryParas))
                    {
                        return("err@您设置的按SQL访问开始节点,但是您没有设置sql.");
                    }
                    break;

                default:
                    break;
                }

                dt = BP.DA.DBAccess.RunSQLReturnTable(sql);
                if (dt.Rows.Count == 0)
                {
                    return("err@您按照:" + nd.HisDeliveryWay + "的方式设置的开始节点的访问规则,但是开始节点没有人员。");
                }

                if (dt.Rows.Count > 300)
                {
                    return("err@可以发起开始节点的人员太多,会导致系统崩溃变慢,您需要在流程属性里设置可以发起的测试用户.");
                }

                // 构造人员表.
                DataTable dtMyEmps = new DataTable();
                dtMyEmps.Columns.Add("No");
                dtMyEmps.Columns.Add("Name");
                dtMyEmps.Columns.Add("FK_DeptText");

                //处理发起人数据.
                string emps = "";
                foreach (DataRow dr in dt.Rows)
                {
                    string myemp = dr[0].ToString();
                    if (emps.Contains("," + myemp + ",") == true)
                    {
                        continue;
                    }

                    emps += "," + myemp + ",";
                    BP.Port.Emp emp = new Emp(myemp);

                    DataRow drNew = dtMyEmps.NewRow();

                    drNew["No"]          = emp.No;
                    drNew["Name"]        = emp.Name;
                    drNew["FK_DeptText"] = emp.FK_DeptText;

                    dtMyEmps.Rows.Add(drNew);
                }


                //检查物理表,避免错误.
                Nodes nds = new Nodes(this.FK_Flow);
                foreach (Node mynd in nds)
                {
                    mynd.HisWork.CheckPhysicsTable();
                }


                //返回数据源.
                return(BP.Tools.Json.ToJson(dtMyEmps));
            }
            catch (Exception ex)
            {
                return("err@<h2>您没有正确的设置开始节点的访问规则,这样导致没有可启动的人员,<a href='http://bbs.ccflow.org/showtopic-4103.aspx' target=_blank ><font color=red>点击这查看解决办法</font>.</a>。</h2> 系统错误提示:" + ex.Message + "<br><h3>也有可能你你切换了OSModel导致的,什么是OSModel,请查看在线帮助文档 <a href='http://ccbpm.mydoc.io' target=_blank>http://ccbpm.mydoc.io</a>  .</h3>");
            }
        }
Esempio n. 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //如果没有Port_Dept 表就可能没有安装ccflow.
                DBAccess.RunSQL("SELECT * FROM Port_Dept WHERE 1=2");
            }
            catch
            {
                /*数据库链接不通或者有异常,说明没有安装.*/
                this.Response.Redirect("../DBInstall.aspx", true);
                return;
            }

            if (this.IsCheckUpdate == false)
            {
                #region 执行admin登陆.
                Emp emp = new Emp();
                emp.No = "admin";
                if (emp.RetrieveFromDBSources() == 1)
                {
                    BP.Web.WebUser.SignInOfGener(emp, true);
                }
                else
                {
                    emp.No      = "admin";
                    emp.Name    = "admin";
                    emp.FK_Dept = "01";
                    emp.Pass    = "******";
                    emp.Insert();
                    BP.Web.WebUser.SignInOfGener(emp, true);
                    //throw new Exception("admin 用户丢失,请注意大小写。");
                }
                #endregion 执行admin登陆.
                return;
            }

            string sql = "";
            string msg = "";
            try
            {
                msg = "@登陆时错误。";
                DBAccess.RunSQL("DELETE Sys_Enum WHERE EnumKey IN ('DeliveryWay','RunModel','OutTimeDeal')");

                BP.Port.Unit u = new BP.Port.Unit();
                u.CheckPhysicsTable();

                //部门
                BP.Port.Dept d = new BP.Port.Dept();
                d.CheckPhysicsTable();

                int i = DBAccess.RunSQLReturnValInt("SELECT COUNT(*) FROM Port_Unit");
                if (i == 0)
                {
                    DBAccess.RunSQL("INSERT INTO Port_Unit (No,Name, ParentNo)VALUES('1','济南驰骋信息技术有限公司','-1')");
                }

                GenerWorkFlow gwf = new GenerWorkFlow();
                gwf.CheckPhysicsTable();

                Flow fl = new Flow();
                fl.CheckPhysicsTable();

                Node nd = new Node();
                nd.CheckPhysicsTable();

                SMS sms = new SMS();
                sms.CheckPhysicsTable();

                #region 执行admin登陆. 2012-12-25 新版本.
                Emp emp = new Emp();
                emp.No = "admin";
                if (emp.RetrieveFromDBSources() == 1)
                {
                    BP.Web.WebUser.SignInOfGener(emp, true);
                }
                else
                {
                    emp.No      = "admin";
                    emp.Name    = "admin";
                    emp.FK_Dept = "01";
                    emp.Pass    = "******";
                    emp.Insert();
                    BP.Web.WebUser.SignInOfGener(emp, true);
                    //throw new Exception("admin 用户丢失,请注意大小写。");
                }
                #endregion 执行admin登陆.
            }
            catch (Exception ex)
            {
                this.Response.Write("问题出处:" + ex.Message + "<hr>" + msg + "<br>详细信息:@" + ex.StackTrace + "<br>@<a href='../DBInstall.aspx' >点这里到系统升级界面。</a>");
                return;
            }
        }
Esempio n. 15
0
        /// <summary>
        /// 增量同步组织结构
        /// </summary>
        /// <returns></returns>
        public string AnsyIncrementOrgToGPM()
        {
            string access_token = getAccessToken();
            string url          = "https://oapi.dingtalk.com/department/list?access_token=" + access_token;

            try
            {
                StringBuilder   append         = new StringBuilder();
                string          str            = new HttpWebResponseUtility().HttpResponseGet(url);
                DepartMent_List departMentList = FormatToJson.ParseFromJson <DepartMent_List>(str);
                if (departMentList == null || departMentList.department == null || departMentList.department.Count == 0)
                {
                    return("钉钉获取部门出错。");
                }

                #region 获取钉钉组织结构,进行更新与新增
                //增加跟部门
                int  deptIdx     = 0;
                bool doSomeThing = false;
                //部门信息
                foreach (DepartMentDetailInfo deptMentInfo in departMentList.department)
                {
                    deptIdx++;
                    doSomeThing = false;
                    //增加部门,排除根目录
                    if (deptMentInfo.id != "1")
                    {
                        Dept dept = new Dept();
                        if (dept.IsExit(DeptAttr.No, deptMentInfo.id) == true)
                        {
                            if (dept.No == deptMentInfo.id && !dept.Name.Equals(deptMentInfo.name))
                            {
                                doSomeThing = true;
                                append.Append("\r\n部门名称发生变化:" + dept.Name + " --> " + deptMentInfo.name);
                            }
                            if (!dept.ParentNo.Equals(deptMentInfo.parentid))
                            {
                                doSomeThing = true;
                                append.Append("\r\n部门父级发生变化:" + dept.ParentNo + " --> " + deptMentInfo.parentid);
                            }
                            //有变化,更新
                            if (doSomeThing == true)
                            {
                                dept.No       = deptMentInfo.id;
                                dept.Name     = deptMentInfo.name;
                                dept.ParentNo = deptMentInfo.parentid;
                                dept.DirectUpdate();
                            }
                        }
                        else
                        {
                            //不存在则新增
                            dept.No       = deptMentInfo.id;
                            dept.Name     = deptMentInfo.name;
                            dept.ParentNo = deptMentInfo.parentid;
                            dept.DirectInsert();
                            append.Append("\r\n新增部门:" + deptMentInfo.id + " - " + deptMentInfo.name);
                        }
                    }
                    //部门人员
                    DepartMentUser_List userList = GenerDeptUser_List(access_token, deptMentInfo.id);
                    if (userList != null)
                    {
                        foreach (DepartMentUserInfo userInfo in userList.userlist)
                        {
                            Emp emp = new Emp();
                            emp.No = userInfo.userid;

                            DeptEmp deptEmp = new DeptEmp();
                            //如果账户存在则人员信息不添加,添加关联表
                            if (emp.RetrieveFromDBSources() > 0)
                            {
                                if (!emp.Name.Equals(userInfo.name))
                                {
                                    emp.Name = userInfo.name;
                                    emp.DirectUpdate();
                                    append.Append("\r\n人员名称发生变化:" + emp.Name + " --> " + userInfo.name);
                                }

                                deptEmp.MyPK = deptMentInfo.id + "_" + emp.No;
                                if (deptEmp.RetrieveFromDBSources() > 0)
                                {
                                    continue;
                                }

                                //增加人员归属部门
                                deptEmp.FK_Dept = deptMentInfo.id;
                                deptEmp.FK_Emp  = emp.No;
                                deptEmp.DirectInsert();
                                append.Append("\r\n增加人员归属部门:" + emp.Name + " - " + deptMentInfo.name);
                                continue;
                            }

                            //增加人员
                            emp.No      = userInfo.userid;
                            emp.Name    = userInfo.name;
                            emp.FK_Dept = deptMentInfo.id;
                            emp.Tel     = userInfo.mobile;
                            emp.Email   = userInfo.email;
                            //emp.Idx = DataType.IsNullOrEmpty(userInfo.order) == true ? 0 : Int32.Parse(userInfo.order);
                            emp.DirectInsert();
                            append.Append("\r\n增加人员:" + emp.Name + "  所属部门:" + deptMentInfo.name);

                            //增加人员与部门对应表
                            deptEmp.MyPK    = deptMentInfo.id + "_" + emp.No;
                            deptEmp.FK_Dept = deptMentInfo.id;
                            deptEmp.FK_Emp  = emp.No;
                            deptEmp.DirectInsert();
                        }
                    }
                }
                #endregion

                #region GPM组织结构,在钉钉不存在进行删除部门与人员关系表,人员表不进行删除,删除业务人员表WF_Emp
                Depts gpm_Depts = new Depts();
                gpm_Depts.RetrieveAllFromDBSource();
                foreach (Dept gpm_Dept in gpm_Depts)
                {
                    bool isHave = false;
                    foreach (DepartMentDetailInfo ding_Dept in departMentList.department)
                    {
                        if (gpm_Dept.No.Equals(ding_Dept.id))
                        {
                            isHave = true;
                            break;
                        }
                    }

                    //部门在钉钉不存在则进行删除:部门表、部门人员、部门人员岗位、部门职位、部门岗位
                    if (isHave == false)
                    {
                        //部门岗位
                        DeptStation deptStation  = new DeptStation();
                        int         iDeptStation = deptStation.Delete(DeptStationAttr.FK_Dept, gpm_Dept.No);

                        //部门人员岗位
                        DeptEmpStation deptEmpStation  = new DeptEmpStation();
                        int            iDeptEmpStation = deptEmpStation.Delete(DeptEmpStationAttr.FK_Dept, gpm_Dept.No);
                        //部门人员
                        DeptEmp deptEmp  = new DeptEmp();
                        int     iDeptEmp = deptEmp.Delete(DeptEmpAttr.FK_Dept, gpm_Dept.No);
                        //部门表
                        Dept dt = new Dept(gpm_Dept.No);
                        dt.Delete();
                        append.Append("\r\n删除部门:" + gpm_Dept.Name + " 部门全路径:" + gpm_Dept.NameOfPath);
                        append.Append("\r\n        部门岗位 " + iDeptStation + " 条记录");
                        append.Append("\r\n        部门人员岗位 " + iDeptEmpStation + " 条记录");
                        append.Append("\r\n        部门人员 " + iDeptEmp + " 条记录");
                    }
                    else
                    {
                        //组织结构人员
                        DeptEmps    deptEmps = new DeptEmps();
                        QueryObject obj      = new QueryObject(deptEmps);
                        obj.AddWhere(DeptEmpAttr.FK_Dept, gpm_Dept.No);
                        obj.addAnd();
                        obj.AddWhereNotIn(DeptEmpAttr.FK_Emp, "'admin'");
                        obj.DoQuery();

                        //部门下没有人员不需要处理
                        if (deptEmps == null || deptEmps.Count == 0)
                        {
                            continue;
                        }

                        //钉钉部门人员
                        DepartMentUser_List userList = GenerDeptUser_List(access_token, gpm_Dept.No);
                        //部门下没有人员,清除部门下的所有人员
                        if (userList == null || userList.userlist.Count == 0)
                        {
                            append.Append("\r\n删除部门下的人员,部门:" + gpm_Dept.Name + " 部门全路径:" + gpm_Dept.NameOfPath);
                            foreach (DeptEmp dt in deptEmps)
                            {
                                dt.Delete();
                                Emp ep = new Emp();
                                ep.No = dt.FK_Emp;
                                ep.RetrieveFromDBSources();
                                append.Append("\r\n        人员编号:" + dt.FK_Emp + " 姓名:" + ep.Name);
                            }
                            continue;
                        }

                        //判断部门下的人员是否存在
                        foreach (DeptEmp deptEmp in deptEmps)
                        {
                            isHave = false;
                            foreach (DepartMentUserInfo userInfo in userList.userlist)
                            {
                                if (deptEmp.FK_Emp.Equals(userInfo.userid))
                                {
                                    isHave = true;
                                    break;
                                }
                            }

                            //不存在,删除
                            if (isHave == false)
                            {
                                deptEmp.Delete();
                                Emp ep = new Emp();
                                ep.No = deptEmp.FK_Emp;
                                ep.RetrieveFromDBSources();
                                append.Append("\r\n删除部门下的人员,部门:" + gpm_Dept.Name + " 部门全路径:" + gpm_Dept.NameOfPath);
                                append.Append("\r\n        人员编号:" + deptEmp.FK_Emp + " 姓名:" + ep.Name);
                            }
                        }
                    }
                }
                //删除没包含在部门的人员

                #endregion

                #region 处理部门名称全程
                //OrgInit_NameOfPath nameOfPath = new OrgInit_NameOfPath();
                //if (nameOfPath.IsCanDo)
                //    nameOfPath.Do();
                #endregion
                return(append.ToString());
            }
            catch (Exception ex)
            {
                BP.DA.Log.DefaultLogWriteLineError(ex.Message);
            }
            return(null);
        }