示例#1
0
 private void UploadScanDocuments()
 {
     //Get the list of datasource to be processed
     DataSet ds = new DataLayer().RetrieveScanDocuments();
     logger.Log(NLog.LogLevel.Info, "<br/><font color=red>Creation  of scan documents........." + DateTime.Now.ToString());
     if (ds.Tables[0].Rows.Count > 0)
     {
         for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
         {
             string fileName = ds.Tables[0].Rows[i]["fileName"].ToString();
             CopyFilestoProcessor(fileName);
            // DownloadFilesfromFTP();
         }
     }
 }
示例#2
0
        private void CreateWSF()
        {
            string dateTime = DateTime.Now.ToString("yyyyMMdd");
            string requestedDate = DateTime.Now.ToString("yyMMdd");
            //_filePath = System.Configuration.ConfigurationManager.AppSettings["ftpPathWriteProcessorWSF"].ToString();
            string folderPath = System.Configuration.ConfigurationManager.AppSettings["ftpPathWriteProcessorWSF"].ToString();
            double totalBalance = 0d;
            string processorCode = string.Empty;
            Int64 rowCount = 0;

            //Get the list of datasource to be processed
            DataSet ds = new DataLayer().RetrieveWSFInformation();
            logger.Log(NLog.LogLevel.Info, "<br/><font color=red>Creation  of the WSF files starts........." + DateTime.Now.ToString());
            //Get the list of processors to process the data file
            if (ds.Tables[1].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[1].Rows.Count; i++)
                {

                    processorCode = ds.Tables[1].Rows[i]["processorId"].ToString();

                    #region Process the files
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        rowCount = ds.Tables[0].Rows.Count;
                        //_filePath = string.Concat(processorCode.Substring(0, 2), requestedDate.Substring(0, 6), ".wsf");
                        string fileName= string.Concat(processorCode.Substring(0, 2), requestedDate.Substring(0, 6), ".wsf");

                    //    using (MRFWriter writer = new MRFWriter(_filePath))
                        using (MRFWriter writer = new MRFWriter(Path.Combine(folderPath, fileName)))
                        {
                            ProcessorRow rowHeader = new ProcessorRow();
                            rowHeader.Add(String.Format("HEADER"));
                            rowHeader.Add(String.Format(dateTime));
                            rowHeader.Add(String.Format(processorCode));
                            writer.WriteRow(rowHeader);
                            for (int count = 0; count <= rowCount - 1; count++)
                            {
                                /// Need to add logic to create the file based on the values from the file/db
                                ProcessorRow row = new ProcessorRow();
                                row.Add(String.Format(dateTime));
                                row.Add(String.Format(processorCode));
                                row.Add(String.Format(ds.Tables[0].Rows[count]["merchantId"].ToString()));
                                row.Add(String.Format(ds.Tables[0].Rows[count]["processorNumber"].ToString()));
                                row.Add(String.Format(ds.Tables[0].Rows[count]["balance"].ToString()));
                                row.Add(String.Format(ds.Tables[0].Rows[count]["rate"].ToString()));
                               totalBalance+=Convert.ToDouble(ds.Tables[0].Rows[count]["balance"].ToString());
                                writer.WriteRow(row);
                            }
                            ProcessorRow rowTrailer = new ProcessorRow();
                            rowTrailer.Add(String.Format("TRAILER"));
                            rowTrailer.Add(String.Format(dateTime));
                            rowTrailer.Add(String.Format(processorCode));
                            rowTrailer.Add(String.Format(rowCount.ToString()));
                            rowTrailer.Add(String.Format(totalBalance.ToString()));
                            writer.WriteRow(rowTrailer);

                        }
                    }

                }
                    #endregion
                logger.Log(NLog.LogLevel.Info, "<br/><font color=red>Reading of the files Ends........." + DateTime.Now.ToString());
            }
        }
