public EInboxAttachment AddInboxAttachment(DatabaseConnection dbConn, string AttachmentFileName, string AttachmentFullPath) { attachmentFileCount++; string uploadFolder = AppUtils.GetDocumentUploadFolder(dbConn); string relativePath = dbConn.Connection.Database + @"\Inbox\" + InboxID + "_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + "-" + attachmentFileCount + ".hrd"; string destinationFile = System.IO.Path.Combine(uploadFolder, relativePath); System.IO.DirectoryInfo inboxDirectoryInfo = new System.IO.DirectoryInfo(System.IO.Path.GetDirectoryName(destinationFile)); if (!inboxDirectoryInfo.Exists) { inboxDirectoryInfo.Create(); } zip.Compress(System.IO.Path.GetDirectoryName(AttachmentFullPath), System.IO.Path.GetFileName(AttachmentFullPath), destinationFile); System.IO.File.Delete(AttachmentFullPath); EInboxAttachment attachment = new EInboxAttachment(); attachment.InboxID = InboxID; attachment.InboxAttachmentOriginalFileName = AttachmentFileName; attachment.InboxAttachmentStoredFileName = relativePath; attachment.InboxAttachmentIsCompressed = true; attachment.InboxAttachmentSize = new System.IO.FileInfo(destinationFile).Length; EInboxAttachment.db.insert(dbConn, attachment); return(attachment); }
protected void UploadFromInbox(int InboxID) { PageErrors errors = PageErrors.getErrors(db, Page.Master); errors.clear(); if (bankFileCutOffDateTime < currentDateTime) { errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_SAAS_FILE_SUBMIT_AFTER_CUTOFF, new string[] { bankFileCutOffDateTime.ToString("HH:mm") })); return; } HROne.Lib.Entities.EInbox o = new HROne.Lib.Entities.EInbox(); o.InboxID = InboxID; if (HROne.Lib.Entities.EInbox.db.select(dbConn, o)) { if (!o.UserID.Equals(user.UserID)) { Response.Redirect("~/AccessDeny.aspx"); } System.Collections.Generic.List <string> inboxTypeArray = new System.Collections.Generic.List <string>(o.InboxType.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries)); if (inboxTypeArray.Contains(HROne.Lib.Entities.EInbox.INBOX_TYPE_FOR_ECHANNEL) && !inboxTypeArray.Contains(HROne.Lib.Entities.EInbox.INBOX_TYPE_FOR_ECHANNEL_SUBMITTED)) { string uploadFolder = uploadFolder = AppUtils.GetDocumentUploadFolder(dbConn); DBFilter attachmentFilter = new DBFilter(); attachmentFilter.add(new Match("InboxID", o.InboxID)); ArrayList attachmentList = HROne.Lib.Entities.EInboxAttachment.db.select(dbConn, attachmentFilter); HROne.Lib.Entities.EInboxAttachment attachment = (HROne.Lib.Entities.EInboxAttachment)attachmentList[0]; string documentFilePath = attachment.GetDocumentPhysicalPath(dbConn); string transferFilePath = documentFilePath; string strTmpFolder = HROne.Common.Folder.GetOrCreateSessionTempFolder(Session.SessionID).FullName;; //Environment.GetFolderPath(Environment.SpecialFolder.InternetCache); string strTmpFile = System.IO.Path.Combine(strTmpFolder, currentDateTime.ToString("~yyyyMMddHHmmss_") + attachment.InboxAttachmentOriginalFileName); if (attachment.InboxAttachmentIsCompressed) { transferFilePath = attachment.GetExtractedFilePath(dbConn); System.IO.File.Move(transferFilePath, strTmpFile); } else { System.IO.File.Copy(transferFilePath, strTmpFile); } try { UploadToMasterDB(strTmpFile); inboxTypeArray.Add(HROne.Lib.Entities.EInbox.INBOX_TYPE_FOR_ECHANNEL_SUBMITTED); o.InboxType = string.Join("|", inboxTypeArray.ToArray()); HROne.Lib.Entities.EInbox.db.update(dbConn, o); } catch (Exception ex) { System.IO.File.Delete(strTmpFile); errors.addError(ex.Message); } } else { errors.addError("File is already submitted"); } } }