public static async Task<StatusInfo> SwiftVoidAsync(int batchNum) { var i = new StatusInfo(); try { //i.StatusMessage = "LETS PRETEND THE CHECKS ARE PRINTED NOW... "; //System.Threading.Thread.Sleep(5000); // client.BaseAddress = new Uri("http://*****:*****@reckner.com", "(manos)3k"); using (var client = new HttpClient(new HttpClientHandler { Credentials = credentials })) { #else using (var client = new HttpClient(new HttpClientHandler() { UseDefaultCredentials = true })) { #endif client.BaseAddress = new Uri(Settings.Default.SwiftPaySite); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // HTTP POST var response = await client.PostAsync(String.Format("api/swiftpayment/swiftvoid?batchNum={0}", batchNum), null); if (response.IsSuccessStatusCode) i.StatusMessage = "Swiftpay processing started"; i.IsBusy = false; } } catch (Exception e) { i.StatusMessage = String.Format("Swiftpay processing error for batch {0}", batchNum); i.ErrorMessage = e.Message; } return i; }
public async void GetPayments(PaymentReportCriteria p) { Status = new StatusInfo { ErrorMessage = "", IsBusy = true, StatusMessage = "getting payments..." }; try { ShowGridData = false; Payments = await Task<ObservableCollection<vwPayment>>.Factory.StartNew(() => { var task = RptSvc.GetOpenPayments(p); var v = new ObservableCollection<vwPayment>(task.Result); return v; }); HeadingText = string.Format("{0} Account Open Payment Report for Payments as of {1:ddd, MMM d, yyyy}", p.Account.account_name, p.EndDate); } catch (Exception e) { Status = new StatusInfo { StatusMessage = "Error loading payments", ErrorMessage = e.Message }; } }
public async void GetPayments(PaymentReportCriteria p) { Status = new StatusInfo { ErrorMessage = "", IsBusy = true, StatusMessage = "getting payments..." }; try { Payments = await Task<ObservableCollection<vwVoidedPayment>>.Factory.StartNew(() => { var task = RptSvc.GetVoidedPayments(p); return new ObservableCollection<vwVoidedPayment>(task.Result); }); } catch (Exception e) { Status = new StatusInfo { StatusMessage = "Error loading payments", ErrorMessage = e.Message }; } }
public async void UpdateBatchJob(int batchNum, int jobNum) { Status = new StatusInfo() { StatusMessage = String.Format("updating job associated with batch {0} to job number {1}", batchNum, jobNum), IsBusy = true }; await Task.Factory.StartNew(() => { try { var sb = BatchEdit.GetBatchEdit(batchNum); sb.JobNum = jobNum; sb = sb.Save(); } catch (Exception ex) { Status = new StatusInfo() { StatusMessage = String.Format("failed to update job number for batch {0}", batchNum), ErrorMessage = ex.Message }; } }); Status = new StatusInfo() { StatusMessage = String.Format("Batch {0} updated to JobNum {1} ", batchNum, jobNum) }; }
private void ResetState() { ShowGridData = false; Status = new StatusInfo { StatusMessage = "", ErrorMessage = "" }; }
private void ResetAll() { ResetState(); ExcelFilePath = DefaultWorkbook; SelectedWorksheet = DefaultSelectedWorksheet; Status = new StatusInfo { StatusMessage = DefaultWorkbook }; }
public async void ResetState() { Status = new StatusInfo { IsBusy = true, StatusMessage = "please wait. loading clients..." }; ClientReportCriteria = new ClientReportCriteria(); ClientReportCriteria.SearchType = ClientReportCriteria.ALLCLIENTJOBS; Clients = new ObservableCollection<CoopCheckClient>(await ClientSvc.GetClients()); JobYears = new ObservableCollection<string>(JobYearSvc.GetJobYears()); ClientReportCriteria.SelectedJobYear = ClientReportCriteria.ALLJOBYEARS; Status = new StatusInfo { StatusMessage = "pick a client or enter a specific job number" }; ShowGridData = false; }
public static async Task<StatusInfo> PrintOutstandingBalanceReportAsync(OutstandingBalanceStats stats) { return await Task<StatusInfo>.Factory.StartNew(() => { var status = new StatusInfo(); try { var app = new Application(); status = PrintOutstandingBalanceReport(app, stats); app.Quit(); } catch (Exception e) { status.StatusMessage = "printing failed"; status.ErrorMessage = e.Message; } return status; }); }
/// <summary> /// Initializes a new instance of the StatusViewModel class. /// </summary> public StatusViewModel() { var s = new StatusInfo { StatusMessage = "Welcome to Coopcheck", ErrorMessage = "", IsBusy = false }; Status = s; Messenger.Default.Register<NotificationMessage<StatusInfo>>(this, message => { Status = ObjectCopier.Clone(message.Content); //if (Status.ShowMessageBox) //{ // Messenger.Default.Send(new NotificationMessage(Notifications.ShowPopupStatus)); // Status.ShowMessageBox = false; //} }); }
private async void cbSheets_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { cbSheets.IsEnabled = false; _vm.Status = new StatusInfo { StatusMessage = "Importing worksheet...", ErrorMessage = "", IsBusy = true }; await Task.Factory.StartNew(() => { _vm.LoadWorkSheetData(); }); cbSheets.IsEnabled = true; } catch (Exception ex) { var s = new StatusInfo(); s.ErrorMessage = ex.Message; s.StatusMessage = "import failed"; _vm.Status = s; } }
public async void GetJobs() { ShowGridData = false; Jobs = new ObservableCollection<vwJobRpt>(); try { Jobs = new ObservableCollection<vwJobRpt>(); Status = new StatusInfo { ErrorMessage = "", IsBusy = true, StatusMessage = "refreshing job list..." }; Jobs = new ObservableCollection<vwJobRpt>(await RptSvc.GetJobRpt(PaymentReportCriteria)); } catch (Exception e) { Status = new StatusInfo { StatusMessage = "Error loading job list", ErrorMessage = e.Message }; } }
private void LoadWorksheetData() { Status = new StatusInfo { StatusMessage = "loading vouchers and checking address...", IsBusy = true }; if (!_voucherImporter.IsBusy) _voucherImporter.RunWorkerAsync(); StartEnabled = !_voucherImporter.IsBusy; }
public async void VoidCheck() { Status = new StatusInfo { StatusMessage = "voiding payment", IsBusy = true }; await Task.Factory.StartNew(() => { try { // if its a character check number then it is a swiftpayment if (SelectedPayment.IsSwiftPayment) VoidSwiftPromoCodeCommand.Execute(SelectedPayment.tran_id); else VoidCheckCommand.Execute(SelectedPayment.tran_id); GetPayments(); } catch (Exception ex) { Status = new StatusInfo { StatusMessage = "failed to void payment", ErrorMessage = ex.Message //ShowMessageBox = true }; } }); Status = new StatusInfo { StatusMessage = string.Format("check number {0} has been voided", SelectedPayment.check_num) //ShowMessageBox = true }; }
private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { StartEnabled = !_voucherImporter.IsBusy; Messenger.Default.Send(new NotificationMessage(Notifications.RefreshOpenBatchList)); Messenger.Default.Send(new NotificationMessage(Notifications.ImportWorksheetReady)); Status = new StatusInfo { StatusMessage = "vouchers loaded - select next to continue", IsBusy = false }; }
public void ImportVouchers() { VoucherImports = new ObservableCollection<VoucherImport>(); VoucherCnt = 0; VoucherTotalDollars = 0; try { if (!ShowColumnErrorData) { ExcelBook.AddMapping("First", "FIRST NAME"); ExcelBook.AddMapping("Last", "LAST NAME"); ExcelBook.AddMapping("AddressLine1", "ADDRESS 1"); ExcelBook.AddMapping("AddressLine2", "ADDRESS 2"); ExcelBook.AddMapping("Municipality", "CITY"); ExcelBook.AddMapping("Region", "STATE"); ExcelBook.AddMapping("PostalCode", "ZIPCODE"); ExcelBook.AddMapping("PhoneNumber", "PHONE"); ExcelBook.AddMapping("Amount", "AMOUNT"); ExcelBook.AddMapping("EmailAddress", "E-MAIL"); ExcelBook.AddMapping("JobNumber", "JOB #"); var vouchers = from a in ExcelBook.Worksheet<VoucherImport>(SelectedWorksheet) select a; foreach (var a in vouchers.Where(x => x.Last != "").Where(x => x.First != "")) { a.RecordID = Guid.NewGuid().ToString(); if (a.PostalCode != null && a.PostalCode.Length < 5) a.PostalCode = a.PostalCode.PadLeft(5, '0'); VoucherImports.Add(a); } VoucherCnt = VoucherImports.Count(); VoucherTotalDollars = VoucherImports.Select(x => x.Amount).Sum().GetValueOrDefault(0); CanProceed = true; } } catch (Exception e) { var s = new StatusInfo(); s.ErrorMessage = e.Message; s.StatusMessage = "import failed"; Status = s; } }
public async void SaveSelectedBatch() { //if ((SelectedBatch.IsSavable) && UserCanWrite) if (UserCanWrite) { Status = new StatusInfo {StatusMessage = "saving...", IsBusy = true}; try { SelectedBatch = await SelectedBatch.SaveAsync(); Status = new StatusInfo {StatusMessage = "saved"}; RefreshBatchList(); } catch (Exception ex) { log.Error(string.Format("batch save failed {0}", ex.Message)); Status = new StatusInfo {StatusMessage = "error during save", ErrorMessage = ex.Message}; } } else if (UserCanWrite) { var msgs = new List<string>(); var a = SelectedBatch.GetBrokenRules(); msgs.Add(a.ToString()); foreach (var v in SelectedBatch.Vouchers) { msgs.Add(v.BrokenRulesCollection.ToString()); } Status = new StatusInfo { StatusMessage = "Batch cannot be saved until all vouchers are valid", ErrorMessage = msgs.ToString() }; } }
public async void SwiftPay() { Status = new StatusInfo { ErrorMessage = "", IsBusy = true, StatusMessage = "executing swiftpay..." }; IsBusy = true; Status = await Task<StatusInfo>.Factory.StartNew(() => { try { var v = PaymentSvc.SwiftFulfillAsync(SelectedBatch.batch_num); return v.Result; } catch (Exception e) { Status = new StatusInfo { ErrorMessage = e.Message, IsBusy = true, StatusMessage = "swift payment failed" }; return Status; } }); IsBusy = false; }
public void LoadWorkSheetData() { if (SelectedWorksheet != DefaultSelectedWorksheet) { try { LoadWorksheetStats(); ImportVouchers(); //Status = new StatusInfo() //{ // StatusMessage = "select import to load this worksheet" //}; } catch (Exception e) { Status = new StatusInfo { StatusMessage = "Worksheet import failed", ErrorMessage = e.Message }; } } }
public async void ClearCheck() { Status = new StatusInfo { StatusMessage = "clearing check", IsBusy = true }; await Task.Factory.StartNew(() => { try { ClearCheckCommand.Execute(SelectedPayment.tran_id, DateTime.Today, SelectedPayment.tran_amount.GetValueOrDefault(0)); GetPayments(); } catch (Exception ex) { Status = new StatusInfo { StatusMessage = string.Format("failed to clear check number {0}", SelectedPayment.check_num), ErrorMessage = ex.Message }; } }); Status = new StatusInfo { StatusMessage = string.Format("check number {0} has been cleared", SelectedPayment.check_num) }; }
public async void CleanVouchers(List<VoucherImportWrapper> vouchers) { Messenger.Default.Send(new NotificationMessage(Notifications.HaveUncommittedVouchers)); Messenger.Default.Send(new NotificationMessage(Notifications.HaveDirtyVouchers)); Status = new StatusInfo { StatusMessage = "please wait - checking the street addresses, email and phone numbers of the vouchers...", IsBusy = true }; IsCleaning = true; CanPost = false; try { var results = await DataCleanVoucherImportSvc.CleanVouchers(vouchers); Messenger.Default.Send(new NotificationMessage<VoucherWrappersMessage>( new VoucherWrappersMessage { ExcelFileInfo = ExcelFileInfo, VoucherImports = results }, Notifications.VouchersDataCleaned)); CanPost = true; IsCleaning = false; } catch (Exception e) { log.Error(string.Format("clean vouchers failed {0} {1}", e.Message, e.InnerException?.Message )); CanPost = false; IsCleaning = false; log.Error(string.Format("cleaning the vouchers failed - {0} - {1} ", e.Message, e.InnerException?.Message)); string errorMessage = string.Format("error cleaning vouchers: {0}", e.Message); ModernDialog.ShowMessage(errorMessage, "Cleaning vouchers failed", MessageBoxButton.OK); } }
public void ResetState() { ShowSelectedBatch = false; ShowSelectedVoucher = false; Status = new StatusInfo(); //{ // StatusMessage = "fill and verify the details about the voucher batch ", // ErrorMessage = "" //}; UserCanRead = UserAuth.Instance.CanRead; UserCanWrite = UserAuth.Instance.CanWrite; }
public async void GetBatches() { ShowGridData = false; try { Status = new StatusInfo() { ErrorMessage = "", IsBusy = true, StatusMessage = "refreshing Batch list..." }; var v = await RptSvc.GetJobBatchRpt(ParentJob.job_num); BatchTotalDollars = v.Sum(x => x.total_amount).GetValueOrDefault(0); Batches = new ObservableCollection<vwBatchRpt>(v); SelectedBatch = null; } catch (Exception e) { Status = new StatusInfo() { StatusMessage = "Error loading Batch list", ErrorMessage = e.Message }; } }
public async void DeleteSelectedBatch() { if (SelectedBatch != null) { var v = SelectedBatch.Num; if (UserCanWrite) { try { await BatchSvc.DeleteBatchEditAsync(v); Messenger.Default.Send(new NotificationMessage(Notifications.RefreshOpenBatchList)); Status = new StatusInfo { StatusMessage = string.Format("{0} Batch has been deleted", v) }; ResetState(); } catch (Exception e) { Status = new StatusInfo { StatusMessage = string.Format("{0} could not delete batch", v), ErrorMessage = e.Message }; } } } ; }
public void LoadWorksheetStats() { Status = new StatusInfo { StatusMessage = "Loading columns...", IsBusy = true, ErrorMessage = "" }; try { SrcColumnNames = new ObservableCollection<string>(ExcelBook.GetColumnNames(SelectedWorksheet)); ColumnNameValidator(); Status = new StatusInfo { StatusMessage = "", ErrorMessage = "" }; } catch (Exception ex) { Status = new StatusInfo { StatusMessage = "Error reading column names does selected worksheet contain vouchers?", ErrorMessage = ex.Message }; } }
public async void GetPayments() { try { var pay = await RptSvc.GetPayeePayments(LastName, FirstName); Payments = new ObservableCollection<vwPayment>(pay); } catch (Exception e) { Status = new StatusInfo { StatusMessage = "Error loading payments", ErrorMessage = e.Message }; } }
public void ColumnNameValidator() { var s = new StatusInfo(); if (SrcColumnNames == null) { s.ErrorMessage = "No valid Columns found"; s.StatusMessage = "Cannot Import"; Status = s; VoucherCnt = 0; return; } var found = false; foreach (var t in ValidColumnNames) { for (var x = 0; x < SrcColumnNames.Count; x++) { if (t == SrcColumnNames[x]) { ColumnMap.Add(new ColumnPropertyMap { ColumnName = t, Available = true, ColumnOffset = x }); found = true; break; } } if (!found) { ColumnMap.Add(new ColumnPropertyMap { ColumnName = t, Available = false }); } } if (!ColumnMap.Any(x => x.Available)) { s.ErrorMessage = "No valid Columns found"; s.StatusMessage = "Cannot Import"; VoucherCnt = 0; ShowColumnErrorData = true; } else if (ColumnMap.Any(x => x.Available == false)) { s.StatusMessage = "Cannot Import"; s.ErrorMessage = "Some required columns were not found "; VoucherCnt = 0; ShowColumnErrorData = true; } else { s.StatusMessage = "Click Next to continue"; s.ErrorMessage = ""; ShowColumnErrorData = false; CanProceed = true; } Status = s; }
public async void CleanVouchers(List<VoucherImportWrapper> vouchers) { Messenger.Default.Send(new NotificationMessage(Notifications.HaveUncommittedVouchers)); Messenger.Default.Send(new NotificationMessage(Notifications.HaveDirtyVouchers)); Messenger.Default.Send(new NotificationMessage(Notifications.ImportWorksheetReady)); Status = new StatusInfo { StatusMessage = "please wait - checking the street addresses, email and phone numbers of the vouchers...", IsBusy = true }; var results = await DataCleanVoucherImportSvc.CleanVouchers(vouchers); Messenger.Default.Send(new NotificationMessage<VoucherWrappersMessage>( new VoucherWrappersMessage { ExcelFileInfo = new ExcelFileInfoMessage { ExcelFilePath = ExcelFilePath, SelectedWorksheet = SelectedWorksheet }, VoucherImports = results }, Notifications.VouchersDataCleaned)); }
public async void AutoSaveSelectedBatch() { if ((SelectedBatch.IsSavable) && UserCanWrite) { Status = new StatusInfo { StatusMessage = "saving...", IsBusy = true }; try { SelectedBatch = await SelectedBatch.SaveAsync(); } catch (Exception ex) { log.Error(string.Format("batch save failed {0}", ex.Message)); Status = new StatusInfo { StatusMessage = "error saving", ErrorMessage = ex.Message, IsBusy = false }; } } }
public async void GetJobs() { ShowGridData = false; Jobs = new ObservableCollection<vwJobRpt>(); try { Status = new StatusInfo { ErrorMessage = "", IsBusy = true, StatusMessage = "refreshing job list..." }; if (ClientReportCriteria.SearchType == ClientReportCriteria.ONEJOB) Jobs = new ObservableCollection<vwJobRpt>( await RptSvc.GetJob(int.Parse(ClientReportCriteria.SelectedJobNum))); else { if (ClientReportCriteria.SearchType == ClientReportCriteria.ALLCLIENTJOBS) Jobs = new ObservableCollection<vwJobRpt>( await RptSvc.GetAllClientJobs(ClientReportCriteria.SelectedClientID)); } if (ClientReportCriteria.SearchType == ClientReportCriteria.ALLCLIENTJOBSFORYEAR) { Jobs = new ObservableCollection<vwJobRpt>( await RptSvc.GetAllClientJobs(ClientReportCriteria.SelectedClientID, ClientReportCriteria.SelectedJobYear)); } } catch (Exception e) { Status = new StatusInfo { StatusMessage = "Error loading job list", ErrorMessage = e.Message }; } }
public void LoadWorksheetMetaData() { var s = new StatusInfo(); if (File.Exists(ExcelFilePath)) try { ExcelBook = new ExcelQueryFactory(ExcelFilePath); WorkSheets = new ObservableCollection<string>(ExcelBook.GetWorksheetNames()); SelectedWorksheet = WorkSheets.First(); } catch (Exception e) { s.ErrorMessage = string.Format("File could not be processed {0}", e.Message); } else s.ErrorMessage = string.Format("File Not Found {0}", ExcelFilePath); Status = s; }