private async Task <bool> DeleteAccountTitleAsync()
        {
            var success = false;
            IEnumerable <IMasterData> accountTitles = null;
            await ServiceProxyFactory.DoAsync(async (AccountTitleMasterClient client) =>
            {
                if (DeletePostProcessor != null)
                {
                    var result = await client.GetAsync(SessionKey, new int[] { AccountTitleId });
                    if (result.ProcessResult.Result)
                    {
                        accountTitles = result.AccountTitles;
                    }
                }

                var deleteResult = await client.DeleteAsync(SessionKey, AccountTitleId);
                success          = (deleteResult?.ProcessResult.Result ?? false) &&
                                   deleteResult?.Count > 0;
            });

            var syncResult = true;

            if (DeletePostProcessor != null && success)
            {
                syncResult = DeletePostProcessor.Invoke(accountTitles);
            }
            success &= syncResult;

            if (success)
            {
                await LoadGrid();
            }
            return(success);
        }
Beispiel #2
0
        private async Task <bool> DeleteStaffInfo()
        {
            bool success = true;
            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var service = factory.Create <StaffMasterClient>();

                StaffsResult staffResult = null;
                CountResult deleteResult = null;
                if (DeletePostProcessor != null)
                {
                    staffResult = await service.GetAsync(SessionKey, new int[] { StaffId });
                }

                deleteResult = await service.DeleteAsync(SessionKey, StaffId);
                success      = (deleteResult?.ProcessResult.Result ?? false) &&
                               deleteResult?.Count > 0;

                var syncResult = true;
                if (DeletePostProcessor != null && success)
                {
                    syncResult = DeletePostProcessor.Invoke(staffResult
                                                            .Staffs.AsEnumerable().Select(x => x as IMasterData));
                }
                success &= syncResult;
                if (success)
                {
                    await LoadStaffGrid();
                }
            });

            return(success);
        }
Beispiel #3
0
        private async Task <ImportResult> RegisterForImportAsync(UnitOfWork <Staff> imported)
        {
            ImportResultStaff result = null;
            var syncResult           = true;

            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var service = factory.Create <StaffMasterClient>();
                result      = await service.ImportAsync(SessionKey, imported.New.ToArray(), imported.Dirty.ToArray(), imported.Removed.ToArray());
            });

            if (DeletePostProcessor != null && (imported.Removed?.Any() ?? false))
            {
                syncResult = DeletePostProcessor.Invoke(imported.Removed.Select(x => x as IMasterData));
            }

            if (syncResult && SavePostProcessor != null && (result.Staffs?.Any() ?? false))
            {
                syncResult = SavePostProcessor.Invoke(result.Staffs.Select(x => x as IMasterData));
            }

            return(result);
        }
Beispiel #4
0
        private bool UpdateExcludeAmount(IEnumerable <ReceiptExclude> updateItems, System.Action errorMessaging)
        {
            var deleteItems  = new List <ReceiptExclude>();
            var newItems     = new List <ReceiptExclude>();
            var receiptItems = new List <Receipt>();
            var receiptId    = CurrentReceipt.Id;

            var success     = true;
            var syncResult  = true;
            var updateValid = true;

            ProgressDialog.Start(ParentForm, async(cancel, progress) =>
            {
                if (IsPostProessorImplemented)
                {
                    await ServiceProxyFactory.DoAsync(async(ReceiptExcludeServiceClient client) =>
                    {
                        var result = await client.GetByReceiptIdAsync(SessionKey, receiptId);
                        if (result.ProcessResult.Result &&
                            result.ReceiptExcludes != null &&
                            result.ReceiptExcludes.Any(x => x != null))
                        {
                            deleteItems.AddRange(result.ReceiptExcludes);
                        }
                    });
                }
                await ServiceProxyFactory.DoAsync(async(ReceiptServiceClient client) =>
                {
                    var saveResult = await client.SaveExcludeAmountAsync(SessionKey, updateItems.ToArray());
                    success        = saveResult?.ProcessResult.Result ?? false;
                    newItems.AddRange(saveResult.ReceiptExclude.Where(x => x.Id != 0L));

                    if (!success)
                    {
                        updateValid = !(saveResult.ProcessResult.ErrorCode == Rac.VOne.Common.ErrorCode.OtherUserAlreadyUpdated);
                    }

                    if (success)
                    {
                        var receiptResult  = await client.GetAsync(SessionKey, updateItems.Select(x => x.ReceiptId).Distinct().ToArray());
                        var updatedReceipt = receiptResult.Receipts.First();
                        CurrentReceipt     = updatedReceipt;
                        if (IsPostProessorImplemented)
                        {
                            receiptItems.AddRange(receiptResult.Receipts);
                        }
                    }
                });
                if (!success)
                {
                    return;
                }
                if (IsPostProessorImplemented)
                {
                    syncResult = DeletePostProcessor.Invoke(deleteItems.Select(x => x as ITransactionData));
                    if (!syncResult)
                    {
                        return;
                    }
                    syncResult = ExcludePostProcessor.Invoke(newItems.Select(x => x as ITransactionData));
                    if (!syncResult)
                    {
                        return;
                    }
                    syncResult = SavePostProcessor.Invoke(receiptItems.Select(x => x as ITransactionData));
                }
                IsSaved = true;
            }, false, SessionKey);
            if (!syncResult)
            {
                ShowWarningDialog(MsgErrPostProcessFailure);
                return(false);
            }
            if (!updateValid)
            {
                ShowWarningDialog(MsgWngAlreadyUpdated);
                return(false);
            }
            if (!success)
            {
                errorMessaging?.Invoke();
                return(false);
            }
            return(success);
        }