private void AdjustSelectedInvoice(AdjustInputDetails adjustInputDetails) { BaseValidator validator = new BaseValidator(); if (!validator.AdjustInvoice(adjustInputDetails)) { ShowError(validator.ClientException, AdjustLineItemError); return; } MessageBoxResult msgResult; if (userdata.IsMultipleLineItemAdjust) { msgResult = MessageBox.Show("Are you sure you want to adjust this line items?", "Adjustment Confirmation", MessageBoxButton.OKCancel); } else { msgResult = MessageBox.Show("Are you sure you want to adjust these line item?", "Adjustment Confirmation", MessageBoxButton.OKCancel); } if (msgResult == MessageBoxResult.Cancel) { EnableApplicationBar(); return; } string postData = JsonConvert.SerializeObject(adjustInputDetails); try { ServiceInvoker.InvokeServiceUsingPost("api/t360/LineItem/AdjustLineItems", postData, false, delegate(object a, ServiceEventArgs serviceEventArgs) { ServiceResponse result = serviceEventArgs.Result; if (result.Status) { Deployment.Current.Dispatcher.BeginInvoke(() => { EnableApplicationBar(); NavigationService.GoBack(); }); } else { List <Error> resultError = result.ErrorDetails; ShowError(new AppException(resultError), AdjustLineItemError); if (resultError[0] != null && T360ErrorCodes.NotInReviewerQueue == resultError[0].Code) { Deployment.Current.Dispatcher.BeginInvoke(() => { RedirectToInvoiceList(); }); } } }); } catch (Exception ex) { ShowError((AppException)ex); } }
private void doneButton_Click(object sender, EventArgs e) { DisableApplicationBar(); try { if (!ServiceInvoker.IsConnected) { ShowError(new AppException(T360ErrorCodes.UnableToConnectServer)); EnableApplicationBar(); return; } if (Source == Model.Base.Source.LINE_ITEM_MULTI_ADJUST) { GotoLineItemAdjustPage(); } else if (Source == Model.Base.Source.LINE_ITEM_MULTI_REJECT) { GotoLineItemRejectPage(); } else if (Source == Model.Base.Source.INVOICE_MULTI_APPROVE) { string message = InvoiceInputDetails.SelectedInvoices.Count == 1 ? "Are you sure you want to approve this invoice?" :"Are you sure you want to approve these invoices?"; MessageBoxResult msgResult = MessageBox.Show(message, "Approve Confirmation", MessageBoxButton.OKCancel); if (msgResult == MessageBoxResult.Cancel) { EnableApplicationBar(); return; } Dictionary <string, object> selectedInvoiceIds = new Dictionary <string, object>(); selectedInvoiceIds.Add(Constants.SelectedInvoiceIds, GetSelectedIds(InvoiceInputDetails.SelectedInvoices)); selectedInvoiceIds.Add(Constants.ForceApprove, false); ServiceInvoker.InvokeServiceUsingPost("api/t360/Invoice/ApproveMultipleInvoice", JsonConvert.SerializeObject(selectedInvoiceIds), false, InvoiceMultiApproveHandler); } else if (Source == Model.Base.Source.INVOICE_MULTI_REJECT) { InvoiceInputDetails.SelectedInvoiceIds = GetSelectedIds(InvoiceInputDetails.SelectedInvoices); InvoiceInputDetails.NetTotal = InvoiceInputDetails.NetTotal; UserData.Instance.IsMultipleInvoiceReject = true; GotoRejectPage(); } } catch (Exception ex) { if (ex is AppException) { ShowError((AppException)ex); } else { ShowError(new AppException(T360ErrorCodes.UNKNOWN)); } EnableApplicationBar(); } }
private void CalculateInvoiceNetAmount(bool isApprove) { try { if (!ServiceInvoker.IsConnected) { ShowError(new AppException(T360ErrorCodes.UnableToConnectServer)); EnableApplicationBar(); return; } IsApprove = isApprove; List <InvoiceModel> selectedInvoices = InvoiceListModel.InvoiceList.Where(x => x.IsCheckboxChecked).ToList(); List <string> selectedIds = new List <string>(); selectedInvoices.ForEach(x => { selectedIds.Add(x.InvoiceId.ToString()); }); Dictionary <string, List <string> > selectedInvoiceIds = new Dictionary <string, List <string> >(); selectedInvoiceIds.Add("SelectedInvoiceIds", selectedIds); ServiceInvoker.InvokeServiceUsingPost("/api/t360/Invoice/CalculateInvoiceNetAmount", JsonConvert.SerializeObject(selectedInvoiceIds), false, TotalNetAmountHandler); } catch (Exception ex) { if (ex is AppException) { ShowError((AppException)ex); } else { ShowError(new AppException(T360ErrorCodes.UNKNOWN)); } EnableApplicationBar(); } }
private void GotoAdjustPage() { List <string> ids = new List <string>(); ids.Add(CurrentLineItem.LineItemId); string postData = JsonConvert.SerializeObject(new ReasonCodeMultipleInput() { Action = Constants.AdjustLineItemAction, InvoiceId = HeaderDetails.InvoiceId.ToString(), SelectedLineItemIds = ids }); try { PageInProgress = true; this.ProgressBar.Show(); ServiceInvoker.InvokeServiceUsingPost("/api/t360/Invoice/GetReasonCodes", postData, false, AdjustLineItem); } catch (Exception ex) { if (ex is AppException) { ShowError((AppException)ex); } else { ShowError(new AppException(T360ErrorCodes.UNKNOWN)); } } }
private void GetLineItemsList(InvoiceInputDetails selectedInvoice) { string postData = DataSerializer.JsonSerializer <InvoiceInputDetails>(selectedInvoice); try { ServiceInvoker.InvokeServiceUsingPost("Invoice/InvoiceService.svc/GetLineItemList", postData, false, delegate(object a, ServiceEventArgs serviceEventArgs) { ServiceResponse result = serviceEventArgs.Result; if (result.Status) { List <InvoiceBasicInfo> lineItems = DataSerializer.JsonDeserialize <List <InvoiceBasicInfo> >(result.Output); this.invoiceLineItems = (from l in lineItems select l.LineItemId).ToList <string>(); this.GetLineItemsListResponse(result.Output); } else { List <Error> resultError = result.ErrorDetails; ShowError(new AppException(resultError), LineItemListError); if (resultError[0] != null && T360ErrorCodes.NotInReviewerQueue == resultError[0].Code) { Deployment.Current.Dispatcher.BeginInvoke(() => { RedirectToInvoiceList(); }); } } }); } catch (Exception ex) { ShowError((AppException)ex); } }
private void preferredCurrencyToggleSwitch_Checked(object sender, RoutedEventArgs e) { if (!ServiceInvoker.IsConnected) { DisableEvents(); preferredCurrencyToggleSwitch.IsChecked = false; EnableEvents(); ShowError(new AppException(T360ErrorCodes.UnableToConnectServer)); return; } string postData = JsonConvert.SerializeObject(new UserSettings() { IsPreferenceCurrencyEnabled = true }); try { ServiceInvoker.InvokeServiceUsingPost("/api/t360/Settings/UpdateSettings", postData, false, delegate(object a, ServiceEventArgs serviceEventArgs) { ServiceResponse result = serviceEventArgs.Result; if (!result.Status) { ShowError(new AppException(result.ErrorDetails), SettingsError); } }); } catch (Exception ex) { ShowError((AppException)ex); } }
private void RejectSelectedInvoice(RejectInput rejectInputDetails, string postData) { try { if (Source == Model.Base.Source.INVOICE_MULTI_REJECT_CONFIRMATION) { ServiceInvoker.InvokeServiceUsingPost("/api/t360/Invoice/RejectMultipleInvoice", postData, false, delegate(object a, ServiceEventArgs serviceEventArgs) { ServiceResponse result = serviceEventArgs.Result; if (result.Status) { Deployment.Current.Dispatcher.BeginInvoke(() => { RedirectToInvoiceList(); }); } else { handleRejectError(result.ErrorDetails, Constants.RejectInvoiceError); } }); } else if (Source == Model.Base.Source.INVOICE_SINGLE_REJECT) { ServiceInvoker.InvokeServiceUsingPost("/api/t360/Invoice/RejectInvoice", postData, false, delegate(object a, ServiceEventArgs serviceEventArgs) { ServiceResponse result = serviceEventArgs.Result; if (result.Status) { Deployment.Current.Dispatcher.BeginInvoke(() => { NavigationService.RemoveBackEntry(); NavigationService.GoBack(); }); } else { List <Error> resultError = result.ErrorDetails; ShowError(new AppException(resultError), Constants.RejectInvoiceError); if (resultError[0] != null && T360ErrorCodes.NotInReviewerQueue == resultError[0].Code) { Deployment.Current.Dispatcher.BeginInvoke(() => { RedirectToInvoiceList(); }); } } }); } } catch (Exception ex) { ShowError((AppException)ex); } }
private void GotoLineItemAdjustPage() { string postData = JsonConvert.SerializeObject(new ReasonCodeMultipleInput() { Action = "AdjustSelectedLineItems", InvoiceId = LineItemInputDetails.InvoiceId, SelectedLineItemIds = LineItemInputDetails.SelectedLineItemIds }); try { ServiceInvoker.InvokeServiceUsingPost("/api/t360/Invoice/GetReasonCodes", postData, false, delegate(object a, ServiceEventArgs serviceEventArgs) { ServiceResponse result = serviceEventArgs.Result; if (result.Status) { LineItemInputDetails.Reasons = JsonConvert.DeserializeObject <List <ReasonCode> >(result.Output); Deployment.Current.Dispatcher.BeginInvoke(() => { this.ProgressBar.Show(); PageInProgress = true; string url = string.Format("/Tymetrix.T360.Mobile.Client.AppWP8;component/Invoice/AdjustPage.xaml"); NavigationService.Navigate(new Uri(url, UriKind.Relative)); this.ProgressBar.Hide(); }); } else { List <Error> resultError = result.ErrorDetails; ShowError(new AppException(resultError), ConfirmationError); if (resultError[0] != null && T360ErrorCodes.NotInReviewerQueue == resultError[0].Code) { Deployment.Current.Dispatcher.BeginInvoke(() => { this.ProgressBar.Hide(); PageInProgress = false; RedirectToInvoiceList(); }); } else { EnableApplicationBar(); } } PageInProgress = false; }); } catch (Exception ex) { ShowError((AppException)ex); EnableApplicationBar(); } }
private void LoadTotalNetAmount() { InvoiceBasicInfo invoiceSummary = (InvoiceBasicInfo)PhoneApplicationService.Current.State[SelectedInvoice]; rejectMultiple.InvoiceId = invoiceSummary.InvoiceId; rejectMultiple.SelectedLineItemIds = new List <string>(); for (int i = 0; i < lstLineItems.Count; i++) { rejectMultiple.SelectedLineItemIds.Add(lstLineItems[i].LineItemId); } string postData = JsonConvert.SerializeObject(rejectMultiple); try { ServiceInvoker.InvokeServiceUsingPost("/api/t360/LineItem/CalculateLineItemNetAmount", postData, false, delegate(object a, ServiceEventArgs serviceEventArgs) { ServiceResponse result = serviceEventArgs.Result; if (result.Status) { MultipleLineItemsInputDetails rejectMultipleitem = JsonConvert.DeserializeObject <MultipleLineItemsInputDetails>(result.Output); rejectMultipleitem.InvoiceId = rejectMultiple.InvoiceId; rejectMultipleitem.SelectedLineItemIds = rejectMultiple.SelectedLineItemIds; PopulateRejectionData(rejectMultipleitem); } else { List <Error> resultError = result.ErrorDetails; ShowError(new AppException(resultError), LineItemReasonError); if (resultError[0] != null && T360ErrorCodes.NotInReviewerQueue == resultError[0].Code) { Deployment.Current.Dispatcher.BeginInvoke(() => { RedirectToInvoiceList(); }); } } PageInProgress = false; }); } catch (Exception ex) { ShowError((AppException)ex); } }
private void GotoAdjustPage() { string postData = JsonConvert.SerializeObject(new ReasonCodeMultipleInput() { Action = "AdjustSelectedLineItems", InvoiceId = rejectMultiple.InvoiceId, SelectedLineItemIds = lstLineItems.Select <InvoiceLineItemsInfo, string>(delegate(InvoiceLineItemsInfo info) { return(info.LineItemId); }).ToList() }); try { ServiceInvoker.InvokeServiceUsingPost("/api/t360/Invoice/GetReasonCodes", postData, false, delegate(object a, ServiceEventArgs serviceEventArgs) { ServiceResponse result = serviceEventArgs.Result; if (result.Status) { AdjustInput = JsonConvert.DeserializeObject <List <ReasonCode> >(result.Output); Deployment.Current.Dispatcher.BeginInvoke(() => { string adjustMultipleLineitems = JsonConvert.SerializeObject(rejectMultiple); string url = string.Format("/Tymetrix.T360.Mobile.Client.AppWP7;component/Invoice/AdjustLineItem.xaml?MultipleItems={0}", adjustMultipleLineitems); NavigationService.Navigate(new Uri(url, UriKind.Relative)); }); } else { List <Error> resultError = result.ErrorDetails; ShowError(new AppException(resultError), InvoiceReasonsError); if (resultError[0] != null && T360ErrorCodes.NotInReviewerQueue == resultError[0].Code) { Deployment.Current.Dispatcher.BeginInvoke(() => { RedirectToInvoiceList(); }); } } PageInProgress = false; }); } catch (Exception ex) { ShowError((AppException)ex); } }
private void doneButton_Click(object sender, EventArgs e) { try { if (!Constants.Warning.ToUpper().Equals((InvoiceDetails.PageType.ToUpper()))) { ReturnToInvoiceListPage(); return; } if (!ServiceInvoker.IsConnected) { ShowError(new AppException(T360ErrorCodes.UnableToConnectServer)); return; } List <InvoiceModel> selectedInvoices = InvoiceDetails.InvoiceBasicDetails; List <string> selectedIds = new List <string>(); selectedInvoices.ForEach(x => { selectedIds.Add(x.InvoiceId.ToString()); }); Dictionary <string, object> selectedInvoiceIds = new Dictionary <string, object>(); selectedInvoiceIds.Add(Constants.SelectedInvoiceIds, selectedIds); selectedInvoiceIds.Add(Constants.ForceApprove, true); ServiceInvoker.InvokeServiceUsingPost("api/t360/Invoice/ApproveMultipleInvoice", JsonConvert.SerializeObject(selectedInvoiceIds), false, InvoiceMultiApproveHandler); } catch (Exception ex) { if (ex is AppException) { ShowError((AppException)ex); } else { ShowError(new AppException(T360ErrorCodes.UNKNOWN)); } } }
private void LoadReasons(string action) { string postData = JsonConvert.SerializeObject(new ReasonCodeInputDetails() { Action = action }); try { ServiceInvoker.InvokeServiceUsingPost("/api/t360/Invoice/GetReasonCodes", postData, false, delegate(object a, ServiceEventArgs serviceEventArgs) { ServiceResponse result = serviceEventArgs.Result; if (result.Status) { Reasons = JsonConvert.DeserializeObject <List <ReasonCode> >(result.Output); LoadReasons(); } else { List <Error> resultError = result.ErrorDetails; ShowError(new AppException(resultError), InvoiceReasonsError); if (resultError[0] != null && T360ErrorCodes.NotInReviewerQueue == resultError[0].Code) { Deployment.Current.Dispatcher.BeginInvoke(() => { RedirectToInvoiceList(); }); } } PageInProgress = false; }); } catch (Exception ex) { ShowError((AppException)ex); } }
private void ChangePassword() { PageInProgress = true; ProgressBar.Show(); if (!ServiceInvoker.IsConnected) { ShowError(new AppException(T360ErrorCodes.UnableToConnectServer)); return; } BaseValidator validator = new BaseValidator(); Credential credential = GetData(); if (!validator.ResetPassword(credential) && !credential.UseLastPassword) { ShowError(validator.ClientException, PasswordError); FocusText(); return; } string postData = JsonConvert.SerializeObject(credential); ServiceInvoker.InvokeServiceUsingPost("api/t360/Security/ResetPassword", postData, false, delegate(object obj, ServiceEventArgs arg) { ServiceResponse response = arg.Result; if (!response.Status) { Deployment.Current.Dispatcher.BeginInvoke(() => { FocusText(); }); if (T360ErrorCodes.PasswordReset.Equals(response.ErrorDetails[0].Code) || T360ErrorCodes.RequestPasswordReset.Equals(response.ErrorDetails[0].Code) || T360ErrorCodes.TooSimplePassword.Equals(response.ErrorDetails[0].Code)) { Deployment.Current.Dispatcher.BeginInvoke(() => { credential = Credential.Instance; credential.Rules = response.ErrorDetails[0].Data; credential.ShowKeepCurrentPassword = T360ErrorCodes.RequestPasswordReset.Equals(response.ErrorDetails[0].Code); }); } else if (T360ErrorCodes.Disclaimer.Equals(response.ErrorDetails[0].Code)) { Deployment.Current.Dispatcher.BeginInvoke(() => { UserData.Instance.HasDisclaimer = true; UserData.Instance.DisclaimerTitle = response.ErrorDetails[0].Data[0]; UserData.Instance.DisclaimerData = response.ErrorDetails[0].Data[1]; Uri uri = new Uri("/Tymetrix.T360.Mobile.Client.AppWP7;component/Disclaimer/Disclaimer.xaml", UriKind.Relative); this.NavigationService.Navigate(uri); this.ProgressBar.Hide(); }); } else if (T360ErrorCodes.LicenseAgreement.Equals(response.ErrorDetails[0].Code)) { Deployment.Current.Dispatcher.BeginInvoke(() => { ShowError(new AppException(T360ErrorCodes.LicenseAgreement), "Login Failed"); RedirectToLogin(); }); } else { Deployment.Current.Dispatcher.BeginInvoke(() => { ShowError(new AppException(response.ErrorDetails), PasswordError); }); } return; } Deployment.Current.Dispatcher.BeginInvoke(() => { ProcessUserData(response.Output, "/Tymetrix.T360.Mobile.Client.AppWP7"); }); }); }
private void DoLogin(UserData userInfo) { BaseValidator validator = new BaseValidator(); if (!validator.ValidateLogOnFields(userInfo)) { ShowError(validator.ClientException, LoginError); return; } UserData.Instance.HasSaveUserName = (bool)saveUserToggleButton.IsChecked; UserData.Instance.HasIntegratedLogin = (bool)IntegratedToggleButton.IsChecked; ServiceInvoker.Initialize(delegate(object a, ServiceEventArgs serviceEventArgs) { ServiceResponse result = serviceEventArgs.Result; if (!result.Status) { ShowError(new AppException(result.ErrorDetails), LoginError); return; } if (!Convert.ToBoolean(result.Output)) { ShowError(new AppException(result.ErrorDetails), LoginError); return; } IsolatedStorageSettings.ApplicationSettings.Save(); string postData = JsonConvert.SerializeObject(userInfo); ServiceInvoker.InvokeServiceUsingPost("api/t360/Security/DoLogin", postData, true, delegate(object obj, ServiceEventArgs arg) { ServiceResponse response = arg.Result; if (!response.Status) { if (T360ErrorCodes.Disclaimer.Equals(response.ErrorDetails[0].Code)) { Deployment.Current.Dispatcher.BeginInvoke(() => { UserData.Instance.HasDisclaimer = true; UserData.Instance.DisclaimerTitle = response.ErrorDetails[0].Data[0]; UserData.Instance.DisclaimerData = response.ErrorDetails[0].Data[1]; UserActivity.Instance.LoadTimer(); UserData.Instance.IsAuthenticated = true; Uri uri = new Uri("/Tymetrix.T360.Mobile.Client.AppWP7;component/Disclaimer/Disclaimer.xaml", UriKind.Relative); this.NavigationService.Navigate(uri); this.ProgressBar.Hide(); }); } else if (T360ErrorCodes.PasswordReset.Equals(response.ErrorDetails[0].Code) || T360ErrorCodes.RequestPasswordReset.Equals(response.ErrorDetails[0].Code) || T360ErrorCodes.TooSimplePassword.Equals(response.ErrorDetails[0].Code)) { Deployment.Current.Dispatcher.BeginInvoke(() => { Credential credential = Credential.Instance; credential.Rules = response.ErrorDetails[0].Data; credential.ShowKeepCurrentPassword = T360ErrorCodes.RequestPasswordReset.Equals(response.ErrorDetails[0].Code); UserActivity.Instance.LoadTimer(); UserData.Instance.IsAuthenticated = true; Uri uri = new Uri("/Tymetrix.T360.Mobile.Client.AppWP7;component/ResetPassword/ResetPassword.xaml", UriKind.Relative); this.NavigationService.Navigate(uri); this.ProgressBar.Hide(); }); } else { ShowError(new AppException(response.ErrorDetails), LoginError); } return; } Deployment.Current.Dispatcher.BeginInvoke(() => { ProcessUserData(response.Output, "/Tymetrix.T360.Mobile.Client.AppWP7"); }); }); }); }