/// <summary> /// 取得技能證書 /// </summary> /// <param name="filePath"></param> /// <returns></returns> public ActionResult GetLicense(string filePath) { try { var url = ServerProfile.GetInstance().LICENSE_PATH; var fullPath = url + filePath; if (!System.IO.File.Exists(fullPath)) { fullPath = ServerProfile.GetInstance().NON_FILE_PATH; } if (string.IsNullOrEmpty(fullPath)) { throw new NullReferenceException($"no find data"); } return(File(fullPath, fullPath.GetContentType())); } catch (Exception ex) { _logger.Error(ex.Message); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
public HttpResponseMessage SaveLogHQ() { try { HttpMultipartParser.MultipartFormDataParser parser = new HttpMultipartParser.MultipartFormDataParser(HttpContext.Current.Request.InputStream); var Files = parser.Files; var user = ((PtcIdentity)this.User.Identity).currentUser; string url = ServerProfile.GetInstance().LOG_PATH; if (Files == null || Files.Count() == 0) { throw new ArgumentNullException($"[ERROR]=>上傳LOG FILE時,並未給入檔案"); } foreach (var file in Files) { string fullPath = $"{url}/{user.CompCd}/{user.RoleId}/{user.UserId}/"; FileUtil.Save(fullPath, file.Name, file.Data); } } catch (Exception ex) { _logger.Error(ex.Message); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"{ ex.GetType().Name}:message:{ex.Message}")); } return(Request.CreateResponse( HttpStatusCode.OK, new JsonResult <Boolean>(true, "上傳LOG FILE成功", 1, true))); }
public HttpResponseMessage GetSticker(string filePath) { //頭貼路徑 var path = ServerProfile.GetInstance().STICKER_PATH; //完整路徑 var img = Image.FromFile(path + filePath); using (MemoryStream ms = new MemoryStream()) { img.Save(ms, System.Drawing.Imaging.ImageFormat.Png); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new ByteArrayContent(ms.ToArray()); result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png"); result.Headers.CacheControl = new CacheControlHeaderValue() { NoStore = true, NoCache = true, MustRevalidate = true }; img.Dispose(); ms.Dispose(); return(result); } }
public HttpResponseMessage GetcompressionCallog(string filePath) { //頭貼路徑 var path = ServerProfile.GetInstance().CALLOG_PATH; //完整路徑 var img = Image.FromFile(path + filePath); Bitmap bit = new Bitmap(img, 100, 150); using (MemoryStream ms = new MemoryStream()) { bit.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new ByteArrayContent(ms.ToArray()); result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/Jpeg"); result.Headers.CacheControl = new CacheControlHeaderValue() { NoStore = true, NoCache = true, MustRevalidate = true }; img.Dispose(); ms.Dispose(); return(result); } }
public HttpResponseMessage CheckVersion(string Version) { try { string NowVersion = ServerProfile.GetInstance().VendorVesion; string NowVersionNew = ServerProfile.GetInstance().VendorVesionNew; if (Version != NowVersion && Version != NowVersionNew) { _logger.Error("版本不正確,登入者的廠商APP版本:" + Version); return(Request.CreateResponse( HttpStatusCode.OK, new JsonResult <Boolean>(false, "版本不正確", 0, false))); } else { return(Request.CreateResponse( HttpStatusCode.OK, new JsonResult <Boolean>(true, "版本正確", 1, true))); } } catch (Exception ex) { _logger.Error(ex.Message + ",登入者的廠商APP版本:" + Version); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"{ ex.GetType().Name}:Message:{ex.Message}")); } }
public ActionResult ResetPasswordConfirmation() { if (ServerProfile.GetInstance().Debugger == "0") { return(View()); } else { Response.Redirect(ServerProfile.GetInstance().WebFormUrl, false); return(null); } }
public ActionResult Login(string returnUrl) { ViewBag.ReturnUrl = returnUrl; if (ServerProfile.GetInstance().Debugger == "0") { return(View()); } else { Response.Redirect(ServerProfile.GetInstance().WebFormUrl, false); return(null); } }
//[ValidateAntiForgeryToken] public ActionResult LogOff() { MvcSiteMapProvider.SiteMaps.ReleaseSiteMap(); Ptc.AspnetMvc.Util.Cache.Clear(); AuthenticationManager.SignOut(); if (ServerProfile.GetInstance().Debugger == "0") { return(RedirectToAction("Index", "Home")); } else { Response.Redirect(ServerProfile.GetInstance().WebFormUrl, false); return(null); } }
public TechnicianService(ISystemLog Logger, ITechnicianProvider TechnicianProvider, IBaseRepository <DataBase.TUSRMST, Tusrmst> tusrstRepo, IBaseRepository <DataBase.TTechnicianGroup, TtechnicianGroup> TechnicianGroupRepo, IBaseRepository <DataBase.TVenderTechnician, TvenderTechnician> TechnicianRepo) { this._tusrstRepo = tusrstRepo; this._logger = Logger; this._technicianRepo = TechnicianRepo; this._technicianProvider = TechnicianProvider; this._technicianGroupRepo = TechnicianGroupRepo; this._stickerPath = ServerProfile.GetInstance().STICKER_PATH; this._technicianPath = ServerProfile.GetInstance().TECHNICIAN_PATH; this._license = ServerProfile.GetInstance().LICENSE_PATH; }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (MethodHelper.IsNullOrEmpty(model.User_Id, model.Password, model.CompCd)) { ModelState.AddModelError("", "請輸入帳號密碼。"); if (ServerProfile.GetInstance().Debugger == "0") { return(View()); } else { Response.Redirect(ServerProfile.GetInstance().WebFormUrl, false); return(null); } } var jsonUserInfo = JsonConvert.SerializeObject(new UserBase() { CompCd = model.CompCd, UserId = model.User_Id }); //var test = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(model.Password, "md5"); //轉成MD5 var md5Password = Identity.ClearPassword.GetMd5Hash(model.Password).ToUpper(); var user = await UserManager.FindAsync(jsonUserInfo, md5Password); if (user == null) { ModelState.AddModelError("", "使用者帳號或密碼無效。"); if (ServerProfile.GetInstance().Debugger == "0") { return(View()); } else { Response.Redirect(ServerProfile.GetInstance().WebFormUrl, false); return(null); } } await SignInAsync(user, model.RememberMe); return(RedirectToAction("Index", "Technician")); }
public HttpResponseMessage GetCallog(string CompCd, string Sn, byte Seq) { //頭貼路徑 var path = ServerProfile.GetInstance().CALLOG_PATH; var con = new Conditions <DataBase.TCALIMG>(); con.And(x => x.Comp_Cd == CompCd && //公司別 x.Sn == Sn && //叫修案件 x.Seq == Seq); //序號 Tcalimg callog = _callogImg.Get(con); // Convert Base64 String to byte[] byte[] imageBytes = callog.CallImage; MemoryStream msImg = new MemoryStream(imageBytes, 0, imageBytes.Length); // Convert byte[] to Image msImg.Write(imageBytes, 0, imageBytes.Length); Image image = Image.FromStream(msImg, true); //完整路徑 // var img = Image.FromFile("data:image/png;base64," + Convert.ToBase64String(callog.CallImage )); using (MemoryStream ms = new MemoryStream()) { image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new ByteArrayContent(ms.ToArray()); result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png"); result.Headers.CacheControl = new CacheControlHeaderValue() { NoStore = true, NoCache = true, MustRevalidate = true }; image.Dispose(); image.Dispose(); return(result); } }
public CallogService(ISystemLog Logger, ICallogFactory CallogFactory, IVendorFactory VendorFactory, IPushFactory NotifyFactory, ITechnicianProvider TechnicianProvider, IImgRepository ImgRepo, IBaseRepository <DataBase.TCMPDAT, Tcmpdat> CompRepo, IBaseRepository <DataBase.TVENDER, Tvender> VenderRepo, IBaseRepository <DataBase.TCALLOG, Tcallog> CallogRepo, IBaseRepository <DataBase.TVenderTechnician, TvenderTechnician> TechnicianRepo, IBaseRepository <DataBase.TVNDZO, Tvndzo> vndzoRepo, IBaseRepository <DataBase.TZOCODE, Tzocode> zocodeRepo, IBaseRepository <DataBase.TTechnicianGroup, TtechnicianGroup> technicianGroupRepo, IBaseRepository <DataBase.TTechnicianGroupClaims, TtechnicianGroupClaims> technicianGroupClaimsRepo, IBaseRepository <DataBase.TCallogCourse, TCallogCourse> CallogCourseRepo, IBaseRepository <DataBase.TSTRMST, Tstrmst> storeRepo, IBaseRepository <DataBase.TCallLogDateRecord, TCallLogDateRecord> DateRecordRepo, IBaseRepository <DataBase.TCALINV, TCALINV> CALINVRepo, IMailFactory MailFactory) : base(Logger, CallogRepo, CompRepo, VenderRepo, TechnicianRepo) { _logger = Logger; _callogRepo = CallogRepo; _vendorFactory = VendorFactory; _venderRepo = VenderRepo; _notifyFactory = NotifyFactory; _callogFactory = CallogFactory; _technicianRepo = TechnicianRepo; _technicianProvider = TechnicianProvider; _url = ServerProfile.GetInstance().CALLOG_PATH; _vndzoRepo = vndzoRepo; _zocodeRepo = zocodeRepo; _technicianGroupRepo = technicianGroupRepo; _technicianGroupClaimsRepo = technicianGroupClaimsRepo; _ImgRepo = ImgRepo; _CallogCourseRepo = CallogCourseRepo; _storeRepo = storeRepo; _MailFactory = MailFactory; DateRecordRepo = _DateRecordRepo; _CALINVRepo = CALINVRepo; }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new AspNet.Identity.IdentityUser() { UserName = model.Email, Email = model.Email }; IdentityResult result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInAsync(user, isPersistent : false); // 如需如何启用帐户确认和密码重设的详细信息,请造访 http://go.microsoft.com/fwlink/?LinkID=320771 // 传送包含此链接的电子邮件 // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "确认您的账户", "请单击此连结确认您的账户 <a href=\"" + callbackUrl + "\">这里</a>"); if (ServerProfile.GetInstance().Debugger == "0") { return(RedirectToAction("Index", "Home")); } else { Response.Redirect(ServerProfile.GetInstance().WebFormUrl, false); return(null); } } else { AddErrors(result); } } // 如果執行到這裡,發生某項失敗,則重新顯示表單 return(View(model)); }
public CallogDetailApiViewModel() { this._localPath = ServerProfile.GetInstance().LOCAL_API_SITE; }
public TechnicianListDetailViewModel() { this._localPath = ServerProfile.GetInstance().LOCAL_SITE; }
/// <summary> /// 多案件、單一技師指派 /// </summary> /// <param name="user"></param> /// <param name="Sn"></param> /// <param name="Account"></param> /// <returns>從Web進行指派</returns> public Boolean NotificationForAppoint(UserBase user, List <string> Sn, List <string> Account) { _logger.Info("更新技師待受理案件(網頁指派案件)"); DateTime now = DateTime.Now; using (TransactionScope scope = new TransactionScope()) { _logger.Info($"案件認養/指派-準備更新資料"); Sn.ForEach(sn => { int DataCount; #region 移除案件與技師關聯 using (TransactionScope tss = new TransactionScope(TransactionScopeOption.RequiresNew)) { DataCount = _technicianProvider.GetCallLogClaimsCount(user.CompCd, sn); _logger.Info($"移除案件與技師關聯[前],CallLogClaims關聯資料筆數 :{DataCount}, 查詢條件-公司別:{user.CompCd}、案件編號:{sn}"); _logger.Info($"案件認養/指派-準備移除案件與技師關聯,公司別:{user.CompCd}、案件編號:{sn}"); _technicianProvider.RemoveAwaitAcceptLog(user.CompCd, sn); tss.Complete(); } #endregion using (TransactionScope tss = new TransactionScope(TransactionScopeOption.Suppress)) { DataCount = _technicianProvider.GetCallLogClaimsCount(user.CompCd, sn); _logger.Info($"移除案件與技師關聯[後],CallLogClaims關聯資料筆數 :{DataCount}, 查詢條件-公司別:{user.CompCd}、案件編號:{sn}"); } if (DataCount != 0) { string Mail = ServerProfile.GetInstance().Mail; string[] MailList = Mail.Split(';'); _MailFactory.Excute(new MailRequest( MailList, "移除案件與技師關聯失敗", $"認養或指派時,刪除技師與案件關聯失敗,案件編號:{sn}" )); throw new Exception($"[ERROR]=>案件編號:{sn},技師認養案件時,認養失敗"); } else { #region 更新資料 //取得案件 Tcallog callog = base.GetCallog(user.CompCd, sn); TacceptedLog tacceptedLog = new TacceptedLog() { Account = Account[0].ToString(), Sn = sn, RcvDatetime = now, RcvRemark = "no defind", Name = Account[2].ToString(), }; callog.TacceptedLog = tacceptedLog; callog.TimePoint = (int)TimePoint.Accepted; if (!_callogFactory.TechnicianAccept(callog)) { throw new Exception("[ERROR]=>技師認養案件時,認養失敗"); } #endregion } #region 新增案件歷程 Conditions <DataBase.TCallogCourse> Con = new Conditions <DataBase.TCallogCourse>(); TCallogCourse course = new TCallogCourse() { CompCd = user.CompCd, Sn = sn, Assignor = user.UserName, Admissibility = Account[2].ToString(), Datetime = now }; //新增案件歷程 _CallogCourseRepo.Insert(Con, course); #endregion }); scope.Complete(); } #region 推播 var bo = _notifyFactory.Exucte( new JPushRequest(user.CompCd, user.VenderCd) { Content = "您有新案件待銷案", Title = "認養案件", Extras = new Dictionary <string, string>() { { "FeatureName", "VenderConfirm" } } } , Sn , Account); #endregion return(true); }
public async Task <ActionResult> LoginByToken(string tokenBase64, string returnUrl) { //轉成LoginViewModel LoginViewModel model = new LoginViewModel(); string token = System.Text.Encoding.GetEncoding("utf-8").GetString(Convert.FromBase64String(tokenBase64)); //驗證結果 var isSuccess = TokenUtility.Validate(token); if (!isSuccess) { ModelState.AddModelError("", "TOKEN驗證異常"); if (ServerProfile.GetInstance().Debugger == "0") { return(RedirectToAction("Index", "Home")); } else { Response.Redirect(ServerProfile.GetInstance().WebFormUrl, false); return(null); } } //取得內容 var tokenString = TokenUtility.GetTokenValue(token); if (string.IsNullOrEmpty(tokenString)) { ModelState.AddModelError("", "TOKEN 取得內容異常"); if (ServerProfile.GetInstance().Debugger == "0") { return(RedirectToAction("Index", "Home")); } else { Response.Redirect(ServerProfile.GetInstance().WebFormUrl, false); return(null); } } var tokenArray = tokenString.Split('@'); model.User_Id = tokenArray[0]; model.Password = tokenArray[2]; model.CompCd = tokenArray[1]; if (MethodHelper.IsNullOrEmpty(model.User_Id, model.CompCd)) { ModelState.AddModelError("", "解析內容異常"); } //轉成json var jsonUserInfo = JsonConvert.SerializeObject(new UserBase() { CompCd = model.CompCd, UserId = model.User_Id }); var user = await UserManager.FindAsync(jsonUserInfo, model.Password); if (user == null) { ModelState.AddModelError("", "使用者帳號或密碼無效。"); if (ServerProfile.GetInstance().Debugger == "0") { return(RedirectToAction("Index", "Home")); } else { Response.Redirect(ServerProfile.GetInstance().WebFormUrl, false); return(null); } } await SignInAsync(user, model.RememberMe); return(RedirectToLocal(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath + returnUrl)); }
/// <summary> /// 技師認養案件/廠商指派案件 /// </summary> /// <param name="log">畫面上選擇的案件</param> /// <param name="account">登入的技師/廠商選取的技師</param> /// <returns></returns> public Boolean TechnicianAccept(Tcallog log, string account, Boolean isVndAssign, string username) { _logger.Info($"案件認養/指派-公司別:{log.CompCd},案件編號:{log.Sn}"); #region 驗證與取得資訊 //取得案件 Tcallog callog = base.GetCallog(log.CompCd, log.Sn); if (callog.TacceptedLog != null) { throw new IndexOutOfRangeException($"案件已由{callog.TacceptedLog.Name}認養"); } //如果已經銷案不允許再指通知了 if (callog.CloseSts > (byte)CloseSts.process) { throw new IndexOutOfRangeException($"此案件已銷案"); } //取得技師 TvenderTechnician technician = base.GetTechnician(log.CompCd, account); _logger.Info($"案件認養/指派-公司別:{callog.CompCd}"); _logger.Info($"案件認養/指派-廠商別:{callog.VenderCd}"); _logger.Info($"案件認養/指派-技師代號:{technician.Account}"); #endregion #region 組合物件 DateTime now = DateTime.Now; TacceptedLog tacceptedLog = new TacceptedLog() { Account = technician.Account, Sn = callog.Sn, RcvDatetime = now, RcvRemark = "no defind", Name = technician.Name, }; callog.TacceptedLog = tacceptedLog; callog.TimePoint = (int)TimePoint.Accepted; #endregion using (TransactionScope scope = new TransactionScope()) { _logger.Info($"案件認養/指派-準備更新資料"); #region 技師認養 if (!_callogFactory.TechnicianAccept(callog)) { throw new Exception("[ERROR]=>技師認養案件時,認養失敗"); } #endregion _logger.Info($"案件認養/指派-移除案件與技師關聯"); #region 移除案件與技師關聯 //bool bo = _technicianProvider.RemoveAwaitAcceptLog(log.CompCd, log.Sn); //if (bo == false) //{ // string Mail = ServerProfile.GetInstance().Mail; // string[] MailList = Mail.Split(';'); // _MailFactory.Excute(new MailRequest( // MailList, // "移除案件與技師關聯失敗", // $"認養或指派時,刪除技師與案件關聯失敗,案件編號:{log.Sn}" // )); // throw new Exception("[ERROR]=>技師認養案件時,認養失敗"); //} int DataCount; using (TransactionScope tss = new TransactionScope(TransactionScopeOption.RequiresNew)) { DataCount = _technicianProvider.GetCallLogClaimsCount(log.CompCd, log.Sn); _logger.Info($"移除案件與技師關聯[前],CallLogClaims關聯資料筆數 :{DataCount}, 查詢條件-公司別:{log.CompCd}、案件編號:{log.Sn}"); _logger.Info($"案件認養/指派-準備移除案件與技師關聯,公司別:{log.CompCd}、案件編號:{log.Sn}"); _technicianProvider.RemoveAwaitAcceptLog(log.CompCd, log.Sn); tss.Complete(); } using (TransactionScope tss = new TransactionScope(TransactionScopeOption.Suppress)) { DataCount = _technicianProvider.GetCallLogClaimsCount(log.CompCd, log.Sn); _logger.Info($"移除案件與技師關聯[後],CallLogClaims關聯資料筆數 :{DataCount}, 查詢條件-公司別:{log.CompCd}、案件編號:{log.Sn}"); } if (DataCount != 0) { string Mail = ServerProfile.GetInstance().Mail; string[] MailList = Mail.Split(';'); _MailFactory.Excute(new MailRequest( MailList, "移除案件與技師關聯失敗", $"認養或指派時,刪除技師與案件關聯失敗,案件編號:{log.Sn}" )); throw new Exception($"[ERROR]=>案件編號:{log.Sn},技師認養案件時,認養失敗"); } #endregion scope.Complete(); } #region 推播訊息 string Assignor = ""; if (isVndAssign) //由廠商指派的才需要推播 { _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" } } }); Assignor = username; } else { Assignor = technician.Name; } var Con = new Conditions <DataBase.TCallogCourse>(); TCallogCourse course = new TCallogCourse() { CompCd = log.CompCd, Sn = log.Sn, Assignor = Assignor, Admissibility = technician.Name, Datetime = now }; //新增案件歷程 _CallogCourseRepo.Insert(Con, course); #endregion return(true); }
public ActionResult Register() { //return View(); Response.Redirect(ServerProfile.GetInstance().WebFormUrl, false); return(null); }