Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void SaveRequeueFile(string srcFileName, string desFileName, MessageDetails msgDetails, ServerDetails srcServerDetails, ServerDetails desServerDetails)
        {
            //create requeue folder if not exist
            string requeueFolder = msgDetails.BackupFolder.Substring(0, msgDetails.BackupFolder.LastIndexOfAny(@"\".ToCharArray())) + @"\" + IAPL.Transport.Configuration.Config.GetAppSettingsValue("RequeueFolder", "requeue");
            string requeuePath   = string.Empty;
            string dumpPath      = msgDetails.BackupFolder.Substring(0, msgDetails.BackupFolder.LastIndexOfAny(@"\".ToCharArray())) + @"\" + Config.GetAppSettingsValue("tempfolderforzip", "temp") + @"\Dump";
            string sourcePath    = string.Empty;

            if (!IAPL.Transport.Util.CommonTools.DirectoryExist(requeueFolder))
            {
                System.IO.Directory.CreateDirectory(requeueFolder);
            }

            requeuePath = desServerDetails.GetNetworkSourceFile(requeueFolder, desFileName);

            if (File.Exists(srcFileName))
            {
                sourcePath = srcFileName;

                if (File.Exists(requeuePath))
                {
                    File.Delete(requeuePath);
                }

                File.Copy(sourcePath, requeuePath);
            }
            else
            {
                sourcePath = desServerDetails.GetNetworkSourceFile(dumpPath, srcFileName);

                if (File.Exists(sourcePath))
                {
                    if (File.Exists(requeuePath))
                    {
                        File.Delete(requeuePath);
                    }

                    File.Copy(sourcePath, requeuePath);

                    string origSourcePath = srcServerDetails.GetNetworkSourceFile(srcServerDetails.ServerAddress, srcFileName);

                    if (File.Exists(origSourcePath))
                    {
                        File.Delete(origSourcePath);
                    }
                }
                else
                {
                    sourcePath = desServerDetails.GetNetworkSourceFile(msgDetails.BackupFolder, srcFileName);

                    if (File.Exists(requeuePath))
                    {
                        File.Delete(requeuePath);
                    }

                    File.Copy(sourcePath, requeuePath);
                }
            }
            //save to requeue table
            RequeueFile theRequeueFile = new RequeueFile();

            theRequeueFile.RequeueFileId  = 0;
            theRequeueFile.trdpCode       = msgDetails.TradingCode;
            theRequeueFile.MsgCode        = msgDetails.MessageCode;
            theRequeueFile.SourceFileName = (msgDetails.FilesSentBatch && msgDetails.IsZIP && msgDetails.SourceFiles != string.Empty) ? msgDetails.SourceFiles : srcFileName;
            theRequeueFile.OutputFileName = desFileName;
            theRequeueFile.CreateDate     = DateTime.Now;
            theRequeueFile.UpdateDate     = DateTime.MinValue;
            theRequeueFile.IsActive       = true;
            theRequeueFile.TempExtension  = (desServerDetails.IsUseFileTempExtension ? desServerDetails.FileTempExtension : string.Empty);

            RequeueFileDALC theRequeueFileDALC = new RequeueFileDALC();

            theRequeueFileDALC.SaveRequeueFile(theRequeueFile);
        }
Ejemplo n.º 3
0
        private string CreateHTMLEmailForClient(bool isSuccessful, string xsltFile, List <string> Sent, ServerDetails srvDetails, MessageDetails msgDetails, List <string> Pending)
        {
            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(srvDetails.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(msgDetails.SupplierName));      //messageInformation.SupplierName));
                xmlData.AddElement("NewDataSet", "SourceFileName", this.returnHtmlData(Path.GetFileName(xsltFile))); //this.SourceFile));
                xmlData.AddElement("NewDataSet", "SourceFolder", this.returnHtmlData(msgDetails.SourceFolder));
                xmlData.AddElement("NewDataSet", "ERPID", this.returnHtmlData(msgDetails.ERP));                      //this.messageInformation.ERP));
                xmlData.AddElement("NewDataSet", "DestinationURL", this.returnHtmlData(srvDetails.ServerAddress));   //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.º 4
0
        public bool GenerateHTML(List <string> Sent, List <string> Failed, string TempFolderEmail, string XSLTFile, ServerDetails sDetails, MessageDetails mDetails, List <SentDetail_BO> filesSent, 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"));
            }


            //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, sDetails, mDetails, Failed);



            //SEND EMAIL
            if (toSend != "")
            {
                //Successful mailing
                Operation.Email _ToMail = new IAPL.Transport.Operation.Email(sDetails.EmailAddressFrom, sDetails.EmailAddressTo, sDetails.EmailAddressCC, sDetails.EmailAddressBCC, sDetails.EmailSubject, 3, Configuration.Config.GetAppSettingsValue("emailnotificationsmtp", ""));
                _ToMail.Send(true, toSend, null);
            }



            #endregion

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


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