Ejemplo n.º 1
0
        private void SendSuccessEmail(HTTPProcessObject _httpProcess)//string _msgCode, string _erp, string _sourceFile, string _url, string suppName, string backupFolder)
        {
            List <string>    _failed          = new List <string>();
            List <string>    _sent            = new List <string>();
            EmailTransaction emailTrans       = new EmailTransaction();
            ServerDetails    desServerDetails = new ServerDetails();
            MessageDetails   msgDetails       = new MessageDetails();

            for (int i = 0; i < _SentDetails.Count; i++)
            {
                if (emailTrans.HTTPSendingFailed(_httpProcess.MessageCode, _httpProcess.ERP, _SentDetails[i].FileName))
                {
                    _failed.Add(_SentDetails[i].FileName);
                }
                else
                {
                    _sent.Add(_SentDetails[i].FileName);
                }
            }

            //Remove Batch file from List
            _sent.Remove(_httpProcess.SourceFile);
            _failed.Remove(_httpProcess.SourceFile);



            bool _a = emailTrans.GenerateHTML(_sent, _failed, _httpProcess.Guid + "requeue\\", _httpProcess.EmailXSLTPath, _SentDetails, _httpProcess, false);//, desServerDetails, msgDetails, _SentDetails, false);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        //REQUEUE OVERLOAD
        private string CreateHTMLEmailForClient(bool isSuccessful, string xsltFile, List <string> Sent, List <string> Pending, HTTPProcessObject _httpProcess)
        {
            string result = "";

            IAPL.Transport.Util.XmlData xmlData = new IAPL.Transport.Util.XmlData();
            // this.ErrorMessage = "";
            try
            {
                int _total = Sent.Count + Pending.Count;
                xmlData.CreateMainTag("NewDataSet");
                xmlData.AddElement("NewDataSet", "Table", "");
                //xmlData.CreateMainTag("Table");

                xmlData.AddElement("NewDataSet", "Subject", this.returnHtmlData(_httpProcess.EmailSubject));         //this.serverInformation.EmailSubject));
                xmlData.AddElement("NewDataSet", "DateTime", this.returnHtmlData(DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss")));
                xmlData.AddElement("NewDataSet", "SupplierName", this.returnHtmlData(_httpProcess.SupplierName));    //messageInformation.SupplierName));
                xmlData.AddElement("NewDataSet", "SourceFileName", this.returnHtmlData(Path.GetFileName(xsltFile))); //this.SourceFile));
                xmlData.AddElement("NewDataSet", "SourceFolder", this.returnHtmlData(_httpProcess.Guid));
                xmlData.AddElement("NewDataSet", "ERPID", this.returnHtmlData(_httpProcess.ERP));                    //this.messageInformation.ERP));
                xmlData.AddElement("NewDataSet", "DestinationURL", this.returnHtmlData(_httpProcess.URL));           //this.messageInformation.ERP));
                xmlData.AddElement("NewDataSet", "Total", this.returnHtmlData(Sent.Count + " / " + _total));         //this.messageInformation.ERP));

                for (int i = 1; i < Sent.Count + 1; i++)
                {
                    xmlData.AddElement("NewDataSet", "ItemEntry" + (i - 1), this.returnHtmlData(Sent[i - 1].ToString()));//this.messageInformation.ERP));
                }

                for (int i = 1; i < Pending.Count + 1; i++)
                {
                    xmlData.AddElement("NewDataSet", "PendingEntry" + (i - 1), this.returnHtmlData(Sent[i - 1].ToString()));//this.messageInformation.ERP));
                }
                if (!isSuccessful)
                {
                    xmlData.AddElement("Table", "ProcesslogID", this.returnHtmlData("ProcessLOGID"));//this.messageInformation.ProcessLogID));
                    xmlData.AddElement("Table", "CustomerID", "");
                    xmlData.AddElement("Table", "prlgProcessSource", "");
                    xmlData.AddElement("Table", "prlgStartDate", this.returnHtmlData("DateToday")); //this.messageInformation.StartDate));
                    xmlData.AddElement("Table", "prlgEndDate", this.returnHtmlData("END DATE"));    //this.messageInformation.EndDate));
                    xmlData.AddElement("Table", "ERPID", this.returnHtmlData("ANOTHER ERPID"));     //this.messageInformation.ERP));


                    xmlData.AddElement("Table", "prlgIsSuccess", "0");

                    xmlData.AddElement("Table", "apluCode", this.returnHtmlData("APLU CODE"));                        //this.messageInformation.ApplicationCode));
                    xmlData.AddElement("Table", "prlgDescription", this.returnHtmlData("Description"));               //this.messageInformation.TransDescription));
                    xmlData.AddElement("Table", "prlgTechnicalErrDesc", this.returnHtmlData("Technical Error Desc")); //this.messageInformation.TechnicalErrorDescription));
                    xmlData.AddElement("Table", "prlgSourceParentCount", "");
                    xmlData.AddElement("Table", "prlgSourceParent", "");
                    xmlData.AddElement("Table", "prlgSourceChild", "0");
                    xmlData.AddElement("Table", "prlgSourceChildCount", "0");
                    xmlData.AddElement("Table", "prlgAddDate", this.returnHtmlData("ADD DATE"));//this.messageInformation.StartDate));
                }

                result = convertXSLTToHTML(xsltFile, xmlData.GetXmlData);
            }
            catch (Exception ex)
            {
                string _result = ex.Message;
                Console.WriteLine("CreateHTMLEmailForClient: " + ex.Message);
                //this.ErrorMessage = ex.Message.ToString();
            }

            return(result);
        }
Ejemplo n.º 5
0
        //REQUEUE OVERLOAD
        public bool GenerateHTML(List <string> Sent, List <string> Failed, string TempFolderEmail, string XSLTFile, List <SentDetail_BO> filesSent, HTTPProcessObject _httpProcess, bool isTechnicalError)
        {
            //Demo purposes

            //Preparation Code
            //1. Create Guid folder

            string _tempGUID    = IAPL.Transport.Util.CommonTools.CreateGuidFolder(TempFolderEmail) + "\\";
            string _fileName    = Path.GetFileName(XSLTFile);
            string _workingFile = _tempGUID + _fileName;

            //2. copy XSLTFile to Guid
            File.Copy(XSLTFile, _tempGUID + _fileName);

            //3. add sent files to file


            //Add the sent stuff
            #region SENT

            StringBuilder _sbHeader = new StringBuilder();
            StringBuilder _sbBody   = new StringBuilder();

            //Sent Files
            for (int i = 0; i < Sent.Count; i++)
            {
                string a = Sent[i].ToString();
                string b = filesSent[i].FileName;
                string c = filesSent[i].DateSent;

                _sbHeader.AppendLine(AddEntry("ItemEntry", i, true, filesSent[i].DateSent, "SentFiles"));
                _sbBody.AppendLine(AddEntry("ItemEntry", i, false, filesSent[i].DateSent, "SentFiles"));
                //MessageBox.Show(_list[i]);
            }

            //READY THE LOOP FOR PENDING FILES
            for (int i = 0; i < Failed.Count; i++)
            {
                _sbHeader.AppendLine(AddEntry("PendingEntry", i, true, filesSent[i].DateSent, "PendingFiles"));
                _sbBody.AppendLine(AddEntry("PendingEntry", i, false, filesSent[i].DateSent, "PendingFiles"));
            }

            //if (isTechnicalError)
            //{
            //    string a = sDetails.ErrorMessage;
            //    string b = "";
            //}

            //XSLT FOR CLIENT HAS BEEN CREATED
            bool success = AppendToFile(_workingFile, "ItemEntry", _sbHeader, _tempGUID + "BBraunClient.xslt", _sbBody, true);
            //CREATE THE HTML EMAIL FOR THE CLIENT
            string toSend = CreateHTMLEmailForClient(false, _tempGUID + "BBraunClient.xslt", Sent, Failed, _httpProcess);



            //SEND EMAIL
            if (toSend != "")
            {
                //Successful mailing
                Operation.Email _ToMail = new IAPL.Transport.Operation.Email(_httpProcess.EmailFrom, _httpProcess.EmailTo, _httpProcess.EmailCC, _httpProcess.EmailBCC, _httpProcess.EmailSubject, 3, Configuration.Config.GetAppSettingsValue("emailnotificationsmtp", ""));
                // _ToMail.Send(true, toSend, null);
            }



            #endregion

            //Clean up
            Directory.Delete(_tempGUID, true);


            return(true);
        }
Ejemplo n.º 6
0
        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);
                }
            }
        }