private string SaveTempFile() { FileService fileService = new FileService(); TranFileInfo file = new TranFileInfo() { CompanyInfo = string.Empty, Id = Guid.NewGuid().ToString(), UserInfo = WebSecurity.CurrentUserName, UploadStartDate = DateTime.Now }; string fileSavePath = string.Empty; if (HttpContext.Current.Request.Files.AllKeys.Any()) { var httpPostedFile = HttpContext.Current.Request.Files["UploadedFile"]; if (httpPostedFile != null) { fileSavePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format(@"data\tmp\{0}_{1}_{2}.csv", httpPostedFile.FileName, Guid.NewGuid(), DateTime.Now.ToString("dd.MM.yyyy"))); httpPostedFile.SaveAs(fileSavePath); file.Path = fileSavePath; file.UploadEndDate = DateTime.Now; file.UploadTime = file.UploadEndDate - file.UploadStartDate; fileService.Create(file); } } return file.Id; }
private TranFileInfo SaveTempFile(string tranType) { FileService fileService = new FileService(); TranFileInfo file = new TranFileInfo() { CompanyInfo = string.Empty, Id = Guid.NewGuid().ToString(), UserInfo = WebSecurity.CurrentUserName, UploadStartDate = DateTime.Now }; string fileSavePath = string.Empty; if (HttpContext.Current.Request.Files.AllKeys.Any()) { var httpPostedFile = HttpContext.Current.Request.Files["upload"]; if (httpPostedFile != null) { var processor = TransactionHelper.GetDynamicTransactionProcessor(tranType); string tableName = processor.UploadFile(tranType, httpPostedFile.InputStream, file.Id); file.FileName = httpPostedFile.FileName; file.Path = fileSavePath; file.UploadEndDate = DateTime.Now; file.UploadTime = file.UploadEndDate - file.UploadStartDate; file.ContentLocation = FileContentLocation.TempTable; file.TempTableName = tableName; file.TransactionType = tranType; fileService.Create(file); } } return file; }