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);
        }
Beispiel #2
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);
        }
Beispiel #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);
        }
Beispiel #4
0
        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);
        }