Ejemplo n.º 1
0
        /// <summary>
        /// 获取人员领导层数
        /// </summary>
        /// <param name="workno"></param>
        /// <param name="CompanyId">公司Id</param>
        /// <returns></returns>
        public static int GetParentRoleLength(string workno, ref string nextUserId, ref string nextUserName, string CompanyId, string type)
        {
            int length = 0;

            string    sql = "";
            DataTable dt  = new DataTable();

            if (!string.IsNullOrEmpty(CompanyId))
            {
                sql = @"select psncode1,psncode2,psncode3,psncode4,psncode5,psncode6 from V_GWRelation where pk_JobCode in
                        (select top 1 pk_gw from fld_ryxx where psncode='{0}' and pk_corp='" + CompanyId + "')";

                sql = string.Format(sql, workno);
                dt  = GetData(sql, MiddleCon);
            }
            if (dt == null || dt.Rows.Count == 0)
            {
                sql = @"select psncode1,psncode2,psncode3,psncode4,psncode5,psncode6 from V_GWRelation where pk_JobCode in
                        (select top 1 pk_gw from fld_ryxx where psncode='{0}' and pk_gw is not null and isnull(outdutydate,'')='' order by indutydate desc)";

                sql = string.Format(sql, workno);
                dt  = GetData(sql, MiddleCon);
            }

            bool    hasuser = false;
            SysUser userent = null;

            if (dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];
                for (var i = 1; i < 7; i++)
                {
                    if (row["psncode" + i] != System.DBNull.Value && row["psncode" + i].ToString().Trim() != "")
                    {
                        if (length == 0 || userent == null)
                        {
                            userent = SysUser.FindAllByProperty(SysUser.Prop_WorkNo, row["psncode" + i] + "").FirstOrDefault();
                            if (userent != null)
                            {
                                nextUserId   = userent.UserID;
                                nextUserName = userent.Name;
                                hasuser      = true;
                            }
                        }
                        length++;
                    }
                }
            }
            if (!hasuser)
            {
                nextUserId   = "";
                nextUserName = "";
            }
            return(length);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="uname"></param>
        /// <param name="pwd"></param>
        private void LoginUser(string uname, string pwd, bool pwdEncrypted)
        {
            try
            {
                SysUser userent = SysUser.FindAllByProperty(SysUser.Prop_LoginName, uname).FirstOrDefault();
                if (userent == null)
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "adsf", "window.parent.location.href='/Login.aspx'", true);
                    return;
                }

                string   CorpId = userent.Pk_corp;
                SysGroup group  = SysGroup.TryFind(CorpId);
                Session["CompanyId"] = CorpId;
                if (group != null)
                {
                    Session["CompanyName"] = group.Name;
                }
                else
                {
                    Session["CompanyName"] = "";
                }

                string sid = PortalService.AuthUser(uname, pwd, false);
                if (!String.IsNullOrEmpty(sid))
                {
                    string url = FormsAuthentication.GetRedirectUrl(uname, true);
                    Response.Redirect(url);
                    return;
                }
                else
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "adsf", "window.parent.location.href='/Login.aspx'", true);
                    return;
                }
            }
            catch { }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Aim.Portal.Web.WebPortalService.CheckLogon();
            }
            catch
            {
                Response.Write("<script> window.parent.location.href = '/Login.aspx';</script>");
                Response.End();
            }
            string          action = Request["action"];
            SysGroup        sgEnt  = null;
            SysUser         suEnt  = null;
            IList <SysUser> suEnts = null;
            string          sql    = "";
            DataTable       dt     = null;

            string where = "";
            MD5Encrypt encrypt = new MD5Encrypt();

            switch (action)
            {
            case "sync":
                string           connstr = ConfigurationManager.ConnectionStrings["NimsConn"].ToString();
                OracleConnection conn    = new OracleConnection(connstr);
                sql = "select * from apps.cux_hr_org_structrue_v where ORG_ID_CHILD='228' or org_id_parent='228'";
                OracleCommand     com = new OracleCommand(sql, conn);
                OracleDataAdapter da  = new OracleDataAdapter(com);
                DataSet           ds  = new DataSet();
                da.Fill(ds);
                //首先同步部门信息
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    sgEnt = SysGroup.TryFind(dr["ORG_ID_CHILD"] + "");
                    if (sgEnt == null)    //如果不存在该部门
                    {
                        //此处将PATH字段用来存储父部门的名称
                        sql = "insert into SysGroup (GroupID,Name,Code,ParentID,Path,Status) values('{0}','{1}','{2}','{3}','{4}',1)";
                        sql = string.Format(sql, dr["ORG_ID_CHILD"], dr["ORG_NAME_CHILD"], dr["ORG_CODE_CHILD"], dr["ORG_ID_PARENT"], dr["ORG_NAME_PARENT"]);
                        DataHelper.ExecSql(sql);
                    }
                    else
                    {
                        sql = "update SysGroup set Name='{0}',Code='{1}',ParentID='{2}',Path='{3}' where GroupID='{4}'";
                        sql = string.Format(sql, dr["ORG_NAME_CHILD"], dr["ORG_CODE_CHILD"], dr["ORG_ID_PARENT"], dr["ORG_NAME_PARENT"], dr["ORG_ID_CHILD"]);
                        DataHelper.ExecSql(sql);
                    }
                }
                //同步人员信息
                sql = @"select * from apps.cux_hr_employee_v where ORG_ID in 
                    (select ORG_ID_CHILD from apps.cux_hr_org_structrue_v where ORG_ID_CHILD='228' or org_id_parent='228') and primary_flag='Y'";
                com = new OracleCommand(sql, conn);
                da  = new OracleDataAdapter(com);
                ds  = new DataSet();
                da.Fill(ds);
                SqlConnection conn_sql = new SqlConnection();
                conn_sql.ConnectionString = ConfigurationManager.AppSettings["Con_Portal"];
                conn_sql.Open();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    suEnts = SysUser.FindAllByProperty(SysUser.Prop_IDNumber, dr["NATIONAL_IDENTIFIER"]);    //通过身份证就行匹配
                    if (suEnts.Count == 0)
                    {
                        sql = @"insert into SysUser (UserID,LoginName,Name,Password,Email,Phone,HomePhone,Sex,IDNumber,Server_IAGUID,Server_Seed,Status,CreateDate)
                            values(@UserID,@LoginName,@Name,@Password,@Email,@Phone,@HomePhone,@Sex,@IDNumber,@Server_IAGUID,@Server_Seed,@Status,@CreateDate)";
                        SqlParameter[] sparray = new SqlParameter[13];
                        sparray[0]        = new SqlParameter("@UserID", dr["PERSON_ID"]);
                        sparray[1]        = new SqlParameter("@LoginName", dr["EMP_NUM"]);//NIMS数据库工号是不能为空的 即进入的NIMS系统的员工工号是肯定有的
                        sparray[2]        = new SqlParameter("@Name", dr["LAST_NAME"]);
                        sparray[3]        = new SqlParameter("@Password", encrypt.GetMD5FromString(dr["SYS_ACCOUNT"].ToString()));
                        sparray[4]        = new SqlParameter("@Email", dr["EMAIL_ADDRESS"]);
                        sparray[5]        = new SqlParameter("@Phone", dr["MOBILE_PHONE_NUMBER"]);
                        sparray[6]        = new SqlParameter("@HomePhone", dr["OFFICE_PHONE_NUMBER"]);
                        sparray[7]        = new SqlParameter("@Sex", dr["SEX"]);
                        sparray[8]        = new SqlParameter("@IDNumber", dr["NATIONAL_IDENTIFIER"]);
                        sparray[9]        = new SqlParameter("@Server_IAGUID", dr["ORG_ID"]);
                        sparray[10]       = new SqlParameter("@Server_Seed", dr["ORG_NAME"]);
                        sparray[11]       = new SqlParameter("@Status", SqlDbType.TinyInt);
                        sparray[11].Value = 1;
                        sparray[12]       = new SqlParameter("@CreateDate", dr["HIRE_DATE"]);
                        SqlCommand com_sql = new SqlCommand(sql, conn_sql);
                        com_sql.Parameters.AddRange(sparray);
                        com_sql.ExecuteNonQuery();
                    }
                    else
                    {
                        sql = @"update SysUser set LoginName=@LoginName,Name=@Name,Email=@Email,Phone=@Phone,HomePhone=@HomePhone,
                            Sex=@Sex,Server_IAGUID=@Server_IAGUID,Server_Seed=@Server_Seed,CreateDate=@CreateDate where IDNumber=@IDNumber";
                        SqlParameter[] sparray = new SqlParameter[10];
                        sparray[0] = new SqlParameter("@LoginName", dr["EMP_NUM"]);
                        sparray[1] = new SqlParameter("@Name", dr["LAST_NAME"]);
                        sparray[2] = new SqlParameter("@Email", dr["EMAIL_ADDRESS"]);
                        sparray[3] = new SqlParameter("@Phone", dr["MOBILE_PHONE_NUMBER"]);
                        sparray[4] = new SqlParameter("@HomePhone", dr["OFFICE_PHONE_NUMBER"]);
                        sparray[5] = new SqlParameter("@Sex", dr["SEX"]);
                        sparray[6] = new SqlParameter("@Server_IAGUID", dr["ORG_ID"]);
                        sparray[7] = new SqlParameter("@Server_Seed", dr["ORG_NAME"]);
                        sparray[8] = new SqlParameter("@CreateDate", dr["HIRE_DATE"]);
                        sparray[9] = new SqlParameter("@IDNumber", dr["NATIONAL_IDENTIFIER"]);
                        SqlCommand com_sql = new SqlCommand(sql, conn_sql);
                        com_sql.Parameters.AddRange(sparray);
                        com_sql.ExecuteNonQuery();
                    }
                }
                conn_sql.Close();
                Response.Write("{success:true}");
                Response.End();
                break;

            case "inipsd":
                suEnt          = SysUser.Find(Request["UserId"]);
                suEnt.Password = encrypt.GetMD5FromString(suEnt.LoginName);
                suEnt.DoUpdate();
                Response.Write("{success:true}");
                Response.End();
                break;

            case "loadtreedata":
                string id = Request["id"];
                sql = "select GroupID as id,replace(Name,'江西瑞林建设监理有限公司','') as name,1 as leaf from SysGroup where ParentId='" + id + "' order by Code asc";
                dt  = DataHelper.QueryDataTable(sql);
                Response.Write(JsonHelper.GetJsonStringFromDataTable(dt));
                Response.End();
                break;

            case "loaduser":
                string groupid = Request["groupid"];
                if (!string.IsNullOrEmpty(Request["name_workno"]))
                {
                    where += " and (LoginName like '%" + Request["name_workno"] + "%' or Name like '%" + Request["name_workno"] + "%')";
                }
                if (!string.IsNullOrEmpty(Request["UserType"]))
                {
                    where += "  and UserType='" + Request["UserType"] + "'";
                }
                if (!string.IsNullOrEmpty(Request["Status"]))
                {
                    where += "  and Status='" + Request["Status"] + "'";
                }
                if (string.IsNullOrEmpty(groupid) || groupid == "228")
                {
                    sql = @"select UserID as UserId,Name,LoginName,Sex,Phone,Replace(Server_Seed,'江西瑞林建设监理有限公司','') as  Server_Seed,
                        HomePhone,IDNumber,CreateDate from SysUser where 
                        (Server_Seed like '%江西瑞林建设监理有限公司%' ) " + where;
                }
                else
                {
                    sql = @"select UserID as UserId,Name,LoginName,Sex,Phone,Replace(Server_Seed,'江西瑞林建设监理有限公司','') as  Server_Seed,
                        HomePhone,IDNumber,CreateDate from SysUser
                        where Server_Seed like '%江西瑞林建设监理有限公司%' and Server_IAGUID='" + groupid + "'" + where;
                }
                dt = DataHelper.QueryDataTable(sql);
                Response.Write("{'rows':" + JsonHelper.GetJsonStringFromDataTable(dt) + ",total:'" + totalProperty + "'}");
                Response.End();
                break;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="uname"></param>
        /// <param name="pwd"></param>
        private void LoginUser(string uname, string pwd, bool pwdEncrypted, string loginstate)
        {
            try
            {
                string  CorpId  = RequestData.Get <string>("CorpId");
                SysUser userent = SysUser.FindAllByProperty(SysUser.Prop_LoginName, uname).FirstOrDefault();
                if (userent == null)
                {
                    PageState.Add("error", "用户名错误!");
                    return;
                }
                if (string.IsNullOrEmpty(userent.Password))
                {
                    PageState.Add("error", "nullpwd");
                    return;
                }

                //判断登陆人有没有在这个公司
                string sql       = @"select count(1) from SysUserGroup where UserId='{0}' and GroupId not in (select RoleId from sysRole) and isnull(outdutydate,'')='' and pk_gw is not null and pk_corp='{1}'";
                int    corpcount = DataHelper.QueryValue <int>(string.Format(sql, userent.UserID, CorpId));
                if (corpcount > 0 || uname == "admin")
                {
                    string sid = PortalService.AuthUser(uname, pwd, false);
                    if (!String.IsNullOrEmpty(sid))
                    {
                        string url       = FormsAuthentication.GetRedirectUrl(uname, true);
                        string returnUrl = RequestData.Get <string>("ReturnUrl");
                        Session["CompanyId"] = CorpId;
                        if (!string.IsNullOrEmpty(returnUrl))
                        {
                            url = returnUrl;
                            Session["CompanyId"] = CorpId;
                            //公司
                            SysGroup group = SysGroup.TryFind(CorpId);
                            if (group != null)
                            {
                                Session["CompanyName"] = group.Name;
                            }
                            else
                            {
                                Session["CompanyName"] = "";
                            }
                        }
                        PageState.Add("url", url);
                    }
                    else
                    {
                        PageState.Add("error", "登陆失败,用户名或密码不正确!");
                    }
                    return;
                }
                else
                {
                    //查询该人员有没有
                    DataTable dtrole = DataHelper.QueryDataTable("select CompanyIds from sysrole where roleid in ( select RoleID from SysUserRole where UserId='" + userent.UserID + "')");
                    bool      hasQX  = false;
                    foreach (DataRow row in dtrole.Rows)
                    {
                        if ((row["CompanyIds"] + "").Contains(CorpId))
                        {
                            hasQX = true;
                            break;
                        }
                    }
                    if (hasQX)
                    {
                        string sid = PortalService.AuthUser(uname, pwd, false);
                        if (!String.IsNullOrEmpty(sid))
                        {
                            string url = FormsAuthentication.GetRedirectUrl(uname, true);
                            PageState.Add("url", url);

                            Session["CompanyId"] = CorpId;
                        }
                        else
                        {
                            PageState.Add("error", "登陆失败,用户名或密码不正确!");
                        }
                    }
                    else
                    {
                        PageState.Add("error", "您没有该公司的权限,请重新选择公司!");
                    }
                    return;
                }
            }
            catch (Exception ex)
            {
                PageState.Add("error", ex.Message);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取人员领导层数
        /// </summary>
        /// <param name="workno"></param>
        /// <param name="deptid"></param>
        /// <returns></returns>
        public static int GetParentRoleLength(string workno, ref string nextUserId, ref string nextUserName, string DeptId)
        {
            int length = 0;

            string    sql = "";
            DataTable dt  = new DataTable();

            if (!string.IsNullOrEmpty(DeptId))
            {
                string MiddleDBName = ConfigurationManager.AppSettings["MiddleDBName"];
                int    gws          = DataHelper.QueryValue <int>("select count(1) from " + MiddleDBName + "..fld_ryxx where psncode='" + workno + "' and pk_corp=(select top 1 pk_corp from " + MiddleDBName + "..fld_bmml where pk_deptdoc='" + DeptId + "')");
                if (gws > 1)
                {
                    string path = DataHelper.QueryValue("select [path]+GroupId from SysGroup where GroupId='" + DeptId + "'") + "";
                    sql = @"select psncode1,psncode2,psncode3,psncode4,psncode5,psncode6 from V_GWRelation where pk_JobCode in
                       (select top 1 pk_gw from fld_ryxx where psncode='{0}' and '" + path + "' like '%'+ pk_deptdoc+'%')";
                }
                else
                {
                    sql = @"select psncode1,psncode2,psncode3,psncode4,psncode5,psncode6 from V_GWRelation where pk_JobCode in
                       (select top 1 pk_gw from fld_ryxx where psncode='{0}' and pk_corp=(select top 1 pk_corp from fld_bmml where pk_deptdoc='" + DeptId + "'))";
                }
                sql = string.Format(sql, workno);
                dt  = GetData(sql, MiddleCon);
            }
            if (dt == null || dt.Rows.Count == 0)
            {
                sql = @"select psncode1,psncode2,psncode3,psncode4,psncode5,psncode6 from V_GWRelation where pk_JobCode in
                        (select top 1 pk_gw from fld_ryxx where psncode='{0}' and pk_gw is not null and isnull(outdutydate,'')='' order by indutydate desc)";

                sql = string.Format(sql, workno);
                dt  = GetData(sql, MiddleCon);
            }
            bool    hasuser = false;
            SysUser userent = null;

            if (dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];
                for (var i = 1; i < 7; i++)
                {
                    if (row["psncode" + i] != System.DBNull.Value && row["psncode" + i].ToString().Trim() != "")
                    {
                        if (length == 0 || userent == null)
                        {
                            userent = SysUser.FindAllByProperty(SysUser.Prop_WorkNo, row["psncode" + i] + "").FirstOrDefault();
                            if (userent != null)
                            {
                                nextUserId   = userent.UserID;
                                nextUserName = userent.Name;
                                hasuser      = true;
                            }
                        }
                        length++;
                    }
                }
            }
            if (!hasuser)
            {
                nextUserId   = "";
                nextUserName = "";
            }
            return(length);
        }