Ejemplo n.º 1
0
        public void Update(string resourceKind, CorrelatedResSyncInfo info)
        {
            ICorrelatedResSyncTableAdapter correlatedResSyncTableAdapter = this.GetAdapter(resourceKind);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                if (!correlatedResSyncTableAdapter.Update(info, jetTransaction))
                {
                    throw new StoreException(string.Format("No correlated ResSync exists for the resource kind '{0}' that can be updated.", resourceKind));
                }

                jetTransaction.Commit();
            }
        }
Ejemplo n.º 2
0
        public ICorrelatedResSyncInfoEnumerator GetAll(string resourceKind)
        {
            CorrelatedResSyncInfo[] resultInfos;

            ICorrelatedResSyncTableAdapter correlatedResSyncTableAdapter = this.GetAdapter(resourceKind);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                resultInfos = correlatedResSyncTableAdapter.GetAll(jetTransaction);

                jetTransaction.Commit();
            }

            return((null != resultInfos) ? new CorrelatedResSyncInfoEnumerator(resultInfos) : new CorrelatedResSyncInfoEnumerator(new CorrelatedResSyncInfo[0]));
        }
Ejemplo n.º 3
0
        public CorrelatedResSyncInfo[] GetByUuid(string resourceKind, Guid[] uuids)
        {
            CorrelatedResSyncInfo[] resultInfos;

            ICorrelatedResSyncTableAdapter correlatedResSyncTableAdapter = this.GetAdapter(resourceKind);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                resultInfos = correlatedResSyncTableAdapter.GetByUuids(uuids, jetTransaction);

                jetTransaction.Commit();
            }

            return((null != resultInfos) ? resultInfos : new CorrelatedResSyncInfo[0]);
        }
Ejemplo n.º 4
0
        public void Delete(string resourceKind, Guid uuid)
        {
            ICorrelatedResSyncTableAdapter correlatedResSyncTableAdapter = this.GetAdapter(resourceKind);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                try
                {
                    correlatedResSyncTableAdapter.Remove(uuid, jetTransaction);
                }
                catch (OleDbException exception)
                {
                    throw new StoreException(string.Format("An error occured while removing the correlated ResSyncs with uuid '{0}'. No correlated ResSync has been removed.", uuid), exception);
                }
                jetTransaction.Commit();
            }
        }
Ejemplo n.º 5
0
        public ICorrelatedResSyncInfoEnumerator GetSinceTick(string resourceKind, string endpoint, int tick)
        {
            CorrelatedResSyncInfo[] resultInfos;

            ICorrelatedResSyncTableAdapter correlatedResSyncTableAdapter = this.GetAdapter(resourceKind);
            IEndpointTableAdapter          endpointTableAdapter          = StoreEnvironment.Resolve <IEndpointTableAdapter>(_context);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                EndpointInfo endpointInfo = endpointTableAdapter.GetOrCreate(endpoint, jetTransaction);

                resultInfos = correlatedResSyncTableAdapter.GetSinceTick(endpointInfo.Id, tick, jetTransaction);

                jetTransaction.Commit();
            }

            return((null != resultInfos) ? new CorrelatedResSyncInfoEnumerator(resultInfos) : new CorrelatedResSyncInfoEnumerator(new CorrelatedResSyncInfo[0]));
        }
Ejemplo n.º 6
0
        public CorrelatedResSyncInfo[] GetPaged(string resourceKind, int pageNumber, int itemsPerPage, out int totalResult)
        {
            CorrelatedResSyncInfo[] resultInfos;

            ICorrelatedResSyncTableAdapter correlatedResSyncTableAdapter = this.GetAdapter(resourceKind);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                resultInfos = correlatedResSyncTableAdapter.GetAll(jetTransaction);

                jetTransaction.Commit();
            }

            // TODO: TO BE REVIEWED!!!
            totalResult = resultInfos.Length;
            if (totalResult == 0)
            {
                return(new CorrelatedResSyncInfo[0]);
            }

            int startIndex = ((pageNumber - 1) * itemsPerPage) + 1;

            if (totalResult < startIndex)
            {
                return(new CorrelatedResSyncInfo[0]);
            }

            int realItemsPerPage;

            if ((totalResult - startIndex) > itemsPerPage)
            {
                realItemsPerPage = itemsPerPage;
            }
            else
            {
                realItemsPerPage = totalResult - startIndex;
            }

            CorrelatedResSyncInfo[] destinationArray = new CorrelatedResSyncInfo[realItemsPerPage];

            Array.Copy(resultInfos, startIndex - 1, destinationArray, 0, realItemsPerPage);

            return(destinationArray);
        }
Ejemplo n.º 7
0
        public void Add(string resourceKind, CorrelatedResSyncInfo info)
        {
            ICorrelatedResSyncTableAdapter correlatedResSyncTableAdapter = this.GetAdapter(resourceKind);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                try
                {
                    correlatedResSyncTableAdapter.Insert(info, jetTransaction);
                }
                catch (OleDbException exception)
                {
                    if (exception.Errors.Count == 1 && exception.Errors[0].SQLState == "3022")
                    {
                        throw new StoreException(string.Format("An error occured while adding a new correlated ResSync. A correlated ResSync already exists for the uuid '{0}' and local id '{1}.", info.ResSyncInfo.Uuid, info.LocalId), exception);
                    }

                    throw;
                }
                jetTransaction.Commit();
            }
        }