private void OnAccountSettingsChanged(RoyaltyServiceWorker.AccountService.AccountSettings newItem, RoyaltyServiceWorker.AccountService.AccountSettings oldItem)
 {
     if (oldItem != null)
     {
         oldItem.PropertyChanged -= AccountSettingsPropertyChanged;
     }
     if (newItem != null)
     {
         collectionForEdit = newItem.ImportDirectories?.ToList() ?? new List<RoyaltyServiceWorker.AccountService.AccountSettingsImportDirectory>();
         AccountSettingsImportDirectoriesEdit = CollectionViewSource.GetDefaultView(collectionForEdit);
         newItem.PropertyChanged += AccountSettingsPropertyChanged;
     }
 }
 private void OnAccountChanged(RoyaltyServiceWorker.AccountService.Account newItem, RoyaltyServiceWorker.AccountService.Account oldItem)
 {
     localCollection.Clear();
     From = null;
     To = null;
 }
Exemplo n.º 3
0
        private Task<bool> DeleteTask(RoyaltyServiceWorker.AccountService.Account item)
        {
            IsBusy = true;

            var client = new RoyaltyServiceWorker.AccountService.AccountServiceClient();
            var task = client.RemoveAsync(item.Id);
            var taskRes = task.ContinueWith((res) =>
            {
                try
                {
                    if (res.Result.Error != null)
                        throw new Exception(res.Result.Error);
                    return true;
                }
                catch (Exception ex)
                {
                    Error = ex.ToString();
                    return false;
                }
                finally
                {
                    try { client.Close(); } catch { }
                    IsBusy = false;
                }
            }, GetCancellationToken(), TaskContinuationOptions.AttachedToParent, TaskScheduler.FromCurrentSynchronizationContext());

            return taskRes;
        }
Exemplo n.º 4
0
        private Task<bool> SaveTask(RoyaltyServiceWorker.AccountService.Account item)
        {
            IsBusy = true;

            var client = new RoyaltyServiceWorker.AccountService.AccountServiceClient();
            var task = Account.Id == Guid.Empty
                ? client.PutAsync(item)
                : client.UpdateAsync(item);

            var taskRes = task.ContinueWith((res) => 
            {
                try
                {
                    if (res.Result.Error != null)
                        throw new Exception(res.Result.Error);

                    if (Account != null)
                    {
                        Account.CopyObjectFrom(res.Result.Value);
                    } else
                    {
                        Account = res.Result.Value;
                    }
                    return true;
                }
                catch(Exception ex)
                {
                    Error = ex.ToString();
                    return false;
                }
                finally
                {
                    try { client.Close(); } catch { }
                    IsBusy = false;
                }
            }, GetCancellationToken(), TaskContinuationOptions.AttachedToParent, TaskScheduler.FromCurrentSynchronizationContext());

            return taskRes;
        }
Exemplo n.º 5
0
 private void RestoreFromSource(RoyaltyServiceWorker.AccountService.Account source)
 {
     if (AccountEdit == null)
         AccountEdit = new RoyaltyServiceWorker.AccountService.Account();
     if (source != null)
         AccountEdit.CopyObjectFrom(source);
 }
Exemplo n.º 6
0
 private void OnAccountChanged(RoyaltyServiceWorker.AccountService.Account newItem, RoyaltyServiceWorker.AccountService.Account oldItem)
 {
     IsBusy = false;
     Error = null;
     RaiseCommands();
     RestoreFromSource(newItem);
     if (newItem != null)
         newItem.PropertyChanged += AccountPropertyChanged;
     if (oldItem != null)
         oldItem.PropertyChanged -= AccountPropertyChanged;
 }
        private Task<bool> SaveTask(RoyaltyServiceWorker.AccountService.AccountDataRecordAdditionalColumn item)
        {
            var startTask = Task.Factory.StartNew(() => 
            {
                IsBusy = true;
            }, GetCancellationToken(), TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());

            var clientTask = startTask.ContinueWith((t) => 
            {
                var client = new RoyaltyServiceWorker.AccountService.AccountServiceClient();
                try
                {
                    return item.Id == default(long)
                        ? client.PutAdditionalColumn(item)
                        : client.UpdateAdditionalColumn(item);
                }
                finally
                {
                    try { client.Close(); } catch { }
                }
            }, GetCancellationToken(), TaskContinuationOptions.AttachedToParent, TaskScheduler.Default);

            var taskRes = clientTask.ContinueWith((res) => 
            {
                try
                {
                    if (res.Result.Error != null)
                        throw new Exception(res.Result.Error);

                    item.CopyObjectFrom(res.Result.Value);
                    
                    return true;
                }
                catch(Exception ex)
                {
                    Error = ex.ToString();
                    return false;
                }
                finally
                {
                    IsBusy = false;
                }
            }, GetCancellationToken(), TaskContinuationOptions.AttachedToParent, TaskScheduler.FromCurrentSynchronizationContext());

            return taskRes;
        }
 private void OnAccountChanged(RoyaltyServiceWorker.AccountService.Account newItem, RoyaltyServiceWorker.AccountService.Account oldItem)
 {
     localCollection.Clear();
     Filter = string.Empty;
 }
Exemplo n.º 9
0
 private void UpdateAccountSettings(RoyaltyServiceWorker.AccountService.AccountSettings newItem, RoyaltyServiceWorker.AccountService.AccountSettings oldItem)
 {
     if (newItem != null)
     {
         AccountSettingsEdit = new RoyaltyServiceWorker.AccountService.AccountSettings();
         AccountSettingsEdit.CopyObjectFrom(newItem);
         newItem.PropertyChanged += AccountSettingsPropertyChanged;
     }
     if (oldItem != null)
     {
         oldItem.PropertyChanged -= AccountSettingsPropertyChanged;
     }
 }
Exemplo n.º 10
0
 private void UpdateAccount(RoyaltyServiceWorker.AccountService.Account newItem, RoyaltyServiceWorker.AccountService.Account oldItem)
 {
     IsBusy = false;
     Error = null;
     RaiseCommands();
     if (newItem != null)
         newItem.PropertyChanged += AccountPropertyChanged;
     if (oldItem != null)
         oldItem.PropertyChanged -= AccountPropertyChanged;
     UpdateAccountSettings(newItem?.Settings, oldItem?.Settings);
 }
Exemplo n.º 11
0
 private void UpdateAccount(RoyaltyServiceWorker.AccountService.Account newItem, RoyaltyServiceWorker.AccountService.Account oldItem)
 {
 }
Exemplo n.º 12
0
 private void OnAccountForEditChanged(RoyaltyServiceWorker.AccountService.Account account)
 {
     View = (account == null)
         ? AccountsViewEnum.Accounts
         : AccountsViewEnum.Account;
 }