コード例 #1
0
        protected override void OnStart(string[] args)
        {
            // TODO: Add code here to start your service.
            LogFunction2.WriteMaintenaceLogToFile("Maintenance Service started {0}");

            LogFunction2.WriteMaintenaceLogToFile("");

            //LogFunction2.WriteMaintenaceLogToFile("Email Serice Processing Started");
            //System.Timers.Timer timer = new System.Timers.Timer();
            //timer.Interval = 60000 * 3; // 60 seconds * 60 minute * 4 hours
            //timer.Elapsed += new System.Timers.ElapsedEventHandler(this.EmailScheduleService);
            //timer.Start();
            ////this.ScheduleService();
            LogFunction2.WriteMaintenaceLogToFile("");
            this.ScheduleService();
        }
コード例 #2
0
        public string RPT_GenSettlementMASTER(DateTime SETTDATE, string reportPATH, string logopath, string conString)
        {
            LogFunction2.WriteMaintenaceLogToFile("IN........RPT_GenSettlementMASTER");
            //LogFunction2.WriteMaintenaceLogToFile("IN2........RPT_GenSettlementMASTER");

            var SETT = SETTDATE;

            string settlementpathdate = Path.Combine(reportPATH, "SETTLEMENT_DETAIL_SETT_" + SETT.ToString("dd-MMM-yyyy"));

            //LogFunction2.WriteMaintenaceLogToFile("IN........RPT_GenSettlementMASTER" + settlementpathdate);

            if (!Directory.Exists(settlementpathdate))
            {
                Directory.CreateDirectory(settlementpathdate);
            }


            string output = string.Empty;
            //string bankName = string.Empty;
            //string bankshort = string.Empty;
            //string cbncode = string.Empty;
            //string cardScheme = string.Empty;
            string RECON_FILE = Path.Combine(settlementpathdate, "SETTLEMENT_MASTER");

            if (!Directory.Exists(RECON_FILE))
            {
                Directory.CreateDirectory(RECON_FILE);
            }

            string reportname     = "SETTLEMENT_DETAIL.xlsx";
            string reportnameMAIN = RECON_FILE + "\\" + reportname;

            try
            {
                if (File.Exists(reportnameMAIN))
                {
                    File.Delete(reportnameMAIN);
                }
            }
            catch
            {
            }
            //LogFunction2.WriteMaintenaceLogToFile("IN........RPT_GenSettlementMASTER" + RECON_FILE);

            output = rptSett.GenSettlementAll("", "ALL", "U", SETT, reportPATH, RECON_FILE, logopath, "NAIRA SETTLEMENT", "DOM");
            return(output);
        }
コード例 #3
0
        public void ScheduleService()
        {
            try
            {
                LogFunction2.WriteMaintenaceLogToFile("Maintenance Generation Schedular {0}");
                Schedular = new Timer(new TimerCallback(SchedularCallback));
                string mode = ConfigurationManager.AppSettings["Mode"].ToUpper();
                LogFunction2.WriteMaintenaceLogToFile("Maintenance Service Mode: " + mode + " {0}");

                //Set the Default Time.
                DateTime scheduledTime = DateTime.MinValue;
                //var gen = new GenXml();
                //var schedule2 = gen.GetSchedule();

                //foreach (var d in schedule2)
                //{
                //    // int intervalMinutes;
                //    if (DateTime.TryParse(d.SCHEDULE_TIME, out scheduledTime))
                //    {

                //        if (DateTime.Now > scheduledTime)
                //        {
                //            //If Scheduled Time is passed set Schedule for the next day.
                //            scheduledTime = scheduledTime.AddDays(1);
                //            break;

                //        }
                //    }

                //}
                if (mode == "DAILY")
                {
                    //Get the Scheduled Time from AppSettings.
                    scheduledTime = DateTime.Parse(ConfigurationManager.AppSettings["ScheduledTime"]);
                    if (DateTime.Now > scheduledTime)
                    {
                        //If Scheduled Time is passed set Schedule for the next day.
                        scheduledTime = scheduledTime.AddDays(1);
                    }
                }

                //if (mode.ToUpper() == "INTERVAL")
                //{
                //    //Get the Interval in Minutes from AppSettings.
                //    int intervalMinutes = Convert.ToInt32(ConfigurationManager.AppSettings["IntervalMinutes"]);

                //    //Set the Scheduled Time by adding the Interval to Current Time.
                //    scheduledTime = DateTime.Now.AddMinutes(intervalMinutes);
                //    if (DateTime.Now > scheduledTime)
                //    {
                //        //If Scheduled Time is passed set Schedule for the next Interval.
                //        scheduledTime = scheduledTime.AddMinutes(intervalMinutes);
                //    }
                //}

                TimeSpan timeSpan = scheduledTime.Subtract(DateTime.Now);
                string   schedule = string.Format("{0} day(s) {1} hour(s) {2} minute(s) {3} seconds(s)", timeSpan.Days, timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);

                LogFunction2.WriteMaintenaceLogToFile("Maintenance Service scheduled to run after: " + schedule + " {0}");

                //Get the difference in Minutes between the Scheduled and Current Time.
                int dueTime = Convert.ToInt32(timeSpan.TotalMilliseconds);

                //Change the Timer's Due Time.
                Schedular.Change(dueTime, Timeout.Infinite);
            }
            catch (Exception ex)
            {
                LogFunction2.WriteMaintenaceLogToFile("Maintenance Service Error on: {0} " + ex.Message + ex.StackTrace);

                //Stop the Windows Service.
                //using (System.ServiceProcess.ServiceController serviceController = new System.ServiceProcess.ServiceController("SimpleService"))
                //{
                //    serviceController.Stop();
                //}
            }
        }
