public void writeOrdersTest() { LegacyService ls = new LegacyService(); ls.writeOrders(); List <Orders> orders = new IProductRepository(new ProdDB()).getOrders(); string RootPath = Path.Combine(Path.GetFullPath(Directory.GetCurrentDirectory()), @"..\..\..\"); bool check; int count = 0; foreach (Orders o in orders) { string path = Path.Combine(RootPath, o.product_Name + "Order.txt"); if (File.Exists(path)) { count++; } } if (count == 3) { check = true; } else { check = false; } Assert.IsTrue(check); }
private async void ResendExecute() { if (_sentCode == null) { //... return; } if (_sentCode.HasNextType) { IsLoading = true; var response = await LegacyService.ResendCodeAsync(_phoneNumber, _sentCode.PhoneCodeHash); if (response.IsSucceeded) { if (response.Result.Type is TLAuthSentCodeTypeSms || response.Result.Type is TLAuthSentCodeTypeApp) { NavigationService.Navigate(typeof(SignInSentCodePage), new SignInSentCodePage.NavigationParameters { PhoneNumber = _phoneNumber, //Result = response.Result }); } } } }
private async void ForgotExecute() { if (_parameters == null) { // TODO: ... return; } if (_parameters.Result.HasRecoveryEmailAddress) { IsLoading = true; var response = await LegacyService.RequestPasswordRecoveryAsync(); if (response.IsSucceeded) { await TLMessageDialog.ShowAsync(string.Format(Strings.Resources.RestoreEmailSent, response.Result.EmailPattern), Strings.Resources.AppName, Strings.Resources.OK); // TODO: show recovery page } else if (response.Error != null) { IsLoading = false; await TLMessageDialog.ShowAsync(response.Error.ErrorMessage, Strings.Resources.AppName, Strings.Resources.OK); } } else { await TLMessageDialog.ShowAsync(Strings.Resources.RestorePasswordNoEmailText, Strings.Resources.RestorePasswordNoEmailTitle, Strings.Resources.OK); IsResettable = true; } }
private async void ForgotExecute() { if (_passwordBase == null) { // TODO: ... return; } if (_passwordBase.HasRecovery) { IsLoading = true; var response = await LegacyService.RequestPasswordRecoveryAsync(); if (response.IsSucceeded) { await TLMessageDialog.ShowAsync(string.Format("We have sent a recovery code to the e-mail you provided:\n\n{0}", response.Result.EmailPattern), "Telegram", "OK"); } else if (response.Error != null) { IsLoading = false; await new TLMessageDialog(response.Error.ErrorMessage ?? "Error message", response.Error.ErrorCode.ToString()).ShowQueuedAsync(); } } else { await TLMessageDialog.ShowAsync("Since you haven't provided a recovery e-mail when setting up your password, your remaining options are either to remember your password or to reset your account.", "Sorry", "OK"); //IsResettable = true; } }
private async void Update() { var response = await LegacyService.GetPasswordAsync(); if (response.IsSucceeded) { } }
public async Task <IActionResult> BadBlocking8() { var service = new LegacyService(); var result = await service.DoAsyncOverSyncOperation(); return(Ok(result)); }
public async Task <IActionResult> GoodBlocking() { var service = new LegacyService(); var result = await service.DoSyncOperationWithAsyncReturn(); return(Ok(result)); }
public async Task <IActionResult> AsyncCall() { var service = new LegacyService(); var result = await service.DoAsyncOperation(); return(Ok(result)); }
public async Task <IActionResult> AsyncCallLegacyGood() { var service = new LegacyService(); var result = await service.DoAsyncOperationOverLegacy(HttpContext.RequestAborted); return(Ok(result)); }
public async Task <IActionResult> LegacyCancellationWithCancellationGood() { var service = new LegacyService(); var result = await service.DoAsyncOperation().WithCancellation(HttpContext.RequestAborted); return(Ok(result)); }
public IActionResult BadBlocking7() { var service = new LegacyService(); var result = service.DoOperationBlocking7(); return(Ok(result)); }
public async Task <IActionResult> LegacyCancellationWithTimeoutGood() { var service = new LegacyService(); var timeout = TimeSpan.FromSeconds(10); var result = await service.DoAsyncOperation().TimeoutAfter(timeout); return(Ok(result)); }
private async void SendExecute() { if (_sentCode == null) { //... return; } if (_firstName == null) { RaisePropertyChanged("FIRSTNAME_INVALID"); return; } var phoneNumber = _phoneNumber; var phoneCodeHash = _sentCode.PhoneCodeHash; IsLoading = true; var response = await LegacyService.SignUpAsync(phoneNumber, phoneCodeHash, _phoneCode, _firstName, _lastName); if (response.IsSucceeded) { // TODO: maybe ask about notifications? NavigationService.Navigate(typeof(MainPage)); } else if (response.Error != null) { IsLoading = false; if (response.Error.TypeEquals(TLErrorType.PHONE_NUMBER_INVALID)) { await TLMessageDialog.ShowAsync(Strings.Resources.InvalidPhoneNumber, Strings.Resources.AppName, Strings.Resources.OK); } else if (response.Error.TypeEquals(TLErrorType.PHONE_CODE_EMPTY) || response.Error.TypeEquals(TLErrorType.PHONE_CODE_INVALID)) { await TLMessageDialog.ShowAsync(Strings.Resources.InvalidCode, Strings.Resources.AppName, Strings.Resources.OK); } else if (response.Error.TypeEquals(TLErrorType.PHONE_CODE_EXPIRED)) { await TLMessageDialog.ShowAsync(Strings.Resources.CodeExpired, Strings.Resources.AppName, Strings.Resources.OK); } else if (response.Error.TypeEquals(TLErrorType.FIRSTNAME_INVALID)) { await TLMessageDialog.ShowAsync(Strings.Resources.InvalidFirstName, Strings.Resources.AppName, Strings.Resources.OK); } else if (response.Error.TypeEquals(TLErrorType.LASTNAME_INVALID)) { await TLMessageDialog.ShowAsync(Strings.Resources.InvalidLastName, Strings.Resources.AppName, Strings.Resources.OK); } else { await TLMessageDialog.ShowAsync(response.Error.ErrorMessage, Strings.Resources.AppName, Strings.Resources.OK); } } }
private async void SendExecute() { IsLoading = true; var passwordResponse = await LegacyService.GetPasswordAsync(); if (passwordResponse.IsSucceeded) { if (passwordResponse.Result is TLAccountPassword password) { var currentSalt = password.CurrentSalt; var hash = TLUtils.Combine(currentSalt, Encoding.UTF8.GetBytes(_password), currentSalt); var input = CryptographicBuffer.CreateFromByteArray(hash); var hasher = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256); var hashed = hasher.HashData(input); CryptographicBuffer.CopyToByteArray(hashed, out byte[] data); var response = await LegacyService.GetTmpPasswordAsync(data, 60 * 30); if (response.IsSucceeded) { ApplicationSettings.Current.TmpPassword = response.Result; //NavigationService.NavigateToPaymentFormStep5(_message, _paymentForm, _info, _requestedInfo, _shipping, null, null, true); } else if (response.Error != null) { IsLoading = false; if (response.Error.TypeEquals(TLErrorType.PASSWORD_HASH_INVALID)) { Password = string.Empty; RaisePropertyChanged(response.Error.ErrorMessage); } else { } } } else { } } else if (passwordResponse.Error != null) { IsLoading = false; } }
private async void SendExecute() { var disclaimer = await TLMessageDialog.ShowAsync(string.Format(Strings.Resources.PaymentWarningText, _bot.FullName, _provider.FullName), Strings.Resources.PaymentWarning, Strings.Resources.OK); var confirm = await TLMessageDialog.ShowAsync(string.Format(Strings.Resources.PaymentTransactionMessage, Locale.FormatCurrency(_totalAmount, _paymentForm.Invoice.Currency), _bot.FullName, _invoice.Title), Strings.Resources.PaymentTransactionReview, Strings.Resources.OK, Strings.Resources.Cancel); if (confirm != Windows.UI.Xaml.Controls.ContentDialogResult.Primary) { return; } IsLoading = true; TLInputPaymentCredentialsBase credentials; if (_paymentForm.HasSavedCredentials && _paymentForm.SavedCredentials is TLPaymentSavedCredentialsCard savedCard) { credentials = new TLInputPaymentCredentialsSaved { Id = savedCard.Id, TmpPassword = ApplicationSettings.Current.TmpPassword.TmpPassword }; } else { credentials = new TLInputPaymentCredentials { Data = new TLDataJSON { Data = _credentials }, IsSave = _save }; } var response = await LegacyService.SendPaymentFormAsync(_message.Id, _requestedInfo?.Id, _shipping?.Id, credentials); if (response.IsSucceeded) { if (response.Result is TLPaymentsPaymentVerficationNeeded verificationNeeded) { if (Uri.TryCreate(verificationNeeded.Url, UriKind.Absolute, out Uri uri)) { await Launcher.LaunchUriAsync(uri); } } NavigationService.GoBackAt(1); } else if (response.Error != null) { } }
private async void SendExecute() { if (_passwordBase == null) { // TODO: ... return; } if (_password == null) { await TLMessageDialog.ShowAsync("Please enter your password."); return; } var currentSalt = _passwordBase.CurrentSalt; var hash = TLUtils.Combine(currentSalt, Encoding.UTF8.GetBytes(_password), currentSalt); var input = CryptographicBuffer.CreateFromByteArray(hash); var hasher = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256); var hashed = hasher.HashData(input); CryptographicBuffer.CopyToByteArray(hashed, out byte[] data); var response = await LegacyService.CheckPasswordAsync(data); if (response.IsSucceeded) { // TODO: maybe ask about notifications? NavigationService.Navigate(typeof(MainPage)); } else { if (response.Error.TypeEquals(TLErrorType.PASSWORD_HASH_INVALID)) { //await new MessageDialog(Resources.PasswordInvalidString, Resources.Error).ShowAsync(); } else if (response.Error.CodeEquals(TLErrorCode.FLOOD)) { //await new MessageDialog($"{Resources.FloodWaitString}\r\n\r\n({result.Error.Message})", Resources.Error).ShowAsync(); } Execute.ShowDebugMessage("account.checkPassword error " + response.Error); } }
public ActionResult DocumentazioneVia() { ActionResult result = null; int id = Parse.ToInt32OrDefault(Request.QueryString["ID_Progetto"], 0); int oggettoProceduraID = LegacyService.GetUltimoOggettoProceduraID(id); if (id > 0 && oggettoProceduraID > 0) { result = RedirectToActionPermanent("Documentazione", "Oggetti", new { id = id, oggettoProceduraID = oggettoProceduraID }); } else { result = HttpNotFound(); } return(result); }
public ActionResult MetadatoDocumentoVas() { ActionResult result = null; int id = Parse.ToInt32OrDefault(Request.QueryString["ID_Documento"], 0); if (id > 0) { id = LegacyService.GetDocumentoVasID(id); result = RedirectToActionPermanent("MetadatoDocumento", "Oggetti", new { id = id }); } else { result = HttpNotFound(); } return(result); }
public ActionResult InfoVas() { ActionResult result = null; int id = Parse.ToInt32OrDefault(Request.QueryString["ID_PianoProgramma"], 0); if (id > 0) { id = LegacyService.GetOggettoVasID(id); result = RedirectToActionPermanent("Info", "Oggetti", new { id = id }); } else { result = HttpNotFound(); } return(result); }
private async void SendExecute() { if (string.IsNullOrEmpty(_phoneCode)) { RaisePropertyChanged("PHONE_CODE_INVALID"); return; } if (string.IsNullOrEmpty(_phoneNumber)) { RaisePropertyChanged("PHONE_NUMBER_INVALID"); return; } IsLoading = true; var response = await LegacyService.SendChangePhoneCodeAsync(_phoneCode + _phoneNumber, /* TODO: Verify */ null); if (response.IsSucceeded) { var state = new SettingsPhoneSentCodePage.NavigationParameters { PhoneNumber = PhoneCode.TrimStart('+') + PhoneNumber, Result = response.Result, }; NavigationService.Navigate(typeof(SettingsPhoneSentCodePage), state); } else if (response.Error != null) { IsLoading = false; if (response.Error.TypeEquals(TLErrorType.PHONE_NUMBER_FLOOD)) { await TLMessageDialog.ShowAsync("Sorry, you have deleted and re-created your account too many times recently. Please wait for a few days before signing up again.", "Telegram", "OK"); } else { await new TLMessageDialog(response.Error.ErrorMessage ?? "Error message", response.Error.ErrorCode.ToString()).ShowQueuedAsync(); } } }
private async void ResetExecute() { var confirm = await TLMessageDialog.ShowAsync(Strings.Resources.ResetMyAccountWarningText, Strings.Resources.ResetMyAccountWarning, Strings.Resources.ResetMyAccountWarningReset, Strings.Resources.Cancel); if (confirm == ContentDialogResult.Primary) { IsLoading = true; var response = await LegacyService.DeleteAccountAsync("Forgot password"); if (response.IsSucceeded) { //var logout = await LegacyService.LogOutAsync(); var state = new SignUpPage.NavigationParameters { PhoneNumber = _parameters.PhoneNumber, PhoneCode = _parameters.PhoneCode, Result = _parameters.Result, }; NavigationService.Navigate(typeof(SignUpPage), state); } else if (response.Error != null) { IsLoading = false; if (response.Error.ErrorMessage.Contains("2FA_RECENT_CONFIRM")) { await TLMessageDialog.ShowAsync(Strings.Resources.ResetAccountCancelledAlert, Strings.Resources.AppName, Strings.Resources.OK); } else if (response.Error.ErrorMessage.StartsWith("2FA_CONFIRM_WAIT_")) { // TODO: show info } else { await TLMessageDialog.ShowAsync(response.Error.ErrorMessage, Strings.Resources.AppName, Strings.Resources.OK); } } } }
private async void SendExecute() { IsLoading = true; var save = _isSave ?? false; var info = new TLPaymentRequestedInfo(); if (_paymentForm.Invoice.IsNameRequested) { info.Name = _info.Name; } if (_paymentForm.Invoice.IsEmailRequested) { info.Email = _info.Email; } if (_paymentForm.Invoice.IsPhoneRequested) { info.Phone = _info.Phone; } if (_paymentForm.Invoice.IsShippingAddressRequested) { info.ShippingAddress = _info.ShippingAddress; info.ShippingAddress.CountryIso2 = _selectedCountry?.Code?.ToUpper(); } var response = await LegacyService.ValidateRequestedInfoAsync(_message.Id, info, save); if (response.IsSucceeded) { IsLoading = false; if (_paymentForm.HasSavedInfo && !save) { LegacyService.ClearSavedInfoAsync(true, false, null, null); } if (_paymentForm.Invoice.IsFlexible) { //NavigationService.NavigateToPaymentFormStep2(_message, _paymentForm, info, response.Result); } else if (_paymentForm.HasSavedCredentials) { if (ApplicationSettings.Current.TmpPassword != null) { if (ApplicationSettings.Current.TmpPassword.ValidUntil < TLUtils.Now + 60) { ApplicationSettings.Current.TmpPassword = null; } } if (ApplicationSettings.Current.TmpPassword != null) { //NavigationService.NavigateToPaymentFormStep5(_message, _paymentForm, info, response.Result, null, null, null, true); } else { //NavigationService.NavigateToPaymentFormStep4(_message, _paymentForm, info, response.Result, null); } } else { //NavigationService.NavigateToPaymentFormStep3(_message, _paymentForm, info, response.Result, null); } } else if (response.Error != null) { IsLoading = false; switch (response.Error.ErrorMessage) { case "REQ_INFO_NAME_INVALID": case "REQ_INFO_PHONE_INVALID": case "REQ_INFO_EMAIL_INVALID": case "ADDRESS_COUNTRY_INVALID": case "ADDRESS_CITY_INVALID": case "ADDRESS_POSTCODE_INVALID": case "ADDRESS_STATE_INVALID": case "ADDRESS_STREET_LINE1_INVALID": case "ADDRESS_STREET_LINE2_INVALID": RaisePropertyChanged(response.Error.ErrorMessage); break; default: //AlertsCreator.processError(error, PaymentFormActivity.this, req); break; } } }
private async void SendExecute() { if (_sentCode == null) { //... return; } if (string.IsNullOrEmpty(_phoneCode)) { RaisePropertyChanged("SENT_CODE_INVALID"); return; } var phoneNumber = _phoneNumber; var phoneCodeHash = _sentCode.PhoneCodeHash; IsLoading = true; var response = await LegacyService.ChangePhoneAsync(phoneNumber, phoneCodeHash, _phoneCode); if (response.IsSucceeded) { while (NavigationService.Frame.BackStackDepth > 1) { NavigationService.Frame.BackStack.RemoveAt(1); } NavigationService.GoBack(); } else { IsLoading = false; if (response.Error.TypeEquals(TLErrorType.PHONE_NUMBER_UNOCCUPIED)) { //var signup = await ProtoService.SignUpAsync(phoneNumber, phoneCodeHash, PhoneCode, "Paolo", "Veneziani"); //if (signup.IsSucceeded) //{ // ProtoService.SetInitState(); // ProtoService.CurrentUserId = signup.Value.User.Id; // SettingsHelper.IsAuthorized = true; // SettingsHelper.UserId = signup.Value.User.Id; //} //this._callTimer.Stop(); //this.StateService.ClearNavigationStack = true; //this.NavigationService.UriFor<SignUpViewModel>().Navigate(); var state = new SignUpPage.NavigationParameters { PhoneNumber = _phoneNumber, PhoneCode = _phoneCode, //Result = _sentCode, }; NavigationService.Navigate(typeof(SignUpPage), state); } else if (response.Error.TypeEquals(TLErrorType.PHONE_CODE_INVALID)) { //await new MessageDialog(Resources.PhoneCodeInvalidString, Resources.Error).ShowAsync(); } else if (response.Error.TypeEquals(TLErrorType.PHONE_CODE_EMPTY)) { //await new MessageDialog(Resources.PhoneCodeEmpty, Resources.Error).ShowAsync(); } else if (response.Error.TypeEquals(TLErrorType.PHONE_CODE_EXPIRED)) { //await new MessageDialog(Resources.PhoneCodeExpiredString, Resources.Error).ShowAsync(); } else if (response.Error.TypeEquals(TLErrorType.SESSION_PASSWORD_NEEDED)) { //this.IsWorking = true; var password = await LegacyService.GetPasswordAsync(); if (password.IsSucceeded && password.Result is TLAccountPassword) { var state = new SignInPasswordPage.NavigationParameters { PhoneNumber = _phoneNumber, PhoneCode = _phoneCode, //Result = _sentCode, //Password = password.Result as TLAccountPassword }; NavigationService.Navigate(typeof(SignInPasswordPage), state); } else { Execute.ShowDebugMessage("account.getPassword error " + password.Error); } } else if (response.Error.CodeEquals(TLErrorCode.FLOOD)) { //await new MessageDialog($"{Resources.FloodWaitString}\r\n\r\n({error.Message})", Resources.Error).ShowAsync(); } Execute.ShowDebugMessage("account.signIn error " + response.Error); } }
private async void SendExecute() { var save = _isSave ?? false; if (_paymentForm.HasSavedCredentials && !save && _paymentForm.IsCanSaveCredentials) { _paymentForm.HasSavedCredentials = false; _paymentForm.SavedCredentials = null; ApplicationSettings.Current.TmpPassword = null; LegacyService.ClearSavedInfoAsync(false, true, null, null); } var month = 0; var year = 0; if (_date != null) { var args = _date.Split('/'); if (args.Length == 2) { month = int.Parse(args[0]); year = int.Parse(args[1]); } } var card = new Card( _card, month, year, _cvc, _cardName, null, null, null, null, _postcode, _selectedCountry?.Code?.ToUpper(), null); if (!card.ValidateNumber()) { RaisePropertyChanged("CARD_NUMBER_INVALID"); return; } if (!card.ValidateExpireDate()) { RaisePropertyChanged("CARD_EXPIRE_DATE_INVALID"); return; } if (NeedCardholderName && string.IsNullOrWhiteSpace(_cardName)) { RaisePropertyChanged("CARD_HOLDER_NAME_INVALID"); return; } if (!card.ValidateCVC()) { RaisePropertyChanged("CARD_CVC_INVALID"); return; } if (NeedCountry && _selectedCountry == null) { RaisePropertyChanged("CARD_COUNTRY_INVALID"); return; } if (NeedZip && string.IsNullOrWhiteSpace(_postcode)) { RaisePropertyChanged("CARD_ZIP_INVALID"); return; } IsLoading = true; using (var stripe = new StripeClient(_publishableKey)) { var token = await stripe.CreateTokenAsync(card); if (token != null) { var title = card.GetBrand() + " *" + card.GetLast4(); var credentials = string.Format("{{\"type\":\"{0}\", \"id\":\"{1}\"}}", token.Type, token.Id); NavigateToNextStep(title, credentials, _isSave ?? false); } else { IsLoading = false; } } //var save = _isSave ?? false; //var info = new TLPaymentRequestedInfo(); //if (_paymentForm.Invoice.IsNameRequested) //{ // info.Name = _info.Name; //} //if (_paymentForm.Invoice.IsEmailRequested) //{ // info.Email = _info.Email; //} //if (_paymentForm.Invoice.IsPhoneRequested) //{ // info.Phone = _info.Phone; //} //if (_paymentForm.Invoice.IsShippingAddressRequested) //{ // info.ShippingAddress = _info.ShippingAddress; // info.ShippingAddress.CountryIso2 = _selectedCountry?.Code; //} //var response = await ProtoService.ValidateRequestedInfoAsync(save, _message.Id, info); //if (response.IsSucceeded) //{ // IsLoading = false; // if (_paymentForm.HasSavedInfo && !save) // { // ProtoService.ClearSavedInfoAsync(true, false, null, null); // } // if (_paymentForm.Invoice.IsFlexible) // { // NavigationService.Navigate(typeof(PaymentFormStep2Page), TLTuple.Create(_message, _paymentForm, response.Result)); // } // else if (_paymentForm.HasSavedCredentials) // { // // TODO: Is password expired? // var expired = true; // if (expired) // { // NavigationService.Navigate(typeof(PaymentFormStep4Page)); // } // else // { // NavigationService.Navigate(typeof(PaymentFormStep5Page)); // } // } // else // { // NavigationService.Navigate(typeof(PaymentFormStep3Page)); // } //} }