using System; using System.Collections.Generic; using System.Linq; using System.Text; using QMAPP.Entity.Sys; using QMFrameWork.Data; using QMAPP.DAL.Sys; using System.Data; namespace QMAPP.BLL.Sys { /// /// 支持交互问题类型逻辑层对象 /// 创建者:wangyf /// 创建日期:2015.03.30 /// public class SupportInteractionBLL :BaseBLL { #region 常量 private const string _beforeTitle = "您在工厂物流管理平台(PLP)系统中有一个类型为\""; private const string _afterTitle = "\"的问题需要处理。"; private const string _beforeMiddleFinger = "["; private const string _afterMiddleFinger = "]"; private const string _questionNo = "问题编号"; #endregion #region 获取信息 /// /// 获取信息 /// /// 条件 /// 信息 public SupportInteraction GetInfo(SupportInteraction model) { try { return new SupportInteractionDAL().GetInfo(model); } catch (Exception ex) { throw ex; } } #endregion #region 获取问题处理方法列表 /// /// 获取列表 /// /// 条件 /// 数据页 /// 数据页 public DataPage GetList(SupportInteraction condition, DataPage page) { try { return new SupportInteractionDAL().GetList(condition, page); } catch (Exception ex) { throw ex; } } #endregion #region 获取问题列表 /// /// 获取列表 /// /// 条件 /// 数据页 /// 数据页 public DataPage GetProblemList(SupportInteraction condition, DataPage page) { try { return new SupportInteractionDAL().GetProblemList(condition, page, this.LoginUser.UserID,this.LoginUser.OrganID); } catch (Exception ex) { throw ex; } } #endregion #region 插入信息 /// /// 插入信息(单表) /// /// 信息 /// 插入行数 public int Insert(SupportInteraction model) { try { SupportInteractionDAL dal = new SupportInteractionDAL(); //基本信息 model.CreateUser = this.LoginUser.UserID; model.CreateDate = DateTime.Now; model.FlgDel = "0"; model.Ncind = "0"; model.Ecind = "0"; int count = dal.Insert(model); //获取用户邮箱信息 SupportInteraction userModel = dal.GetUserModel(model); //提交人不为空时 if (userModel != null && !string.IsNullOrEmpty(userModel.Email)) { //如果提交到的用户邮箱不为空,给用户发送邮件 SentMail(model, userModel.Email); } //插入通知提醒 if (!string.IsNullOrEmpty(model.SUser)) { NoticeInfo notice = new NoticeInfo(); notice.NOTICETITLE = _beforeTitle + model.PTypeName + _afterTitle + _questionNo + _beforeMiddleFinger + model.PSequ + _afterMiddleFinger + _beforeMiddleFinger + DateTime.Now.ToString("yyyy-MM-dd") + _afterMiddleFinger; notice.NOTICETYPE = "1"; notice.NOTICECONTEXT = _beforeTitle + model.PTypeName + _afterTitle + _questionNo + _beforeMiddleFinger + model.PSequ + _afterMiddleFinger +_beforeMiddleFinger + DateTime.Now.ToString("yyyy-MM-dd") + _afterMiddleFinger; notice.CANREPLY = "0"; notice.USETIME = DateTime.Now; notice.OUTTIME = notice.USETIME.AddDays(1); notice.SENDAIM = model.SUser; notice.CREATEUSER = this.LoginUser.UserID; notice.UPDATEUSER = notice.CREATEUSER; new NoticeManageBll().Save(notice); } return count; } catch (Exception ex) { throw ex; } } #endregion #region 提交 /// /// 提交 /// /// 信息 /// 插入行数 public int UpdateSupportInteraction(SupportInteraction model) { try { SupportInteractionDAL dal = new SupportInteractionDAL(); model.CreateUser = this.LoginUser.UserID; //获取用户邮箱信息 SupportInteraction userModel = dal.GetUserModel(model); //提交信息更新到数据库中 int count = dal.UpdateSupportInteraction(model, userModel); //提交人不为空时 if (userModel != null && !string.IsNullOrEmpty(userModel.Email)) { //如果提交到的用户邮箱不为空,给用户发送邮件 SentMail(model, userModel.Email); } //基本信息 return count; } catch (Exception ex) { throw ex; } } #endregion #region 发送邮件共通 /// /// 发送邮件共通 /// public void SentMail(SupportInteraction model, string userMail) { if (!string.IsNullOrEmpty(userMail)) { //给提交用户发送邮件提醒 List mailList = new List(); mailList.Add(new OverTimeRemind() { ActionTime = DateTime.Now.ToString(), PDesp = _beforeTitle + model.PTypeName + _afterTitle + _questionNo + _beforeMiddleFinger + model.PSequ + _afterMiddleFinger + _beforeMiddleFinger + DateTime.Now.ToString("yyyy-MM-dd") + _afterMiddleFinger, SDept = model.SDept }); new OverTimeRemindBLL().SentMailToUser(mailList); } } #endregion #region 解决问题 /// /// 解决问题 /// /// 信息 /// 插入行数 public int SloveSupportInteraction(SupportInteraction model) { try { SupportInteractionDAL dal = new SupportInteractionDAL(); model.CreateUser = this.LoginUser.UserID; model.CDate = DateTime.Now; TimeSpan ts = DateTime.Now - model.CreateDate; decimal hours = Convert.ToDecimal(ts.TotalHours); model.SDays = hours / 24; if (!string.IsNullOrEmpty(model.Refer)) { model.IsRefer = "1"; } //设置处理人员为当前用户 model.SUser = this.LoginUser.UserID; //基本信息 return dal.SloveSupportInteraction(model); } catch (Exception ex) { throw ex; } } #endregion #region 获取问题类型的下拉列表 /// /// 获取列表 /// /// 条件 /// 数据页 /// 数据页 public List GetTypeList() { try { return new SupportInteractionDAL().GetTypeList(); } catch (Exception ex) { throw ex; } } #endregion #region 获取问题解决方法导出的数据 /// /// 获取问题解决方法导出的数据 /// /// 查询条件 /// 数据 public DataTable GetExportData(SupportInteraction entity) { DataTable dt = new DataTable(); try { dt = new SupportInteractionDAL().GetExportData(entity); return dt; } catch (Exception ex) { throw ex; } } #endregion #region 获取问题管理导出的数据 /// /// 获取问题管理导出的数据 /// /// 查询条件 /// 数据 public DataTable GetProblemManageExportData(SupportInteraction entity) { DataTable dt = new DataTable(); try { dt = new SupportInteractionDAL().GetProblemManageExportData(entity, this.LoginUser.UserID, this.LoginUser.OrganID); return dt; } catch (Exception ex) { throw ex; } } #endregion #region 判断选中的问题是否已经关闭 /// /// 判断选中的问题是否已经关闭 /// /// 查询条件 /// 数据 public bool CheckProblemClosed(SupportInteraction entity) { bool retBool = false; try { SupportInteraction model = new SupportInteractionDAL().Get(entity); if ("1".Equals(model.Ecind)) { retBool = true; } return retBool; } catch (Exception ex) { throw ex; } } #endregion #region 校验选中问题的处理部门是否为当前用户部门 /// /// 校验选中问题的处理部门是否为当前用户部门 /// /// 查询条件 /// 数据 public bool CheckProblemDept(SupportInteraction entity) { bool retBool = false; try { SupportInteraction model = new SupportInteractionDAL().Get(entity); if (model.SDept == this.LoginUser.OrganID) { retBool = true; } return retBool; } catch (Exception ex) { throw ex; } } #endregion #region 校验选中问题的处理人是否为当前用户 /// /// 校验选中问题的处理人是否为当前用户 /// /// 查询条件 /// 数据 public bool CheckProblemUser(SupportInteraction entity) { bool retBool = false; try { SupportInteraction model = new SupportInteractionDAL().Get(entity); //处理人为当前用户或者处理人为空时.可以处理当前部门的问题 if (model.SUser == this.LoginUser.UserID || string.IsNullOrEmpty(model.SUser)) { retBool = true; } return retBool; } catch (Exception ex) { throw ex; } } #endregion #region 获取处理记录列表 /// /// 获取处理记录列表 /// /// 条件 /// 数据页 /// 数据页 public DataPage GetSIDealList(ZPDealInfo condition, DataPage page) { try { return new SupportInteractionDAL().GetSIDealList(condition, page); } catch (Exception ex) { throw ex; } } #endregion #region 获取当前用户的处理机构 /// /// 获取当前用户的处理机构 /// /// public List GetCurrentHandleOrga(ZPFlow entity) { SupportInteractionDAL dal = new SupportInteractionDAL(); List zpList = null; //判断用户的机构是否在级流程中 if (dal.CheckCurrentUserInFlowLevel("1" , this.LoginUser.OrganID) >0) { //查询二级机构的列表 zpList = dal.GetNextFlowLevel("2"); } else { //查询所有列表 zpList = dal.GetAllFlowLevel(); } return zpList; } #endregion } }