public bool GetDisableUsers(Guid transactionid, AdminInfo admin, int curpage, int pagesize, string searchstr, out string strJsonResult) { bool result = true; strJsonResult = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); string paramstr = string.Empty; paramstr += $"userID:{admin.UserID}"; paramstr += $"||UserAccount:{admin.UserAccount}"; paramstr += $"||curpage:{curpage}"; paramstr += $"||pagesize:{pagesize}"; paramstr += $"||searchstr:{searchstr}"; string funname = "GetDisableUsers"; try { do { BaseListInfo lists = new BaseListInfo(); SystemReportDBProvider Provider = new SystemReportDBProvider(); if (!Provider.GetDisableUsers(transactionid, admin, curpage, pagesize, searchstr, out lists, out error)) { strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; break; } error.Code = ErrorCode.None; string json = JsonConvert.SerializeObject(lists); LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), true, transactionid); strJsonResult = JsonHelper.ReturnJson(true, Convert.ToInt32(error.Code), error.Info, json); result = true; } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); LoggerHelper.Error("SystemReportManager调用GetDisableUsers异常", paramstr, ex.ToString(), transactionid); strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); result = false; } return(result); }
public bool ExportDisableUsersToExcel(Guid transactionid, AdminInfo admin, int curpage, int pagesize, string searchstr, out byte[] filebyte, out string strJsonResult) { bool result = true; strJsonResult = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); filebyte = new byte[0]; string paramstr = string.Empty; paramstr += $"userID:{admin.UserID}"; paramstr += $"||UserAccount:{admin.UserAccount}"; paramstr += $"||curpage:{curpage}"; paramstr += $"||pagesize:{pagesize}"; paramstr += $"||searchstr:{searchstr}"; string funname = "ExportDisableUsersToExcel"; try { do { BaseListInfo lists = new BaseListInfo(); SystemReportDBProvider Provider = new SystemReportDBProvider(); if (!Provider.GetDisableUsers(transactionid, admin, curpage, pagesize, searchstr, out lists, out error)) { strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; break; } using (ExcelPackage package = new ExcelPackage()) { ExcelWorksheet sheet = package.Workbook.Worksheets.Add("已禁用用户统计"); sheet.Cells[1, 1].Value = "显示名称"; sheet.Column(1).Width = 30; //设置列宽 sheet.Cells[1, 2].Value = "邮箱"; sheet.Column(2).Width = 50; //设置列宽 sheet.Cells[1, 3].Value = "创建时间"; sheet.Column(3).Width = 30; //设置列宽 sheet.Cells[1, 4].Value = "最近登录时间"; sheet.Column(4).Width = 30; //设置列宽 sheet.Cells[1, 5].Value = "所在路径"; sheet.Column(5).Width = 150; //设置列宽 for (int i = 0; i < lists.Lists.Count; i++) { SystemReportInfo info = (SystemReportInfo)lists.Lists[i]; sheet.Cells[i + 2, 1].Value = info.DisplayName; sheet.Cells[i + 2, 2].Value = info.UserAccount; sheet.Cells[i + 2, 3].Value = info.CreateTimeName; sheet.Cells[i + 2, 4].Value = info.LastLoginTimeName; sheet.Cells[i + 2, 5].Value = info.DistinguishedName; } filebyte = package.GetAsByteArray(); } error.Code = ErrorCode.None; string json = JsonConvert.SerializeObject(lists); LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), true, transactionid); strJsonResult = JsonHelper.ReturnJson(true, Convert.ToInt32(error.Code), error.Info, json); result = true; } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Info(admin.UserAccount, funname, paramstr, Convert.ToString(error.Code), false, transactionid); LoggerHelper.Error("SystemReportManager调用GetDisableUsers异常", paramstr, ex.ToString(), transactionid); strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); result = false; } return(result); }