Ejemplo n.º 1
0
        // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        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);
        }
Ejemplo n.º 2
0
        private string IMSreadNoticationMessageBody(int Report, bool isSuccessful, string xsltFile, System.Collections.Hashtable DetailsForIMS, bool IMSBatchRun)
        {
            string result = "";

            IAPL.Transport.Util.XmlData xmlData = new IAPL.Transport.Util.XmlData();
            this.ErrorMessage = "";
            try
            {
                xmlData.CreateMainTag("NewDataSet");
                DateTime DataStatusReportDate = System.DateTime.Now;
                xmlData.AddElement("NewDataSet", "IMSDataStatusReportDate", this.returnHtmlData(DataStatusReportDate.ToString("MMMM dd, yyyy") + " (" + DataStatusReportDate.DayOfWeek + ")"));

                int ctr = 0;
                //do sorting

                //DetailsForIMS = (Hashtable)IAPL.Transport.Util.Utility.SortedHashTable(DetailsForIMS);
                foreach (DictionaryEntry IMSData in (Hashtable)DetailsForIMS)
                {
                    ctr++;
                    IAPL.Transport.IMS.Process.IMSReportDetails IMS = (IAPL.Transport.IMS.Process.IMSReportDetails)DetailsForIMS[IMSData.Key.ToString()];

                    switch (Report)
                    {
                    case 1:             // Exception Report summary
                        if (IMSBatchRun)
                        {
                            xmlData = IMSRepBuildXML(Report, xmlData, IMS);
                        }
                        else
                        {
                            if (!IMS.IMSDataSeq.Equals(string.Empty))
                            {
                                xmlData = IMSRepBuildXML(Report, xmlData, IMS);
                            }
                        }
                        break;

                    case 2:             // IMS Summary Report
                        if (IMSBatchRun)
                        {
                            xmlData = IMSRepBuildXML(Report, xmlData, IMS);
                        }
                        else
                        {
                            if (!IMS.IMSDataSeq.Equals(string.Empty))
                            {
                                xmlData = IMSRepBuildXML(Report, xmlData, IMS);
                            }
                        }
                        break;
                    }
                }

                if (System.IO.File.Exists(xsltFile))
                {
                    result = convertXSLTToHTML(xsltFile, xmlData.GetXmlData);
                }
                else
                {
                    result            = "";
                    this.ErrorMessage = xsltFile + " not found";
                }
            }
            catch (Exception ex)
            {
                result            = "";
                this.ErrorMessage = ex.Message.ToString();
            }

            return(result);
        }
Ejemplo n.º 3
0
        // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        // **********************************************************
        // 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);
        }
Ejemplo n.º 4
0
        private IAPL.Transport.Util.XmlData IMSRepBuildXML(int Report,
                                                           IAPL.Transport.Util.XmlData xmlData,
                                                           IAPL.Transport.IMS.Process.IMSReportDetails IMS)
        {
            xmlData.AddElement("NewDataSet", "Details", string.Empty);
            xmlData.AddElement("Details", "Country", this.returnHtmlData(IMS.Country));
            xmlData.AddElement("Details", "CountryCode", this.returnHtmlData(IMS.CountryCode));
            xmlData.AddElement("Details", "IMSDataSeq", this.returnHtmlData(IMS.IMSDataSeq));

            if (IMS.SizeKB.Equals(0))
            {
                xmlData.AddElement("Details", "SizeKB", "");
            }
            else
            {
                xmlData.AddElement("Details", "SizeKB", this.returnHtmlData(Convert.ToDouble(IMS.SizeKB).ToString()));
            }

            if (!IMSNoFilesFound)
            {
                if (!IMS.IMSDataSeq.Equals(string.Empty))
                {
                    DateTime dt = IMS.DateSent;
                    xmlData.AddElement("Details", "ISGDateSent", this.returnHtmlData(dt.ToString("MMMM dd, yyyy")));
                }
                else
                {
                    xmlData.AddElement("Details", "ISGDateSent", "");
                }
            }
            else
            {
                xmlData.AddElement("Details", "ISGDateSent", "");
            }

            switch (Report)
            {
            case 1:             // Exception Report summary
                xmlData.AddElement("Details", "SendStatus", this.returnHtmlData(Convert.ToString(IMS.SendStatus)));
                xmlData.AddElement("Details", "Issue", this.returnHtmlData(IMS.ERS_Issue));
                xmlData.AddElement("Details", "Resolution", "");
                xmlData.AddElement("Details", "IMSSingaporeComment", "");
                xmlData.AddElement("Details", "ISGComment", "");
                break;

            case 2:
                xmlData.AddElement("Details", "Issue", this.returnHtmlData(IMS.IMSSR_Issue));
                xmlData.AddElement("Details", "CommentResolution", this.returnHtmlData(IMS.CommentResolution));
                xmlData.AddElement("Details", "DataFileRcvd", this.returnHtmlData(Convert.ToString(IMS.DataFileRecvd)));
                xmlData.AddElement("Details", "TransactionDate", this.returnHtmlData(Convert.ToString(IMS.TransactionDate)));

                if (IMS.SizeKB.Equals(0))
                {
                    xmlData.AddElement("Details", "RecordCount", "");
                }
                else
                {
                    xmlData.AddElement("Details", "RecordCount", this.returnHtmlData(Convert.ToString(IMS.RecordCount)));
                }

                if (IMS.SizeKB.Equals(0))
                {
                    xmlData.AddElement("Details", "IMSExtractionValue", "");
                }
                else
                {
                    xmlData.AddElement("Details", "IMSExtractionValue", this.returnHtmlData(Convert.ToString(IMS.IMSExtractionValue)));
                }

                break;
            }
            return(xmlData);
        }