public static string GetNextFileName() { return(TimestampID.GetInstance().Next(data => { return data.ToString("yyyyMMddhhmmss"); })); }
private GetManyResult GetManyInternal(Guid clientGuid, string domain, FactTreeMemento tree, Dictionary <long, long> pivotIds) { var localPivotIds = new List <FactID>(); FactTreeMemento messageBody = new FactTreeMemento(0); Dictionary <FactID, FactID> localIdByRemoteId = ForEachFact(tree, fact => _repository.Save(domain, fact, clientGuid)); Dictionary <long, long> newPivotIds = new Dictionary <long, long>(); foreach (var pivot in pivotIds) { long remotePivotId = pivot.Key; FactID localPivotId; long pivotValue = pivot.Value; TimestampID timestamp = new TimestampID(0, pivotValue); if (localIdByRemoteId.TryGetValue(new FactID { key = remotePivotId }, out localPivotId)) { List <FactID> recentMessages = _repository.LoadRecentMessages(domain, localPivotId, clientGuid, timestamp); foreach (FactID recentMessage in recentMessages) { AddToFactTree(domain, messageBody, recentMessage, localIdByRemoteId); if (recentMessage.key > pivotValue) { pivotValue = recentMessage.key; } } newPivotIds[remotePivotId] = pivotValue; localPivotIds.Add(localPivotId); } } foreach (var pivot in newPivotIds) { pivotIds[pivot.Key] = pivot.Value; } var result = new GetManyResult() { Tree = messageBody, PivotIds = pivotIds, LocalPivotIds = localPivotIds }; return(result); }
public List <FactID> GetRecentMessages(FactID pivotId, TimestampID timestamp, int clientId) { _session.Command.CommandText = "SELECT TOP (20) FactId " + "FROM Message " + "WHERE PivotId = @PivotId " + "AND FactId > @Timestamp " + "AND ClientId != @ClientId " + "ORDER BY FactId"; AddParameter("@PivotId", pivotId.key); AddParameter("@Timestamp", timestamp.Key); AddParameter("@ClientId", clientId); using (var loader = new Loader(_session.Command.ExecuteReader())) { _session.Command.Parameters.Clear(); return(loader.LoadIDs().ToList()); } }
private GetManyResult GetManyInternal(Guid clientGuid, string domain, FactTreeMemento tree, Dictionary<long, long> pivotIds) { var localPivotIds = new List<FactID>(); FactTreeMemento messageBody = new FactTreeMemento(0); Dictionary<FactID, FactID> localIdByRemoteId = ForEachFact(tree, fact => _repository.Save(domain, fact, clientGuid)); Dictionary<long, long> newPivotIds = new Dictionary<long, long>(); foreach (var pivot in pivotIds) { long remotePivotId = pivot.Key; FactID localPivotId; long pivotValue = pivot.Value; TimestampID timestamp = new TimestampID(0, pivotValue); if (localIdByRemoteId.TryGetValue(new FactID { key = remotePivotId }, out localPivotId)) { List<FactID> recentMessages = _repository.LoadRecentMessages(domain, localPivotId, clientGuid, timestamp); foreach (FactID recentMessage in recentMessages) { AddToFactTree(domain, messageBody, recentMessage, localIdByRemoteId); if (recentMessage.key > pivotValue) pivotValue = recentMessage.key; } newPivotIds[remotePivotId] = pivotValue; localPivotIds.Add(localPivotId); } } foreach (var pivot in newPivotIds) pivotIds[pivot.Key] = pivot.Value; var result = new GetManyResult() { Tree = messageBody, PivotIds = pivotIds, LocalPivotIds = localPivotIds }; return result; }
public List<FactID> LoadRecentMessages(string domain, FactID localPivotId, Guid clientGuid, TimestampID timestamp) { return _messageTable.Where(message => message.Message.PivotId.Equals(localPivotId) && message.Message.FactId.key > timestamp.Key && message.Source != clientGuid).Select(message => message.Message.FactId).Distinct() .ToList(); }
public List <FactID> LoadRecentMessages(string domain, FactID pivotId, Guid clientGuid, TimestampID timestamp) { using (var session = new Session(_connectionString)) { int clientId = SaveClient(session, clientGuid); session.Command.CommandText = "SELECT TOP (20) FactId " + "FROM Message " + "WHERE PivotId = @PivotId " + "AND FactId > @Timestamp " + "AND ClientId != @ClientId " + "ORDER BY FactId"; AddParameter(session.Command, "@PivotId", pivotId.key); AddParameter(session.Command, "@Timestamp", timestamp.Key); AddParameter(session.Command, "@ClientId", clientId); using (IDataReader messageReader = session.Command.ExecuteReader()) { session.Command.Parameters.Clear(); return(LoadIDsFromReader(messageReader).ToList()); } } }
public List<FactID> GetRecentMessages(FactID pivotId, TimestampID timestamp, int clientId) { _session.Command.CommandText = "SELECT TOP (20) FactId " + "FROM Message " + "WHERE PivotId = @PivotId " + "AND FactId > @Timestamp " + "AND ClientId != @ClientId " + "ORDER BY FactId"; AddParameter("@PivotId", pivotId.key); AddParameter("@Timestamp", timestamp.Key); AddParameter("@ClientId", clientId); using (var loader = new Loader(_session.Command.ExecuteReader())) { _session.Command.Parameters.Clear(); return loader.LoadIDs().ToList(); } }
public List <FactID> LoadRecentMessages(string domain, FactID localPivotId, Guid clientGuid, TimestampID timestamp) { return(_messageTable.Where(message => message.Message.PivotId.Equals(localPivotId) && message.Message.FactId.key > timestamp.Key && message.Source != clientGuid).Select(message => message.Message.FactId).Distinct() .ToList()); }
public List <FactID> LoadRecentMessages(string domain, FactID pivotId, Guid clientGuid, TimestampID timestamp) { using (var procedures = new Procedures(new Session(_connectionString))) { int clientId = SaveClient(procedures, clientGuid); return(procedures.GetRecentMessages(pivotId, timestamp, clientId)); } }
public List<FactID> LoadRecentMessages(string domain, FactID pivotId, Guid clientGuid, TimestampID timestamp) { using (var procedures = new Procedures(new Session(_connectionString))) { int clientId = SaveClient(procedures, clientGuid); return procedures.GetRecentMessages(pivotId, timestamp, clientId); } }