private void Initialize() { if (ID != UInt32.MaxValue && childId != UInt32.MaxValue) { // Only get the first dialogue. startDialogue = DialogueLine.ConvertRow(TableDatabase.Get.GetRow("dialogues", childId), overrideTable ? collection : LocalizationEditorSettings.GetStringTableCollection("Dialogues")); var field = TableDatabase.Get.GetField(Name, "data", ID); if (field != null) { StoryTable.ParseNodeData(this, (JObject)field.Data); } } if (characterID != UInt32.MaxValue) { TableDatabase database = TableDatabase.Get; Tuple <uint, TableRow> link = database.FindLink("characters", "name", characterID); if (link != null) { var field = database.GetField(link.Item2, "name"); if (field != null) { characterName = (string)field.Data; } Debug.Log(characterName); } } }
private void WriteEntries(IEnumerable <Entry> entries, SqliteConnection connection, int maxId, ref DateTime min, ref DateTime max) { using (var transaction = connection.BeginTransaction()) { foreach (var e in entries) { StoryTable.Write(e, connection, transaction); if (e.Date > max) { max = e.Date; } if (e.Date < min) { min = e.Date; } } DateRangeTable.Write(min, max, connection, transaction); LastWriteTable.Write(maxId, connection, transaction); transaction.Commit(); } }
public PostCountsByDay Get() { lock (Lock) { if (memoryCache.TryGetValue(nameof(PostCountsByDay), out PostCountsByDay cachedResult)) { return(cachedResult); } if (!DateRangeTable.TryRead(connection, out var range)) { throw new InvalidOperationException("Empty date range table in SQLite database."); } var min = range.from; var max = range.to; var totalsByDay = new Dictionary <DateTime, ushort>(); foreach (var entry in StoryTable.GetEntries(connection)) { var day = entry.Date.Date; if (!totalsByDay.ContainsKey(day)) { totalsByDay[day] = 1; } else { totalsByDay[day]++; } } var days = new List <DateTime>(); var counts = new List <ushort>(); var current = min; while (current.Date < max.Date) { days.Add(current.Date); if (totalsByDay.TryGetValue(current.Date, out var count)) { counts.Add(count); } else { counts.Add(0); } current = current.AddDays(1); } cachedResult = new PostCountsByDay(min, max, counts, days); memoryCache.Set(nameof(PostCountsByDay), cachedResult); return(cachedResult); } }
public ActionResult SetDataInDatabase(StoryTable model) { if (ModelState.IsValid && model != null) { _db.Create(model); return(RedirectToAction("ShowDataBaseForUser")); } return(View()); }
public async void Schema(int tableId, int uc) { SCLM sclm = await Utilities.GetContextAsync(uc); StoryTable <Profile> table = await sclm.GetTableAsync <Profile>(tableId); Assert.NotNull(table); Assert.NotNull(table.Schema); Assert.Equal(5, table.Schema.Count()); }
public async void GetTableById(int tableId, int uc) { SCLM sclm = await Utilities.GetContextAsync(uc); StoryTable <Profile> table = await sclm.GetTableAsync <Profile>(tableId); Assert.NotNull(table); Assert.Equal(_tableName, table.Name); Assert.Equal(_tableId, table.Id); }
public LegendContent(StoryTable st) { this._brushes = new Dictionary <string, Brush>(); foreach (Story s in st) { if (!_brushes.ContainsKey(s.GetLabel())) { _brushes.Add(s.GetLabel(), new SolidColorBrush((Color)ColorConverter.ConvertFromString("#" + s.GetEventColor().Substring(0, 6)))); } } }
public void Create_CallTestFromSetDataInDatabase() { StoryTable storyTable = new StoryTable(); var analyzer = new RegisterControllerTests(); var sut = analyzer.SetDataInDatabase(storyTable); analyzer.ClassStub .Received(1) .Create(storyTable); }
public void SetDataInDatabase_Return_ShouldReturnView() { //arrange StoryTable storyTable = null; var controller = new RegisterController(ClassStub); //act var result = controller.SetDataInDatabase(storyTable); //assert Assert.That(result, Is.TypeOf(typeof(ViewResult))); }
public void SetDataInDatabase_Call_ShouldReturnRedirectToRouteResult() { //arrange StoryTable storyTable = new StoryTable(); var controller = new RegisterController(ClassStub); //act var result = controller.SetDataInDatabase(storyTable); //assert Assert.That(result, Is.TypeOf(typeof(RedirectToRouteResult))); Assert.IsNotNull(result); }
public async void GetAllClientTables(int clientId, int uc, string tableName) { SCLM sclm = await Utilities.GetContextAsync(uc); IEnumerable <StoryTable <Profile> > tables = await sclm.GetTablesAsync <Profile>(clientId); Assert.True(tables.Count() > 0); StoryTable <Profile> table = tables.FirstOrDefault(t => t.Name.Contains(tableName)); Assert.NotNull(table); }
private static void WriteFileIntoDatabase(string filename, SQLiteConnection connection, DataTrackers trackers) { using (var file = File.OpenRead(filename)) using (var reader = new BinaryReader(file)) { while (file.Position < file.Length) { var entry = EntryExtensions.Read(reader); trackers.Update(entry); StoryTable.Write(entry, connection); } } }
public int Get() { lock (Lock) { if (memoryCache.TryGetValue(nameof(StoryCountCache), out int value)) { return(value); } value = StoryTable.GetCount(connection); memoryCache.Set(nameof(StoryCountCache), value); return(value); } }
public ActionResult Edit(int id) { StoryTable storyTable = _db.GetStoryTable(id); return(View(storyTable)); }
public static void Index(string indexDirectory, SQLiteConnection connection, IndexWriter indexWriter) { Guard.CheckDirectoryValid(indexDirectory, nameof(indexDirectory), false); var lockFile = Path.Combine(indexDirectory, "index.lock"); if (File.Exists(lockFile)) { return; } lock (Lock) { var indexFile = Path.Combine(indexDirectory, "index.bin"); var lastIndexedId = int.MinValue; var firstRun = !File.Exists(indexFile); if (!firstRun) { if (RequiresUpdate(indexFile, out var actualLastIndexed)) { lastIndexedId = actualLastIndexed; } else { return; } } if (!LastWriteTable.TryRead(connection, out var lastWriteId) || lastIndexedId >= lastWriteId) { Trace.WriteLine($"No indexing required, last indexed {lastIndexedId} which is equal to (or greater than) {lastWriteId}."); return; } Trace.WriteLine($"Indexing from {lastWriteId} to {lastWriteId}."); try { File.WriteAllBytes(lockFile, Array.Empty <byte>()); var count = 1; foreach (var entry in StoryTable.GetEntries(connection, lastIndexedId)) { var document = entry.ToDocument(); indexWriter.AddDocument(document); if (count % 1000 == 0) { Trace.WriteLine($"Finished indexing #{count}."); } count++; } Trace.WriteLine($"Index complete, setting last indexed id to {lastWriteId}."); File.WriteAllText(indexFile, lastWriteId.ToString(CultureInfo.InvariantCulture)); } finally { File.Delete(lockFile); } } }