コード例 #1
0
        public EmployeesManagerWindow()
        {
            InitializeComponent();

            RemotingConfiguration.Configure("ClientApp.exe.config", false);

            int idClient = Math.Abs(DateTime.Now.GetHashCode()/100000);

            Title += ", id: " + idClient;

            try
            {
                _dataBaseSingleton = new DataBaseSingleton();
                _transactionCacheCao = new TransactionCacheCao();
                _transactionCacheCao.SetIdClient(idClient);
                _transactionControllerSinglecall = new TransactionControllerSinglecall();
            }
            catch (WebException)
            {
                MessageBox.Show("Сервер недоступен");
                IsEnabled = false;
                return;
            }

            CacheDataBase();
            UpdateListBox();
        }
コード例 #2
0
        public Exception Commit(TransactionCacheCao transactionCacheCao, DataBaseSingleton dataBaseSingleton)
        {
            Console.WriteLine("{0}: Вызов метода Commit() в TransactionControllerSinglecall", transactionCacheCao.IdClient);

            var trancatcionList = transactionCacheCao.GetCacheEmployeesList();
            var dataBaseList = dataBaseSingleton.GetEmployeesList();

            var generateException = new GenerateException();

            foreach (var transEmployee in trancatcionList)
            {
                if (transEmployee.StateField != StateField.NoChange)
                {
                    // Ищем в базе запись (null - запись не найдена)
                    var bdEmployee = dataBaseList.FirstOrDefault(e => e.Id == transEmployee.Id);

                    if (bdEmployee == null)
                    {
                        if (transEmployee.StateField == StateField.Added || transEmployee.StateField == StateField.Updated)
                        {
                            dataBaseSingleton.AddField(transEmployee);
                        }
                    }
                    else
                    {
                        if (bdEmployee.IsNotChange(transEmployee))
                        {
                            if (bdEmployee.StateField != StateField.Deleted)
                            {
                                dataBaseSingleton.UpdateField(transEmployee);
                            }
                            else
                            {
                                generateException.AddField(transEmployee);
                            }
                        }
                        else
                        {
                            generateException.AddField(transEmployee);
                        }
                    }
                }
            }

            return generateException.Generate();
        }
コード例 #3
0
        public void Rollback(TransactionCacheCao transactionCacheCao)
        {
            transactionCacheCao.Clear();

            Console.WriteLine("{0}: Вызов метода Rollback() в TransactionControllerSinglecall", transactionCacheCao.IdClient);
        }