public bool GenerateAllSummaryFiles() { try { string dbPath = MyConstants.DBReceivedFromServer; // concern var dbDates = this.jrt._ds.GetRunDatesFromDB(dbPath); if (dbDates != null) { this.jrt._tabs._scView.Log("Generating daily payments summary files..."); foreach (string dbDate in dbDates) { jrt.Customers = new List <Customer> (); jrt.UserAddedCustomers = new List <Customer> (); jrt.MainJobList = new List <Job> (); jrt.UserCreatedJobs = new List <Job> (); this.jrt._ds.ReadRunData(dbDate, dbPath); this.SummaryMode = SummaryModes.Money; this.ViewDidAppear(false); // string summary = String.Join (String.Empty, SummaryData.ToArray ()); GeneratePaymentsSummaryFile(dbDate); } } return(true); } catch (Exception e) { this.jrt._tabs._scView.Log("Exception : " + e.Message + "\n" + e.StackTrace); return(false); } }
public PaymentsSummary(RootElement root, PaymentsSummaryNavigationController pnav, JobRunTable JRT) : base(root) { SummaryMode = SummaryModes.Money; jrt = JRT; Nav = pnav; Root.Caption = "Daily payments summary"; Root.Add(new Section("Customer# Type To collect Received")); Root.Add(new Section("Totals")); Root[0].Footer = ""; // Payments = new List<JobPayment>(); SummaryData = new List <string>(); JobsByType = new Dictionary <string, int>(); PrintDailySummary = delegate { if (this.View != null) { // exception handling here string pdfFileName = MyConstants.PreparePDFFileForPrintingAView(this.TableView); if (pdfFileName != "") { BeginPrintingDailySummary(pdfFileName); } else { var savingError = new UIAlertView("Failed to generate a summary file for printing.", "", null, "Sad times..."); savingError.Show(); } } }; EmailDailySummary = delegate { if (MFMailComposeViewController.CanSendMail) { string dailySummaryType = (this.SummaryMode == SummaryModes.Money)? "Payments" : "Stock"; string dailySummaryPath = (this.SummaryMode == SummaryModes.Money)? GeneratePaymentsSummaryFile() : GenerateStockSummaryFile(); NSData fileContents = NSData.FromFile(dailySummaryPath); mail = new MFMailComposeViewController(); if (fileContents != null) { mail.AddAttachmentData(fileContents, "text/plain", String.Format("{0} {1}.txt", MyConstants.DEBUG_TODAY.Substring(2, 10), dailySummaryType)); } Action act = delegate { }; mail.SetSubject(String.Format("{0} summary {1}", dailySummaryType, MyConstants.DEBUG_TODAY.Substring(2, 10))); mail.SetToRecipients(new string[] { "*****@*****.**" }); mail.Finished += delegate(object sender, MFComposeResultEventArgs e) { if (e.Result == MFMailComposeResult.Sent) { var alert = new UIAlertView("", "Email sent.", null, "OK"); alert.Show(); } else { var alert = new UIAlertView(e.Result.ToString(), "Email has not been sent.", null, "OK"); alert.Show(); } this.DismissViewController(true, act); }; this.PresentViewController(mail, true, act); // this.PresentModalViewController (mail, true); } else { var alert = new UIAlertView("", "It seems like this iPad cannot send e-mails at the time. Please check the network settings and try again", null, "OK"); alert.Show(); } }; WeeklySummaryMail = delegate { if (MFMailComposeViewController.CanSendMail) { UIAlertView notYet = new UIAlertView("Not implemented yet...", "", null, "OK"); notYet.Show(); } else { var alert = new UIAlertView("", "It seems like this iPad cannot send e-mails at the time. Please check the network settings and try again", null, "OK"); alert.Show(); } }; SwitchToMoney = delegate { UIView.BeginAnimations(null); // UIView.SetAnimationDuration (0.3f); ToolbarItems = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Print this summary", UIBarButtonItemStyle.Bordered, PrintDailySummary), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Email this summary", UIBarButtonItemStyle.Bordered, EmailDailySummary), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Switch to stock", UIBarButtonItemStyle.Bordered, SwitchToStock), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), }; this.SummaryMode = SummaryModes.Money; this.ViewDidAppear(false); UIView.CommitAnimations(); }; SwitchToStock = delegate { UIView.BeginAnimations(null); // UIView.SetAnimationDuration (0.5f); ToolbarItems = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Print this summary", UIBarButtonItemStyle.Bordered, PrintDailySummary), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Email this summary", UIBarButtonItemStyle.Bordered, EmailDailySummary), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("View stock float", UIBarButtonItemStyle.Bordered, SwitchToStockFloat), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Switch to money", UIBarButtonItemStyle.Bordered, SwitchToMoney), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), }; this.SummaryMode = SummaryModes.Stock; this.ViewDidAppear(false); this.ReloadData(); UIView.CommitAnimations(); }; SwitchToStockFloat = delegate { UIView.BeginAnimations(null); ToolbarItems = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("View stock used", UIBarButtonItemStyle.Bordered, SwitchToStock), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Switch to money", UIBarButtonItemStyle.Bordered, SwitchToMoney), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), }; this.SummaryMode = SummaryModes.Float; this.ViewDidAppear(false); this.ReloadData(); UIView.CommitAnimations(); }; ToolbarItems = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Print this summary", UIBarButtonItemStyle.Plain, PrintDailySummary), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Email this summary", UIBarButtonItemStyle.Plain, EmailDailySummary), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Switch to stock", UIBarButtonItemStyle.Plain, SwitchToStock), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), }; }