示例#1
0
        public void Insert(int resourceKindId, SyncDigestEntryInfo[] syncDigestEntryInfo, IJetTransaction jetTransaction)
        {
            IEndPointTableAdapter EndPointTableAdapter = StoreEnvironment.Resolve <IEndPointTableAdapter>(this.Context);
            OleDbCommand          oleDbCommand         = jetTransaction.CreateOleCommand();
            EndPointInfo          tmpEndPointInfo;

            string sqlQuery = string.Empty;

            sqlQuery = "INSERT INTO [{0}] ([tick], [ConflictPriority], [Stamp], [FKResourceKindId], [FKEndPointId]) VALUES (@tick, @ConflictPriority, @Stamp, @ResourceKindId, @EndPointId);";

            oleDbCommand.CommandText = string.Format(sqlQuery, _syncDigestTable.TableName);

            foreach (SyncDigestEntryInfo info in syncDigestEntryInfo)
            {
                // TODO: Use prepared query
                tmpEndPointInfo = EndPointTableAdapter.GetOrCreate(info.EndPoint, jetTransaction);
                //oleDbCommand.Parameters.Clear();
                oleDbCommand.Parameters.AddWithValue("@tick", info.Tick);
                oleDbCommand.Parameters.AddWithValue("@ConflictPriority", info.ConflictPriority);
                oleDbCommand.Parameters.AddWithValue("@Stamp", info.Stamp.ToString());
                oleDbCommand.Parameters.AddWithValue("@ResourceKindId", resourceKindId);
                oleDbCommand.Parameters.AddWithValue("@EndPointId", tmpEndPointInfo.Id);

                oleDbCommand.ExecuteNonQuery();
            }
        }
示例#2
0
        public bool Update(CorrelatedResSyncInfo info, IJetTransaction jetTransaction)
        {
            IEndPointTableAdapter EndPointTableAdapter = StoreEnvironment.Resolve <IEndPointTableAdapter>(this.Context);
            EndPointInfo          EndPointInfo         = EndPointTableAdapter.GetOrCreate(info.ResSyncInfo.EndPoint, jetTransaction);

            OleDbCommand oleDbCommand = jetTransaction.CreateOleCommand();

            string sqlQuery = string.Empty;

            // store only correlation data if tick is set to -1
            if (info.ResSyncInfo.Tick == -1)
            {
                sqlQuery = "UPDATE [{0}] SET  [LocalId]=@LocalId WHERE (Uuid=@Uuid);";

                oleDbCommand.CommandText = string.Format(sqlQuery, _correlatedResSyncTable.TableName);
                oleDbCommand.Parameters.AddWithValue("@LocalId", info.LocalId);
                oleDbCommand.Parameters.AddWithValue("@Uuid", info.ResSyncInfo.Uuid);
            }
            else
            {
                sqlQuery = "UPDATE [{0}] SET [tick]=@tick, [ModifiedStamp]=@ModifiedStamp, [Etag]=@Etag, [LocalId]=@LocalId , [FKEndPointId]=@EndPointId  WHERE (Uuid=@Uuid);";

                oleDbCommand.CommandText = string.Format(sqlQuery, _correlatedResSyncTable.TableName);

                oleDbCommand.Parameters.AddWithValue("@tick", info.ResSyncInfo.Tick);
                oleDbCommand.Parameters.AddWithValue("@ModifiedStamp", info.ResSyncInfo.ModifiedStamp.ToString());
                oleDbCommand.Parameters.AddWithValue("@Etag", info.ResSyncInfo.Etag);
                oleDbCommand.Parameters.AddWithValue("@LocalId", info.LocalId);
                oleDbCommand.Parameters.AddWithValue("@EndPointId", EndPointInfo.Id);
                oleDbCommand.Parameters.AddWithValue("@Uuid", info.ResSyncInfo.Uuid);
            }


            return(0 != oleDbCommand.ExecuteNonQuery());
        }
示例#3
0
        /// <summary>
        /// Gets the port from the store table for a given store and environment (Development, Staging, Production)
        /// </summary>
        public static string GetStorePortByEnvironment(StoreEnvironment environment, int storeId)
        {
            var store = GetStoreById(storeId);

            switch (environment)
            {
            case StoreEnvironment.Development:
                return(store.DevelopmentPort);

            case StoreEnvironment.Staging:
                return(store.StagingPort);
            }

            return(store.ProductionPort);
        }
