Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            id   = RequestData.Get <string>("id", String.Empty);
            type = RequestData.Get <string>("type", String.Empty).ToLower();

            switch (RequestAction)
            {
            case RequestActionEnum.Custom:
                if (RequestActionString == "addgrpuser" || RequestActionString == "delgrpuser")
                {
                    IList <string> userIDs = RequestData.GetList <string>("UserIDs");

                    if (!String.IsNullOrEmpty(id))
                    {
                        using (new SessionScope())
                        {
                            SysGroup grp = SysGroup.Find(id);

                            if (RequestActionString == "addgrpuser")
                            {
                                grp.AddUsers(userIDs);
                                //更新到岗级
                                //if (grp.Type == 3)
                                //{
                                //    PRJ_PostDuty pd = PRJ_PostDuty.FindFirstByProperties(new string[]{"Post",grp.Name});
                                //   // pd.EmployeeId=userIDs
                                //    SysUser[] usrsToAdd = SysUser.FindAllByPrimaryKeys(userIDs.ToArray());
                                //    string names = "";
                                //    string ids = "";
                                //    foreach (SysUser sy in usrsToAdd)
                                //    {
                                //        ids += sy.UserID+",";
                                //        names += sy.Name+",";
                                //    }
                                //    pd.EmployeeId = pd.EmployeeId+","+ids.Substring(0, ids.Length - 1);
                                //    pd.EmployeeName = pd.EmployeeName+","+names.Substring(0, names.Length - 1);
                                //    pd.Update();
                                //}
                            }
                            else if (RequestActionString == "delgrpuser")
                            {
                                grp.RemoveUsers(userIDs);
                            }
                        }
                    }
                }
                break;
            }

            if (type == "group" && !String.IsNullOrEmpty(id))
            {
                using (new Castle.ActiveRecord.SessionScope())
                {
                    ICriterion cirt = Expression.Sql("UserID IN (SELECT UserID FROM SysUserGroup WHERE GroupID in (select GroupID from SysGroup where Path like '%?%' ))", id, NHibernateUtil.String);

                    //string SQL = @"SELECT UserID FROM SysUserGroup WHERE GroupID in (select GroupID from SysGroup where Path like '%{0}%'";
                    //SQL = string.Format(SQL, id);
                    //users =  .FindAll(SearchCriterion, cirt);

                    this.PageState.Add("UsrList", SysUser.FindAll(SearchCriterion, Expression.Sql("UserID IN (SELECT UserID FROM SysUserGroup WHERE GroupID in (select GroupID from SysGroup where Path like '%" + id + "%' or GroupID like '%" + id + "%'  ))")));
                }
            }
            else
            {
                users = SysUserRule.FindAll(SearchCriterion);
                this.PageState.Add("UsrList", users);
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Request.Files.Count > 0)
            {
                string guid     = Guid.NewGuid().ToString();
                string filePath = "//WorkTime//InputExcelFiles//" + Guid.NewGuid().ToString() + System.IO.Path.GetExtension(Request.Files[0].FileName);
                this.Request.Files[0].SaveAs(Server.MapPath(filePath));
                ExcelProcessor ep = ExcelService.GetProcessor(Server.MapPath(filePath));
                DataSet        ds = ep.GetDataSet();
                InputDatas(ds.Tables[0]);
                Response.Write("{success:true}");
                Response.End();
            }

            id   = RequestData.Get <string>("id", String.Empty);
            type = RequestData.Get <string>("type", String.Empty);

            SysUser usr = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Create:
                usr = this.GetPostedData <SysUser>();
                usr.DoCreate();
                this.SetMessage("新建成功!");
                break;

            case RequestActionEnum.Update:
                usr = this.GetMergedData <SysUser>();
                usr.DoUpdate();
                this.SetMessage("保存成功!");
                break;

            case RequestActionEnum.Delete:
                usr = this.GetTargetData <SysUser>();
                usr.DoDelete();
                this.SetMessage("删除成功!");
                break;

            default:
                if (RequestActionString == "clearpass")
                {
                    usr          = SysUser.Find(this.RequestData.Get <string>("UserId"));
                    usr.Password = "";
                    usr.Remark   = "";
                    usr.Save();
                }
                else if (RequestActionString == "setpass")
                {
                    MD5Encrypt encrypt = new MD5Encrypt();
                    SysUser[]  users   = SysUser.FindAll();
                    foreach (SysUser user in users)
                    {
                        Random rnd           = new Random();
                        int    rndNum        = rnd.Next(10000000, 99999999);
                        string encryPassword = encrypt.GetMD5FromString(rndNum.ToString());
                        user.Password = encryPassword;
                        user.Remark   = rndNum.ToString();
                        user.Save();
                    }
                }
                else if (RequestActionString == "checkkey")
                {
                    if (SysUser.FindAllByProperties("Server_IAGUID", this.RequestData.Get <string>("usbguid")).Length > 0)
                    {
                        this.PageState.Add("UserName", SysUser.FindAllByProperties("Server_IAGUID", this.RequestData.Get <string>("usbguid"))[0].Name);
                    }
                    else
                    {
                        this.PageState.Add("UserName", "");
                    }
                }
                else if (RequestActionString == "setkey")
                {
                    SysUser user = SysUser.Find(this.RequestData.Get <string>("userid"));
                    user.Server_IAGUID = this.RequestData.Get <string>("usbguid");
                    user.Server_Seed   = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
                    user.ThreeDESKEY   = "ABCDEFGhijklmn0123456789";
                    user.Save();
                }
                else if (RequestActionString == "sendmail")
                {
                    IList <object> idList = RequestData.GetList <object>("IdList");
                    SysUser[]      tents  = SysUser.FindAll(Expression.In("UserID", idList.ToArray()));

                    foreach (SysUser user in tents)
                    {
                        string body = SysParameter.FindAllByProperties("Code", "MailText")[0].Description + "<br>";
                        body += "您的登录用户名:" + user.LoginName + ";密码:" + user.Remark;
                        string mailAccount       = SysParameter.FindAllByProperties("Code", "MailAccount")[0].Value;
                        string mailPass          = SysParameter.FindAllByProperties("Code", "MailPassword")[0].Value;
                        string mailServer        = SysParameter.FindAllByProperties("Code", "MailSmtpServer")[0].Value;
                        string mailSenderAddress = SysParameter.FindAllByProperties("Code", "MailSenderAddress")[0].Value;
                        MailHelper.SendMail(mailSenderAddress, user.Email, "工时分配系统邮件", body, mailAccount, mailPass, mailServer);
                    }
                }
                else
                {
                    SearchCriterion.AutoOrder = false;
                    SearchCriterion.SetOrder(SysUser.Prop_WorkNo);
                    string dName  = SearchCriterion.GetSearchValue <string>("Name");
                    string workNo = SearchCriterion.GetSearchValue <string>("WorkNo");
                    SearchCriterion.SetOrder(SysUser.Prop_WorkNo);
                    if (dName != null && dName.Trim() != "")
                    {
                        string where = "select * from SysUser where " + GetPinyinWhereString("Name", dName);
                        where       += " and WorkNo like '%" + workNo + "%'";
                        this.PageState.Add("UsrList", DataHelper.QueryDictList(where));
                    }
                    else
                    {
                        users = SysUserRule.FindAll(SearchCriterion);
                        this.PageState.Add("UsrList", users);
                    }
                }
                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取上级主管
        /// </summary>
        /// <param name="UserId">UserId</param>
        /// <param name="cengshu">层数</param>
        /// <returns>SysUser</returns>
        public static SysUser GetParentUsers(string UserId, int cengshu, string DeptId)
        {
            //先更具人和部门获取
            string    sql = "";
            DataTable dt  = new DataTable();

            if (!string.IsNullOrEmpty(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 pk_deptdoc='" + DeptId + "')";

                SysUser userent = SysUser.Find(UserId);
                sql = string.Format(sql, userent.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)";

                SysUser userent = SysUser.Find(UserId);
                sql = string.Format(sql, userent.WorkNo);
                dt  = GetData(sql, MiddleCon);
            }
            List <EasyDictionary> ess = new List <EasyDictionary>();
            int     count             = 0;
            SysUser user = 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() != "")
                    {
                        count++;
                        if (count == cengshu)
                        {
                            string workNo = row["psncode" + i] + "";
                            user = SysUser.FindAll(Expression.Sql(" WorkNo='" + workNo + "' and isnull(outdutydate,'')='' ")).FirstOrDefault();
                            if (user == null)
                            {
                                cengshu++;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }

                //if (li != 0)
                //{
                //    string workNo = row["psncode" + li].ToString();
                //    user = SysUser.FindAllByProperties(SysUser.Prop_WorkNo, workNo)[0];
                //    return user;
                //}
            }
            return(user);
        }