/// <summary> /// 查询用户登录记录列表 /// </summary> /// <param name="userName">用户名</param> /// <returns>用户登录记录列表</returns> public ReturnBody <List <UserLoginLogEntity> > GetUserLoginLogList(string userName) { ReturnBody <List <UserLoginLogEntity> > ret = null; //请求信息没记录下来 ExceptionInfoEntity exception = WipLogHelper.GetExceptionInfo <string>(namespaceName, "GetUserLoginLogList", userName, "", ""); try {//校验 IValidateFactory factory = new UserLoginLogValiFactory(); IValidate validate = factory.CreateValidate(); ret = validate.Validate <string, List <UserLoginLogEntity> >(userName, ref exception); if (ret != null) { return(ret); } ret = new ReturnBody <List <UserLoginLogEntity> >(); ret.resCode = ResCode.SUCCESS; ret.resData = IOCContainer.Container.GetExport <IUserLoginLogBLL>("UserLoginLog").Value.GetUserLoginLogList(userName); } catch (Exception ex) {//异常信息没有记录下来 WipLogHelper.GetExceptionInfoForError(ex, ref exception); WipLogHelper.WriteExceptionInfo(exception); ret.resCode = ResCode.FAILURE; ret.resMsg = ex.Message; } return(ret); }
/// <summary> /// 打印操作 /// </summary> /// <param name="workbook"></param> /// <param name="printInfo"></param> /// <returns></returns> public void Print(string json_cellList, PrintInfoModel printInfo, PageOrientationType orientation) { IDictionary <string, object> logDict = new Dictionary <string, object>(); logDict.Add("json_cellList", json_cellList); logDict.Add("printInfo", printInfo); logDict.Add("orientation", orientation); ExceptionInfoEntity exception = WipLogHelper.GetExceptionInfo <IDictionary <string, object> >(namespaceName, "Print", logDict , "", printInfo == null ? "" : printInfo.processCardNumber, ExceptionSource.WIPPost, ExceptionLevel.BusinessError, wipSource); try { //创建文件 List <ExcelSheetModel> sheetModelList = new List <ExcelSheetModel>(); List <ExcelCellModel> cellModelList = JsonConvert.DeserializeObject <List <ExcelCellModel> >(json_cellList); ExcelSheetModel sheetModel = new ExcelSheetModel() { sheetName = this.workbook.GetSheetAt(0).SheetName, dataList = cellModelList, sheetType = "", }; sheetModelList.Add(sheetModel); byte[] bytes = ExcelUtil.writeExcelToFile(this.workbook, sheetModelList, printInfo.tempName); //修改为“打印中” var result = UpdatePrintStatusToPrinting(printInfo.id); if (!result) { throw new Exception("更新状态为打印中失败,printInfo.id:" + printInfo.id.ToString()); } PrintHelper.PrintExcel(bytes, printInfo.printerName, orientation); //打印成功 this.DoByPrintResultSuccess(printInfo); } catch (Exception ex) { WipLogHelper.GetExceptionInfoForError(ex, ref exception); WipLogHelper.WriteExceptionInfo(exception); //打印失败 this.DoByPrintResultFailure(printInfo, ex); } }
/// <summary> /// 处理打印结果 /// </summary> /// <param name="printResult">打印结果</param> /// <param name="printInfo">打印信息</param> /// <param name="errMsg">错误信息</param> /// <returns></returns> public virtual bool DoByPrintResult(bool printResult, PrintInfoModel printInfo, string errMsg = "") { var retResult = false;//返回结果 IDictionary <string, object> logDict = new Dictionary <string, object>(); logDict.Add("printResult", printResult); logDict.Add("printInfo", printInfo); ExceptionInfoEntity exception = WipLogHelper.GetExceptionInfo <IDictionary <string, object> >(namespaceName, "DoByPrintResult", logDict , "", printInfo == null ? "" : printInfo.processCardNumber, ExceptionSource.WIPPost, ExceptionLevel.BusinessError, wipSource); try { #region 准备数据 SqlParameter[] parameters_UpdatePrintResult = this.GetSqlParamForUpdatePrintResult(printResult, printInfo, errMsg); #endregion #region 事务处理 using (SqlConnection conn = new SqlConnection(SQLServerHelper.connectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) { TransactionModel transModel = new TransactionModel() { conn = conn, trans = trans }; try { var execResult = WIPDataAccess.CreateDAL <IPrintInfoDAL>("PrintInfoDAL").UpdatePrintResult(parameters_UpdatePrintResult, transModel); if (execResult != 1) {//返回1代表执行成功,返回-1代表失败 throw new Exception("处理打印结果失败,parameters:" + JsonConvert.SerializeObject(parameters_UpdatePrintResult) + ",execResult:" + execResult.ToString()); } trans.Commit(); retResult = true; } catch { retResult = false; trans.Rollback(); throw; } } } #endregion } catch (Exception ex) { retResult = false; WipLogHelper.GetExceptionInfoForError(ex, ref exception); WipLogHelper.WriteExceptionInfo(exception); } return(retResult); }