public void Execute(ResultExecutionContext context) { var proxy = new MoneyServiceClient(); if (isDeposit) { proxy.DepositCompleted += OnSavingCompleted; proxy.DepositAsync(userId: userId, accountId: accountId, operationDate: operationDate, price: price, quantity: quantity, comment: comment, categoryId: categoryId ); } else { proxy.WithdrawalCompleted += OnSavingCompleted; proxy.WithdrawalAsync(userId: userId, accountId: accountId, operationDate: operationDate, price: price, quantity: quantity, comment: comment, categoryId: categoryId ); } }
/// <summary> /// Create MoneyService client proxy. /// </summary> /// <returns>New MoneyService client proxy.</returns> public static MoneyServiceClient CreateMoneyService() { var proxy = new MoneyServiceClient(); SetupServiceUri(proxy.Endpoint); SetupClientCredentials(proxy.ClientCredentials); SetupPersonalServiceUri(proxy); return(proxy); }
public void Execute(ResultExecutionContext context) { var proxy = new MoneyServiceClient(); proxy.DeleteTransactionCompleted += OnDeleteCompleted; proxy.DeleteTransactionAsync(userId, accountId, transactionId, DateTime.UtcNow ); }
/// <summary> /// Use personal service host only if available. /// </summary> /// <param name="proxy">Client proxy instance.</param> private static void SetupPersonalServiceUri(MoneyServiceClient proxy) { if (proxy == null) { throw new ArgumentNullException("proxy"); } if (!string.IsNullOrEmpty(PersonalServiceUri)) { proxy.Endpoint.Address = new EndpointAddress(PersonalServiceUri); } }
public void Execute(ResultExecutionContext context) { var proxy = new MoneyServiceClient(); proxy.TransferCompleted += OnTransferCompleted; proxy.TransferAsync(user1Id, account1Id, user2Id, account2Id, operationDate, amount, comment ); }
public void Execute(ResultExecutionContext context) { var proxy = new MoneyServiceClient(); proxy.UpdateTransactionCompleted += OnUpdateTransactionCompleted; proxy.UpdateTransactionAsync(transactionId, userId, accountId, operationDate, price, quantity, comment, categoryId, isDeposit ); }
public void Execute(ResultExecutionContext context) { var proxy = new MoneyServiceClient(); proxy.GetAllAccountsCompleted += (s, e) => { if (e.Error != null) { Caliburn.PresentationFramework.Invocation.Execute.OnUIThread( () => Completed(this, new ResultCompletionEventArgs { Error = e.Error })); } else { Accounts = e.Result; Caliburn.PresentationFramework.Invocation.Execute.OnUIThread(() => Completed(this, new ResultCompletionEventArgs())); } }; proxy.GetAllAccountsAsync(userId: userId); }
public void Execute(ResultExecutionContext context) { var proxy = new MoneyServiceClient(); proxy.GetTransactionCompleted += (sender, args) => { if (args.Error != null) { Caliburn.PresentationFramework.Invocation.Execute.OnUIThread( () => Completed(this, new ResultCompletionEventArgs { Error = args.Error })); } else { Transaction = args.Result; Caliburn.PresentationFramework.Invocation.Execute.OnUIThread(() => Completed(this, new ResultCompletionEventArgs())); } }; proxy.GetTransactionAsync(userId, accountId, transactionId); }
private async void Button_Click_1(object sender, RoutedEventArgs e) { var serviceUrl = ServiceUrl.Text; var service = new MoneyServiceClient(); service.ClientCredentials.UserName.UserName = Username.Text; service.ClientCredentials.UserName.Password = Password.Text; SetupServiceUri(service.Endpoint, serviceUrl); var accountsResult = await service.GetAllAccountsAsync(); Frame.Navigate(typeof(GroupedItemsPage), accountsResult); /* * new SampleDataGroup( * "AllGroups", * "Group Title", * accountsResult.First().Name, * string.Empty, * accountsResult.First().Balance.ToString())); */ }
/// <summary> /// Start import data from old SQL database to new one via service calls. /// </summary> /// <param name="sender">Start button.</param> /// <param name="e">Routed event data.</param> private void StartButtonClick(object sender, RoutedEventArgs e) { canselPending = false; Clear(); EnableUI(false); stopWatch = Stopwatch.StartNew(); try { moneyClient = new MoneyServiceClient( new BasicHttpBinding(), new EndpointAddress(ServiceUrlTextBox.Text.Trim() + MoneyServiceUrlPostfix)); userСlient = new UserServiceClient( new BasicHttpBinding(), new EndpointAddress(ServiceUrlTextBox.Text.Trim() + UserServiceUrlPostfix)); UpdateStatus("Registering user \"" + UsernameTextBox.Text.Trim() + "\"..."); user = userСlient.Register(UsernameTextBox.Text.Trim(), PasswordTextBox.Text.Trim()); userId = user.Id; if (canselPending) { UpdateStatus("Canceled"); return; } UpdateStatus("Creating account \"" + AccountTextBox.Text.Trim() + "\"..."); accountId = moneyClient.CreateAccount(userId, AccountTextBox.Text.Trim(), 1); // UAH account by default if (canselPending) { UpdateStatus("Canceled"); return; } using (var context = new ProfitAndExpenseEntities(new EntityConnection(string.Format(ConnectionStringTemplate, ConnectionStringTextBox.Text.Trim())))) { UpdateStatus("Retrieving expense category list..."); List <ExpenseGroup> expenseGroups = context.TblExpenseGroups.OrderBy(expenseGroup => expenseGroup.Id).ToList(); if (canselPending) { UpdateStatus("Canceled"); return; } for (int i = 0; i < expenseGroups.Count; i++) { if (canselPending) { break; } UpdateStatus("Creating " + i + " / " + expenseGroups.Count + " expense category..."); int categoryId = moneyClient.CreateCategory(userId, expenseGroups[i].Name, CategoryType.Withdrawal); // withdrawal category categoryMap.Add(new KeyValuePair <int, bool>(expenseGroups[i].Id, true), categoryId); } if (canselPending) { UpdateStatus("Canceled"); return; } UpdateStatus("Retrieving revenue category list..."); List <RevenueGroup> revenueGroups = context.TblRevenueGroups.OrderBy(revenueGroup => revenueGroup.Id).ToList(); if (canselPending) { UpdateStatus("Canceled"); return; } for (int i = 0; i < revenueGroups.Count; i++) { if (canselPending) { break; } UpdateStatus("Creating " + i + " / " + revenueGroups.Count + " revenue category..."); int categoryId = moneyClient.CreateCategory(userId, revenueGroups[i].Name, CategoryType.Deposit); // deposit category categoryMap.Add(new KeyValuePair <int, bool>(revenueGroups[i].Id, false), categoryId); } if (canselPending) { UpdateStatus("Canceled"); return; } Import(context); stopWatch.Stop(); UpdateStatus( string.Format( "Done in {0:00}:{1:00}:{2:00}.{3:00}", stopWatch.Elapsed.TotalHours, stopWatch.Elapsed.Minutes, stopWatch.Elapsed.Seconds, stopWatch.Elapsed.Milliseconds)); } } catch (Exception exception) { stopWatch.Stop(); #if DEBUG throw; #endif #pragma warning disable 162 ShowError(exception); #pragma warning restore 162 } finally { stopWatch.Stop(); EnableUI(true); } }