Exemplo n.º 1
0
        /// <summary>
        /// 查询角色列表
        /// </summary>
        public string QueryRoleListData()
        {
            var form = Request("form").DeserializeJSONTo <RoleQueryEntity>();

            var       appSysService = new AppSysService(CurrentUserInfo);
            RoleModel list          = new RoleModel();

            string content = string.Empty;
            string key     = string.Empty;

            if (form.app_sys_id != null && form.app_sys_id != string.Empty)
            {
                key = form.app_sys_id.Trim();
            }
            list = appSysService.GetRolesByAppSysId(key, 1000, 0, "", "", "");

            var jsonData = new JsonData();

            jsonData.totalCount = list.RoleInfoList.Count.ToString();
            jsonData.data       = list.RoleInfoList;

            content = string.Format("{{\"totalCount\":{1},\"topics\":{0}}}",
                                    list.RoleInfoList.ToJSON(),
                                    list.RoleInfoList.Count);
            return(content);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 角色列表
        /// </summary>
        public string GetRoleListData()
        {
            var       loggininfo    = new SessionManager().CurrentUserLoginInfo;
            var       appSysService = new AppSysService(new SessionManager().CurrentUserLoginInfo);
            RoleModel list          = new RoleModel();

            string content = string.Empty;
            string key     = string.Empty;

            if (Request("app_sys_id") != null && Request("app_sys_id") != string.Empty)
            {
                key  = Request("app_sys_id").ToString().Trim();
                list = appSysService.GetRolesByAppSysId(key, 1000, 0, "", "", loggininfo.UserID);
            }
            else
            {
                list = new RoleModel();
                list.RoleInfoList = new List <RoleModel>();
            }

            var jsonData = new JsonData();

            jsonData.totalCount = list.RoleInfoList.Count.ToString();
            jsonData.data       = list.RoleInfoList;

            content = jsonData.ToJSON();
            return(content);
        }
Exemplo n.º 3
0
        public string GetRole(string pRequest)
        {
            var rd     = new APIResponse <GetRoleRD>();
            var rdData = new GetRoleRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <GetRoleRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = new LoggingSessionManager().CurrentSession;

            try
            {
                var       appSysService = new AppSysService(loggingSessionInfo);
                RoleModel list          = new RoleModel();
                string    key           = "D8C5FF6041AA4EA19D83F924DBF56F93";
                //if (form.app_sys_id != null && form.app_sys_id != string.Empty)
                //{
                //    key = form.app_sys_id.Trim();
                //}
                list            = appSysService.GetRolesByAppSysId(key, 1000, 0, "", "", "");
                rdData.RoleList = list.RoleInfoList;
                rdData.Count    = list.RoleInfoList.Count;
                rd.Data         = rdData;
                rd.ResultCode   = 0;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            return(rd.ToJSON());
        }
Exemplo n.º 4
0
        /// <summary>
        /// 查询角色列表
        /// </summary>
        public string QueryRoleListData()
        {
            var responseData = new ResponseData();
            LoggingSessionInfo loggingSessionInfo = null;

            if (CurrentUserInfo != null)
            {
                loggingSessionInfo = CurrentUserInfo;
            }
            else
            {
                if (string.IsNullOrEmpty(Request("CustomerID")))
                {
                    responseData.success = false;
                    responseData.msg     = "缺少商户标识";
                    return(responseData.ToString());
                }
                else if (string.IsNullOrEmpty(Request("CustomerUserID")))
                {
                    responseData.success = false;
                    responseData.msg     = "缺少登陆员工的标识";
                    return(responseData.ToString());
                }
                else if (string.IsNullOrEmpty(Request("CustomerUserID")))
                {
                    responseData.success = false;
                    responseData.msg     = "缺少登陆员工的标识";
                    return(responseData.ToString());
                }
                else
                {
                    loggingSessionInfo = Default.GetBSLoggingSession(Request("CustomerID"), Request("CustomerUserID"));
                }
            }

            var form = Request("form").DeserializeJSONTo <RoleQueryEntity>();

            var       appSysService = new AppSysService(loggingSessionInfo);//使用兼容模式
            RoleModel list          = new RoleModel();

            string content = string.Empty;
            string key     = string.Empty;

            if (form.app_sys_id != null && form.app_sys_id != string.Empty)
            {
                key = form.app_sys_id.Trim();
            }
            int maxRowCount = PageSize;                          //每页数量
            int limit       = Utils.GetIntVal(Request("limit")); //传过来的参数

            if (limit != 0)
            {
                maxRowCount = PageSize = limit;
            }


            int page = Utils.GetIntVal(Request("page"));//第几页面

            if (page == 0)
            {
                page = 1;
            }
            int startRowIndex = (page - 1) * PageSize + 1;//因为row_number()从1开始


            list = appSysService.GetRolesByAppSysId(key, maxRowCount, startRowIndex
                                                    , form.type_id ?? "", form.role_name ?? "", loggingSessionInfo.UserID);
            //在为用户配置门店角色关系时
            //多加一个参数,在这里选择门店,必须重新加载角色列表,因为创建用户角色门店关系时,角色必须和门店同一个type_level上
            if (!string.IsNullOrEmpty(form.unit_id))
            {
                t_unitBLL    t_unitBll = new t_unitBLL(CurrentUserInfo);
                t_unitEntity t_unitEn  = t_unitBll.GetByID(form.unit_id);

                if (t_unitEn != null)
                {
                    T_TypeBLL    T_TypeBLL = new T_TypeBLL(CurrentUserInfo);
                    T_TypeEntity t_typeEn  = T_TypeBLL.GetByID(t_unitEn.type_id);
                    list.RoleInfoList = list.RoleInfoList.Where(p => p.org_level == t_typeEn.type_Level).ToList();
                }
            }

            var jsonData = new JsonData();

            jsonData.totalCount = list.RoleInfoList.Count.ToString();
            jsonData.data       = list.RoleInfoList;

            content = string.Format("{{\"totalCount\":{1},\"TotalPage\":{2},\"topics\":{0}}}",
                                    list.RoleInfoList.ToJSON(),
                                    list.ICount,
                                    list.TotalPage);
            return(content);
        }
Exemplo n.º 5
0
        public string GetUserList(string pRequest)
        {
            var rd     = new APIResponse <GetUserRD>();
            var rdData = new GetUserRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <GetUserRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = new LoggingSessionManager().CurrentSession;

            try
            {
                //获取普通员工employee角色标识
                string    roleId        = string.Empty;
                var       appSysService = new AppSysService(loggingSessionInfo);
                RoleModel list          = new RoleModel();
                string    key           = "D8C5FF6041AA4EA19D83F924DBF56F93";
                list = appSysService.GetRolesByAppSysId(key, 1000, 0, "", "", "");

                foreach (var item in list.RoleInfoList)
                {
                    if (item.Role_Code.ToLower() == "employee")
                    {
                        roleId = item.Role_Id;
                        break;
                    }
                }
                if (string.IsNullOrEmpty(roleId) || roleId == "")
                {
                    throw new APIException("employee的roleId未获取到")
                          {
                              ErrorCode = 103
                          }
                }
                ;

                T_UserBLL userBll = new T_UserBLL(loggingSessionInfo);
                //string typeID = System.Configuration.ConfigurationManager.AppSettings["TypeID"].ToString();
                int             totalPage = 0;
                QueryUserEntity entity    = new QueryUserEntity();
                entity.QUserName      = rp.Parameters.Keyword;
                entity.QUnitID        = rp.Parameters.UnitID;
                entity.QJobFunctionID = rp.Parameters.JobFunctionID;
                entity.QRoleID        = roleId;
                DataTable dTable = userBll.GetUserList(rp.Parameters.UserID, rp.Parameters.PageIndex, rp.Parameters.PageSize, out totalPage, entity);

                //排序
                DataView dv   = dTable.DefaultView;
                string   sort = string.IsNullOrEmpty(rp.Parameters.sort) ? "UserEmail asc" : rp.Parameters.sort;
                sort    = "UserStatus desc," + sort;
                dv.Sort = sort;
                DataTable dt2 = dv.ToTable();
                dTable = dt2;


                if (dTable != null)
                {
                    rdData.UserList = DataTableToObject.ConvertToList <UserInfo>(dTable);
                }
                rdData.TotalPage = totalPage;
                rd.Data          = rdData;
                rd.ResultCode    = 0;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            return(rd.ToJSON());
        }
Exemplo n.º 6
0
        public string ExportStaff(string pRequest)
        {
            var rd     = new APIResponse <ExportStaffRD>();
            var rdData = new ExportStaffRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <ExportStaffRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = new LoggingSessionManager().CurrentSession;

            try
            {
                //获取普通员工employee角色标识
                string    roleId        = string.Empty;
                var       appSysService = new AppSysService(loggingSessionInfo);
                RoleModel list          = new RoleModel();
                string    key           = "D8C5FF6041AA4EA19D83F924DBF56F93";
                list = appSysService.GetRolesByAppSysId(key, 1000, 0, "", "", "");

                foreach (var item in list.RoleInfoList)
                {
                    if (item.Role_Code.ToLower() == "employee")
                    {
                        roleId = item.Role_Id;
                        break;
                    }
                }

                if (string.IsNullOrEmpty(roleId) || roleId == "")
                {
                    throw new APIException("employee的roleId未获取到")
                          {
                              ErrorCode = 103
                          }
                }
                ;

                rp.Parameters.ExportType = rp.Parameters.ExportType.ToLower();
                //所有页
                if (rp.Parameters.ExportType == "allpage")
                {
                    rp.Parameters.PageIndex = 0;
                    rp.Parameters.PageSize  = 5000;
                }

                //数据获取
                T_UserBLL       userBll   = new T_UserBLL(loggingSessionInfo);
                int             totalPage = 0;
                QueryUserEntity entity    = new QueryUserEntity();
                entity.QUserName      = rp.Parameters.Keyword;
                entity.QUnitID        = rp.Parameters.UnitID;
                entity.QJobFunctionID = rp.Parameters.JobFunctionID;
                entity.QRoleID        = roleId;
                DataTable dTable = userBll.GetUserList(rp.Parameters.UserID, rp.Parameters.PageIndex, rp.Parameters.PageSize, out totalPage, entity);

                //过滤选择的员工
                if (rp.Parameters.ExportType == "select")
                {
                    string[] ids    = rp.Parameters.StaffIds.Split(',');
                    string   strIds = "'',";
                    for (int i = 0; i < ids.Length; i++)
                    {
                        strIds += "'" + ids[i] + "',";
                    }
                    strIds = strIds.Substring(0, strIds.Length - 1);
                    DataRow[] drs = dTable.Select("UserID in (" + strIds + ")");
                    DataTable d   = dTable.Clone();
                    foreach (var item in drs)
                    {
                        d.ImportRow(item);
                    }
                    dTable = d;
                }
                else
                if (rp.Parameters.ExportType == "noselect")
                {
                    dTable = dTable.Clone();
                }

                //排序
                DataView dv   = dTable.DefaultView;
                string   sort = string.IsNullOrEmpty(rp.Parameters.sort) ? "UserEmail asc" : rp.Parameters.sort;
                sort    = "UserStatus desc," + sort;
                dv.Sort = sort;
                DataTable dt2 = dv.ToTable();
                dTable = dt2;

                //表格标题设置
                DataTable lastTable = dTable.DefaultView.ToTable(false, "UserCode", "UserName", "UserNameEn", "UserEmail", "UserGenderT", "UserBirthday", "UserTelephone", "UserCellphone", "DeptName", "JobFuncName", "UserStatusDesc");
                //重置标题名称
                lastTable.Columns["UserCode"].ColumnName       = "用户编码";
                lastTable.Columns["UserName"].ColumnName       = "姓名";
                lastTable.Columns["UserNameEn"].ColumnName     = "英文名";
                lastTable.Columns["UserEmail"].ColumnName      = "邮箱";
                lastTable.Columns["UserGenderT"].ColumnName    = "性别";
                lastTable.Columns["UserBirthday"].ColumnName   = "生日";
                lastTable.Columns["UserTelephone"].ColumnName  = "手机";
                lastTable.Columns["UserCellphone"].ColumnName  = "电话";
                lastTable.Columns["DeptName"].ColumnName       = "部门";
                lastTable.Columns["JobFuncName"].ColumnName    = "职务";
                lastTable.Columns["UserStatusDesc"].ColumnName = "状态";

                //数据获取
                Workbook wb       = DataTableExporter.WriteXLS(lastTable, 0);
                string   savePath = HttpContext.Current.Server.MapPath(@"~/File/Excel");
                if (!System.IO.Directory.Exists(savePath))
                {
                    System.IO.Directory.CreateDirectory(savePath);
                }
                savePath = savePath + "\\企信员工-" + lastTable.TableName + ".xls";
                wb.Save(savePath);//保存Excel文件
                new ExcelCommon().OutPutExcel(HttpContext.Current, savePath);

                HttpContext.Current.Response.End();

                rd.ResultCode = 0;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            return(rd.ToJSON());
        }