Ejemplo n.º 1
0
        public JObject exportAdmin(Dictionary <String, object> condition)
        {
            var    admins         = db.Admin.OrderByDescending(e => e.ID);
            string attachment_url = "";

            if (admins != null)
            {
                var query = admins.AsEnumerable();

                foreach (Admin row in query)
                {
                    if (row.Roletype != null)
                    {
                        row.RoletypeShow = EnumRoletype.RoletypeShow(Convert.ToChar(row.Roletype));
                    }
                    if (row.Seescope != null)
                    {
                        row.SeescopeShow = EnumSeescope.SeescopeShow(Convert.ToChar(row.Seescope));
                    }
                    row.Department_Name = row.Department.Department_Name;
                }

                DataTable dt = UtilDataTable.ToDataTable(query);
                dt.TableName = "Admin";
                UtilDataTable.DeleteColumns(dt, "Seescope", "Roletype", "Department_ID");
                Dictionary <string, string> dic = new Dictionary <string, string>()
                {
                    { "ID", "编号" },
                    { "Department_Name", "部门名称" },
                    { "Username", "用户名称" },
                    { "Password", "密码" },
                    { "Realname", "真实姓名" },
                    { "RoletypeShow", "扮演角色" },
                    { "SeescopeShow", "视野" },
                    { "LoginTimes", "登录次数" },
                    { "CommitTime", "创建时间" },
                    { "UpdateTime", "更新时间" }
                };
                UtilDataTable.ReplaceColumnName(dt, dic);

                string fileName = "admin" + UtilDateTime.NowS() + ".xls";
                attachment_url = Gc.UploadUrl + "/attachment/admin/" + fileName;
                fileName       = Path.Combine(Gc.UploadPath, "attachment", "admin", fileName);
                UtilExcelOle.DataTableToExcel(fileName, dt);
            }

            return(new JObject(
                       new JProperty("success", true),
                       new JProperty("data", attachment_url)
                       ));
        }
Ejemplo n.º 2
0
        public void exportAdmin()
        {
            //获取系统管理员数据
            List <Admin> admins = db.Admin.OrderByDescending(e => e.ID).Take(50).ToList();

            if (admins != null)
            {
                var query = admins.AsEnumerable();

                foreach (Administrator row in query)
                {
                    if (row.Roletype != null)
                    {
                        row.RoletypeShow = EnumRoletype.RoletypeShow(Convert.ToChar(row.Roletype));
                    }
                    if (row.Seescope != null)
                    {
                        row.SeescopeShow = EnumSeescope.SeescopeShow(Convert.ToChar(row.Seescope));
                    }
                    row.Department_Name = row.Department.Department_Name;
                }
                //管理员数据导出到excel
                DataTable dt = UtilDataTable.ToDataTable(query);
                dt.TableName = "Admin";
                UtilDataTable.DeleteColumns(dt, "Seescope", "Roletype", "Department_ID");
                Dictionary <string, string> dic = new Dictionary <string, string>()
                {
                    { "ID", "编号" },
                    { "Department_Name", "部门名称" },
                    { "Username", "用户名称" },
                    { "Password", "密码" },
                    { "Realname", "真实姓名" },
                    { "RoletypeShow", "扮演角色" },
                    { "SeescopeShow", "视野" },
                    { "LoginTimes", "登录次数" },
                    { "CommitTime", "创建时间" },
                    { "UpdateTime", "更新时间" }
                };

                UtilDataTable.ReplaceColumnName(dt, dic);

                string fileName = Path.Combine(Gc.UploadPath, "attachment", "admin", UtilDateTime.NowS() + ".xls");
                UtilExcelNpoi.DataTableToExcel(fileName, dt, "Admin");
                Console.WriteLine("导出文件:" + fileName);
            }
        }
Ejemplo n.º 3
0
        public ExtServiceAdmin queryPageAdmin(Dictionary <String, object> condition)
        {
            int StartPoint = 1, EndPoint = 15;

            if (condition.ContainsKey("start"))
            {
                StartPoint = Convert.ToInt16(condition["start"]) + 1;
            }
            if (condition.ContainsKey("limit"))
            {
                EndPoint = Convert.ToInt16(condition["limit"]);
                EndPoint = StartPoint + EndPoint - 1;
            }
            UtilDictionary.Removes(condition, "start", "limit");

            if (adminService == null)
            {
                adminService = new ServiceAdmin();
            }
            string WhereClause = FiltertoCondition(condition);
            int    RowCount    = adminService.Count(WhereClause);//总行记录数

            if (RowCount > 0)
            {
                List <Admin> listAdmins = adminService.QueryPage(StartPoint, EndPoint, WhereClause).ToList <Admin>();
                if (EndPoint > RowCount)
                {
                    EndPoint = RowCount;
                }
                this.Stores = new List <Object>();
                foreach (Admin admin in listAdmins)
                {
                    admin.RoletypeShow    = EnumRoletype.RoletypeShow(Convert.ToChar(admin.Roletype));
                    admin.SeescopeShow    = EnumSeescope.SeescopeShow(Convert.ToChar(admin.Seescope));
                    admin.Department_Name = admin.Department.Department_Name;
                    this.Stores.Add((Admin)ClearInclude(admin));
                }
            }
            this.TotalCount = RowCount;
            this.Success    = true;
            return(this);
        }