public void Send <T>(T cmd) where T : ICommand
        {
            var handler = container.Build <IHandleCommand <T> >();
            var handled = false;

            while (handled == false)
            {
                try
                {
                    handler.Handle(cmd);
                    // Trigger persistence and concurrency checking.
                    persistenceManager.Commit();
                    handled = true;
                }
                catch (ConcurrencyException)
                {
                    // Hit a concurrency exception, must retry the command.
                }
            }
        }
Exemple #2
0
        private CacheItem LoadDocument(long rowId, IOperationContext operationContext)
        {
            ITransaction transaction = null;

            try
            {
                //transaction = _persistenceManager.BeginTransaction(null, true);
                var       document = _persistenceManager.GetDocument(_parent.Name, rowId);
                CacheItem cItem    = new CacheItem()
                {
                    Document = document
                };
                //If query exection then cache insert is optional
                if (operationContext.ContainsKey(ContextItem.QueryExecution) && _cacheSpace.IsFull)
                {
                    return(cItem);
                }
                CacheInsert(rowId, cItem);
                return(cItem);
            }
            catch (Exception e)
            {
                Console.WriteLine("Read Through Exception " + e);
                if (LoggerManager.Instance.StorageLogger != null && LoggerManager.Instance.StorageLogger.IsErrorEnabled)
                {
                    LoggerManager.Instance.StorageLogger.Error("Exception Reading Thru : Collection = " + Name, " Row ID: " + rowId + " and Exception is = " + e);
                }

                throw;
            }
            finally
            {
                if (transaction != null)
                {
                    _persistenceManager.Commit(transaction);
                }
            }
        }