using System; using System.Collections.Generic; using System.Linq; using System.Text; using QMAPP.BLL; using QMAPP.MD.Entity; using QMAPP.Entity; using QMFrameWork.Data; using QMAPP.MD.DAL; using QMFrameWork.Log; using QMAPP.MD.Entity.Sys; using QMAPP.FJC.DAL.Basic; using QMAPP.FJC.Entity.Basic; using QMAPP.Entity.Sys; namespace QMAPP.MD.BLL { /// /// 模 块:逻辑矩阵 /// 作 者:郭兆福 /// 时 间:2018年04月20日 /// public class UserWithMachineBLL : BaseBLL { #region 获取信息 /// /// 获取信息 /// /// 条件 /// 信息 public DataResult Get(UserWithMachine model) { DataResult result = new DataResult(); try { result.Result = new UserWithMachineDAL().Get(model); } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } #endregion #region 修改时获取设备信息 /// /// 获取分页列表 /// /// 条件 /// 数据页 /// 数据页 public DataResult GetList(UserWithMachine condition, DataPage page) { DataResult result = new DataResult(); try { //获取物料信息列表 DataPage dataPage = new UserWithMachineDAL().GetList(condition, page); result.Result = dataPage; } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } #endregion #region 信息是否重复 /// /// 判断名称是否存在 /// /// /// true:已存在;fasel:不存在。 public bool ExistsMateriel(UserWithMachine model) { try { return new UserWithMachineDAL().ExistsMateriel(model); } catch (Exception ex) { throw ex; } } #endregion #region 插入信息 /// /// 插入信息 /// /// 信息 /// 插入行数 public DataResult InsertUserWithMachine(UserWithMachine model, List machinelist) { List List = new List(); DataResult result = new DataResult(); UserWithMachineDAL cmdDAL = new UserWithMachineDAL(); cmdDAL.BaseSession = AppDataFactory.CreateMainSession(); foreach (MachineInfo ma in machinelist) { UserWithMachine planmodel = new UserWithMachine(); planmodel.PID = Guid.NewGuid().ToString(); planmodel.USERID = model.USERID; planmodel.MACHINEID = ma.PID; planmodel.CREATEUSER = this.LoginUser.UserID; planmodel.CREATEDATE = DateTime.Now; planmodel.UPDATEUSER = planmodel.CREATEUSER; planmodel.UPDATEDATE = planmodel.CREATEDATE; List.Add(planmodel); } try { if (ExistsMateriel(model)) { result.IsSuccess = false; result.Msg = Resource.MaterielCodeIsHave; return result; } result.Result = cmdDAL.InsertUserWithMachine(List); } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Tag = ex.StackTrace, Info = "逻辑矩阵逻辑层-插入信息!" }); result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } #endregion #region 删除 #region 主列表界面点击删除 /// /// 主列表界面点击删除 /// /// /// 删除个数 public DataResult Delete(string userid) { DataResult result = new DataResult(); string[] list = userid.Split(":".ToCharArray()); try { foreach (string str in list) { result.Result += this.DeleteUserWithMachine(new UserWithMachine { USERID = userid }); } } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } /// /// 主列表界面点击删除 /// /// 信息 /// 删除个数 public int DeleteUserWithMachine(UserWithMachine model) { int count = 0; try { count = new UserWithMachineDAL().EditDeleteUserWithMachine(model); return count; } catch (Exception ex) { throw ex; } } #endregion #region 编辑时删除 /// /// 编辑时删除 /// /// /// 删除个数 public DataResult EditDelete(UserWithMachine model) { DataResult result = new DataResult(); if (string.IsNullOrEmpty(model.EDITFLAG)) { string[] list = model.MachineIds.Split(";".ToCharArray()); try { foreach (string str in list) { result.Result += this.EditDeleteUserWithMachine(new UserWithMachine { MACHINEID = str, USERID = model.USERID }); } } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } } else { try { result.Result += this.EditDeleteUserWithMachine(new UserWithMachine {USERID = model.USERID }); } catch (Exception ex) { result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } } result.IsSuccess = true; return result; } /// /// 删除信息 /// /// 信息 /// 删除个数 public int EditDeleteUserWithMachine(UserWithMachine model) { int count = 0; try { count = new UserWithMachineDAL().EditDeleteUserWithMachine(model); return count; } catch (Exception ex) { throw ex; } } #endregion #endregion #region 获取用户列表(下拉列表使用) /// /// /// /// /// public DataResult> GetUserInfoList(User condition) { DataResult> result = new DataResult>(); try { result.Result = new UserWithMachineDAL().GetUserInfoList(condition); } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Tag = ex.StackTrace, Info = "逻辑矩阵逻辑层-获取列表(绑定下拉列表使用)!" }); result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } #endregion #region 获取设备信息,填充Grid /// /// 获取设备信息,填充Grid /// /// /// public MachineInfo GetMachineInfo(MachineInfo condition) { MachineInfo material = new MachineInfo(); //根据设备iD获取本体信息 material.PID = condition.PID; material.Machineids = condition.Machineids; try { List materialList = new MachineInfoDAL().GetMachineInfoList(material); foreach (MachineInfo m in materialList) { material.MACHINECODDE = m.MACHINECODDE; material.MACHINENAME = m.MACHINENAME; } } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Tag = ex.StackTrace, Info = "逻辑矩阵逻辑层-获取本体信息!" }); throw ex; } return material; } #endregion #region 保存时获取设备信息 /// /// 获取本体信息 /// /// /// public List GetMachineList(MachineInfo condition) { //MachineInfo machine = new MachineInfo(); ////根据设备主键信息 //machine.Machineids = condition.Machineids; //machine.PIDS = condition.PIDS; try { return new MachineInfoDAL().GetMachineInfoList(condition); } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Tag = ex.StackTrace, Info = "逻辑矩阵逻辑层-获取设备信息!" }); throw ex; } } #endregion #region /// /// /// /// /// public DataResult> GetUserInfoListForEdit(User condition) { DataResult> result = new DataResult>(); try { result.Result = new UserWithMachineDAL().GetUserInfoListForEdit(condition); } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Tag = ex.StackTrace, Info = "逻辑矩阵逻辑层-获取列表(绑定下拉列表使用)!" }); result.IsSuccess = false; result.Msg = Resource.SystemException; throw ex; } result.IsSuccess = true; return result; } #endregion public List GetUserAbility(string userid) { return new UserWithMachineDAL().GetUserAbility(userid); } } }