Exemple #1
0
        public JsonResult GetList(GridPager pager, string queryStr)
        {
            Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;
            List <SysPositionModel>       list           = serviceSession.SysPosition.GetList(ref pager, queryStr);
            var json = new
            {
                total = pager.totalRows,
                rows  = (from r in list
                         select new SysPositionModel()
                {
                    Id = r.Id,
                    Name = r.Name,

                    Remark = r.Remark,
                    Sort = r.Sort,
                    CreateTime = r.CreateTime,
                    Enable = r.Enable,
                    MemberCount = r.MemberCount,
                    DepId = r.DepId,
                    DepName = r.DepName
                }).ToArray()
            };

            return(Json(json));
        }
        public JsonResult GetList(string id)
        {
            Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;
            if (id == null)
            {
                id = "0";
            }
            List <SysStructModel> list = serviceSession.SysStruct.GetList(id);
            var json = from r in list
                       select new SysStructModel()
            {
                Id         = r.Id,
                Name       = r.Name,
                ParentId   = r.ParentId,
                Sort       = r.Sort,
                Enable     = r.Enable,
                Higher     = r.Higher,
                Remark     = r.Remark,
                CreateTime = r.CreateTime,
                state      = (serviceSession.SysStruct.GetList(r.Id).Count > 0) ? "closed" : "open"
            };


            return(Json(json));
        }
Exemple #3
0
        public JsonResult GetUserListByDep(GridPager pager, string depId, string queryStr)
        {
            Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;

            if (string.IsNullOrWhiteSpace(depId))
            {
                return(Json(0));
            }
            var userList = serviceSession.SysUser.GetUserByDepId(ref pager, depId, queryStr);

            var jsonData = new
            {
                total = pager.totalRows,
                rows  = (
                    from r in userList
                    select new SysUserModel()
                {
                    Id = r.Id,
                    UserName = r.UserName,
                    TrueName = r.TrueName,
                    DepName = serviceSession.SysStruct.GetById(r.DepId).Name,
                    PosName = serviceSession.SysPosition.GetById(r.PosId).Name,
                    Flag = "<input type='checkbox' id='cb_" + r.Id + "' onclick='SetValue(\"" + r.Id + "\",\"" + r.TrueName + "\")'>",
                }
                    ).ToArray()
            };

            return(Json(jsonData));
        }
Exemple #4
0
 public JsonResult Delete(string id)
 {
     if (!string.IsNullOrWhiteSpace(id))
     {
         Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;
         string userId   = OpeCur.AccountNow.Id;
         string ErrorCol = errors.Error;
         if (id == "2017admin")
         {
             LogHandler.WriteServiceLog(userId, "尝试删除管理员", "失败", "删除", "用户设置");
             return(OpeCur.AjaxMsgNOOK("管理员不能被删除" + ErrorCol));
         }
         serviceSession.SysUser.RemoveById(ref errors, id);
         if (serviceSession.SaveChange() > 0)
         {
             LogHandler.WriteServiceLog(userId, "Id:" + id, "成功", "删除", "用户设置");
             return(OpeCur.AjaxMsgOK(Resource.DeleteSucceed + ErrorCol));
         }
         else
         {
             ErrorCol = errors.Error;
             LogHandler.WriteServiceLog(userId, "Id:" + id + "," + ErrorCol, "失败", "删除", "用户设置");
             return(OpeCur.AjaxMsgNOOK(Resource.DeleteFail + ErrorCol));
         }
     }
     else
     {
         return(OpeCur.AjaxMsgNOOK(Resource.DeleteFail));
     }
 }
Exemple #5
0
        public JsonResult GetRoleListByUser(GridPager pager, string userId)
        {
            Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;
            if (string.IsNullOrWhiteSpace(userId))
            {
                return(Json(0));
            }
            var userList = serviceSession.SysUser.GetRoleByUserId(ref pager, userId);
            var jsonData = new
            {
                total = pager.totalRows,
                rows  = (
                    from r in userList
                    select new SysRoleModel()
                {
                    Id = r.Id,
                    Name = r.Name,
                    Description = r.Description,
                    Flag = r.flag == "0" ? "0" : "1",
                }
                    ).ToArray()
            };

            return(Json(jsonData));
        }