コード例 #4
0
 protected override void OnStop()
 {
     // TODO: Add code here to perform any tear-down necessary to stop your service.
     LogFunction2.WriteMaintenaceLogToFile("Maintenance Service stopped {0}");
     this.Schedular.Dispose();
 }
コード例 #5
0
        private void SchedularCallback(object e)
        {
            try
            {
                DateTime dtFromA;
                LogFunction2.WriteMaintenaceLogToFile("Start processing..........");
                var conDate = ConfigurationManager.AppSettings["SettlementDate"].ToUpper();
                var dtFrom  = "";
                if (DateTime.TryParse(conDate, out dtFromA))
                {
                    dtFrom = dtFromA.ToString("dd-MMM-yyyy");
                }
                else
                {
                    dtFrom = DateTime.Now.ToString("dd-MMM-yyyy");
                }
                LogFunction2.WriteMaintenaceLogToFile("enter a report processing date..........");
                // string dtFrom = Console.ReadLine();

                LogFunction2.WriteMaintenaceLogToFile(dtFrom);

                DateTime dtFromDate = Convert.ToDateTime(dtFrom);


                ////IDapperSettlementReport _repoSETT = new DapperSettlementReport();
                ////bool sett = _repoSETT.GenSettlementFileSETT_EEPLUS(dtFromDate, null, reportPath, logopath, null);

                //LogFunction2.WriteMaintenaceLogToFile("enter a report type..........");
                //LogFunction2.WriteMaintenaceLogToFile("1.  SETTLEMENT MASTER REPORTS");
                //LogFunction2.WriteMaintenaceLogToFile("2.  NIBSS SETTLEMENT REPORTS");
                //LogFunction2.WriteMaintenaceLogToFile("3.  ACQUIRERE/ISSUER/MDB REPORTS");
                //LogFunction2.WriteMaintenaceLogToFile("4.  MERCHANT REPORTS");
                //LogFunction2.WriteMaintenaceLogToFile("5.  PTSP/PTSA/TERW/SWTH REPORTS");

                //string opt = Console.ReadLine();
                IMainReport _repoSETT = new MainReport();
                //var P = new EmailProcess();
                //string emailSubject = string.Format("SETTLEMENT REPORT FOR {0} ", dtFromDate.ToString("dd-MMM-yyyy"));

                try
                {
                    LogFunction2.WriteMaintenaceLogToFile("processing........SETTLEMENT MASTER REPORT" + dtFrom);
                    //LogFunction2.WriteMaintenaceLogToFile("processing........Settlement Date--" + dtFromDate);
                    // LogFunction2.WriteMaintenaceLogToFile("processing........Settlement Report Path--" + reportPath);
                    //LogFunction2.WriteMaintenaceLogToFile("processing........Settlement Logo Path--" + logopath);

                    string sett = _repoSETT.RPT_GenSettlementMASTER(dtFromDate, reportPath, logopath, null);
                    try
                    {
                        //SEND EMAIL HERE
                        //  P.SendSettlementMasterNotification(dtFrom, string.Concat(emailSubject, ":SETTLEMENT MASTER REPORT"));
                    }
                    catch (Exception ex)
                    {
                        LogFunction2.WriteMaintenaceLogToFile("Maintenance Settlement Email Service Error on: {0} " + ex.Message + ex.StackTrace);
                    }
                    LogFunction2.WriteMaintenaceLogToFile("completed........SETTLEMENT MASTER REPORT: {0}" + dtFrom);
                }
                catch (Exception ex)
                {
                    LogFunction2.WriteMaintenaceLogToFile("Maintenance Service Error on: {0} " + ex.Message + ex.StackTrace);
                }

                //try
                //{
                //    LogFunction2.WriteMaintenaceLogToFile("processing..........Merchant Reports" + dtFrom);
                //    string sett = _repoSETT.RPT_GenARTEEMerchant(dtFromDate, reportPath, logopath, null);
                //    try
                //    {
                //        LogFunction2.WriteMaintenaceLogToFile("completed..........Merchant Reports" + dtFrom);
                //        P.SendMerchantarteeSettlementEmail(dtFrom, "");
                //    }
                //    catch
                //    {

                //    }
                //}
                //catch (Exception ex)
                //{
                //    LogFunction2.WriteMaintenaceLogToFile("Maintenance Service Error on: {0} " + ex.Message + ex.StackTrace);
                //}

                //try
                //{
                //    LogFunction2.WriteMaintenaceLogToFile("processing.........NIBSS Settlement Report" + dtFrom);
                //    string sett = _repoSETT.RPT_GenSettlementFile2(dtFromDate, reportPath, logopath, null);
                //    try
                //    {
                //        P.SendSettlementMasterNotification(dtFrom, string.Concat(emailSubject, ":NIBSS REPORT"));
                //    }
                //    catch (Exception ex)
                //    {
                //        LogFunction2.WriteMaintenaceLogToFile("Maintenance Nibss Email Service Error on: {0} " + ex.Message + ex.StackTrace);
                //    }
                //    LogFunction2.WriteMaintenaceLogToFile("completed.........NIBSS Settlement Report" + dtFrom);
                //}
                //catch (Exception ex)
                //{
                //    LogFunction2.WriteMaintenaceLogToFile("Maintenance Service Error on: {0} " + ex.Message + ex.StackTrace);
                //}

                //try
                //{
                //    LogFunction2.WriteMaintenaceLogToFile("processing.........ACQUIRER/ISSUER/MDB REPORT" + dtFrom);
                //    string sett = _repoSETT.RPT_GenSettlementFile(dtFromDate, reportPath, logopath, null);
                //    //SEND EMAIL HERE
                //    //P.SendSettlementInstitutionNotification("12-MAY-2017", "");
                //    LogFunction2.WriteMaintenaceLogToFile("completed.........ACQUIRER/ISSUER/MDB REPORT" + dtFrom);
                //}
                //catch (Exception ex)
                //{
                //    LogFunction2.WriteMaintenaceLogToFile("Maintenance Service Error on: {0} " + ex.Message + ex.StackTrace);
                //}

                //try
                //{
                //    LogFunction2.WriteMaintenaceLogToFile("processing..........Party Report (PTSP/PTSA/TERW/SWTH)" + dtFrom);

                //    string sett = _repoSETT.RPT_Settlement(dtFromDate, reportPath, logopath, null);
                //    LogFunction2.WriteMaintenaceLogToFile("completed..........Party Report (PTSP/PTSA/TERW/SWTH)" + dtFrom);
                //}
                //catch (Exception ex)
                //{
                //    LogFunction2.WriteMaintenaceLogToFile("Maintenance Service Error on: {0} " + ex.Message + ex.StackTrace);
                //}
                //try
                //{
                //    LogFunction2.WriteMaintenaceLogToFile("processing..........Merchant Reports" + dtFrom);
                //    string sett = _repoSETT.RPT_GenMerchants(dtFromDate, reportPath, logopath, null);
                //    LogFunction2.WriteMaintenaceLogToFile("completed..........Merchant Reports" + dtFrom);
                //}
                //catch (Exception ex)
                //{
                //    LogFunction2.WriteMaintenaceLogToFile("Maintenance Service Error on: {0} " + ex.Message + ex.StackTrace);
                //}

                //try
                //{
                //    LogFunction2.WriteMaintenaceLogToFile("processing..........Merchant Reports" + dtFrom);
                //    string sett = _repoSETT.RPT_GenMerchants(dtFromDate, reportPath, logopath, null);
                //    LogFunction2.WriteMaintenaceLogToFile("completed..........Merchant Reports" + dtFrom);
                //}
                //catch (Exception ex)
                //{
                //    LogFunction2.WriteMaintenaceLogToFile("Maintenance Service Error on: {0} " + ex.Message + ex.StackTrace);
                //}


                ////if (opt == "5")
                ////{
                ////    LogFunction2.WriteMaintenaceLogToFile("processing..........Merchant Report By Merchant Deposit Bank" + dtFrom);

                ////    string sett = _repoSETT.RPT_GenMDBMerchants(DateTime.Parse(dtFrom), reportPath, logopath, null);
                ////}



                LogFunction2.WriteMaintenaceLogToFile("processing Completed");
            }
            catch (Exception ex)
            {
                LogFunction2.WriteMaintenaceLogToFile("Maintenance Service Error on: {0} " + ex.Message + ex.StackTrace);
            }
            //try
            //{
            //   var pDays = ConfigurationManager.AppSettings["purgedays"].ToUpper();
            //    int purgeDays = 0;
            //    if (int.TryParse(pDays, out purgeDays))
            //    {
            //        LogFunction2.WriteMaintenaceLogToFile("Maintenance Service Log: {0}");
            //        var gen = new Maintenance();
            //        gen.Purge(purgeDays);
            //        LogFunction2.WriteMaintenaceLogToFile("Maintenance Service Completed Log: {0}");
            //    }
            //        this.ScheduleService();

            //}
            //catch (Exception ex)
            //{
            //    LogFunction2.WriteMaintenaceLogToFile("Maintenance Service Error on: {0} " + ex.Message + ex.StackTrace);

            //    //Stop the Windows Service.
            //    //using (System.ServiceProcess.ServiceController serviceController = new System.ServiceProcess.ServiceController("SimpleService"))
            //    //{
            //    //    serviceController.Stop();
            //    //}
            //}
        }
