コード例 #1
0
        public void Add(string resourceKind, object applicationBookmark)
        {
            string assemblyQualifiedName = applicationBookmark.GetType().AssemblyQualifiedName;
            object blob = this.SerializeApplicationBookmark(applicationBookmark);

            IAppBookmarkTableAdapter  appBookmarkTableAdapter  = StoreEnvironment.Resolve <IAppBookmarkTableAdapter>(_context);
            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                ResourceKindInfo resourceKindInfo = resourceKindTableAdapter.GetOrCreate(resourceKind, jetTransaction);

                try
                {
                    appBookmarkTableAdapter.Insert(resourceKindInfo.Id, blob, assemblyQualifiedName, 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 application bookmark. An application bookmark already exists for the resource kind '{0}'.", resourceKind), exception);
                    }

                    throw;
                }

                jetTransaction.Commit();
            }
        }
コード例 #2
0
        public void Add(string resourceKind, SyncDigestEntryInfo info)
        {
            ISyncDigestTableAdapter   syncDigestTableAdapter   = StoreEnvironment.Resolve <ISyncDigestTableAdapter>(_context);
            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                ResourceKindInfo resourceKindInfo = resourceKindTableAdapter.GetOrCreate(resourceKind, jetTransaction);

                try
                {
                    syncDigestTableAdapter.Insert(resourceKindInfo.Id, new SyncDigestEntryInfo[] { 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 sync digest entry. A sync digest entry already exists for the resource kind '{0}' and EndPoint '{1}.", resourceKind, info.EndPoint), exception);
                    }

                    throw;
                }

                jetTransaction.Commit();
            }
        }
コード例 #3
0
 public AppBookmarkInfoStoreProvider(IJetConnectionProvider jetConnectionProvider, IAppBookmarkSerializer serializer, SdataContext context)
 {
     _jetConnectionProvider = jetConnectionProvider;
     _serializer            = serializer;
     _context = context;
     StoreEnvironment.Initialize(jetConnectionProvider, context);
 }
コード例 #4
0
        public bool Get(string resourceKind, Type type, out object applicationBookmark)
        {
            bool result = false;

            applicationBookmark = null;
            string assemblyQualifiedName = type.AssemblyQualifiedName;

            IAppBookmarkTableAdapter  appBookmarkTableAdapter  = StoreEnvironment.Resolve <IAppBookmarkTableAdapter>(_context);
            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                ResourceKindInfo resourceKindInfo = resourceKindTableAdapter.GetOrCreate(resourceKind, jetTransaction);

                byte[] blob;
                string receivedAssemblyQualifiedName;
                if (appBookmarkTableAdapter.Get(resourceKindInfo.Id, out blob, out receivedAssemblyQualifiedName, jetTransaction))
                {
                    applicationBookmark = this.DeserializeBlob(blob, type);    // use given type not the one stored
                    result = true;
                }

                jetTransaction.Commit();
            }

            return(result);
        }
コード例 #5
0
        public Int32tickProvider(IJetConnectionProvider jetConnectionProvider, SdataContext context)
        {
            _jetConnectionProvider = jetConnectionProvider;
            _context = context;

            StoreEnvironment.Initialize(jetConnectionProvider, context);
        }
コード例 #6
0
        internal int CreateNexttick(string resourceKind)
        {
            int nexttick;
            int currenttick;

            ItickTableAdapter         tickTableAdapter         = StoreEnvironment.Resolve <ItickTableAdapter>(_context);
            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                ResourceKindInfo resourceKindInfo = resourceKindTableAdapter.GetOrCreate(resourceKind, jetTransaction);

                if (!tickTableAdapter.TryGet(resourceKindInfo.Id, out currenttick, jetTransaction))
                {
                    currenttick = STARTtick;

                    tickTableAdapter.Insert(resourceKindInfo.Id, currenttick, jetTransaction);
                    nexttick = currenttick;
                }
                else
                {
                    currenttick++;
                    tickTableAdapter.Update(resourceKindInfo.Id, currenttick, jetTransaction);

                    nexttick = currenttick;
                }

                jetTransaction.Commit();
            }

            return(nexttick);
        }
