public static string ImportFile(string fileName) { string retVal = string.Empty; string uploadedFilePath = string.Empty; eInvoiceType invoiceType; System.Web.SessionState.HttpSessionState currentSession = HttpContext.Current.Session; //Replace with system defined regular expression if (fileName.ToLower().Contains("hubinv")) { invoiceType = eInvoiceType.PFHubCharge; } else if (fileName.ToLower().Contains("chargeinv")) { invoiceType = eInvoiceType.PFDepotCharge; } else { invoiceType = eInvoiceType.PFSelfBillDeliveryPayment; } //Check to see if the file already exists. Facade.IPalletForceImportPreInvoice facPFImport = new Facade.PreInvoice(); bool fileAlreadyImported = facPFImport.CheckImportedFiles(fileName); if (currentSession[vs_uploadedFilePath] != null && currentSession[vs_userID] != null && !fileAlreadyImported) { #region Import File uploadedFilePath = currentSession[vs_uploadedFilePath].ToString(); if (File.Exists(uploadedFilePath)) { try { currentSession[vs_pfImportedInvoice] = facPFImport.ImportPalletForceInvoice(uploadedFilePath, invoiceType, currentSession[vs_userID].ToString()); retVal = bool.TrueString; } catch (Exception ex) { #region File Removal on Error retVal = FileRemovalOnError(uploadedFilePath, ex); #endregion } } else { retVal = string.Format("{0}|{1}", 4, -1); } #endregion } else { #region Remove and send Error Message if (currentSession[vs_uploadedFilePath] != null) { try { File.Delete(currentSession[vs_uploadedFilePath].ToString()); } catch (Exception ex) { } finally { retVal = fileAlreadyImported ? string.Format("{0}|{1}", 3, -1) : string.Format("{0}|{1}", 2, -1); } } else { retVal = string.Format("{0}|{1}", 2, -1); } StaticResetSessionVaribles(currentSession); #endregion } return(retVal.ToString()); }