コード例 #6
0
        public static string GenSettlementAll(string searchId, string reportType, string reportClass, DateTime setDate, string reportPATH, string filePath, string logopath, string reportFolder, string reportFolderType)
        {
            // LogFunction2.WriteMaintenaceLogToFile("IN........GenSettlementAll");
            string sett = setDate.ToString("dd-MMM-yyyy");


            string reportname = "SETTLEMENT_ALL" + ".xlsx";



            string _filePath = Path.Combine(filePath, reportFolder);

            if (!Directory.Exists(_filePath))
            {
                Directory.CreateDirectory(_filePath);
            }


            string reportPath = _filePath + "\\" + reportname;


            try
            {
                if (File.Exists(reportPath))
                {
                    File.Delete(reportPath);
                }
            }
            catch
            {
            }

            FileInfo newFile = new FileInfo(reportPath);

            MemoryStream stream = new MemoryStream();

            using (ExcelPackage package = new ExcelPackage(stream))
            {
                DataTable dtMain = null;

                try
                {
                    dsLoadclass dv = new dsLoadclass();
                    //string searchID,string CardScheme,string reportType,string reportClass, string subreporttype, string sett, string ReportPath, string logopath)
                    var wsA = package.Workbook.Worksheets.Add("DETAILS");
                    dtMain = dv.generateDS("", "", "ALL", "U", "", sett, 0);

                    //ExcelRange cols = wsA.Cells["A:XFD"];
                    //wsA.Cells["A:XFD"].Style.Fill.PatternType = ExcelFillStyle.Solid;
                    //wsA.Cells["A:XFD"].Style.Fill.BackgroundColor.SetColor(Color.White);

                    System.Drawing.Image myImage = System.Drawing.Image.FromFile(logopath);
                    var pic = wsA.Drawings.AddPicture("LOGO", myImage);
                    pic.SetPosition(0, 0, 0, 0);

                    var range = wsA.Cells["A11"].LoadFromDataTable(dtMain, true);

                    wsA.Row(11).Style.Fill.PatternType = ExcelFillStyle.Solid;
                    wsA.Row(11).Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.Orange);


                    //wsA.Tables.Add(range, "data");
                    //Write the headers and style them
                    wsA.Cells["A2"].Value           = "Xpress Payment Services Ltd";
                    wsA.Cells["A2"].Style.Font.Size = 18;
                    wsA.Cells["A2"].Style.Font.Bold = true;
                    wsA.Cells["A2:M2"].Merge        = true;
                    wsA.Cells["A2:M2"].Style.HorizontalAlignment = ExcelHorizontalAlignment.CenterContinuous;

                    wsA.Cells["A3"].Value           = "SETTLEMENT DETAIL REPORT ";
                    wsA.Cells["A3"].Style.Font.Size = 14;
                    wsA.Cells["A3"].Style.Font.Bold = true;
                    wsA.Cells["A3:M3"].Merge        = true;
                    wsA.Cells["A3:M3"].Style.HorizontalAlignment = ExcelHorizontalAlignment.CenterContinuous;
                    wsA.Cells["A5"].Value = "SETTLEMENT DATE: " + sett;
                    //wsA.Cells["A5"].Value = "MERCHANT NAME: " + MERCHANTNAME;
                    wsA.Cells["A5"].Style.Font.Size = 10;
                    wsA.Cells["A5:F5"].Merge        = true;
                    //wsA.Cells["A6"].Value = "ADDRESS: " + ADDRESS;
                    wsA.Cells["A6"].Style.Font.Size = 10;
                    wsA.Cells["A6:F6"].Merge        = true;

                    //wsA.Cells["A7"].Value = "SETTLEMENT CURRENCY " + SettlementCur;
                    wsA.Cells["A7"].Style.Font.Size = 10;
                    wsA.Cells["A7"].Style.Font.Bold = true;

                    wsA.View.ShowGridLines = true;
                    //wsA.Cells["A:D"].Style.Numberformat.Format = null;
                    //wsA.Cells["B:B"].Style.Numberformat.Format = "0.00";
                    //wsA.Cells[1, 1].Value = "AA";
                    //wsA.Cells[1, 2].Value = "BB";
                    //wsA.Cells[1, 3].Value = "CC";
                    //wsA.Cells[1, 4].Value = "DD";

                    if (dtMain != null && dtMain.Rows.Count > 1)
                    {
                        int row = wsA.Dimension.End.Row + 1;
                        //wsA.Cells[2, 4, row + 1, 4].Style.Numberformat.Format = "dd-mm-yyyy hh:mm:ss AM/PM";
                        wsA.Cells[2, 4, row + 1, 4].Style.Numberformat.Format = "dd-mm-yyyy";
                        wsA.Cells[2, 5, row + 1, 5].Style.Numberformat.Format = "dd-mm-yyyy";
                        //wsA.Cells[2, 21, row + 1, 21].Style.Numberformat.Format = "#,##0.00";
                        //wsA.Cells[2, 23, row + 1, 26].Style.Numberformat.Format = "#,##0.00";


                        //wsA.Cells[row + 1, 1].Value = "TOTAL";
                        //wsA.Cells[row + 1, 21, row + 1, 21].Formula = string.Format("=SUM(U{0}:U{1})", 12, row - 1);

                        //wsA.Cells[row + 1, 23, row + 1, 26].Formula = string.Format("=SUM(W{0}:W{1})", 12, row - 1);
                        //wsA.Cells[row + 1, 23, row + 1, 26].Style.Numberformat.Format = "#,##0.00";
                    }

                    wsA.View.FreezePanes(12, 1);
                    //var tbl1 = wsA.Tables[0];
                    if (range != null)
                    {
                        range.AutoFitColumns();
                    }
                    // tbl1.ShowFilter = false;
                    //wsA.Cells[wsA.Dimension.Address].AutoFilter = true;
                }
                catch (Exception ex)
                {
                    LogFunction2.WriteMaintenaceLogToFile(string.Format("Maintenance Service Error on: {0}-{1} --", "SETT_GEN", sett) + "{0}" + ex.Message + ex.StackTrace);
                }
                dtMain.Dispose();

                //try
                //{

                //    dtMain = generateDS("GEN", "U", sett, reportPath, logopath,null);
                //    var wsA2 = package.Workbook.Worksheets.Add("SETTLEMENT REPORT");
                //    //ExcelRange cols = wsA2.Cells["A:XFD"];
                //    //wsA2.Cells["A:XFD"].Style.Fill.PatternType = ExcelFillStyle.Solid;
                //    //wsA2.Cells["A:XFD"].Style.Fill.BackgroundColor.SetColor(Color.White);

                //    var range2 = wsA2.Cells["A11"].LoadFromDataTable(dtMain, true);

                //    wsA2.Row(11).Style.Fill.PatternType = ExcelFillStyle.Solid;
                //    wsA2.Row(11).Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.Orange);


                //    //wsA2.Tables.Add(range2, "data2");



                //    System.Drawing.Image myImage = System.Drawing.Image.FromFile(logopath);

                //    var pic = wsA2.Drawings.AddPicture("LOGO", myImage);
                //    pic.SetPosition(0, 0, 0, 0);

                //    //Write the headers and style them
                //    wsA2.Cells["A2"].Value = "Xpress Payment Services Ltd";
                //    wsA2.Cells["A2"].Style.Font.Size = 18;
                //    wsA2.Cells["A2"].Style.Font.Bold = true;
                //    wsA2.Cells["A2:M2"].Merge = true;
                //    wsA2.Cells["A2:M2"].Style.HorizontalAlignment = ExcelHorizontalAlignment.CenterContinuous;

                //    wsA2.Cells["A3"].Value = "SETTLEMENT DETAIL REPORT ";
                //    wsA2.Cells["A3"].Style.Font.Size = 14;
                //    wsA2.Cells["A3"].Style.Font.Bold = true;
                //    wsA2.Cells["A3:M3"].Merge = true;
                //    wsA2.Cells["A3:M3"].Style.HorizontalAlignment = ExcelHorizontalAlignment.CenterContinuous;
                //    wsA2.Cells["A5"].Value = "SETTLEMENT DATE: " + sett;
                //    //wsA2.Cells["A5"].Value = "MERCHANT NAME: " + MERCHANTNAME;
                //    wsA2.Cells["A5"].Style.Font.Size = 10;
                //    wsA2.Cells["A5:F5"].Merge = true;
                //    //wsA2.Cells["A6"].Value = "ADDRESS: " + ADDRESS;
                //    wsA2.Cells["A6"].Style.Font.Size = 10;
                //    wsA2.Cells["A6:F6"].Merge = true;

                //   // wsA2.Cells["A7"].Value = "SETTLEMENT CURRENCY " + SettlementCur;
                //    wsA2.Cells["A7"].Style.Font.Size = 10;
                //    wsA2.Cells["A7"].Style.Font.Bold = true;

                //    if (dtMain != null && dtMain.Rows.Count > 1)
                //    {
                //        //int row = wsA2.Dimension.End.Row + 1;

                //        //wsA2.Cells[row + 1, 1].Value = "TOTAL";
                //        //wsA2.Cells[row + 1, 2, row + 1, 4 - 1].Formula = string.Format("=SUM(B{0}:B{1})", 12, row - 1);

                //        //wsA2.Cells[row + 1, 2, row + 1, 4 - 1].Style.Numberformat.Format = "#,##0.00";

                //    }
                //    wsA2.View.FreezePanes(12, 1);
                //    // var tbl2 = wsA2.Tables[0];
                //    if (range2 != null)
                //    {
                //        range2.AutoFitColumns();
                //    }
                //    // tbl2.ShowFilter = false;
                //    //wsA2.Cells[wsA2.Dimension.Address].AutoFilter = true;

                //}
                //catch (Exception ex)
                //{
                //    LogFunction2.WriteMaintenaceLogToFile(string.Format("Maintenance Service Error on: {0}-{1} --", "SETT_ALL", sett) + "{0}" + ex.Message + ex.StackTrace);

                //}
                //dtMain.Dispose();


                package.SaveAs(newFile);
                stream.Dispose();
                package.Dispose();
            }

            return(newFile.FullName);
        }