コード例 #7
0
        public SyncResultsInfoStoreProvider(IJetConnectionProvider jetConnectionProvider, SdataContext context)
        {
            _jetConnectionProvider = jetConnectionProvider;
            _context = context;

            StoreEnvironment.Initialize(jetConnectionProvider, context);
        }
コード例 #8
0
        public void Add(string resourceKind, SyncResultEntryInfo[] syncResultEntryInfos)
        {
            ISyncResultsTableAdapter  syncResultsTableAdapter  = this.GetAdapter(resourceKind);
            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                syncResultsTableAdapter.Insert(syncResultEntryInfos, _runName, _runStamp, jetTransaction);

                jetTransaction.Commit();
            }
        }
コード例 #9
0
        /*
         * public void Update(string resourceKind, SyncDigestInfo info)
         * {
         *  ISyncDigestTableAdapter syncDigestTableAdapter = StoreEnvironment.Resolve<ISyncDigestTableAdapter>(_context);
         *  IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve<IResourceKindTableAdapter>(_context);
         *
         *  using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
         *  {
         *      ResourceKindInfo resourceKindInfo = resourceKindTableAdapter.GetOrCreate(resourceKind, jetTransaction);
         *
         *      try
         *      {
         *          syncDigestTableAdapter.Update(resourceKindInfo.Id, info.ToArray(), jetTransaction);
         *      }
         *      catch (StoreException exception)
         *      {
         *          throw new StoreException(string.Format("An error occured while updating a sync digest entry. No sync digest entry exists for the resource kind '{0}'.", resourceKind), exception);
         *      }
         *      jetTransaction.Commit();
         *  }
         * }
         */
        public bool Update(string resourceKind, SyncDigestEntryInfo info)
        {
            bool result = false;
            ISyncDigestTableAdapter   syncDigestTableAdapter   = StoreEnvironment.Resolve <ISyncDigestTableAdapter>(_context);
            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                ResourceKindInfo resourceKindInfo = resourceKindTableAdapter.GetOrCreate(resourceKind, jetTransaction);

                result = syncDigestTableAdapter.Update(resourceKindInfo.Id, info, jetTransaction);

                jetTransaction.Commit();
            }
            return(result);
        }
コード例 #10
0
        public SyncDigestInfo Get(string resourceKind)
        {
            SyncDigestInfo            resultInfo               = null;
            ISyncDigestTableAdapter   syncDigestTableAdapter   = StoreEnvironment.Resolve <ISyncDigestTableAdapter>(_context);
            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                ResourceKindInfo resourceKindInfo = resourceKindTableAdapter.GetOrCreate(resourceKind, jetTransaction);

                resultInfo = syncDigestTableAdapter.Get(resourceKindInfo.Id, jetTransaction);

                jetTransaction.Commit();
            }

            return(resultInfo);
        }
コード例 #11
0
        private ISyncResultsTableAdapter GetAdapter(string resourceKind)
        {
            ISyncResultsTableAdapter syncResultsTableAdapter;

            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            Dictionary <string, ISyncResultsTableAdapter> adapters = StoreEnvironment.Resolve <Dictionary <string, ISyncResultsTableAdapter> >(_context);

            if (!adapters.TryGetValue(resourceKind, out syncResultsTableAdapter))
            {
                TableAdapterFactory factory = new TableAdapterFactory(_context, _jetConnectionProvider);
                syncResultsTableAdapter = factory.CreateSyncResultsTableAdapter(resourceKind, resourceKindTableAdapter);
                adapters.Add(resourceKind, syncResultsTableAdapter);
                StoreEnvironment.Set <Dictionary <string, ISyncResultsTableAdapter> >(_context, adapters);
            }

            return(syncResultsTableAdapter);
        }
