Ejemplo n.º 1
0
        /// <summary>
        /// Reads a processor file
        /// </summary>
        private void ReadSPF()
        {
            try
            {

            string pathtoRead = string.Empty;
            string[] files;
            // Read sample data from CSV file
               /* if (System.Configuration.ConfigurationManager.AppSettings["isftp"].ToString() == "1")
            {
                logger.Log(NLog.LogLevel.Info, "<br/><font color=red>Reading of the files from ftp starts........." + DateTime.Now.ToString());
                files = GetFilesfromFTP();
                logger.Log(NLog.LogLevel.Info, "<br/><font color=red>Read  files from ftp server........." + files.Count() + "to be downloaded");
                foreach (string item in files)
                {
                    logger.Log(NLog.LogLevel.Info, "<br/><font color=red>Downloading  files from ftp server........." + item + "");
                    DownloadFilesfromFTP(item);
                }
            }*/
            pathtoRead = System.Configuration.ConfigurationManager.AppSettings["systemPathRead"].ToString();
            files = System.IO.Directory.GetFiles(pathtoRead, "*.spf");

            logger.Log(NLog.LogLevel.Info, "<br/><font color=red>Reading of the files starts........." + DateTime.Now.ToString());

            logger.Log(NLog.LogLevel.Info, "<br/>Total # of files........." + files.Count());
            foreach (var item in files)
            {
                #region Read files from a location
                using (SPFReader reader = new SPFReader(item))
                {

                    int count = 0;
                    //   double mccvBaseValue = 0D;
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;
                    settings.CloseOutput = true;
                    settings.OmitXmlDeclaration = false;
                    StringBuilder sbXml = new StringBuilder();
                    XmlWriter writer = XmlWriter.Create(sbXml, settings);

                    ProcessorRow row = new ProcessorRow();
                    writer.WriteStartElement("profiles");
                    while (reader.ReadRow(row))
                    {
                        if (count > 0)
                        {
                            /*
                                 * [0]- Merchant Number,* [1]-Processor Merchant Number* [2]- Processor Code,* [3]-Activity type
                                 * [4]-Retrieval source,* [5]-Currency,* [6]-Total Amount,* [7]-Total Tickets,* [8]-Start date
                                 * [9]-End date,* [10]-Processor Processed Date,* [11]-Processor Merchant Category
                                 * [12]-Processor Merchant Status, * [13]-Processor Merchant Business Start Date
                                 * [14]-Legal Company Name,* [15]-RNC,* [16]-Bank Account Number,* [17]-Authorized Owner Name
                                 * */

                            if (row.Count > 4)
                            {

                                try
                                {
                                    DateTime processedDate;
                                    processedDate = DateTime.ParseExact(Convert.ToString(row[10]), "yyyyMMdd", CultureInfo.InvariantCulture);

                                    writer.WriteStartElement("monthlyprofile");
                                    writer.WriteAttributeString("merchantId", Convert.ToString(row[0]));
                                    writer.WriteAttributeString("pMerchantNumber", Convert.ToString(row[1]));
                                    writer.WriteAttributeString("processorCode", row[2]);
                                    writer.WriteAttributeString("activityType", Convert.ToString(row[3]));
                                    writer.WriteAttributeString("retrievalSource", Convert.ToString(row[4]));
                                    writer.WriteAttributeString("currencyId", Convert.ToString(row[5]));
                                    writer.WriteAttributeString("totalAmount", Convert.ToString(row[6]));
                                    writer.WriteAttributeString("totalTickets", Convert.ToString(row[7]));
                                    writer.WriteAttributeString("startDate", Convert.ToString(row[8]));
                                    writer.WriteAttributeString("endDate", Convert.ToString(row[9]));
                                    writer.WriteAttributeString("processedDate", Convert.ToString(row[10]));
                                    writer.WriteAttributeString("month", Convert.ToString(processedDate.Month));
                                    writer.WriteAttributeString("year", Convert.ToString(processedDate.Year));

                                    writer.WriteAttributeString("processorMerchantCategory", Convert.ToString(row[11]) ?? string.Empty);
                                    if (Convert.ToString(row[12]) == "A")
                                    {
                                        writer.WriteAttributeString("processorMerchantStatus", "1");
                                    }
                                    else
                                    {
                                        writer.WriteAttributeString("processorMerchantStatus", "0");
                                    }

                                    writer.WriteAttributeString("processorMerchantBusinessStartDate", Convert.ToString(row[13]));
                                    writer.WriteAttributeString("legalName", row.ElementAtOrDefault(14));
                                    writer.WriteAttributeString("rnc", row.ElementAtOrDefault(15));
                                    writer.WriteAttributeString("bankAccountNumber", row.ElementAtOrDefault(16));
                                    writer.WriteAttributeString("authorizedOwnerName", row.ElementAtOrDefault(17));
                                    writer.WriteEndElement();
                                }
                                catch (Exception ex)
                                {

                                    logger.Log(NLog.LogLevel.Error, ex.StackTrace);
                                    break;
                                }
                            }
                        }
                        count++;
                    }
                    writer.WriteEndElement();
                    writer.Flush();

                   new DataLayer().InsertCreditProfiles(sbXml.ToString());

                }

                #endregion
                logger.Log(NLog.LogLevel.Info, "<br/>Completed insertion of the data to the system</font>");
                MovetoArchive(item);
            }
            }
            catch (Exception ex)
            {

                logger.Log(NLog.LogLevel.Error, ex.StackTrace);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads a processor file
        /// </summary>
        private void ReadPAF()
        {
            // Read sample data from CSV file

            string pathtoRead = System.Configuration.ConfigurationManager.AppSettings["ftpPathReadProcessorActivity"].ToString();
            logger.Log(NLog.LogLevel.Info, "Reading of the files starts........."+ pathtoRead);
            string[] files = System.IO.Directory.GetFiles(pathtoRead, "*.paf");
            logger.Log(NLog.LogLevel.Info, "<br/>Number of files  to be read ..." +files.Count());
            foreach (var item in files)
            {
                #region Read files from a location
                using (SPFReader reader = new SPFReader(item))
                {
                    int count = 0;
                    //   double mccvBaseValue = 0D;
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;
                    settings.CloseOutput = true;
                    settings.OmitXmlDeclaration = false;
                    StringBuilder sbXml = new StringBuilder();
                    XmlWriter writer = XmlWriter.Create(sbXml, settings);
                    ProcessorRow row = new ProcessorRow();
                    writer.WriteStartElement("processor");
                    while (reader.ReadRow(row))
                    {
                        if (count > 0)
                        {
                            /*
                                 * [0]- Processor Processed date,* [1]-AMI Processor Code* [2]- Processor Merchant Number,* [3]-Retrieval source
                                 * [4]-Total Amount,* [5]-Withdrawal Amount,* [6]-Activity type,* [7]-(Specified Percentage) Rate,* [8]-Start date
                                 * [9]-End date,* [10]-Processor Processed Date,* [11]-Processor Merchant Category
                                 * [12]-Processor Merchant Status, * [13]-Processor Merchant Business Start Date
                                 * [14]-Legal Company Name,* [15]-RNC,* [16]-Bank Account Number,* [17]-Authorized Owner Name
                                 * */
                            if (count==0)
                            {
                                string header = Convert.ToString(row[0]);
                                string processorDate = Convert.ToString(row[1]);
                                string amiprocessorcode = Convert.ToString(row[2]);
                                if (string.IsNullOrEmpty(header) || string.IsNullOrEmpty(processorDate) || string.IsNullOrEmpty(amiprocessorcode))
                                {
                                    logger.Log(NLog.LogLevel.Info, "Missing required paramters");
                                    break;
                                }

                            }

                            if (row.Count > 6)
                            {

                                try
                                {
                                    DateTime processedDate;
                                    processedDate = DateTime.ParseExact(Convert.ToString(row[0]), "yyyyMMdd", CultureInfo.InvariantCulture);
                                    writer.WriteStartElement("processoractivity");
                                    writer.WriteAttributeString("processedDate", Convert.ToString(row[0]));
                                    writer.WriteAttributeString("processorCode", row[1]);
                                    writer.WriteAttributeString("pMerchantNumber", Convert.ToString(row[2]));
                                    writer.WriteAttributeString("retrievalSource", Convert.ToString(row[3]));
                                    writer.WriteAttributeString("totalAmount", Convert.ToString(row[4]));
                                    writer.WriteAttributeString("withdrawalAmount", Convert.ToString(row[5]));
                                    //Activity type 70 Withdrawal and 20 Adjustment
                                    writer.WriteAttributeString("activityType", Convert.ToString(row[6]));
                                    //Percent withheld. (1.00 means 100%, 0.50 means 50% and so on)
                                    writer.WriteAttributeString("specifiedRate", Convert.ToString(row[7]));
                                    writer.WriteAttributeString("startDate", Convert.ToString(row[8]));
                                    writer.WriteAttributeString("endDate", Convert.ToString(row[9]));
                                    writer.WriteEndElement();
                                }
                                catch (Exception ex)
                                {
                                    logger.Log(NLog.LogLevel.Info, "Exception " + ex.ToString() + "<br />" + ex.StackTrace + "<br/>" + Convert.ToString(row[0]));
                                    break;
                                }
                                logger.Log(NLog.LogLevel.Info, "Finished reading row");
                            }
                        }
                        count++;
                    }
                    writer.WriteEndElement();
                    writer.Flush();
                   new DataLayer().InsertProcessorActivities(sbXml.ToString());
                }
                #endregion
                MovetoArchive(item);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Reads a processor file
        /// </summary>
        private void ReadRSF()
        {
            // Read sample data from CSV file

            string pathtoRead = System.Configuration.ConfigurationManager.AppSettings["ftpPathReadProcessorRSF"].ToString();
            logger.Log(NLog.LogLevel.Info, "Reading of the files starts........."+ pathtoRead);
            string[] files = System.IO.Directory.GetFiles(pathtoRead, "*.paf");
            logger.Log(NLog.LogLevel.Info, "<br/>Number of files  to be read ..." +files.Count());
            foreach (var item in files)
            {
                #region Read files from a location
                using (SPFReader reader = new SPFReader(item))
                {
                    int count = 0;
                    //   double mccvBaseValue = 0D;
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;
                    settings.CloseOutput = true;
                    settings.OmitXmlDeclaration = false;
                    StringBuilder sbXml = new StringBuilder();
                    XmlWriter writer = XmlWriter.Create(sbXml, settings);

                    ProcessorRow row = new ProcessorRow();
                    writer.WriteStartElement("processor");
                    while (reader.ReadRow(row))
                    {
                        if (count > 0)
                        {

                            if (count==0)
                            {
                                string header = Convert.ToString(row[0]);
                                string processorDate = Convert.ToString(row[1]);
                                string amiprocessorcode = Convert.ToString(row[2]);
                                if (string.IsNullOrEmpty(header) || string.IsNullOrEmpty(processorDate) || string.IsNullOrEmpty(amiprocessorcode))
                                {
                                    logger.Log(NLog.LogLevel.Info, "Missing required paramters");
                                    break;
                                }
                            }

                            if (row.Count > 4)
                            {

                                try
                                {
                                    DateTime processedDate;
                                    processedDate = DateTime.ParseExact(Convert.ToString(row[0]), "yyyyMMdd", CultureInfo.InvariantCulture);

                                    writer.WriteStartElement("processoractivity");
                                    writer.WriteAttributeString("processedDate", Convert.ToString(row[0]));
                                    writer.WriteAttributeString("processorCode", row[1]);
                                    writer.WriteAttributeString("pMerchantId", Convert.ToString(row[2]));
                                    writer.WriteAttributeString("pMerchantNumber", Convert.ToString(row[2]));
                                    writer.WriteAttributeString("balance", Convert.ToString(row[3]));
                                    writer.WriteAttributeString("rate", Convert.ToString(row[4]));
                                    writer.WriteAttributeString("terminal", Convert.ToString(row[5]));
                                    //Set up status 0 Suucessfull,1- failed,2-No change
                                    writer.WriteAttributeString("setupstatus", Convert.ToString(row[6]));
                                    //Percent withheld. (1.00 means 100%, 0.50 means 50% and so on)
                                    writer.WriteAttributeString("info", Convert.ToString(row[7]));

                                    writer.WriteEndElement();
                                    logger.Log(NLog.LogLevel.Info, "Finished reading row");
                                }
                                catch (Exception ex)
                                {
                                    logger.Log(NLog.LogLevel.Info, "Exception "  + ex.ToString());
                                    break;
                                }
                            }
                        }
                        count++;
                    }
                    writer.WriteEndElement();
                    writer.Flush();
                   new DataLayer().InsertProcessorResponsesetup(sbXml.ToString());
                }
                #endregion
            }
        }