private bool uploadfile(HttpPostedFileBase FileUpload, string idInv, string Pattern, string SerialNo, string NoInv, Company currentCom, string resultLauncher, out string mess) { try { if (FileUpload != null) { bool check = false; //get adjustid string[] listResultLaunchera = resultLauncher.Split(';'); string[] listResultLauncherb = listResultLaunchera[2].ToString().Split('_'); IInvoiceService IInvSrv = InvServiceFactory.GetService(Pattern, currentCom.id); IInvoice invoiceNew = IInvSrv.GetByNo(currentCom.id, Pattern, listResultLaunchera[1].ToString(), Convert.ToDecimal(Convert.ToInt32(listResultLauncherb[1].ToString().Replace(',', ' ')))); int idadjust = (from a in IoC.Resolve <IAdjustInvService>().Query where a.InvId == Convert.ToInt32(idInv) && a.AdjustInvId == invoiceNew.id select a.id).SingleOrDefault(); //end RecordsInv tbRecordsInv = IoC.Resolve <IRecordsInvService>().Query.Where(idAdjust => idAdjust.id == Convert.ToInt32(idadjust)).FirstOrDefault(); IRecordsInvService _SvcRecordsInv = IoC.Resolve <IRecordsInvService>(); string strPath = ""; string strFullPath = ""; string fileext = (Path.GetExtension(FileUpload.FileName).Length > 1) ? Path.GetExtension(FileUpload.FileName).Substring(1) : ""; if (fileext.ToLower() != "docx" && fileext.ToLower() != "pdf" && fileext.ToLower() != "doc") { mess = "File biên bản hủy đính kèm không đúng định dạng !"; return(check); } strPath = @"\RecordsInv\" + currentCom.id + @"\" + Pattern.Replace("/", "") + @"\" + SerialNo.Replace("/", "") + "_" + NoInv + "." + fileext; strFullPath = GetFullPathRecordsCancel(strPath); if (!string.IsNullOrEmpty(strFullPath)) { tbRecordsInv.InvPattern = Pattern; tbRecordsInv.Path = strPath; } _SvcRecordsInv.Update(tbRecordsInv); _SvcRecordsInv.CommitTran(); if (!string.IsNullOrEmpty(strFullPath)) { FileUpload.SaveAs(strFullPath); mess = "Upload biên bản thành công"; } else { mess = "Không upload biên bản thành công!"; } return(true); } else { mess = "Không tồn tại file update!"; return(false); } } catch (Exception ex) { mess = string.Format("Attach file RecordCancel: Pattern={0}, Serial={1}, NoInv={2}, Exception:{3}", Pattern, SerialNo, NoInv, ex.ToString()); return(false); } }
public AdJustController() { _adjustInvSrv = IoC.Resolve <IAdjustInvService>(); _recordsCancelSrv = IoC.Resolve <IRecordsInvService>(); }