コード例 #12
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]));
        }
コード例 #13
0
        private ICorrelatedResSyncTableAdapter GetAdapter(string resourceKind)
        {
            ICorrelatedResSyncTableAdapter correlatedResSyncTableAdapter;

            IEndpointTableAdapter     endpointTableAdapter     = StoreEnvironment.Resolve <IEndpointTableAdapter>(_context);
            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            Dictionary <string, ICorrelatedResSyncTableAdapter> adapters = StoreEnvironment.Resolve <Dictionary <string, ICorrelatedResSyncTableAdapter> >(_context);

            if (!adapters.TryGetValue(resourceKind, out correlatedResSyncTableAdapter))
            {
                TableAdapterFactory factory = new TableAdapterFactory(_context, _jetConnectionProvider);
                correlatedResSyncTableAdapter = factory.CreateCorrelatedResSyncTableAdapter(resourceKind, endpointTableAdapter, resourceKindTableAdapter);
                adapters.Add(resourceKind, correlatedResSyncTableAdapter);
                StoreEnvironment.Set <Dictionary <string, ICorrelatedResSyncTableAdapter> >(_context, adapters);
            }

            return(correlatedResSyncTableAdapter);
        }
コード例 #14
0
        public void Update(string resourceKind, object applicationBookmark)
        {
            string assemblyQualifiedName = applicationBookmark.GetType().AssemblyQualifiedName;
            object blob = this.SerializeApplicationBookmark(applicationBookmark);

            IAppBookmarkTableAdapter  appBookmarkTableAdapter  = StoreEnvironment.Resolve <IAppBookmarkTableAdapter>(_context);
            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                ResourceKindInfo resourceKindInfo = resourceKindTableAdapter.GetOrCreate(resourceKind, jetTransaction);

                if (!appBookmarkTableAdapter.Update(resourceKindInfo.Id, blob, assemblyQualifiedName, jetTransaction))
                {
                    throw new StoreException(string.Format("No application bookmark exists for the resource kind '{0}' that can be updated.", resourceKind));
                }

                jetTransaction.Commit();
            }
        }
コード例 #15
0
        public void RemoveAll(string resourceKind)
        {
            ISyncResultsTableAdapter  syncResultsTableAdapter  = StoreEnvironment.Resolve <ISyncResultsTableAdapter>(_context);
            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
//                ResourceKindInfo resourceKindInfo = resourceKindTableAdapter.GetOrCreate(resourceKind, jetTransaction);

                try
                {
                    syncResultsTableAdapter.Delete(jetTransaction);
                }
                catch
                {
                    return;
                }

                jetTransaction.Commit();
            }
        }
コード例 #16
0
        public void Delete(string resourceKind)
        {
            IAppBookmarkTableAdapter  appBookmarkTableAdapter  = StoreEnvironment.Resolve <IAppBookmarkTableAdapter>(_context);
            IResourceKindTableAdapter resourceKindTableAdapter = StoreEnvironment.Resolve <IResourceKindTableAdapter>(_context);

            using (IJetTransaction jetTransaction = _jetConnectionProvider.GetTransaction(false))
            {
                ResourceKindInfo resourceKindInfo = resourceKindTableAdapter.GetOrCreate(resourceKind, jetTransaction);

                try
                {
                    appBookmarkTableAdapter.Delete(resourceKindInfo.Id, jetTransaction);
                }
                catch
                {
                    return;
                }

                jetTransaction.Commit();
            }
        }
コード例 #17
0
 public CorrelatedResSyncStoreProvider(IJetConnectionProvider jetConnectionProvider, SdataContext context)
 {
     _jetConnectionProvider = jetConnectionProvider;
     _context = context;
     StoreEnvironment.Initialize(jetConnectionProvider, context);
 }