private bool getEmailDistributionListSendAttachment(bool isSuccessful, string fileName, string threadName, string desFilePath) { bool success = true; IAPL.Transport.Transactions.ServerDetails emailDetails = new ServerDetails(); IAPL.Transport.Data.DbTransaction db = new IAPL.Transport.Data.DbTransaction(); db.emailDistributionList(false, messageInformation.MessageCode, messageInformation.ERP, 0); System.Data.DataTable dTable = db.CommonDataTable; string emailSMTP = IAPL.Transport.Configuration.Config.GetAppSettingsValue("emailnotificationsmtp", ""); if (dTable != null) { foreach (System.Data.DataRow row in dTable.Rows) { //IAPL.Transport.Configuration.Config.GetAppSettingsValue("emailnotificationsender", "") IAPL.Transport.Operation.Email email = new IAPL.Transport.Operation.Email( IAPL.Transport.Util.CommonTools.ValueToString((Object)row["emldIntEmailAddrFROM"]), IAPL.Transport.Util.CommonTools.ValueToString((Object)row["emldIntEmailAddrTO"]), IAPL.Transport.Util.CommonTools.ValueToString((Object)row["emldIntEmailAddrCC"]), IAPL.Transport.Util.CommonTools.ValueToString((Object)row["emldIntEmailAddrBCC"]), IAPL.Transport.Util.CommonTools.ValueToString((Object)row["emldEmailSubject"]), 2, emailSMTP); string mesgBody = this.readNoticationMessageBody(fileName, isSuccessful, IAPL.Transport.Util.CommonTools.ValueToString((Object)row["emldXSLTPath"])); ArrayList list = new ArrayList(); fileName = this.serverInformation.GetNetworkSourceFile(desFilePath, fileName); list.Add(fileName); // temporarily set to save as TEXT for the sake of testing.... //success = email.Send(true, mesgBody, list); success = email.Send(false, mesgBody, list); if (!success) { this.ErrorMessage = email.ErrorMessage; } //emailDetails.EmailSubject = row["emldEmailSubject"].ToString(); } } else { success = false; } //return emailDetails; return(success); }
public bool POSTXML(string Url, string File, string UserName, string Password, string Terminator) { System.Uri.CheckHostName(Url); bool success = false; try { //Password = Password;//IAPL.Transport.Util.Utility.Decrypt(Password.Trim()); XmlDocument _xmlText = new XmlDocument(); //GERARD FIX File = File.ToLower(); //OLD CODE SR#33117 Ccenriquez -- December 2, 2009 - Fix FITE send to Destination //if (File.Substring(File.LastIndexOf(".") + 1) == "xml") //NEW CODE SR#33117 Ccenriquez -- December 2, 2009 - Fix FITE send to Destination if (File.Substring(File.LastIndexOf(".") + 1).ToLower() == "xml") { _xmlText.Load(File); ServicePointManager.ServerCertificateValidationCallback = AcceptAllCertificatePolicy; System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;//TLS 1.2 COMPLIANCE WebRequest _request = WebRequest.Create((Url)); _request.Credentials = new NetworkCredential(UserName, Password); _request.Method = "POST"; _request.ContentType = "text/xml"; //_request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)"; XmlTextWriter xw = new XmlTextWriter(_request.GetRequestStream(), Encoding.UTF8); _xmlText.WriteTo(xw); xw.Close(); WebResponse rep = _request.GetResponse(); rep.Close(); } success = true; if (success) { IAPL.Transport.Data.DbTransaction DBTrans = new IAPL.Transport.Data.DbTransaction(); DBTrans.UpdateTransactionLog(true, File + "Successfully sent. ", ""); } } catch (Exception ex) { success = false; this.ErrorMessage = "HTTP-Send()|" + ex.Message.ToString(); // } return(success); }
// private bool getEmailDistributionListSendAttachment(bool isSuccessful, string fileName, string threadName, string desFilePath) private bool getIMSEmailDistributionList(int Report, string fileName, string desFilePath, string ThreadName, System.Collections.Hashtable DetailsForIMS, IAPL.Transport.Transactions.MessageDetails mDetails) { bool success = true; IAPL.Transport.Transactions.ServerDetails emailDetails = new ServerDetails(); IAPL.Transport.Data.DbTransaction db = new IAPL.Transport.Data.DbTransaction(); db.emailDistributionList(true, mDetails.MessageCode, mDetails.ERP, Report); System.Data.DataTable dTable = db.CommonDataTable; string emailSMTP = IAPL.Transport.Configuration.Config.GetAppSettingsValue("emailnotificationsmtp", ""); if (dTable != null) { foreach (System.Data.DataRow row in dTable.Rows) { IAPL.Transport.Operation.Email email = new IAPL.Transport.Operation.Email( IAPL.Transport.Util.CommonTools.ValueToString((Object)row["IMSemldIntEmailAddrFROM"]), IAPL.Transport.Util.CommonTools.ValueToString((Object)row["IMSemldIntEmailAddrTO"]), IAPL.Transport.Util.CommonTools.ValueToString((Object)row["IMSemldIntEmailAddrCC"]), IAPL.Transport.Util.CommonTools.ValueToString((Object)row["IMSemldIntEmailAddrBCC"]), IAPL.Transport.Util.CommonTools.ValueToString((Object)row["IMSemldEmailSubject"]), 2, emailSMTP); string mesgBody = this.IMSreadNoticationMessageBody(Report, success, IAPL.Transport.Util.CommonTools.ValueToString((Object)row["IMSemldXSLTPath"]), DetailsForIMS, mDetails.IMSBatchRun); // Email this! //success = email.Send(true, mesgBody, list); success = email.Send(false, mesgBody, null); if (!success) { this.ErrorMessage = email.ErrorMessage; } } } else { success = false; } //return emailDetails; return(success); }
private bool DeleteHTTPProcess(HTTPProcessObject _httpBO) { bool _ret = true; try { Data.DbTransaction _getDB = new IAPL.Transport.Data.DbTransaction(); _getDB.DeleteHTTPProcess(_httpBO.TradingCode, _httpBO.MessageCode, _httpBO.Principal, _httpBO.SupplierID, _httpBO.FileName); Util.Utility.DeleteFile(_httpBO.path); } catch (Exception ex) { string a = ex.Message; _ret = false; } return(_ret); }
// Update the Convention Counter in the database public static bool UpdateFilenameConventionCounter(string MsgCode, string MsgCounter) { bool success = true; try { IAPL.Transport.Data.DbTransaction db = new IAPL.Transport.Data.DbTransaction(); System.Collections.Hashtable fldList = new System.Collections.Hashtable(); fldList = new System.Collections.Hashtable(); fldList.Add("@MsgCode", MsgCode); fldList.Add("@MsgCounter", MsgCounter); db.UpdateMessageCounter(fldList); } catch { success = false; } return(success); }
private void logErrorToDb(string errorMesg) { IAPL.Transport.Data.DbTransaction db = new IAPL.Transport.Data.DbTransaction(); System.Collections.Hashtable hTable2 = new System.Collections.Hashtable(); //hTable2.Add("@apluCode", mesgDetails.ApplicationCode); //hTable2.Add("@PRNCPL", mesgDetails.Principal); //hTable2.Add("@msgCode", mesgDetails.MessageCode); //hTable2.Add("@ERPID", mesgDetails.ERP); hTable2.Add("@apluCode", "FILETRANSFER"); hTable2.Add("@PRNCPL", ""); hTable2.Add("@msgCode", ""); hTable2.Add("@ERPID", ""); hTable2.Add("@prlgCustID", ""); hTable2.Add("@prlgProcessSource", ""); hTable2.Add("@prlgStartDate", DateTime.Now.ToString()); hTable2.Add("@prlgEndDate", DateTime.Now.ToString()); // this should appear on the update method hTable2.Add("@prlgIsSuccess", "0"); // this should appear on the update method hTable2.Add("@prlgDescription", "FILETRANSFER: Ping server - failed."); hTable2.Add("@prlgTechnicalErrDesc", errorMesg); hTable2.Add("@prlgSourceParent", ""); hTable2.Add("@prlgSourceParentCount", "0"); hTable2.Add("@prlgSourceChild", "0"); hTable2.Add("@prlgSourceChildCount", "0"); //log to text file if with error if (!db.LogProcessInfo(hTable2)) { string[] aStr = db.ErrorMessage.Split(new char[] { '|' }); IAPL.Transport.Util.TextLogger.LogError(aStr[0], aStr[1]); IAPL.Transport.Util.TextLogger.LogError("Below are the stored procedure's parameter:", ""); foreach (DictionaryEntry dEntry in hTable2) { IAPL.Transport.Util.TextLogger.LogError("tab", dEntry.Key.ToString() + "-" + dEntry.Value); } IAPL.Transport.Util.TextLogger.LogError("---------------------------------------", "-----------------------"); //success = false; } }
private List <HTTPProcessObject> GetProcessObjects() { Data.DbTransaction _getDB = new IAPL.Transport.Data.DbTransaction(); DataTable _dt = _getDB.GetHTTPProcessOrderByFileNameAndDate(); List <HTTPProcessObject> _listHTPPProcess = new List <HTTPProcessObject>(); for (int i = 0; i < _dt.Rows.Count; i++) { HTTPProcessObject _httpBO = new HTTPProcessObject(); _httpBO = new HTTPProcessObject(); _httpBO.URL = _dt.Rows[i]["URL"].ToString(); _httpBO.path = _dt.Rows[i]["Path"].ToString(); _httpBO.Password = _dt.Rows[i]["Password"].ToString(); _httpBO.SourceFile = _dt.Rows[i]["SourceFile"].ToString(); _httpBO.UserName = _dt.Rows[i]["UserName"].ToString(); _httpBO.TradingCode = _dt.Rows[i]["tradingCode"].ToString(); _httpBO.MessageCode = _dt.Rows[i]["msgCode"].ToString(); _httpBO.Principal = _dt.Rows[i]["Prncpal"].ToString(); _httpBO.SupplierID = _dt.Rows[i]["SupplierID"].ToString(); _httpBO.FileName = _dt.Rows[i]["FileName"].ToString(); _httpBO.Guid = _dt.Rows[i]["GUID"].ToString(); _httpBO.SupplierName = _dt.Rows[i]["suppName"].ToString(); _httpBO.ERP = _dt.Rows[i]["erp"].ToString(); _httpBO.EmailSubject = _dt.Rows[i]["emldEmailSubject"].ToString(); // _httpBO.EmailFrom = _dt.Rows[i]["emldIntEmailAddrFROM"].ToString(); _httpBO.EmailTo = _dt.Rows[i]["emldIntEmailAddrTO"].ToString(); _httpBO.EmailCC = _dt.Rows[i]["emldIntEmailAddrCC"].ToString(); _httpBO.EmailBCC = _dt.Rows[i]["emldIntEmailAddrBCC"].ToString(); _httpBO.EmailEXTTo = _dt.Rows[i]["emldExtEmailAddrTO"].ToString(); _httpBO.EmailEXTCC = _dt.Rows[i]["emldExtEmailAddrCC"].ToString(); _httpBO.EmailXSLTPath = _dt.Rows[i]["emldXSLTPath"].ToString(); _listHTPPProcess.Add(_httpBO); } return(_listHTPPProcess); }
private void CreateProcessLog(MessageDetails msgDetails, string _errMessage) { IAPL.Transport.Data.DbTransaction db = new IAPL.Transport.Data.DbTransaction(); //sourcefilelog table System.Collections.Hashtable hTable = new System.Collections.Hashtable(); hTable.Add("@trdpCode", msgDetails.TradingCode); hTable.Add("@msgCode", msgDetails.MessageCode); hTable.Add("@erpID", msgDetails.ERP); hTable.Add("@sflgIsCountrySetup", "1"); hTable.Add("@sflgFileType", "1"); hTable.Add("@sflgSourceFilename", msgDetails.SourceFile);//srcServerDetails.GetSourceFile()); //hTable.Add("@sflgDestinationFilename", desServerDetails.GetFTPSourceFile(srcServerDetails.GenFileName())); hTable.Add("@sflgDestinationFilename", "N/A"); //msgDetails.SourceFile = msgDetails.SourceFile;//fileName; //msgDetails.SourceFolder = msgDetails.SourceFolder;//srcServerDetails.ServerFolder; //processlog table System.Collections.Hashtable hTable2 = new System.Collections.Hashtable(); hTable2.Add("@apluCode", msgDetails.ApplicationCode); hTable2.Add("@PRNCPL", msgDetails.Principal); hTable2.Add("@msgCode", msgDetails.MessageCode); hTable2.Add("@ERPID", msgDetails.ERP); hTable2.Add("@prlgCustID", ""); hTable2.Add("@prlgProcessSource", ""); msgDetails.StartDate = DateTime.Now.ToString(); msgDetails.EndDate = DateTime.Now.ToString(); hTable2.Add("@prlgStartDate", msgDetails.StartDate); hTable2.Add("@prlgEndDate", msgDetails.EndDate); // this should appear on the update method hTable2.Add("@prlgIsSuccess", "0"); // this should appear on the update method hTable2.Add("@prlgDescription", "REQUEUE SENDING FAILED"); hTable2.Add("@prlgTechnicalErrDesc", _errMessage); hTable2.Add("@prlgSourceParent", ""); hTable2.Add("@prlgSourceParentCount", "0"); hTable2.Add("@prlgSourceChild", "0"); hTable2.Add("@prlgSourceChildCount", "0"); db.InsertTransactionLog(hTable, hTable2); }
private void initServerList() { mainDataSet = new System.Data.DataSet(); IAPL.Transport.Data.DbTransaction db = new IAPL.Transport.Data.DbTransaction(); //get the FTP servers if (db.GetServerList(IAPL.Transport.Util.ConstantVariables.TransmissionMode.FTP, "ftpDetails")) { mainDataSet.Tables.Add(db.CommonDataTable.Copy()); } //get the SFTP servers if (db.GetServerList(IAPL.Transport.Util.ConstantVariables.TransmissionMode.SFTP, "sftpDetails")) { mainDataSet.Tables.Add(db.CommonDataTable.Copy()); } //db.GetFileTransferInfo(); //System.Data.DataTable dTable = db.CommonDataTable; //if (dTable.Rows.Count > 0) { // System.Data.DataRow row = dTable.Rows[0]; // //foreach (System.Data.DataRow row in dTable.Rows) { // mesgDetails = new MessageDetails(row["MsetSourceFileMask"].ToString(), row["MsetBackUpFolder"].ToString()); // mesgDetails.ERP = IAPL.Transport.Util.CommonTools.ValueToString((Object)row["ERP"]); // mesgDetails.Principal = IAPL.Transport.Util.CommonTools.ValueToString((Object)row["PRNCPL"]); // mesgDetails.TradingCode = IAPL.Transport.Util.CommonTools.ValueToString((Object)row["trdpCode"]); // mesgDetails.TradingName = IAPL.Transport.Util.CommonTools.ValueToString((Object)row["trdpName"]); // mesgDetails.MessageCode = IAPL.Transport.Util.CommonTools.ValueToString((Object)row["MsgCode"]); // mesgDetails.ApplicationCode = IAPL.Transport.Util.CommonTools.ValueToString((Object)row["apluCode"]); // //} //} }
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public static bool ProcessIMS(string ThreadName, string IncFolder, System.Collections.Hashtable IMSCompleteCountriesName, System.Collections.Hashtable IMSIncompleteCountriesName, IAPL.Transport.Transactions.MessageDetails mDetails, System.Collections.Hashtable FTPFileFoundSentList, out System.Collections.Hashtable DetailsForIMS) { bool success = true; DetailsForIMS = new System.Collections.Hashtable(); if (mDetails.IndividualProcess.Equals(1)) { IAPL.Transport.IMS.Process.IMSReportDetails IMSDetailsStruct = new IAPL.Transport.IMS.Process.IMSReportDetails(); System.Collections.Hashtable IMSData = new System.Collections.Hashtable(); // Get the country list from the database IAPL.Transport.Data.DbTransaction db = new IAPL.Transport.Data.DbTransaction(); db.GetIMSCountries(IAPL.Transport.Util.ConstantVariables.SP_GetIMSDetails, "IMSCountries"); if (db.ErrorMessage.Trim().Length > 0) { success = false; IAPL.Transport.Util.TextLogger.LogError("MessageTransaction-ProcessIMS()", "Database error: " + db.ErrorMessage); } else { System.Data.DataTable dTable = db.CommonDataTable; if (dTable == null) { success = false; } else { // Set initial value foreach (System.Data.DataRow row in dTable.Rows) { IMSDetailsStruct.CountryCode = IAPL.Transport.Util.CommonTools.ValueToString((Object)row["Code"]); IMSDetailsStruct.Country = IAPL.Transport.Util.CommonTools.ValueToString((Object)row["CountryName"]); IMSDetailsStruct.IMSDataSeq = ""; IMSDetailsStruct.SizeKB = 0; IMSDetailsStruct.DateSent = System.DateTime.Now; IMSDetailsStruct.ERS_Issue = ""; IMSDetailsStruct.IMSSR_Issue = ""; IMSDetailsStruct.CommentResolution = ""; IMSDetailsStruct.DataFileRecvd = ""; IMSDetailsStruct.TransactionDate = ""; IMSDetailsStruct.RecordCount = 0; IMSDetailsStruct.IMSExtractionValue = 0; IMSDetailsStruct.SendStatus = ""; IMSData.Add(IMSDetailsStruct.CountryCode, IMSDetailsStruct); } } // Process CompleteCountriesName foreach (System.Collections.DictionaryEntry file in (System.Collections.Hashtable)IMSCompleteCountriesName) { string filename = file.Value.ToString(); string CountryCode = filename.Substring(0, 3); // ------------- Get Struct inside Hashtable then edit value(s) --------------------- IMSReportDetails IMS = (IMSReportDetails)IMSData[CountryCode.ToUpper()]; // Version No. (both reports) IMS.IMSDataSeq = filename.Substring(3); // File size in KB (both reports) string IMSFolderPath = mDetails.BackupFolder + @"\" + mDetails.IMSFolder; long FileSize = IAPL.Transport.Util.Utility.GetFileSize_Local(IMSFolderPath + @"\" + filename + "." + Process.IMSFileExt); IMS.SizeKB = IAPL.Transport.Util.Utility.ConvertByteToKB(FileSize); // Date Sent (both reports) IMS.DateSent = System.DateTime.Now; // Open file and parse string filereadbuf; string IMSLogfile = IMSFolderPath + @"\" + filename + "." + Process.IMSLogExt; int Size = (int)IAPL.Transport.Util.Utility.GetFileSize_Local(IMSLogfile); char[] buf = new char[Size]; StreamReader sr = new StreamReader(new FileStream(IMSLogfile, FileMode.Open, FileAccess.Read)); int retval = sr.ReadBlock(buf, 0, Size); filereadbuf = new string(buf); sr.Close(); string[] ParsedData = IAPL.Transport.Util.Utility.ParseString(filereadbuf); // Issue (both reports) IMS.ERS_Issue = ParsedData[2].ToString(); IMS.IMSSR_Issue = ParsedData[2].ToString(); // Comment/Resolution (IMS Summary Report) IMS.CommentResolution = ParsedData[3].ToString(); // Data File Received (IMS Summary Report) if (FTPFileFoundSentList[CountryCode] != null) { IMS.DataFileRecvd = "Yes"; } else { IMS.DataFileRecvd = "No File"; } // Transaction Date (IMS Summary Report) IMS.TransactionDate = ParsedData[4].ToString(); // Record Count (IMS Summary Report) IMS.RecordCount = Convert.ToInt32(ParsedData[5].ToString()); // IMS Extraction Value (IMS Summary Report) IMS.IMSExtractionValue = Convert.ToDouble(ParsedData[6].ToString()); // Send Status (Exception Report Summary) if (IMS.ERS_Issue.Equals(string.Empty)) { IMS.SendStatus = "SUCCESS"; } else { IMS.SendStatus = IMS.ERS_Issue; } // ---------------------------------------------------------------------------------- // Update Hashtable with edited value(s) IMSData[CountryCode] = IMS; } } // Temp string fileName = ""; string desFilePath = ""; // Email Exception Report Summary success = PerformEmailProcess(1, fileName, desFilePath, ThreadName, IMSData, mDetails, false); // Email IMS Summary Report success = PerformEmailProcess(2, fileName, desFilePath, ThreadName, IMSData, mDetails, false); // Delete Processed files from database db.DeleteIMSFileProcessed(mDetails.IMSProcessId); if (db.ErrorMessage.Trim().Length > 0) { success = false; IAPL.Transport.Util.TextLogger.LogError("MessageTransaction-DeleteIMSFileProcessed()", "Database error: " + db.ErrorMessage); } else { // Delete Process from Temp table db.DeleteIMSProcess(mDetails.IMSProcessId); if (db.ErrorMessage.Trim().Length > 0) { success = false; IAPL.Transport.Util.TextLogger.LogError("MessageTransaction-DeleteIMSFileProcessed()", "Database error: " + db.ErrorMessage); } } } return(success); }
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // ********************************************************** // Project: ISG12043 // Developer: Alrazen Estrella // Date: Oct. 10, 2008 public static bool IMSSendEmailWhenNoFilesFound(string ThreadName, IAPL.Transport.Transactions.MessageDetails mDetails, bool IMSNoFilesFound) { bool success = true; IAPL.Transport.IMS.Process.IMSReportDetails IMSDetailsStruct = new IAPL.Transport.IMS.Process.IMSReportDetails(); System.Collections.Hashtable IMSData = new System.Collections.Hashtable(); // Get the country list from the database IAPL.Transport.Data.DbTransaction db = new IAPL.Transport.Data.DbTransaction(); db.GetIMSCountries(IAPL.Transport.Util.ConstantVariables.SP_GetIMSDetails, "IMSCountries"); if (db.ErrorMessage.Trim().Length > 0) { success = false; IAPL.Transport.Util.TextLogger.LogError("MessageTransaction-ProcessIMS()", "Database error: " + db.ErrorMessage); } else { System.Data.DataTable dTable = db.CommonDataTable; if (dTable == null) { success = false; } else { // Set initial value foreach (System.Data.DataRow row in dTable.Rows) { IMSDetailsStruct.Country = IAPL.Transport.Util.CommonTools.ValueToString((Object)row["CountryName"]); IMSDetailsStruct.CountryCode = IAPL.Transport.Util.CommonTools.ValueToString((Object)row["Code"]); IMSDetailsStruct.ERS_Issue = "NO FILE RECEIVED"; IMSDetailsStruct.CommentResolution = "NO FILE RECEIVED"; //IMSDetailsStruct.DataFileRecvd = ""; //IMSDetailsStruct.TransactionDate = ""; //IMSDetailsStruct.RecordCount = 0; //IMSDetailsStruct.IMSExtractionValue = 0; IMSData.Add(IMSDetailsStruct.CountryCode, IMSDetailsStruct); } } //Gerard Jan 12 2009 System.Data.DataTable _dt = db.GetLastSendDate(mDetails.MessageCode, mDetails.ERP, mDetails.Principal); IMSMailStatus _mailStatus = new IMSMailStatus(); if (_dt.Rows.Count == 0) { Console.WriteLine("IMSSendEmailWhenNoFilesFound-- Initial Run -- updating tables"); //first run no entries found create an entry db.SaveIMSMailStatus(mDetails.MessageCode, mDetails.Principal, mDetails.ERP); _dt = db.GetLastSendDate(mDetails.MessageCode, mDetails.ERP, mDetails.Principal); //_lastSendDate = Convert.ToDateTime(_dt.Rows[0][0]); _mailStatus.LastSendDate = Convert.ToDateTime(_dt.Rows[0][0]); _mailStatus.MailSent = Convert.ToBoolean(_dt.Rows[0][1]); Console.WriteLine("IMSSendEmailWhenNoFilesFound Mail is being sent. -- Exception Report sent"); //Send both reports //Email Summary Report //success = PerformEmailProcess(1, "", "", ThreadName, IMSData, mDetails, true); // Email Exception Report success = PerformEmailProcess(2, "", "", ThreadName, IMSData, mDetails, true); //Update mail sent db.SaveIMSMailStatus(mDetails.MessageCode, mDetails.Principal, mDetails.ERP); } else { Console.WriteLine("IMSSendEmailWhenNoFilesFound -- Entry Found -- Proceeding with mail send logic."); //entry found _mailStatus.LastSendDate = Convert.ToDateTime(_dt.Rows[0][0]); _mailStatus.MailSent = Convert.ToBoolean(_dt.Rows[0][1]); if (_mailStatus.MailSent == false) { Console.WriteLine("IMSSendEmailWhenNoFilesFound Mail is being sent. -- Exception Report Sent --"); //Send both reports //Email Summary Report //success = PerformEmailProcess(1, "", "", ThreadName, IMSData, mDetails, true); // Email Exception Report Summary success = PerformEmailProcess(2, "", "", ThreadName, IMSData, mDetails, true); //Update mail sent db.SaveIMSMailStatus(mDetails.MessageCode, mDetails.Principal, mDetails.ERP); } else { if (_mailStatus.LastSendDate.ToShortDateString() == DateTime.Now.ToShortDateString()) { //Do Nothing Console.WriteLine("IMSSendEmailWhenNoFilesFound Mail already Sent today"); } else { //update the mail status then send emails. Console.WriteLine("IMSSendEmailWhenNoFilesFound - new day -- updating imsMailStatus and sending Exception Report mail"); //Email Summary Report //success = PerformEmailProcess(1, "", "", ThreadName, IMSData, mDetails, true); // Email Exception Report Summary success = PerformEmailProcess(2, "", "", ThreadName, IMSData, mDetails, true); db.SaveIMSMailStatus(mDetails.MessageCode, mDetails.Principal, mDetails.ERP); } } } //Mail hasn't been sent so send emails // Delete Process from Temp table db.DeleteIMSProcess(mDetails.IMSProcessId); if (db.ErrorMessage.Trim().Length > 0) { success = false; IAPL.Transport.Util.TextLogger.LogError("MessageTransaction-DeleteIMSFileProcessed()", "Database error: " + db.ErrorMessage); } } return(success); }
public bool HTTPSendingFailed(string Msgcode, string Prncpal, string Filename) { Data.DbTransaction _db = new IAPL.Transport.Data.DbTransaction(); return(_db.CheckIFHTTPSendingFailed(Msgcode, Prncpal, Filename)); }
private bool getEmailDistributionListEmailNotification(bool isSuccessful, string fileName, string threadName) { bool success = true; IAPL.Transport.Transactions.ServerDetails emailDetails = new ServerDetails(); IAPL.Transport.Data.DbTransaction db = new IAPL.Transport.Data.DbTransaction(); if (!isSuccessful) { db.emailDistributionList(false, IAPL.Transport.Configuration.Config.GetAppSettingsValue("emailnotificationmessagecode", "TECHNICAL_NOTIFICATION"), IAPL.Transport.Configuration.Config.GetAppSettingsValue("emailnotificationerp", "IAPL"), 0); } else { db.emailDistributionList(false, messageInformation.MessageCode, messageInformation.ERP, 0); } System.Data.DataTable dTable = db.CommonDataTable; string emailSMTP = IAPL.Transport.Configuration.Config.GetAppSettingsValue("emailnotificationsmtp", ""); if (dTable != null) { foreach (System.Data.DataRow row in dTable.Rows) { //IAPL.Transport.Configuration.Config.GetAppSettingsValue("emailnotificationsender", "") IAPL.Transport.Operation.Email email = new IAPL.Transport.Operation.Email( IAPL.Transport.Util.CommonTools.ValueToString((Object)row["emldIntEmailAddrFROM"]), IAPL.Transport.Util.CommonTools.ValueToString((Object)row["emldIntEmailAddrTO"]), IAPL.Transport.Util.CommonTools.ValueToString((Object)row["emldIntEmailAddrCC"]), IAPL.Transport.Util.CommonTools.ValueToString((Object)row["emldIntEmailAddrBCC"]), IAPL.Transport.Util.CommonTools.ValueToString((Object)row["emldEmailSubject"]), 2, emailSMTP); string mesgBody = this.readNoticationMessageBody(fileName, isSuccessful, IAPL.Transport.Util.CommonTools.ValueToString((Object)row["emldXSLTPath"])); ArrayList list = new ArrayList(); //fileName = this.serverInformation.GetNetworkSourceFile(desFilePath, fileName); //list.Add(fileName); IAPL.Transport.Util.TextLogger.LogSetting("EmailContent [Subject: " + email.Subject + "]", mesgBody); //IAPL.Transport.Util.TextLogger.Log("-->EmailContent [Subject: " + email.Subject + "]", mesgBody); success = email.Send(true, mesgBody, list); if (!success) { this.ErrorMessage = email.ErrorMessage + " (" + email.SmtpServer + ")"; } //emailDetails.EmailSubject = row["emldEmailSubject"].ToString(); } } else { success = false; } //return emailDetails; return(success); }
private void TechnicalErrorEmail(string errorMessage, HTTPProcessObject _httpObject) { string technicalError = errorMessage; Data.DbTransaction db = new IAPL.Transport.Data.DbTransaction(); MessageDetails msgDetails = new MessageDetails(); errorMessage = _httpObject.SourceFile + "[\'" + _httpObject.FileName + "\'file has been backup on " + _httpObject.Guid + "folder but failed on transmission to " + _httpObject.URL + " Address!] " + errorMessage; //errorMessage = threadName + " [\'" + fileName + "\' file has been backup on " + msgDetails.BackupFolder + " folder but failed on transmisson to " + //desServerDetails.ServerAddress + " server!] " + errorMessage; IAPL.Transport.Util.TextLogger.Log(IAPL.Transport.Util.TextLogger.messageType.Bulleted, "", errorMessage); // send email notification msgDetails.ProcessLogID = db.GetProcessLogID; msgDetails.TransDescription = "FILETRANSFER - failed."; msgDetails.TechnicalErrorDescription = errorMessage; //emailTrans = new EmailTransaction(msgDetails); msgDetails.ERP = _httpObject.ERP; msgDetails.MessageCode = _httpObject.MessageCode; msgDetails.SupplierName = _httpObject.SupplierName; msgDetails.StartDate = DateTime.Now.ToString(); msgDetails.EndDate = DateTime.Now.ToString(); msgDetails.TechnicalErrorDescription = technicalError; msgDetails.ApplicationCode = "Requeue"; msgDetails.TransDescription = errorMessage; msgDetails.SourceFile = _httpObject.SourceFile; msgDetails.SourceFolder = _httpObject.Guid; msgDetails.Principal = _httpObject.Principal; msgDetails.TradingCode = _httpObject.TradingCode; // //CREATE PROCESSLOG //log to db CreateProcessLog(msgDetails, errorMessage); //db.UpdateTransactionLog(false, "FILETRANSFER - failed.", errorMessage); EmailTransaction emailtrans = new EmailTransaction(msgDetails); emailtrans.DestinationFolder = _httpObject.URL; emailtrans.SourceFile = _httpObject.path; emailtrans.OutputFile = "N/A"; //emailTrans.DestinationFolder = desServerDetails.GetDestinationFolder(desServerDetails.ServerFolder); //emailTrans.SourceFile = srcServerDetails.GetSourceFile(); //emailTrans.OutputFile = desServerDetails.GetDestinationFile(desServerDetails.ServerFolder); //IAPL.Transport.Transactions.EmailTransaction emailTrans = new EmailTransaction(msgDetails); if (!emailtrans.SendEmailNotification(_httpObject.FileName, _httpObject.SourceFile, false)) { string[] errorList = IAPL.Transport.Util.TextLogger.ParseError(emailtrans.ErrorMessage); if (errorList.Length >= 2) { IAPL.Transport.Util.TextLogger.LogError(errorList[0], "[Thread: " + _httpObject.SourceFile + "] " + errorList[1]); } else { IAPL.Transport.Util.TextLogger.LogError("Worker-ProcessFile()", "[Thread: " + _httpObject.SourceFile + "] " + emailtrans.ErrorMessage); } } }