示例#3
0
        /// <summary>
        /// Writes a processor file
        /// </summary>
        private void CreateMRF()
        {
            try
            {
            string dateTime = DateTime.Now.ToString("yyyyMMdd");
            string requestedDate = DateTime.Now.ToString("yyMMdd");

            string fileLocation = System.Configuration.ConfigurationManager.AppSettings["systemPathWrite"].ToString();
            string fileName = string.Empty;
            //fileLocation;
            string processorCode = string.Empty;
            string processorName = string.Empty;
            Int64 rowCount = 0;
            Int64 individualRows = 0;
            #region Load File

            //Get the list of datasource to be processed
            DataSet ds = new DataLayer().RetrieveProcessorQueue();
            logger.Log(NLog.LogLevel.Info, "<br/><font color=red>Creation  of the MRF files starts........." + DateTime.Now.ToString());
            //Get the list of processors to process the data file
            if (ds.Tables[1].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[1].Rows.Count; i++)
                {
                    processorCode = ds.Tables[1].Rows[i]["processorId"].ToString();
                    processorName = ds.Tables[1].Rows[i]["name"].ToString();
                    #region Process the files
                    logger.Log(NLog.LogLevel.Info, "<br/><font color=red>Total Rows Count in MRF files Creation........." + ds.Tables[0].Rows.Count.ToString());
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        fileName = string.Concat(processorCode.Substring(0, 2), requestedDate.Substring(0, 6), ".mrf");
                        rowCount = ds.Tables[0].Rows.Count;
                        _filePath = Path.Combine(fileLocation, fileName);
                        logger.Log(NLog.LogLevel.Info, "<br/><font color=red>File Path:   " + _filePath);
                        individualRows = 0;
                        using (MRFWriter writer = new MRFWriter(_filePath))
                        {
                            logger.Log(NLog.LogLevel.Info, "<br/><font color=red> Processor Code:   " + processorCode);
                            ProcessorRow rowHeader = new ProcessorRow();
                            rowHeader.Add(String.Format("HEADER"));
                            rowHeader.Add(String.Format(dateTime));
                            rowHeader.Add(String.Format(processorCode));
                            writer.WriteRow(rowHeader);
                            for (int count = 0; count <= rowCount - 1; count++)
                            {

                                if (processorCode == String.Format(ds.Tables[0].Rows[count]["ProcessorId"].ToString()))
                                {
                                    /// Need to add logic to create the file based on the values from the file/db
                                    ProcessorRow row = new ProcessorRow();
                                    row.Add(String.Format(dateTime));
                                    row.Add(String.Format(ds.Tables[0].Rows[count]["ProcessorId"].ToString()));
                                    row.Add(String.Format(ds.Tables[0].Rows[count]["merchantId"].ToString()));
                                    logger.Log(NLog.LogLevel.Info, "<br/><font color=red> Merchant Id :   " + String.Format(ds.Tables[0].Rows[count]["merchantId"].ToString()));
                                    row.Add(String.Format(ds.Tables[0].Rows[count]["processorNumber"].ToString()));

                                    writer.WriteRow(row);
                                    new DataLayer().UpdateProcessorQueue(Convert.ToInt64(ds.Tables[0].Rows[count]["merchantId"].ToString()), ds.Tables[0].Rows[count]["processorNumber"].ToString());
                                    individualRows++;
                                }
                            }
                            ProcessorRow rowTrailer = new ProcessorRow();
                            rowTrailer.Add(String.Format("TRAILER"));
                            rowTrailer.Add(String.Format(dateTime));
                            rowTrailer.Add(String.Format(processorCode));
                            rowTrailer.Add(String.Format(individualRows.ToString()));
                            writer.WriteRow(rowTrailer);

                        }

                        /* if (System.Configuration.ConfigurationManager.AppSettings["isftp"].ToString() == "1")
                         {
                             FtpWebRequest ftp = (FtpWebRequest)WebRequest.Create(Path.Combine(System.Configuration.ConfigurationManager.AppSettings["ftpPathWrite"].ToString(), fileName));
                             ftp.Credentials = new NetworkCredential(System.Configuration.ConfigurationManager.AppSettings["username"].ToString(), System.Configuration.ConfigurationManager.AppSettings["password"].ToString());
                             ftp.Method = WebRequestMethods.Ftp.UploadFile;
                             FileStream fs = File.OpenRead(_filePath);
                             byte[] buffer = new byte[fs.Length];
                             fs.Read(buffer, 0, buffer.Length);
                             fs.Close();

                             Stream ftpstream = ftp.GetRequestStream();
                             ftpstream.Write(buffer, 0, buffer.Length);
                             ftpstream.Close();
                         }*/
                    }
                }

                    #endregion

                }

            }
            catch(Exception ex)
            {

                logger.Log(NLog.LogLevel.Info, "<br/><font color=red>Error while creating MRF........." + ex.InnerException.ToString());
            }
            logger.Log(NLog.LogLevel.Info, "<br/><font color=red>Creation  of the MRF Ends........." + DateTime.Now.ToString());
            #endregion
        }