Exemple #6
0
 public JsonResult Edit(SysUserModel info)
 {
     if (info != null && ModelState.IsValid)
     {
         Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;
         serviceSession.SysUser.Edit(ref errors, info);
         string ErrorCol = errors.Error;
         if (serviceSession.SaveChange() > 0)
         {
             OpeCur.SetOtherHMC(info.Id);
             OpeCur.AccountNow.AllMerchant = false;
             LogHandler.WriteServiceLog(OpeCur.AccountNow.Id, "Id:" + info.Id + ",Name:" + info.UserName, "成功", "修改", "用户设置");
             return(OpeCur.AjaxMsgOK("修改成功!" + ErrorCol));
         }
         else
         {
             LogHandler.WriteServiceLog(OpeCur.AccountNow.Id, "Id:" + info.Id + ",Name:" + info.UserName + "," + ErrorCol, "失败", "修改", "用户设置");
             return(OpeCur.AjaxMsgNOOK("修改失败!" + ErrorCol));
         }
     }
     else
     {
         return(OpeCur.AjaxMsgNOOK(Resource.ModelStateValidFail));
     }
 }
Exemple #7
0
        public JsonResult Create(SysUserModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;
                string curUserId = OpeCur.AccountNow.Id;
                model.Id           = ResultHelper.NewId;
                model.CreateTime   = ResultHelper.NowTime;
                model.Password     = ValueConvert.MD5(model.Password);
                model.CreatePerson = OpeCur.AccountNow.TrueName;
                model.State        = true;
                serviceSession.SysUser.Create(ref errors, model);
                if (serviceSession.SaveChange() > 0)
                {
                    LogHandler.WriteServiceLog(curUserId, "Id:" + model.Id + ",Name:" + model.UserName, "成功", "创建", "用户设置");
                    return(OpeCur.AjaxMsgOK("创建成功!"));
                }
                else
                {
                    string ErrorCol = errors.Error;
                    LogHandler.WriteServiceLog(curUserId, "Id:" + model.Id + ",Name:" + model.UserName + "," + ErrorCol,

                                               "失败", "创建", "用户设置");
                    return(OpeCur.AjaxMsgNOOK("创建失败!" + ErrorCol));
                }
            }
            else
            {
                return(OpeCur.AjaxMsgNOOK(Resource.ModelStateValidFail));
            }
        }
Exemple #8
0
        public ActionResult Edit(string id)
        {
            Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;

            ViewBag.Areas = new SelectList(serviceSession.SysAreas.GetList("0"), "Id", "Name");

            SysPositionModel entity = serviceSession.SysPosition.GetById(id);

            return(View(entity));
        }