示例#4
0
        /// <summary>
        /// Gets the directory path a.k.a. virtual directory from the store table for a given store and environment (Development, Staging, Live)
        /// </summary>
        public static string GetStoreDirectoryByEnvironment(StoreEnvironment environment, int storeId)
        {
            var store = GetStoreById(storeId);

            switch (environment)
            {
            case StoreEnvironment.Development:
                return(store.DevelopmentDirectoryPath);

            case StoreEnvironment.Staging:
                return(store.StagingDirectoryPath);
            }

            return(store.ProductionDirectoryPath);
        }
示例#5
0
        public void Insert(CorrelatedResSyncInfo info, IJetTransaction jetTransaction)
        {
            IEndPointTableAdapter EndPointTableAdapter = StoreEnvironment.Resolve <IEndPointTableAdapter>(this.Context);
            EndPointInfo          EndPointInfo         = EndPointTableAdapter.GetOrCreate(info.ResSyncInfo.EndPoint, jetTransaction);

            OleDbCommand oleDbCommand = jetTransaction.CreateOleCommand();

            string sqlQuery = string.Empty;

            sqlQuery = "INSERT INTO {0} ([Uuid], [tick], [ModifiedStamp], [Etag], [LocalId], [FKEndPointId], [FKResourceKindId]) VALUES (@Uuid, @tick, @ModifiedStamp, @Etag, @LocalId, @EndPointId, @ResourceKindId);";
            oleDbCommand.CommandText = string.Format(sqlQuery, _correlatedResSyncTable.TableName);

            oleDbCommand.Parameters.AddWithValue("@Uuid", info.ResSyncInfo.Uuid);
            oleDbCommand.Parameters.AddWithValue("@tick", info.ResSyncInfo.Tick);
            oleDbCommand.Parameters.AddWithValue("@ModifiedStamp", info.ResSyncInfo.ModifiedStamp.ToString());
            oleDbCommand.Parameters.AddWithValue("@Etag", info.ResSyncInfo.Etag);
            oleDbCommand.Parameters.AddWithValue("@LocalId", info.LocalId);
            oleDbCommand.Parameters.AddWithValue("@EndPointId", EndPointInfo.Id);
            oleDbCommand.Parameters.AddWithValue("@ResourceKindId", _correlatedResSyncTable.ResourceKindId);

            oleDbCommand.ExecuteNonQuery();
        }
示例#6
0
        public bool Update(int resourceKindId, SyncDigestEntryInfo syncDigestEntryInfo, IJetTransaction jetTransaction)
        {
            IEndPointTableAdapter EndPointTableAdapter = StoreEnvironment.Resolve <IEndPointTableAdapter>(this.Context);
            OleDbCommand          oleDbCommand         = jetTransaction.CreateOleCommand();
            EndPointInfo          tmpEndPointInfo;

            string sqlQuery = string.Empty;

            sqlQuery = "UPDATE [{0}] SET [tick]=@tick, [ConflictPriority]=@ConflictPriority, [Stamp]=@Stamp WHERE (FKResourceKindId=@ResourceKindId AND FKEndPointId=@EndPointId);";

            oleDbCommand.CommandText = string.Format(sqlQuery, _syncDigestTable.TableName);

            // TODO: Use prepared query
            tmpEndPointInfo = EndPointTableAdapter.GetOrCreate(syncDigestEntryInfo.EndPoint, jetTransaction);
            oleDbCommand.Parameters.AddWithValue("@tick", syncDigestEntryInfo.Tick);
            oleDbCommand.Parameters.AddWithValue("@ConflictPriority", syncDigestEntryInfo.ConflictPriority);
            oleDbCommand.Parameters.AddWithValue("@Stamp", syncDigestEntryInfo.Stamp.ToString());
            oleDbCommand.Parameters.AddWithValue("@ResourceKindId", resourceKindId);
            oleDbCommand.Parameters.AddWithValue("@EndPointId", tmpEndPointInfo.Id);

            int count = oleDbCommand.ExecuteNonQuery();

            return(count > 0);
        }
示例#7
0
 public static void Reset(SdataContext context)
 {
     StoreEnvironment.Remove(context);
 }