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;
 }
示例#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;
        }
示例#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;
        }
示例#5
0
 private void RestoreFromSource(RoyaltyServiceWorker.AccountService.Account source)
 {
     if (AccountEdit == null)
         AccountEdit = new RoyaltyServiceWorker.AccountService.Account();
     if (source != null)
         AccountEdit.CopyObjectFrom(source);
 }
示例#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;
 }
 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;
     }
 }
 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);
 }
示例#11
0
 private void UpdateAccount(RoyaltyServiceWorker.AccountService.Account newItem, RoyaltyServiceWorker.AccountService.Account oldItem)
 {
 }
示例#12
0
 private void OnAccountForEditChanged(RoyaltyServiceWorker.AccountService.Account account)
 {
     View = (account == null)
         ? AccountsViewEnum.Accounts
         : AccountsViewEnum.Account;
 }