using System; using System.Collections.Generic; using System.Data; using QMFrameWork.Data; using QMAPP.Entity; using QMAPP.FJC.Entity.QT; using QMAPP.FJC.BLL.QT; using QMAPP.FJC.DAL.QT; using QMAPP.BLL; using QMFrameWork.Log; namespace QMAPP.FJC.BLL.QT { /// /// 模块名称:数据采集校验 /// 作 者:张鹏 /// 编写日期:2017年09月01日 /// public class DAIValidationBLL : BaseBLL { #region 获取信息 /// /// 获取信息 /// /// 条件 /// 信息 public DAIValidation Get(DAIValidation info) { try { return new DAIValidationDAL().Get(info); } catch (Exception ex) { throw ex; } } public DAIValidation GetByID(string PID) { try { return new DAIValidationDAL().GetByPID(PID); } catch (Exception ex) { throw ex; } } #endregion #region 获取列表 /// /// 获取列表 /// /// 条件 /// 数据页 /// 数据页 public DataPage GetList(DAIValidation condition, DataPage page) { try { return new DAIValidationDAL().GetList(condition, page); } catch (Exception ex) { throw ex; } } /// /// 获取列表(WEB可以进行调整的) /// /// 条件 /// 数据页 /// 数据页 public DataResult GetEditableList(DAIValidation condition, DataPage page) { DataResult result = new DataResult(); try { result.Result= new DAIValidationDAL().GetEditableList(condition, page); } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Tag = ex.StackTrace, Info = "获取列表!" }); result.IsSuccess = false; result.Msg = ex.Message; } result.IsSuccess = true; return result; } #endregion #region 信息是否重复 /// /// 判断名称是否存在 /// /// 信息 /// true:已存在;fasel:不存在。 public bool Exists(DAIValidation info) { try { return new DAIValidationDAL().Exists(info); } catch (Exception ex) { throw ex; } } #endregion #region 插入信息 /// /// 插入信息(单表) /// /// 信息 /// 插入行数 public DataResult Insert(DAIValidation info) { DataResult result = new DataResult(); try { //基本信息 info.PID = Guid.NewGuid().ToString(); info.CREATEUSER = this.LoginUser.UserID; info.CREATEDATE = DateTime.Now; info.UPDATEUSER = info.CREATEUSER; info.UPDATEDATE = info.CREATEDATE; DAIValidationDAL cmdDAL = new DAIValidationDAL(); result.Result = new DAIValidationDAL().Insert(info); result.IsSuccess = true; return result; } catch (Exception ex) { throw ex; } } #endregion #region 更新信息 /// /// 更新信息 /// /// 信息 /// 更新行数 public DataResult Update(DAIValidation info) { DataResult result = new DataResult(); try { info.UPDATEUSER = this.LoginUser.UserID; result.Result = new DAIValidationDAL().Update(info); result.IsSuccess = true; return result; } catch (Exception ex) { throw ex; } } #endregion public DataResult Disable(string ids) { int count = 0; DataResult result = new DataResult(); string[] idArray = ids.Split(':'); try { count = new DAL.QT.DAIValidationDAL().Disable(idArray); result.Result = count; result.IsSuccess = true; return result; } catch (Exception ex) { throw ex; } } public DataResult Enable(string ids) { int count = 0; DataResult result = new DataResult(); string[] idArray = ids.Split(':'); try { count = new DAL.QT.DAIValidationDAL().Enable(idArray); result.Result = count; result.IsSuccess = true; return result; } catch (Exception ex) { throw ex; } } #region 删除 /// /// 删除信息 /// /// 主键串 /// 删除个数 public DataResult DeleteArray(string strs) { int count = 0; DataResult result = new DataResult(); string[] list = strs.Split(":".ToCharArray()); try { foreach (string str in list) { count += this.Delete(new DAIValidation { PID = str }); } result.Result = count; result.IsSuccess = true; return result; } catch (Exception ex) { throw ex; } } /// /// 删除信息 /// /// 信息 /// 删除个数 public int Delete(DAIValidation info) { try { return new DAIValidationDAL().Delete(info); } catch (Exception ex) { throw ex; } } #endregion #region 导出数据 /// /// 获取导出的数据 /// /// 查询条件 /// 数据 public DataTable GetExportData(DAIValidation info) { try { return new DAIValidationDAL().GetExportData(info); } catch (Exception ex) { throw ex; } } #endregion #region 导入数据 /// /// 导入数据 /// /// 数据 /// 导入结果 public DataResult ImportData(List list) { DataResult result = new DataResult(); DAIValidationDAL cmDal = new DAIValidationDAL(); List List = new List(); int index = 0; try { result.Result = new ImportMessage(); result.Result.Errors = new List(); using (IDataSession session = AppDataFactory.CreateMainSession()) { //状态判断 foreach (DAIValidation ma in list) { index++; if (!string.IsNullOrEmpty(ma.InfoError)) { ma.PID = null; result.Result.failureNum += 1; continue; } //修改改时根据主键等信息获取详细内容信息 DAIValidation oldInfo = cmDal.Get(ma); if (oldInfo != null) { //更新 ma.PID = oldInfo.PID; ma.CREATEUSER = oldInfo.CREATEUSER; ma.CREATEDATE = oldInfo.CREATEDATE; ma.UPDATEUSER = this.LoginUser.UserID; ma.UPDATEDATE = oldInfo.UPDATEDATE; ma.IsNewInfo = false; result.Result.updateNum += 1; } else { //新增 oldInfo = new DAIValidation(); ma.PID = Guid.NewGuid().ToString(); ma.CREATEUSER = this.LoginUser.UserID; ma.CREATEDATE = DateTime.Now; ma.UPDATEUSER = ma.CREATEUSER; ma.UPDATEDATE = ma.UPDATEDATE; ma.IsNewInfo = true; result.Result.insertNum += 1; } List.Add(ma); } } //导入 cmDal.GetImportData(List); result.Msg = "导入成功"; result.IsSuccess = true; return result; } catch (Exception ex) { result.IsSuccess = false; result.Ex = ex; return result; } } #endregion } }