Exemple #9
0
        public JsonResult Delete(string id)
        {
            if (!string.IsNullOrWhiteSpace(id) && id != "员工")
            {
                Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;
                string userId   = OpeCur.AccountNow.Id;
                string ErrorCol = errors.Error;
                if (id == "2017admin")
                {
                    LogHandler.WriteServiceLog(userId, "尝试删除管理员", "失败", "删除", "用户设置");
                    return(OpeCur.AjaxMsgNOOK("管理员不能被删除" + ErrorCol));
                }
                if (serviceSession.SysPosition.GetById(id).Enable != true)
                {
                    IEnumerable <SysUserModel> sysUserList = serviceSession.SysUser.GetList().Where(t => t.PosId == id);//1、查找用户   2、更新用户
                    foreach (var item in sysUserList)
                    {
                        try
                        {
                            item.PosId   = "员工";
                            item.PosName = "员工";
                            serviceSession.SysUser.EditByPosition(ref errors, item);//更新用户信息
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }
                    serviceSession.SysPosition.RemoveById(ref errors, id);
                    int saveNum = serviceSession.SaveChange();

                    if (saveNum > 0)
                    {
                        LogHandler.WriteServiceLog(userId, "Id:" + id, "成功", "删除", "用户设置");
                        return(OpeCur.AjaxMsgOK(Resource.DeleteSucceed + ErrorCol));
                    }
                    else
                    {
                        ErrorCol = errors.Error;
                        LogHandler.WriteServiceLog(userId, "Id:" + id + "," + ErrorCol, "失败", "删除", "用户设置");
                        return(OpeCur.AjaxMsgNOOK(Resource.DeleteFail + ErrorCol));
                    }
                }
                else
                {
                    ErrorCol = errors.Error;
                    LogHandler.WriteServiceLog(userId, "Id:" + id + "," + ErrorCol, "失败", "删除", "用户设置");
                    return(OpeCur.AjaxMsgNOOK(Resource.DeleteFail + " 职业已启用,请先取消,再删除" + ErrorCol));
                }
            }
            else
            {
                return(OpeCur.AjaxMsgNOOK(Resource.DeleteFail));
            }
        }
Exemple #10
0
        public ActionResult Create()
        {
            Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;
            ViewBag.Struct = new SelectList(serviceSession.SysStruct.GetList("0"), "Id", "Name");
            ViewBag.Areas  = new SelectList(serviceSession.SysAreas.GetList("0"), "Id", "Name");
            SysUserModel model = new SysUserModel()
            {
                Password      = "******",
                JoinDate      = ResultHelper.NowTime,
                MerchantCodes = serviceSession.SysUser.GetMerchantCodes(),
            };

            return(View(model));
        }
Exemple #11
0
        public JsonResult GetPosListByComTree(string depId)
        {
            Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;
            List <SysPositionModel>       list           = serviceSession.SysPosition.GetPosListByDepId(depId).Where(t => t.Enable == true).ToList();
            var json = from r in list
                       select new SysPositionEditModel()
            {
                id    = r.Id,
                text  = r.Name,
                state = "open"
            };


            return(Json(json));
        }
Exemple #12
0
        public JsonResult GetListByComTree(string id)
        {
            Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;
            List <SysStructModel>         list           = serviceSession.SysStruct.GetList(id);
            var json = from r in list
                       select new SysStructEditModel()
            {
                id    = r.Id,
                text  = r.Name,
                state = (serviceSession.SysStruct.GetList(r.Id).Count > 0) ? "closed" : "open"
            };


            return(Json(json));
        }
Exemple #13
0
        public JsonResult GetAreasListByParentId(string id)
        {
            Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;
            if (id == null)
            {
                id = "0";
            }
            List <SysAreasModel> list = serviceSession.SysAreas.GetList(id);
            StringBuilder        sb   = new StringBuilder("");

            foreach (var i in list)
            {
                sb.AppendFormat("<option value='{0}'>{1}</option>", i.Id, i.Name);
            }

            return(Json(sb.ToString()));
        }
Exemple #14
0
        public JsonResult GetList(GridPager pager, string queryStr)
        {
            Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;
            List <SysUserModel>           list           = serviceSession.SysUser.GetUsrList(ref pager, queryStr, u => u.Id == OpeCur.AccountNow.Id);

            if (list.Count <= 0)
            {
                return(OpeCur.AjaxMsgOK(Resource.NoMatchingData));
            }
            var json = new
            {
                total = pager.totalRows,
                rows  = list,
            };

            return(OpeCur.AjaxMsgOK(Resource.GetSuccess, "", json));
        }
Exemple #15
0
        public JsonResult ReSet(string Id, string Pwd)
        {
            Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;

            serviceSession.SysUser.EditPwd(ref errors, Id, Pwd);
            string ErrorCol = errors.Error;

            if (serviceSession.SaveChange() > 0)
            {
                LogHandler.WriteServiceLog(OpeCur.AccountNow.Id, "Id:" + Id + ",密码:********", "成功", "初始化密码", "用户设置");
                return(OpeCur.AjaxMsgOK(Resource.EditSucceed + ErrorCol));
            }
            else
            {
                LogHandler.WriteServiceLog(OpeCur.AccountNow.Id, "Id:" + Id + ",,密码:********" + ErrorCol, "失败", "初始化密码", "用户设置");
                return(OpeCur.AjaxMsgNOOK(Resource.EditFail + ErrorCol));
            }
        }
Exemple #16
0
        public JsonResult AssignRole(string userId, string roleIds)
        {
            Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;

            string[] arr   = roleIds.Split(',');
            string   curId = OpeCur.AccountNow.Id;

            serviceSession.SysUser.UpdateSysRoleSysUser(userId, arr);
            string ErrorCol = errors.Error;

            if (serviceSession.SaveChange() > 0)
            {
                OpeCur.SetOtherUsrPers(userId);
                LogHandler.WriteServiceLog(curId, "Ids:" + roleIds, "成功", "分配角色", "用户设置");
                return(OpeCur.AjaxMsgOK(Resource.SetSucceed + ErrorCol));
            }
            else
            {
                ErrorCol = errors.Error;
                LogHandler.WriteServiceLog(curId, "Ids:" + roleIds, "失败", "分配角色", "用户设置");
                return(OpeCur.AjaxMsgNOOK(Resource.SetFail + ErrorCol));
            }
        }
Exemple #17
0
 public JsonResult Edit(SysPositionModel info)
 {
     if (info != null && ModelState.IsValid)
     {
         Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;
         serviceSession.SysPosition.Modify(ref errors, info, "Name", "Remark", "Sort", "Enable", "MemberCount", "DepId");
         string ErrorCol = errors.Error;
         if (serviceSession.SaveChange() > 0)
         {
             LogHandler.WriteServiceLog(OpeCur.AccountNow.Id, "Id:" + info.Id + ",Name:" + info.Name, "成功", "修改", "用户设置");
             return(OpeCur.AjaxMsgOK("修改成功!" + ErrorCol));
         }
         else
         {
             LogHandler.WriteServiceLog(OpeCur.AccountNow.Id, "Id:" + info.Id + ",Name:" + info.Name + "," + ErrorCol, "失败", "修改", "用户设置");
             return(OpeCur.AjaxMsgNOOK("修改失败!" + ErrorCol));
         }
     }
     else
     {
         return(OpeCur.AjaxMsgNOOK(Resource.ModelStateValidFail));
     }
 }
Exemple #18
0
        public JsonResult ReSet(string Id, string pwd)
        {
            Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;

            if (ValueConvert.MD5(pwd) == OpeCur.AccountNow.Password)
            {
                return(OpeCur.AjaxMsgNOOK(Resource.EditFail + "密码不能和当前密码相同"));
            }
            serviceSession.SysUser.EditPwd(ref errors, Id, pwd);
            string ErrorCol = errors.Error;

            if (serviceSession.SaveChange() > 0)
            {
                LogHandler.WriteServiceLog(OpeCur.AccountNow.Id, "Id:" + Id + ",密码:********", "成功", "初始化密码", "用户设置");
                //Session.Abandon();
                //Session.Clear();
                return(OpeCur.AjaxMsgOK(Resource.EditSucceed + ErrorCol));
            }
            else
            {
                LogHandler.WriteServiceLog(OpeCur.AccountNow.Id, "Id:" + Id + ",,密码:********" + ErrorCol, "失败", "初始化密码", "用户设置");
                return(OpeCur.AjaxMsgNOOK(Resource.EditFail + ErrorCol));
            }
        }
Exemple #19
0
        public JsonResult Delete(string id)
        {
            if (!string.IsNullOrWhiteSpace(id) && id != "root")
            {
                Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession;
                string userId   = OpeCur.AccountNow.Id;
                string ErrorCol = errors.Error;

                var structModel = serviceSession.SysStruct.GetById(id);
                if (id == "2017admin")
                {
                    LogHandler.WriteServiceLog(userId, "尝试删除管理员", "失败", "删除", "用户设置");
                    return(OpeCur.AjaxMsgNOOK("管理员不能被删除" + ErrorCol));
                }
                if (structModel.Enable != true)
                {
                    IEnumerable <SysUserModel>     sysUserList     = serviceSession.SysUser.GetList(t => t.DepId == id);      //1、查找用户   2、更新用户信息
                    IEnumerable <SysPositionModel> sysPositionList = serviceSession.SysPosition.GetList(t => t.DepId == id);  //1、查找职位 2、更新职位信息
                    IEnumerable <SysStructModel>   sysStructList   = serviceSession.SysStruct.GetList(t => t.ParentId == id); //获取子部门信息
                    //更新关联--用户信息
                    foreach (var item in sysUserList)
                    {
                        try
                        {
                            item.DepId   = structModel.ParentId;
                            item.DepName = serviceSession.SysStruct.GetById(structModel.ParentId).Name;
                            serviceSession.SysUser.UpdateByStruct(ref errors, item);//更新用户信息
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }
                    //更新关联--职位信息
                    foreach (var item in sysPositionList)
                    {
                        try
                        {
                            item.DepId   = structModel.ParentId;
                            item.DepName = serviceSession.SysStruct.GetById(structModel.ParentId).Name;
                            serviceSession.SysPosition.UpdateByStruct(ref errors, item);//更新职业信息
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }
                    //更新struct
                    foreach (var item in sysStructList)
                    {
                        try
                        {
                            item.ParentId = serviceSession.SysStruct.GetById(id).ParentId;
                            serviceSession.SysStruct.Modify(ref errors, item, "ParentId");//更新部门所属信息
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }
                    serviceSession.SysStruct.RemoveById(ref errors, id);
                    int saveNum = serviceSession.SaveChange();
                    if (saveNum > 0)
                    {
                        LogHandler.WriteServiceLog(userId, "Id:" + id, "成功", "删除", "用户设置");
                        return(OpeCur.AjaxMsgOK(Resource.DeleteSucceed + ErrorCol));
                    }
                    else
                    {
                        ErrorCol = errors.Error;
                        LogHandler.WriteServiceLog(userId, "Id:" + id + "," + ErrorCol, "失败", "删除", "用户设置");
                        return(OpeCur.AjaxMsgNOOK(Resource.DeleteFail + ErrorCol));
                    }
                }
                else
                {
                    ErrorCol = errors.Error;
                    LogHandler.WriteServiceLog(userId, "Id:" + id + "," + ErrorCol, "失败", "删除", "用户设置");
                    return(OpeCur.AjaxMsgNOOK(Resource.DeleteFail + " 部门已启用,请禁用,再删除 " + ErrorCol));
                }
            }
            else
            {
                return(OpeCur.AjaxMsgNOOK(Resource.DeleteFail));
            }
        }