/// <summary> /// 取得資料範圍 /// </summary> /// <param name="Data"></param> public override void GetDataAuth(ref UserBase Data) { if (!IsMatch(Data)) { _iterator.GetDataAuth(ref Data); return; } UserBase temp = Data; var con = new Conditions <DataBase.TCMPDAT>(); //關聯區域底下的門市 //con.Include(x => x.TSTRMST); ////關聯所屬公司 //con.Include(x => x.TCMPDAT.TVENDER); //對應公司別 con.And(x => x.Comp_Cd == temp.CompCd); //取得區域清單(所屬權限) Tcmpdat range = _compRepo.Get(con); Data.CompShort = range?.CompShort; }
/// <summary> /// 取得資料範圍 /// </summary> /// <param name="Data"></param> public override void GetDataAuth(ref UserBase Data) { if (!IsMatch(Data)) { throw new Exception($"此角色無法使用該功能!"); } UserBase temp = Data; var conVnd = new Conditions <DataBase.TVENDER>(); //關聯所屬公司 //con.Include(x => x.TCMPDAT); //廠商別 conVnd.And(x => x.Vender_Cd == temp.UserId); //公司別 conVnd.And(x => x.Comp_Cd == temp.CompCd); ////廠商到期日 //con.And(x => x.Close_Date >= DateTime.Now); Tvender range = _vendorRepo.Get(conVnd); Data.VenderName = range?.VenderName; if (range == null) { throw new Exception("廠商主檔 查無資料"); } var conComp = new Conditions <DataBase.TCMPDAT>(); conComp.And(x => x.Comp_Cd == range.CompCd); Tcmpdat Comp = _cmpdatRepo.Get(conComp); Data.CompShort = Comp?.CompShort; var datarange = new DataRange(); var vendorcd = new List <string>() { range?.VenderCd }; datarange.VendorCd = vendorcd; Data.DataRange = datarange; }
/// <summary> /// 取得公司資訊 /// </summary> /// <param name="compCd"></param> /// <returns></returns> public virtual Tcmpdat GetComp(string compCd) { if (String.IsNullOrEmpty(compCd)) { throw new ArgumentNullException($"[ERROR]=>取得公司資訊時,並沒有給入公司代號"); } var con = new Conditions <DataBase.TCMPDAT>(); con.And(x => x.Comp_Cd == compCd); Tcmpdat data = _compRepo.Get(con); if (data == null) { throw new NullReferenceException($"[ERROR]=>找不到對應的公司資訊,公司編號:{compCd}"); } return(data); }
/// <summary> /// 廠商改派案件 /// </summary> /// <param name="log">畫面上選擇的案件</param> /// <param name="account">廠商選擇的技師帳號</param> /// <returns></returns> public Boolean VendorChangeLog(Tcallog log, string account, string username) { _logger.Info($"案件改派-公司別:{log.CompCd},案件編號:{log.Sn}"); #region 驗證與取得資訊 //取得案件 Tcallog callog = base.GetCallog(log.CompCd, log.Sn); //取得原來的受理技師帳號,並記錄 if (callog.TacceptedLog == null) { throw new NullReferenceException($"此案件未被認養,因此無法改派"); } //如果已經銷案不允許再指通知了 if (callog.CloseSts > (byte)CloseSts.process) { throw new IndexOutOfRangeException($"此案件已銷案"); } string oldAccount = callog.TacceptedLog.Account; //取得公司 Tcmpdat comp = base.GetComp(log.CompCd); //取得技師 TvenderTechnician technician = base.GetTechnician(log.CompCd, account); _logger.Info($"案件改派-公司別:{callog.CompCd}"); _logger.Info($"案件改派-廠商別:{callog.VenderCd}"); _logger.Info($"案件改派-要被改派的技師代號:{technician.Account}"); _logger.Info($"案件改派-既有的技師代號:{oldAccount}"); #endregion #region 組合物件 DateTime now = DateTime.Now; TacceptedLog tacceptedLog = new TacceptedLog() { Account = technician.Account, Sn = callog.Sn, RcvDatetime = DateTime.Now, RcvRemark = "no defind", Name = technician.Name, }; callog.TacceptedLog = tacceptedLog; #endregion #region 廠商改派 _logger.Info($"案件改派-準備更新資料"); if (!_callogFactory.TechnicianAccept(callog)) { throw new Exception("[ERROR]=>廠商改派案件,改派失敗"); } #endregion #region 推播訊息 _logger.Info($"案件改派-準備通知給帳號:{account}"); string storeName = getStoreName(callog.CompCd, callog.StoreCd); string CallLevel = callog.CallLevel == "1" ? "普通" : "緊急"; _notifyFactory.Exucte(new JPushRequest( callog.CompCd, callog.VenderCd, account) { Sn = callog.Sn, Content = $"您有一筆新案件待銷案,案件編號:{callog.Sn} 店名:{storeName} 叫修等級:{CallLevel}", Title = "廠商改派", Extras = new Dictionary <string, string>() { { "FeatureName", "VenderConfirm" } } }); _logger.Info($"案件改派-準備通知給帳號:{oldAccount}"); _notifyFactory.Exucte(new JPushRequest( callog.CompCd, callog.VenderCd, oldAccount) { Sn = callog.Sn, Content = $"您的案件已經指派給:{ technician.Name},案件編號:{callog.Sn} 店名:{storeName} 叫修等級:{CallLevel}", Title = "廠商改派", Extras = new Dictionary <string, string>() { { "FeatureName", "" } } }); var Con = new Conditions <DataBase.TCallogCourse>(); TCallogCourse course = new TCallogCourse() { CompCd = log.CompCd, Sn = log.Sn, Assignor = username, Admissibility = technician.Name, Datetime = now }; //新增案件歷程 _CallogCourseRepo.Insert(Con, course); #endregion return(true); }
/// <summary> /// 廠商通知技師認養案件 /// </summary> /// <param name="log"></param> /// <param name="accounts"></param> /// <returns></returns> public Boolean VenderNotification(Tcallog log, List <string> accounts) { _logger.Info($"案件通知-公司別:{log.CompCd},案件編號:{log.Sn}"); #region 驗證與取得資訊 //取得案件 Tcallog callog = base.GetCallog(log.CompCd, log.Sn); //如果已經銷案不允許再指通知了 if (callog.CloseSts > (byte)CloseSts.process) { throw new IndexOutOfRangeException($"此案件已銷案"); } if (callog.TacceptedLog != null) { throw new IndexOutOfRangeException($"案件已由{callog.TacceptedLog.Name}認養"); } //取得公司 Tcmpdat comp = base.GetComp(log.CompCd); _logger.Info($"案件通知-公司別:{callog.CompCd}"); _logger.Info($"案件通知-廠商別:{callog.VenderCd}"); #endregion using (TransactionScope scope = new TransactionScope()) { accounts.ForEach(account => { _logger.Info($"準備通知給帳號:{account}"); #region 更新資料 _technicianProvider.AddAwaitAcceptLog(log.CompCd, callog.Sn, account); #endregion #region 推播訊息 string storeName = getStoreName(callog.CompCd, callog.StoreCd); string CallLevel = callog.CallLevel == "1" ? "普通" : "緊急"; _notifyFactory.Exucte(new JPushRequest( callog.CompCd, callog.VenderCd, account) { Sn = callog.Sn, Content = $"您有一筆新案件待認養,案件編號:{callog.Sn} 店名:{storeName} 叫修等級:{CallLevel}", Title = "認養案件", Extras = new Dictionary <string, string>() { { "FeatureName", "VenderAccept" } } }); #endregion }); scope.Complete(); } return(true); }