public string SY_CHANGEINFO_SELECT(string datastring) { string token = AppClass.GetSession("token").ToString(); HR_SY_CHANGEINFO model = Newtonsoft.Json.JsonConvert.DeserializeObject <HR_SY_CHANGEINFO>(datastring); HR_SY_CHANGEINFO_SELECT result = hrmodels.SY_CHANGEINFO.SELECT(model, token); return(Newtonsoft.Json.JsonConvert.SerializeObject(result)); }
public string EXPOST_TJBB_CHANGEINFO_RYINFO(string datastring) { MES_RETURN_UI rst = new MES_RETURN_UI(); string token = AppClass.GetSession("token").ToString(); int STAFFID = Convert.ToInt32(AppClass.GetSession("STAFFID")); HR_SY_CHANGEINFO model = Newtonsoft.Json.JsonConvert.DeserializeObject <HR_SY_CHANGEINFO>(datastring); HR_SY_CHANGEINFO_SELECT result = hrmodels.SY_CHANGEINFO.SELECT(model, token); if (result.MES_RETURN.TYPE == "E") { return(Newtonsoft.Json.JsonConvert.SerializeObject(result.MES_RETURN)); } try { FileStream file = new FileStream(Server.MapPath("~") + @"/Areas/HR/ExportFile/导出模版.xlsx", FileMode.Open, FileAccess.Read); IWorkbook workbook = new XSSFWorkbook(file); ISheet sheet = workbook.GetSheetAt(0); int rowcount = 0; string tt = "工号,修改数据库表,修改字段,旧值,新值,登录账号名,修改时间,操作系统"; string[] ttlist = tt.Split(','); IRow rowtt = sheet.CreateRow(rowcount++); int cellIndex = 0; for (int a = 0; a < ttlist.Length; a++) { rowtt.CreateCell(cellIndex++).SetCellValue(ttlist[a]); } DataTable dtinfo = result.DATALIST; for (int i = 0; i < dtinfo.Rows.Count; i++) { cellIndex = 0; IRow row = sheet.CreateRow(rowcount++); row.CreateCell(cellIndex++).SetCellValue(dtinfo.Rows[i]["GH"].ToString()); row.CreateCell(cellIndex++).SetCellValue(dtinfo.Rows[i]["CHANGETABLE"].ToString()); row.CreateCell(cellIndex++).SetCellValue(dtinfo.Rows[i]["CHANGEZD"].ToString()); row.CreateCell(cellIndex++).SetCellValue(dtinfo.Rows[i]["OLDINFO"].ToString()); row.CreateCell(cellIndex++).SetCellValue(dtinfo.Rows[i]["NEWINFO"].ToString()); row.CreateCell(cellIndex++).SetCellValue(dtinfo.Rows[i]["STAFFUSER"].ToString()); row.CreateCell(cellIndex++).SetCellValue(dtinfo.Rows[i]["CHANGETIME"].ToString()); row.CreateCell(cellIndex++).SetCellValue(dtinfo.Rows[i]["CHANGESY"].ToString()); } string now = DateTime.Now.ToString("yyyyMMddHHmmss.fff"); FileStream file1 = new FileStream(string.Format(@"{0}/Areas/HR/ExportFile/{1}.xlsx", Server.MapPath("~"), now), FileMode.Create); workbook.Write(file1); file1.Close(); rst.TYPE = "S"; rst.MESSAGE = now; } catch { rst.TYPE = "E"; rst.MESSAGE = "生成文件失败!"; } return(Newtonsoft.Json.JsonConvert.SerializeObject(rst)); }