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(); } }
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(); } }
public AppBookmarkInfoStoreProvider(IJetConnectionProvider jetConnectionProvider, IAppBookmarkSerializer serializer, SdataContext context) { _jetConnectionProvider = jetConnectionProvider; _serializer = serializer; _context = context; StoreEnvironment.Initialize(jetConnectionProvider, context); }
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); }
public Int32tickProvider(IJetConnectionProvider jetConnectionProvider, SdataContext context) { _jetConnectionProvider = jetConnectionProvider; _context = context; StoreEnvironment.Initialize(jetConnectionProvider, context); }
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); }
public SyncResultsInfoStoreProvider(IJetConnectionProvider jetConnectionProvider, SdataContext context) { _jetConnectionProvider = jetConnectionProvider; _context = context; StoreEnvironment.Initialize(jetConnectionProvider, context); }
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(); } }
/* * 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); }
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); }
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); }
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])); }
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); }
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(); } }
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(); } }
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(); } }
public CorrelatedResSyncStoreProvider(IJetConnectionProvider jetConnectionProvider, SdataContext context) { _jetConnectionProvider = jetConnectionProvider; _context = context; StoreEnvironment.Initialize(jetConnectionProvider, context); }