public void MainReportsFilterTest() { User user = new User() { AgencyId = 1, RegionId = 1, RoleId = (int)FixedRoles.RegionOfficer }; IPermissionsBase target = PermissionsFactory.GetPermissionsFor(user); Func <MainReport, bool> MainReportsFilter = target.MainReportsFilter.Compile(); MainReport param = new MainReport() { AppBudget = new AppBudget() { App = new App() { AgencyGroup = new AgencyGroup() { Country = new Country() { RegionId = 0 } } } } }; Assert.IsFalse(MainReportsFilter(param)); param.AppBudget.App.AgencyGroup.Country.RegionId = 1; Assert.IsTrue(MainReportsFilter(param)); }
private void Page_Load(object sender, EventArgs e) { if (!base.IsPostBack) { MemoryStream stream1; string text1 = this.Session["licenseNumber"].ToString(); string text2 = this.Session["licenseType"].ToString(); if (text1.Substring(0, 4) == "PEND") { MainReport report1 = new MainReport(text2, text1); ReportDocument document1 = report1.GetDocument("PendingRecipt"); stream1 = report1.ConvertToPDF(document1); } else { MainReport report2 = new MainReport(text2, text1); ReportDocument document2 = report2.GetDocument("MainDocument"); stream1 = report2.ConvertToPDF(document2); } base.Response.Clear(); base.Response.Buffer = true; base.Response.ContentType = "application/pdf"; base.Response.BinaryWrite(stream1.ToArray()); base.Response.End(); } }
public void FormatData_3Records_FormatByAgeLNameFNameEyeColorAndGender() { // Arrange List <Person> list = new List <Person>() { new Person() { age = 10, lastName = "Jones", firstName = "Joseph", eyeColor = "brown", gender = "male" }, new Person() { age = 25, lastName = "Fox", firstName = "Michael", eyeColor = "blue", gender = "male" }, new Person() { age = 50, lastName = "Jordan", firstName = "Michael", eyeColor = "green", gender = "male" }, }; List <string> results = new List <string>(); List <string> firstRecordResults = new List <string>(); // Act results = new MainReport().FormatData(list); firstRecordResults = results.First().Split('|').ToList(); // Assert Assert.AreEqual(firstRecordResults[0].Trim(), "10"); Assert.AreEqual(firstRecordResults[1].Trim(), "Jones"); Assert.AreEqual(firstRecordResults[2].Trim(), "Joseph"); Assert.AreEqual(firstRecordResults[3].Trim(), "brown"); Assert.AreEqual(firstRecordResults[4].Trim(), "male"); }
public void MainReportsFilterTest() { User user = new User() { AgencyId = 1, RoleId = (int)FixedRoles.AgencyUser }; IPermissionsBase target = PermissionsFactory.GetPermissionsFor(user); Func <MainReport, bool> MainReportsFilter = target.MainReportsFilter.Compile(); MainReport mr = new MainReport() { AppBudget = new AppBudget() { App = new App() { AgencyGroup = new AgencyGroup() { Agencies = new List <Agency>() { new Agency() { Id = 1 } } } } } }; Assert.IsTrue(MainReportsFilter(mr)); mr.AppBudget.App.AgencyGroup.Agencies.Clear(); // disallow another agencies mainreports Assert.IsFalse(MainReportsFilter(mr)); }
public void Sort_3Records_SortByAgeLNameAndFname() { // Arrange List <Person> list = new List <Person>() { new Person() { age = 10, lastName = "Jones", firstName = "Joseph" }, new Person() { age = 25, lastName = "Fox", firstName = "Michael" }, new Person() { age = 50, lastName = "Jordan", firstName = "Michael" }, }; List <Person> results = new List <Person>(); // Act results = new MainReport().Sort(list); // Assert Assert.AreEqual(results[0].age, 50); Assert.AreEqual(results[1].age, 25); Assert.AreEqual(results[2].age, 10); }
public List <MainReport> getMainReport(string query) { List <MainReport> data = null; SqlConnection connection = new SqlConnection(CONN_STRING); try { connection.Open(); SqlCommand command = new SqlCommand(query, connection); try { SqlDataReader reader = command.ExecuteReader(); try { data = new List <MainReport>(); while (reader.Read()) { MainReport mainReport = new MainReport(); mainReport.Dept = reader[0].ToString(); data.Add(mainReport); } } catch (Exception e) { Debug.WriteLine(e.Message); errorMessage = e.Message; } finally { reader.Close(); } } catch (Exception e) { Debug.WriteLine(e.Message); errorMessage = e.Message; } finally { command.Dispose(); } } catch (Exception e) { Debug.WriteLine(e.Message); errorMessage = e.Message; } finally { connection.Dispose(); } return(data); }
public void GetRawData_FileExists_ReadData() { // Arrange var inputPath = @"c:\temp\Json\ConsoleJob\Input\"; List <Person> results = new List <Person>(); // Act results = new MainReport().GetRawData(inputPath); // Assert Assert.IsTrue(results.Any()); }
private void reportsToolStripMenuItem_Click(object sender, EventArgs e) { if (mainReport == null || mainReport.IsDisposed) { mainReport = new MainReport(); mainReport.Show(); } else { if (mainReport.WindowState == FormWindowState.Minimized) { mainReport.WindowState = FormWindowState.Maximized; } mainReport.Activate(); } }
public static void AddRecipientsMainReportForRpaApproval(MailMessage msg, MainReport report) { using (var db = new ccEntities()) { var rps = from mr in db.MainReports where mr.Id == report.Id from u in mr.AppBudget.App.AgencyGroup.PoUsers where (u.RoleId == (int)FixedRoles.RegionOfficer || u.RoleId == (int)FixedRoles.RegionAssistant || u.RoleId == (int)FixedRoles.RegionReadOnly) && !u.Disabled select new { DisplayName = (u.FirstName + " " + u.LastName), u.Email, u.AddToBcc, u.RoleId }; foreach (var user in rps) { if (user.RoleId == (int)FixedRoles.RegionOfficer) { if (!user.AddToBcc) { msg.To.TryAdd(user.Email, user.DisplayName); } else { msg.Bcc.TryAdd(user.Email, user.DisplayName); } } else { if (!user.AddToBcc) { msg.CC.TryAdd(user.Email, user.DisplayName); } else { msg.Bcc.TryAdd(user.Email, user.DisplayName); } } } } }
private void btnObfKayit_Click(object sender, EventArgs e) { MainReport ms = new MainReport(); List <ReportModel> models = new List <ReportModel>(); List <MaterialList> items = UICurrentManager.Instance.CurrentTender.MaterialList; List <MaterialListModel> materialModels = grdMaterialList.DataSource as List <MaterialListModel>; //IhalematikModelBase.GetModels<MaterialListModel, MaterialList>(items); double totalAmount = 0; if (materialModels != null) { int i = 1; foreach (var item in materialModels) { ReportModel model = new ReportModel(); model.Description = item.PozOBFDescription; model.PozOBFNumber = item.PozOBFNumber; model.ItemNumber = i.ToString(); model.Quantity = item.Quantity.ToString(); totalAmount += Math.Round(item.TotalFarePreview, 2); model.Total = Math.Round(item.TotalFarePreview, 2).ToString("c2"); model.Unit = item.PozOBFUnit; model.UnitPrice = item.UnitTotalFarePreview.ToString("C2"); models.Add(model); i++; } } WrapperReportModel reportModel = new WrapperReportModel(); reportModel.Items = models; reportModel.TenderNumber = UICurrentManager.Instance.CurrentTender.Number.ToString(); reportModel.TotalAmount = totalAmount.ToString("c2"); ms.DataSource = reportModel; ReportPrintTool tool = new ReportPrintTool(ms); ms.ShowPreview(); }
static void Main(string[] args) { // //string gh = "user id=DPPADMIN; password=DPPADMIN; Connection Timeout=600; Max Pool Size=150; data source= (DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 172.19.4.90)(PORT = 1700)) (CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = TWODB))))"; //string conString = "Data Source=172.19.4.103:1700/TWODB;User Id=DPPADMIN;password=DPPADMIN;"; //string twoConString = !string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["TwoConfig"]) ? Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["TwoConfig"]) : string.Empty; //string MEBSource = !string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["MEBSource"]) ? Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["MEBSource"]) : string.Empty; //string MEBTarget = !string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["MEBTarget"]) ? Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["MEBTarget"]) : string.Empty; string reportPath = !string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["ReportPath"]) ? Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["ReportPath"]) : string.Empty; string logopath = !string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["LogoPath"]) ? Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["LogoPath"]) : string.Empty; IDapperGeneralSettings _repo = new DapperGeneralSettings(); // string conString = twoConString; // var dd = new SettlementProcess().GetMSC_PERC("1654487896", "1199803451", "2044QF28", "2044OG00V000183", "VISA", "566", "8220", 20916, "566", "0", "0",0,0,0,0, "0"); // int rec1 = _repo.PostMEB(MEBSource, MEBTarget, reportPath, logopath, "9622331", null); // DateTime? v_SETTDATE = null; //new SettlementProcess().SETTProcess("9622331"); //(SETTDATE, reportPATH, lgopath, NULL); IMainReport _repoSETT = new MainReport(); ////string sett = _repoSETT.RPT_GenSettlementFile(DateTime.Parse("02-FEB-17"), reportPath, logopath, null); //var g = new EmailProcess(); // g.SendMerchantarteeSettlementEmail("26-May-2017", ""); // IMainReport _repoSETT = new MainReport(); // g.SendMerchantVIPSettlementEmail("29-JUN-2017", ""); // string sett2 = _repoSETT.RPT_GenVIPMerchant(new DateTime(2017,09,06), reportPath, logopath, null); //new SettlementProcess_MEB().SETTProcess("9622331", "08-FEB-17"); //string dtFrom2 = DateTime.Today.ToString("dd-MMM-yyyy"); //new MEBCollectionClass().MEBProcess(dtFrom2); ////v_SETTDATE = DateTime.Today; ////v_SETTDATE.Value.Date.ToString("dd-MMM-yy"); //IDapperSettlementReport _repoSETT = new DapperSettlementReport(); // bool sett = _repoSETT.GenSettlementFileSETT(DateTime.Parse(v_SETTDATE.Value.Date.ToString("dd-MMM-yy")), null, reportPath, logopath, null); // bool sett = _repoSETT.GenSettlementFileSETT(DateTime.Parse("16-JAN-17"), null, reportPath, logopath, null); // int rec2 = _repo.processSettlement(MEBTarget, reportPath, logopath, null); //P.SendSettlementInstitutionNotification("12-MAY-2017", ""); //var cbn_code = "011"; //var prefixM = string.Concat("2", cbn_code, "LA"); ; //var lastMidGen = ""; //var recM = _repo.GetLastMidTidGenerated(prefixM, cbn_code, "M"); //if(recM != null) //{ // lastMidGen = recM.MERCHANTID; //} //var mid = MidTidGenerator.GenMid(prefixM, "2011LAAAAAAAAA9"); //Console.WriteLine("Start processing.........."); //LogFunction lgfn = new LogFunction(); //lgfn.loginfo("", null, DateTime.Now.ToString()); ////var D = new EmailProcess(); ////D.SendMerchantarteeSettlementEmail("24-MAY-2017", ""); //var output = @"C:\POS_AUTOMATION\SETTLEMENT_DETAIL_SETT_28-Jul-2017\ACCESS BANK NIGERIA PLC\ACQUIRER\NAIRA SETTLEMENT\ACCESS BANK NIGERIA PLC_ACQUIRER.xlsx"; //var ext = Path.GetExtension(output); //var fileNameNew = string.Concat(Path.GetFileNameWithoutExtension(output), "_", DateTime.Now.ToString("dd-MM-yyyy"), Path.GetExtension(output)); //var dest = @"C:\FTP_Path\UBA"; //if (File.Exists(output) && Directory.Exists(dest)) //{ // LogFunction2.WriteMaintenaceLogToFile("Directory exist for both source and destination path"); // // copy file to ftp path // File.Copy(output, Path.Combine(dest, fileNameNew)); // LogFunction2.WriteMaintenaceLogToFile("File Copied Successfully"); //} Console.WriteLine("enter a report type.........."); Console.WriteLine("1. SETTLEMENT MASTER REPORTS"); Console.WriteLine("2. NIBSS SETTLEMENT REPORTS"); Console.WriteLine("3. ACQUIRERE/ISSUER/MDB REPORTS"); Console.WriteLine("4. MERCHANT REPORTS"); Console.WriteLine("5. PTSP/PTSA/TERW/SWTH REPORTS"); Console.WriteLine("6. ARTEE MERCHANT REPORTS"); Console.WriteLine("7. VIP MERCHANT REPORT"); Console.WriteLine("8. COLLECTION REPORT"); Console.WriteLine("9. UPHSS REPORT"); Console.WriteLine("10. UPHSS REPORT CONSOLIDATED"); string opt = Console.ReadLine(); //GenHSSReportConsolidated Console.WriteLine("Select Date type.........."); Console.WriteLine("1. By Single Day"); Console.WriteLine("2. By Date Range"); string optdatetype = Console.ReadLine(); int noofdays = 0; string dtFrom = ""; if (optdatetype == "2") { Console.WriteLine("enter a report Start date.........."); string fromdt = Console.ReadLine(); Console.WriteLine("enter a report End date.........."); string todt = Console.ReadLine(); dtFrom = fromdt; noofdays = (Convert.ToDateTime(todt) - Convert.ToDateTime(fromdt)).Days; Console.WriteLine("Starting From" + dtFrom); for (int i = 0; i < noofdays; i++) { DateTime dtFromDate = Convert.ToDateTime(dtFrom); ////IDapperSettlementReport _repoSETT = new DapperSettlementReport(); ////bool sett = _repoSETT.GenSettlementFileSETT_EEPLUS(dtFromDate, null, reportPath, logopath, null); //IMainReport _repoSETT = new MainReport(); // _repoSETT.TestExport(); if (opt == "1") { Console.WriteLine("processing........SETTLEMENT MASTER REPORT" + dtFrom); string sett = _repoSETT.RPT_GenSettlementMASTER(DateTime.Parse(dtFrom), reportPath, logopath, null); } if (opt == "2") { Console.WriteLine("processing.........NIBSS Settlement Report" + dtFrom); //string sett = _repoSETT.RPT_GenSettlementFile2(DateTime.Parse(dtFrom), reportPath, logopath, null); } if (opt == "3") { Console.WriteLine("processing.........ACQUIRER/ISSUER/MDB REPORT" + dtFrom); //string sett = _repoSETT.RPT_GenSettlementFile(DateTime.Parse(dtFrom), reportPath, logopath, null); } if (opt == "4") { Console.WriteLine("processing..........Merchant Reports" + dtFrom); //string sett = _repoSETT.RPT_GenMerchants(DateTime.Parse(dtFrom), reportPath, logopath, null); } if (opt == "6") { Console.WriteLine("processing..........ARTEE Merchant Reports" + dtFrom); //string sett = _repoSETT.RPT_GenARTEEMerchant(DateTime.Parse(dtFrom), reportPath, logopath, null); //var P = new EmailProcess(); //P.SendMerchantarteeSettlementEmail(dtFrom, ""); } if (opt == "7") { Console.WriteLine("processing..........VIP Merchant Reports" + dtFrom); // string sett = _repoSETT.RPT_GenVIPMerchant(DateTime.Parse(dtFrom), reportPath, logopath, null); // var P = new EmailProcess(); //P.SendMerchantVIPSettlementEmail(dtFrom, ""); } if (opt == "8") { Console.WriteLine("processing..........Collection Merchant Reports" + dtFrom); // string sett = _repoSETT.RPT_CollectionGenMerchants(DateTime.Parse(dtFrom), reportPath, logopath, null); // var P = new EmailProcess(); // P.SendMerchantVIPSettlementEmail(dtFrom, ""); } ////if (opt == "5") ////{ //// Console.WriteLine("processing..........Merchant Report By Merchant Deposit Bank" + dtFrom); //// string sett = _repoSETT.RPT_GenMDBMerchants(DateTime.Parse(dtFrom), reportPath, logopath, null); ////} if (opt == "5") { Console.WriteLine("processing..........Party Report (PTSP/PTSA/TERW/SWTH)" + dtFrom); //string sett = _repoSETT.RPT_Settlement(DateTime.Parse(dtFrom), reportPath, logopath, null); } Console.WriteLine("processing Completed For " + dtFrom); dtFrom = Convert.ToDateTime(dtFrom).AddDays(1).ToString(); } Console.WriteLine("processing Completed"); } else { Console.WriteLine("enter a report processing date.........."); dtFrom = Console.ReadLine(); Console.WriteLine(dtFrom); //DateTime dtFromDate =DateTime.Parse(dtFrom); //DateTime dtFromDate = DateTime.ParseExact(dtFrom, "dd/MM/yyyy", null); //Console.WriteLine("enter a report type.........."); //Console.WriteLine("1. SETTLEMENT MASTER REPORTS"); //Console.WriteLine("2. NIBSS SETTLEMENT REPORTS"); //Console.WriteLine("3. ACQUIRERE/ISSUER/MDB REPORTS"); //Console.WriteLine("4. MERCHANT REPORTS"); //Console.WriteLine("5. PTSP/PTSA/TERW/SWTH REPORTS"); //Console.WriteLine("6. ARTEE MERCHANT REPORTS"); //Console.WriteLine("7. VIP MERCHANT REPORT"); //Console.WriteLine("8. COLLECTION REPORT"); // opt = Console.ReadLine(); Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB"); //dd/MM/yyyy if (opt == "1") { Console.WriteLine("processing........SETTLEMENT MASTER REPORT" + dtFrom); string sett = _repoSETT.RPT_GenSettlementMASTER(DateTime.Parse(dtFrom), reportPath, logopath, null); } if (opt == "2") { //Console.WriteLine("processing.........NIBSS Settlement Report" + dtFrom); string sett = _repoSETT.RPT_NIBSS(DateTime.Parse(dtFrom), reportPath, logopath, null); } if (opt == "3") { Console.WriteLine("processing.........ACQUIRERE/ISSUER/MDB REPORT" + dtFrom); string sett = _repoSETT.RPT_ACQUIREREISSMDB(DateTime.Parse(dtFrom), reportPath, logopath, null); } if (opt == "4") { Console.WriteLine("processing..........Merchant Reports" + dtFrom); // string sett = _repoSETT.RPT_GenMerchants(DateTime.Parse(dtFrom), reportPath, logopath, null); } if (opt == "6") { Console.WriteLine("processing..........ARTEE Merchant Reports" + dtFrom); //string sett = _repoSETT.RPT_GenARTEEMerchant(DateTime.Parse(dtFrom), reportPath, logopath, null); //var P = new EmailProcess(); //P.SendMerchantarteeSettlementEmail(dtFrom, ""); } if (opt == "7") { Console.WriteLine("processing..........VIP Merchant Reports" + dtFrom); //string sett = _repoSETT.RPT_GenVIPMerchant(DateTime.Parse(dtFrom), reportPath, logopath, null); //var P = new EmailProcess(); //P.SendMerchantVIPSettlementEmail(dtFrom, ""); } if (opt == "8") { Console.WriteLine("processing..........Collection Merchant Reports" + dtFrom); //string sett = _repoSETT.RPT_CollectionGenMerchants(DateTime.Parse(dtFrom), reportPath, logopath, null); // var P = new EmailProcess(); // P.SendMerchantVIPSettlementEmail(dtFrom, ""); } ////if (opt == "5") ////{ //// Console.WriteLine("processing..........Merchant Report By Merchant Deposit Bank" + dtFrom); //// string sett = _repoSETT.RPT_GenMDBMerchants(DateTime.Parse(dtFrom), reportPath, logopath, null); ////} if (opt == "5") { Console.WriteLine("processing..........Party Report (PTSP/PTSA/TERW/SWTH)" + dtFrom); //string sett = _repoSETT.RPT_Settlement(DateTime.Parse(dtFrom), reportPath, logopath, null); } if (opt == "9") { //string[] sessions = { "2018021916" }; Console.WriteLine("Enter Session ID: "); string sessionID = Console.ReadLine(); //foreach (string sessionID in sessions) //{ Console.WriteLine("processing..........UPHSS REPORT " + dtFrom + " SESSION: " + sessionID); //string sett = _repoSETT.RPT_GenHSSReport(DateTime.Parse(dtFrom), reportPath, logopath, null, sessionID); // } } if (opt == "10") { //string[] sessions = { "2018021916" }; // Console.WriteLine("Enter Session ID: "); // string sessionID = Console.ReadLine(); //foreach (string sessionID in sessions) //{ Console.WriteLine("processing..........UPHSS REPORT cosolidated "); //string sett = _repoSETT.GenHSSReportConsolidated(DateTime.Parse(dtFrom), reportPath, logopath, null); // } } Console.WriteLine("processing Completed"); } }
public override void LoadData() { base.LoadData(); this.StatusEditable = this.User.RoleId == (int)FixedRoles.Admin; this.CanAddAgencyRemarks = this.User.RoleId == (int)FixedRoles.Admin || (MainReport.EditableStatuses.Contains(this.Status) && (FixedRoles.AgencyUser | FixedRoles.Ser | FixedRoles.AgencyUserAndReviewer | FixedRoles.SerAndReviewer).HasFlag((FixedRoles)this.User.RoleId)); this.CanAddPoRemarks = this.User.RoleId == (int)FixedRoles.Admin || ( (this.Status == MainReport.Statuses.AwaitingProgramOfficerApproval || this.Status == MainReport.Statuses.AwaitingProgramAssistantApproval) && (FixedRoles.GlobalOfficer | FixedRoles.RegionOfficer | FixedRoles.RegionAssistant).HasFlag((FixedRoles)this.User.RoleId)); using (var db = new ccEntities()) { var subreports = db.SubReports.Where(this.Permissions.SubReportsFilter); var prevStatus = db.MainReportStatusAudits.Where(f => f.MainReportId == this.Id).OrderByDescending(f => f.StatusChangeDate).FirstOrDefault(); if (prevStatus != null) { this.PrevStatusId = prevStatus.OldStatusId; if (this.PoApprovalModel != null) { this.PoApprovalModel.PrevMainReportStatus = this.PrevStatus; } if (this.PaApprovalModel != null) { this.PaApprovalModel.PrevMainReportStatus = this.PrevStatus; } } var SerNameFE = (from cr in db.ClientReports join sbr in db.SubReports on cr.SubReportId equals sbr.Id join abs in db.AppBudgetServices on sbr.AppBudgetServiceId equals abs.Id join ser in db.Services on abs.ServiceId equals ser.Id where sbr.MainReportId == this.Id && ser.Id == 484//454 //&& cr.Amount != null select cr.Amount).Sum(); if (SerNameFE != 0 && SerNameFE != null) //FE there { var q = from agency in db.Agencies.Where(Permissions.AgencyFilter) where agency.GroupId == this.AgencyGroupId join a in (from c in ( from abs in db.AppBudgetServices where abs.AppBudgetId == this.AppBudgetId join sr in db.SubReports.Where(f => f.MainReportId == this.Id) on abs.Id equals sr.AppBudgetServiceId into srg from sr in srg.DefaultIfEmpty() select new { AgencyId = abs.AgencyId, Amount = sr.Amount, CcGrant = abs.CcGrant, MatchExp = sr.MatchingSum }) group c by c.AgencyId into eg select new { AgencyId = eg.Key, Amount = eg.Sum(f => f.Amount), Match = eg.Sum(f => f.MatchExp), CcGrant = eg.Sum(f => f.CcGrant) }) on agency.Id equals a.AgencyId into ag from a in ag.DefaultIfEmpty() join b in ( from sra in db.viewSubreportAmounts join appbs in db.AppBudgetServices on sra.AppBudgetServiceId equals appbs.Id where appbs.AppBudgetId == this.AppBudgetId join mr in db.MainReports.Where(MainReport.CurrentOrSubmitted(Id)) on sra.MainReportId equals mr.Id where mr.Start <= this.Start where sra.MainReportId == this.Id group sra by appbs.AgencyId into g select new { AgencyId = g.Key, Amount = g.Sum(f => f.Amount), MatchExp = g.Sum(f => f.MatchingSum) }) on a.AgencyId equals b.AgencyId into bg from b in bg.DefaultIfEmpty() select new MainReportDetailsModel.AgnencyTotalsClass() { AgencyId = agency.Id, AgencyName = agency.Name, //CcExp = (decimal?)a.Amount, //+ (decimal?)b.Amount , //CcExpFE = (decimal?)a.Amount + (decimal?)b.Amount, CcExp = (decimal?)b.Amount, //+ (decimal?)a.Amount, YtdMatchExp = (decimal?)b.MatchExp, YtdCcExp = (decimal?)b.Amount, CcGrant = (decimal?)a.CcGrant, CurrencyId = this.CurrencyId }; var ytdServicesQuery = (from appb in db.AppBudgets where appb.Id == this.AppBudgetId from appbs in appb.AppBudgetServices join sra in db.viewSubreportAmounts on appbs.Id equals sra.AppBudgetServiceId join mr in db.MainReports.Where(MainReport.CurrentOrSubmitted(Id)) on sra.MainReportId equals mr.Id where mr.Start <= this.Start select new YtdServicesQueryRow { ServiceId = appbs.ServiceId, ServiceTypeId = appbs.Service.TypeId, ReportingMethodId = appbs.Service.ReportingMethodId, Amount = sra.Amount, Quantity = sra.Quantity }); var ytdServiceTypesQuery = (from a in (from sra in ytdServicesQuery group sra by sra.ServiceTypeId into srag select new { ServiceTypeId = srag.Key, Amount = srag.Sum(f => f.Amount), Quantity = srag.Sum(f => f.Quantity) }) join st in db.ServiceTypes on a.ServiceTypeId equals st.Id select new { ServiceTypeId = st.Id, ServiceTypeName = st.Name, Amount = a.Amount, Quantity = a.Quantity ?? 1 }).ToList(); var ytdAppQuery = (from appb in db.AppBudgets where appb.Id == this.AppBudgetId from appbs in appb.AppBudgetServices join sra in db.viewSubreportAmounts on appbs.Id equals sra.AppBudgetServiceId join mr in db.MainReports on sra.MainReportId equals mr.Id where mr.Start <= this.Start select new YtdServicesQueryRow { ServiceId = appbs.ServiceId, ServiceTypeId = appbs.Service.TypeId, ReportingMethodId = appbs.Service.ReportingMethodId, Amount = sra.Amount, AppMatchBal = (decimal?)sra.MatchingSum, Quantity = sra.Quantity }); var ytdTotalReportedAppQuery = (from a in (from sra in ytdAppQuery group sra by sra.ServiceTypeId into srag select new { ServiceTypeId = srag.Key, Amount = srag.Sum(f => f.Amount), AppMatchBal = srag.Sum(f => f.AppMatchBal), Quantity = srag.Sum(f => f.Quantity) }) join st in db.ServiceTypes on a.ServiceTypeId equals st.Id select new { ServiceTypeId = st.Id, ServiceTypeName = st.Name, Amount = a.Amount, AppMatchBal = a.AppMatchBal, Quantity = a.Quantity ?? 1 }).ToList(); //HcYtdPercentage = ytdServiceTypesQuery.Where(f => f.ServiceTypeId == (int)Service.ServiceTypes.Homecare).Sum(f => f.Amount) / total, // CcExp = CcExp + ytdServicesQuery.y decimal?total = ytdServiceTypesQuery.Sum(f => f.Amount); if (total == 0) { total = null; } decimal?totalApp = total; decimal?totalAppMatchBal = ytdTotalReportedAppQuery.Sum(f => f.AppMatchBal); if (totalAppMatchBal == 0) { totalAppMatchBal = null; } this.Totals = new TotalsClass { AppAmount = this.AppAmount, AppMatch = this.AppMatch, CurrencyId = this.CurrencyId, AgencySubTotals = q.ToList(), HcYtdPercentage = ytdServiceTypesQuery.Where(f => f.ServiceTypeId == (int)Service.ServiceTypes.Homecare).Sum(f => f.Amount) / total, AoYtdPercentage = ytdServiceTypesQuery.Where(f => f.ServiceTypeId == (int)Service.ServiceTypes.AdministrativeOverhead).Sum(f => f.Amount) / total, TotalReportedApp = totalApp, TotalReportedAppMatchBalance = totalAppMatchBal, }; this.ReimbursementCosts = GetAvgReimrusement(ytdServicesQuery); } else { var q = from agency in db.Agencies.Where(Permissions.AgencyFilter) where agency.GroupId == this.AgencyGroupId join a in (from c in ( from abs in db.AppBudgetServices where abs.AppBudgetId == this.AppBudgetId join sr in db.SubReports.Where(f => f.MainReportId == this.Id) on abs.Id equals sr.AppBudgetServiceId into srg from sr in srg.DefaultIfEmpty() select new { AgencyId = abs.AgencyId, Amount = sr.Amount, CcGrant = abs.CcGrant, MatchExp = sr.MatchingSum }) group c by c.AgencyId into eg select new { AgencyId = eg.Key, Amount = eg.Sum(f => f.Amount), Match = eg.Sum(f => f.MatchExp), CcGrant = eg.Sum(f => f.CcGrant) }) on agency.Id equals a.AgencyId into ag from a in ag.DefaultIfEmpty() join b in ( from sra in db.viewSubreportAmounts join appbs in db.AppBudgetServices on sra.AppBudgetServiceId equals appbs.Id where appbs.AppBudgetId == this.AppBudgetId join mr in db.MainReports.Where(MainReport.CurrentOrSubmitted(Id)) on sra.MainReportId equals mr.Id where mr.Start <= this.Start where sra.MainReportId == this.Id //LenaK //join sbr in db.SubReports on sra.id equals sbr.Id group sra by appbs.AgencyId into g select new { AgencyId = g.Key, Amount = g.Sum(f => f.Amount), MatchExp = g.Sum(f => f.MatchingSum) }) on a.AgencyId equals b.AgencyId into bg from b in bg.DefaultIfEmpty() select new MainReportDetailsModel.AgnencyTotalsClass() { AgencyId = agency.Id, AgencyName = agency.Name, //CcExp = (decimal?)a.Amount, //+ (decimal?)b.Amount , // CcExpFE = (decimal?)a.Amount + (decimal?)b.Amount, CcExp = (decimal?)a.Amount, YtdMatchExp = (decimal?)b.MatchExp, YtdCcExp = (decimal?)b.Amount, CcGrant = (decimal?)a.CcGrant, CurrencyId = this.CurrencyId }; var ytdServicesQuery = (from appb in db.AppBudgets where appb.Id == this.AppBudgetId from appbs in appb.AppBudgetServices join sra in db.viewSubreportAmounts on appbs.Id equals sra.AppBudgetServiceId join mr in db.MainReports.Where(MainReport.CurrentOrSubmitted(Id)) on sra.MainReportId equals mr.Id where mr.Start <= this.Start select new YtdServicesQueryRow { ServiceId = appbs.ServiceId, ServiceTypeId = appbs.Service.TypeId, ReportingMethodId = appbs.Service.ReportingMethodId, Amount = sra.Amount, Quantity = sra.Quantity }); var ytdServiceTypesQuery = (from a in (from sra in ytdServicesQuery group sra by sra.ServiceTypeId into srag select new { ServiceTypeId = srag.Key, Amount = srag.Sum(f => f.Amount), Quantity = srag.Sum(f => f.Quantity) }) join st in db.ServiceTypes on a.ServiceTypeId equals st.Id select new { ServiceTypeId = st.Id, ServiceTypeName = st.Name, Amount = a.Amount, Quantity = a.Quantity ?? 1 }).ToList(); var ytdAppQuery = (from appb in db.AppBudgets where appb.Id == this.AppBudgetId from appbs in appb.AppBudgetServices join sra in db.viewSubreportAmounts on appbs.Id equals sra.AppBudgetServiceId join mr in db.MainReports on sra.MainReportId equals mr.Id where mr.Start <= this.Start select new YtdServicesQueryRow { ServiceId = appbs.ServiceId, ServiceTypeId = appbs.Service.TypeId, ReportingMethodId = appbs.Service.ReportingMethodId, Amount = sra.Amount, AppMatchBal = (decimal?)sra.MatchingSum, Quantity = sra.Quantity }); var ytdTotalReportedAppQuery = (from a in (from sra in ytdAppQuery group sra by sra.ServiceTypeId into srag select new { ServiceTypeId = srag.Key, Amount = srag.Sum(f => f.Amount), AppMatchBal = srag.Sum(f => f.AppMatchBal), Quantity = srag.Sum(f => f.Quantity) }) join st in db.ServiceTypes on a.ServiceTypeId equals st.Id select new { ServiceTypeId = st.Id, ServiceTypeName = st.Name, Amount = a.Amount, AppMatchBal = a.AppMatchBal, Quantity = a.Quantity ?? 1 }).ToList(); //HcYtdPercentage = ytdServiceTypesQuery.Where(f => f.ServiceTypeId == (int)Service.ServiceTypes.Homecare).Sum(f => f.Amount) / total, // CcExp = CcExp + ytdServicesQuery.y decimal?total = ytdServiceTypesQuery.Sum(f => f.Amount); decimal?totalApp = ytdTotalReportedAppQuery.Sum(f => f.Amount); decimal?totalAppMatchBal = ytdTotalReportedAppQuery.Sum(f => f.AppMatchBal); if (total == 0) { total = null; } if (totalAppMatchBal == 0) { totalAppMatchBal = null; } this.Totals = new TotalsClass { AppAmount = this.AppAmount, AppMatch = this.AppMatch, CurrencyId = this.CurrencyId, AgencySubTotals = q.ToList(), HcYtdPercentage = ytdServiceTypesQuery.Where(f => f.ServiceTypeId == (int)Service.ServiceTypes.Homecare).Sum(f => f.Amount) / total, AoYtdPercentage = ytdServiceTypesQuery.Where(f => f.ServiceTypeId == (int)Service.ServiceTypes.AdministrativeOverhead).Sum(f => f.Amount) / total, TotalReportedApp = totalApp, TotalReportedAppMatchBalance = totalAppMatchBal, }; this.ReimbursementCosts = GetAvgReimrusement(ytdServicesQuery); } if (this.PoApprovalModel != null || this.PaApprovalModel != null) { var appbudgetServices = from ab in db.AppBudgetServices.Where(this.Permissions.AppBudgetServicesFilter) join mr in db.MainReports on ab.AppBudgetId equals mr.AppBudgetId where mr.Id == this.Id select ab; var totalReported = (from a in appbudgetServices join v in db.viewSubreportAmounts on a.Id equals v.AppBudgetServiceId join mr in db.MainReports.Where(this.Permissions.MainReportsFilter).Where(MainReport.Submitted) on v.MainReportId equals mr.Id group v by a.AppBudgetId into vg select vg.Sum(f => f.Amount) ).SingleOrDefault(); if (this.PaApprovalModel != null) { this.PaApprovalModel.CancellationAmount = this.AppAmount - totalReported; this.PaApprovalModel.CurrencyId = this.CurrencyId; this.PaApprovalModel.LastReport = this.LastReport; } else { this.PoApprovalModel.CancellationAmount = this.AppAmount - totalReported; this.PoApprovalModel.CurrencyId = this.CurrencyId; this.PoApprovalModel.LastReport = this.LastReport; } } } }
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(); // //} //} }
public static HseapSummaryModel HseapDetailedData(CC.Data.ccEntities db, CC.Data.Services.IPermissionsBase permissions, int id) { var result = db.MainReports.Where(permissions.MainReportsFilter) .Select(f => new HseapSummaryModel { Id = f.Id, Start = f.Start, End = f.End, AppId = f.AppBudget.AppId, }) .SingleOrDefault(f => f.Id == id); if (result == null) { throw new ArgumentException("Main report not found"); } var mrs = from sr in db.SubReports.Where(permissions.SubReportsFilter) where sr.MainReportId == result.Id join er in db.EmergencyReports.Where(permissions.EmergencyReportsFilter) on sr.Id equals er.SubReportId group er by new { MainReportId = sr.MainReportId, er.TypeId } into erg select new { MainReportId = erg.Key.MainReportId, TypeId = erg.Key.TypeId, ClientsCount = erg.Select(f => f.ClientId).Distinct().Count(), GrantsCount = erg.Count(), TotalAmount = ((decimal?)erg.Sum(f => f.Total ?? 0) ?? 0) }; var apps = from mr in db.MainReports.Where(permissions.MainReportsFilter).Where(MainReport.CurrentOrSubmitted(id)) where mr.AppBudget.AppId == result.AppId join sr in db.SubReports.Where(permissions.SubReportsFilter) on mr.Id equals sr.MainReportId join er in db.EmergencyReports.Where(permissions.EmergencyReportsFilter) on sr.Id equals er.SubReportId group er by new { AppId = mr.AppBudget.AppId, TypeId = er.TypeId } into erg select new { AppId = erg.Key.AppId, TypeId = erg.Key.TypeId, ClientsCount = erg.Select(f => f.ClientId).Distinct().Count(), GrantsCount = erg.Count(), TotalAmount = ((decimal?)erg.Sum(f => f.Total ?? 0) ?? 0) }; var q = from t in db.EmergencyReportTypes join a in mrs on t.Id equals a.TypeId into mrsg from a in mrsg.DefaultIfEmpty() join b in apps on t.Id equals b.TypeId into appsg from b in appsg.DefaultIfEmpty() select new DataRow { TypeId = t.Id, TypeName = t.Name, TypeDescription = t.Description, ReportSummary = new DataRowSummary { ClientsCount = ((int?)a.ClientsCount) ?? 0, GrantsCount = ((int?)a.GrantsCount) ?? 0, TotalAmount = ((decimal?)a.TotalAmount) ?? 0 }, AppSummary = new DataRowSummary { ClientsCount = ((int?)b.ClientsCount) ?? 0, GrantsCount = ((int?)b.GrantsCount) ?? 0, TotalAmount = ((decimal?)b.TotalAmount) ?? 0 } }; result.Data = q.ToList(); var mrst = from sr in db.SubReports.Where(permissions.SubReportsFilter) where sr.MainReportId == result.Id join er in db.EmergencyReports.Where(permissions.EmergencyReportsFilter) on sr.Id equals er.SubReportId group er by new { MainReportId = sr.MainReportId } into erg select new { MainReportId = erg.Key.MainReportId, ClientsCount = erg.Select(f => f.ClientId).Distinct().Count(), GrantsCount = erg.Count(), TotalAmount = ((decimal?)erg.Sum(f => f.Total ?? 0) ?? 0) }; var appst = from mr in db.MainReports.Where(permissions.MainReportsFilter).Where(MainReport.CurrentOrSubmitted(id)) where mr.AppBudget.AppId == result.AppId join sr in db.SubReports.Where(permissions.SubReportsFilter) on mr.Id equals sr.MainReportId join er in db.EmergencyReports.Where(permissions.EmergencyReportsFilter) on sr.Id equals er.SubReportId group er by new { AppId = mr.AppBudget.AppId } into erg select new { AppId = erg.Key.AppId, ClientsCount = erg.Select(f => f.ClientId).Distinct().Count(), GrantsCount = erg.Count(), TotalAmount = ((decimal?)erg.Sum(f => f.Total ?? 0) ?? 0) }; result.TotalsRow = new DataRow { TypeName = "TOTAL", TypeId = 0, TypeDescription = null, ReportSummary = mrst.Select(f => new DataRowSummary { ClientsCount = f.ClientsCount, GrantsCount = f.GrantsCount, TotalAmount = f.TotalAmount }).FirstOrDefault(), AppSummary = appst.Select(f => new DataRowSummary { ClientsCount = f.ClientsCount, GrantsCount = f.GrantsCount, TotalAmount = f.TotalAmount }).FirstOrDefault() }; return(result); }