private void ProcessAccountingDataSync(IAsyncResult asyncResult)
        {
            try
            {
                using (_currentProxy)
                {
                    bool syncResult = _currentProxy.EndGetCurrentAccountingData(asyncResult);
                    if (!syncResult)
                    {
                        _longOperationHandler.OperationFailed("Cannot perform synchronization with Pohoda");
                        return;
                    }

                    LongOperationResult result = new LongOperationResult {
                        RefreshAll = true
                    };
                    _longOperationHandler.End(result);
                    Logger.Info("Accounting data synchronization finished succesfully.");
                    ClientRepository.ResetDatabaseStatus();
                }
                _currentProxy = null;
            }
            catch (Exception ex)
            {
                _longOperationHandler.OperationFailed(ex.Message);
            }
        }
Ejemplo n.º 2
0
        public bool RemoveMaterial(IMaterial material)
        {
            try
            {
                _longOperationHandler.Start("MaterialRemoving");

                GetLock();

                using (StoreKeeperDataContext dataContext = new StoreKeeperDataContext())
                {
                    SqlParameter articleIdParam = new SqlParameter("@ArticleId", SqlDbType.UniqueIdentifier)
                    {
                        Value = material.MaterialId.ToGuid()
                    };
                    dataContext.Database.ExecuteSqlCommand("exec RemoveMaterial @ArticleId", articleIdParam);
                }

                ReloadData();
                LongOperationResult result = new LongOperationResult {
                    RefreshAll = true
                };
                _longOperationHandler.End(result);

                RequestForCalculation();
                return(true);
            }
            catch (Exception ex)
            {
                _longOperationHandler.OperationFailed(ex.Message);
                Logger.Error(ex);
                return(false);
            }
        }