コード例 #1
0
        public static void MustMatchMaxIdOf(this string sutDB, string masterDB)
        {
            var expctd = AnyLiteDB.GetMaxId(masterDB);
            var actual = AnyLiteDB.GetMaxId(sutDB);

            actual.Should().Be(expctd);
        }
コード例 #2
0
        private string ComposeBroadcastMessage(string fileKey, string filePath)
        {
            var desc = new AppendOnlyDbChangeInfo
            {
                FileKey = fileKey,
                MaxId   = AnyLiteDB.GetMaxId(filePath)
            };

            return(JsonConvert.SerializeObject(desc));
        }
コード例 #3
0
        private bool SameMaxIDs(long remoteMaxId, out long localMaxId)
        {
            if (!File.Exists(_filePath))
            {
                Log("Local DB currently does not exist.");
                localMaxId = 0;
                return(false);
            }
            localMaxId = AnyLiteDB.GetMaxId(_filePath);
            var isSame = localMaxId == remoteMaxId;

            Log(isSame ? $"Local and remote max IDs are both [{localMaxId}]."
                       : $"Local max ID [{localMaxId}] differs from that of remote [{remoteMaxId}].");
            return(isSame);
        }
コード例 #4
0
        public async Task <List <string> > GetRecords(string fileKey, long startId)
        {
            await Task.Delay(0);

            if (!IsValidDbKey(fileKey, out string filePath))
            {
                return(null);
            }
            try
            {
                return(AnyLiteDB.GetRecords(filePath, startId));
            }
            catch (Exception ex)
            {
                _logs.Add(ex);
                return(null);
            }
        }
コード例 #5
0
        public async Task <long> GetMaxId(string fileKey)
        {
            await Task.Delay(0);

            if (!IsValidDbKey(fileKey, out string filePath))
            {
                return(-1);
            }
            try
            {
                return(AnyLiteDB.GetMaxId(filePath));
            }
            catch (Exception ex)
            {
                _logs.Add(ex);
                return(-1);
            }
        }
コード例 #6
0
 private void InsertRecordsToLocalDB(List <string> recs)
 {
     AnyLiteDB.Insert(_filePath, recs);
 }