protected override void Seed(RecordContext context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. }
public async Task ProcessAsync_Success_JObject() { string url = "SomeUrl"; string response = @" { ""ProjectId"": ""ProjectId1"" } "; this.httpClient.AddResponse(url, HttpStatusCode.OK, response); GitHubCollectionNode collectionNode = new GitHubCollectionNode() { ApiName = "ApiName", RecordType = "RecordType", GetInitialUrl = metadata => url, ResponseType = typeof(JObject) }; await this.collector.ProcessAsync(collectionNode).ConfigureAwait(false); List <Tuple <JObject, RecordContext> > records = this.recordWriter.GetRecords(); Assert.AreEqual(1, records.Count); Assert.AreEqual("ProjectId1", records[0].Item1.SelectToken("$.ProjectId").Value <string>()); RecordContext recordContext1 = records[0].Item2; Assert.AreEqual(url, recordContext1.AdditionalMetadata["OriginatingUrl"]); Assert.AreEqual("RecordType", recordContext1.RecordType); }
public Test GetTest(int id) { using (var db = new RecordContext()) { return(db.Tests.Where(t => t.TestId == id).FirstOrDefault()); } }
private async Task ProcessUrlAsync(string requestUrl, string recordType, List <HttpResponseSignature> allowlistedResponses) { HttpResponseMessage response = await this.HttpClient.GetConditionalViaETagAsync(requestUrl, recordType, this.Authentication, allowlistedResponses).ConfigureAwait(false); if (response.StatusCode == HttpStatusCode.NotModified) { return; } if (!response.IsSuccessStatusCode) { // Permitted allowlisted response, but we should not serialize it. return; } JObject record = await HttpUtility.ParseAsJObjectAsync(response).ConfigureAwait(false); RecordContext context = new RecordContext() { RecordType = recordType, AdditionalMetadata = new Dictionary <string, JToken>() { { "OriginatingUrl", requestUrl }, }, }; foreach (IRecordWriter recordWriter in this.RecordWriters) { await recordWriter.WriteRecordAsync(record, context).ConfigureAwait(false); } }
public void AutomaticUpdateRecords(object o) { DbContextOptionsBuilder optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseSqlite(_configuration["ConnectionString_RecordDb"]); RecordContext newRecordContext = new RecordContext(optionsBuilder.Options); newRecordContext.Database.EnsureCreated(); var index = 1; var dbRecords = newRecordContext.Records.Where(r => r.Status == Status.InPending).ToList(); foreach (var record in dbRecords) { record.Status = Status.InWork; var textArr = record.Text.Split(' '); Array.Reverse(textArr); record.Text = string.Join(" ", textArr); record.IndexNumber = index++; } newRecordContext.SaveChanges(); if (dbRecords.Count() > 0) { Task sendUpdateRecords = _hub.Clients.All.SendAsync("transferdata", GetRecords(newRecordContext)); } }
public void TestParseValues_ParsesValues() { FixedLengthSchema schema = new FixedLengthSchema(); schema.AddColumn(new StringColumn("first_name"), new Window(10)) .AddColumn(new StringColumn("last_name"), new Window(10)) .AddColumn(new DateTimeColumn("birth_date") { InputFormat = "yyyyMMdd" }, new Window(8)) .AddColumn(new Int32Column("weight"), new Window(5)); string[] values = new string[] { "bob", "smith", "20120123", "185" }; var recordContext = new RecordContext() { ExecutionContext = new FixedLengthExecutionContext() { Schema = schema, Options = new FixedLengthOptions() } }; object[] parsed = schema.ParseValues(recordContext, values); object[] expected = new object[] { "bob", "smith", new DateTime(2012, 1, 23), 185 }; CollectionAssert.AreEqual(expected, parsed); }
private void RecordContext_Saving(object sender, CancelEventArgs e) { try { Init(); AirportObject = RecordContext.GetWorkspaceRecord("CO$Airports") as IGenericObject; RecordContext.RefreshWorkspace(); if (AirportObject != null) { int IdAirport = Convert.ToInt32(AirportObject.Id); if (IdAirport != 0) { if (!Allday(IdAirport)) { if (!boolGetHours(IdAirport)) { MessageBox.Show("You must have at least one normal hour"); e.Cancel = true; } if (!CheckExtraordinary(IdAirport)) { MessageBox.Show("Extraordinary hours are not under the normal hours."); e.Cancel = true; } } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); throw ex; } }
public Record[] Index() { // Find the record in the database and return it using (var db = new RecordContext()) { return(db.Records.ToArray()); } }
public Record Get(int id) { // Find the record in the database and return it using (var db = new RecordContext()) { return(db.Records.Where(record => record.RecordId == id).FirstOrDefault()); } }
public Endpoint Get(int id) { // Find the record in the database and return it using (var db = new RecordContext()) { return(db.Endpoints.Where(e => e.EndpointId == id).FirstOrDefault()); } }
public Test GetTestConnectathon(int id, int certificateNumber, string state) { using (var db = new RecordContext()) { Test test = new Test(Connectathon.FromId(id, certificateNumber, state)); db.Tests.Add(test); db.SaveChanges(); return(test); } }
public Test NewTest() { using (var db = new RecordContext()) { Test test = new Test(); db.Tests.Add(test); db.SaveChanges(); return(test); } }
public async Task <IEnumerable <Mute> > GetActiveMutesAsync() { if (_db == null) { _db = new RecordContext(); } await _db.Database.EnsureCreatedAsync(); return(_db.Mutes.Where(x => DateTime.Compare(DateTime.UtcNow, x.UnmuteAt) > 0 && x.Active)); }
public Test GetTestConnectathon(int id) { using (var db = new RecordContext()) { Test test = new Test(Connectathon.FromId(id)); db.Tests.Add(test); db.SaveChanges(); return(test); } }
public MainViewModel(RecordContext context) { this.context = context; Records = new ObservableCollection <RecordViewModel>(); var items = context.Record.Select(p => p); foreach (Record item in items) { Records.Add(new RecordViewModel(item, Records)); } }
public ActionResult Delete(int Id) { var dbh = new RecordContext(); FileFormat user = dbh.FileFormats.Find(Id); if (user == null) { return(HttpNotFound()); } return(View(user)); }
public async Task DeactivateBanAsync(int key) { if (_db == null) { _db = new RecordContext(); } await _db.Database.EnsureCreatedAsync(); var ban = await _db.TempBans.FirstOrDefaultAsync(x => x.Key == key); ban.Active = false; await _db.SaveChangesAsync(); }
public static void Initialize(RecordContext context) { if (context.Records.Any()) { return; } context.Records.AddRange( new Record(100, 1000), new Record(100, 1060), new Record(100, 1111) ); context.SaveChanges(); }
public async Task <int> PerformTestConnectathon(int id) { using (var db = new RecordContext()) { Test test = new Test(Connectathon.FromId(id)); string input = await new StreamReader(Request.Body, Encoding.UTF8).ReadToEndAsync(); if (!String.IsNullOrEmpty(input)) { test = test.Run(new DeathRecord(input)); } return(test.Incorrect); } }
public async Task DeactivateMuteAsync(int key) { if (_db == null) { _db = new RecordContext(); } await _db.Database.EnsureCreatedAsync(); var mute = await _db.Mutes.FirstOrDefaultAsync(x => x.Key == key); mute.Active = false; await _db.SaveChangesAsync(); }
public async Task <Mute> AddMuteAsync(Mute mute) { if (_db == null) { _db = new RecordContext(); } await _db.Database.EnsureCreatedAsync(); var entry = await _db.Mutes.AddAsync(mute); await _db.SaveChangesAsync(); return(entry.Entity); }
public async Task <SoftBan> AddSoftBanAsync(SoftBan ban) { if (_db == null) { _db = new RecordContext(); } await _db.Database.EnsureCreatedAsync(); var entry = await _db.SoftBans.AddAsync(ban); await _db.SaveChangesAsync(); return(entry.Entity); }
private List <DTORecord> GetRecords(RecordContext newRecordContext) { return(newRecordContext.Records.Include(c => c.Type).Select(r => new DTORecord { RecordId = r.Id, IndexNumber = r.IndexNumber, Status = r.Status.ToString(), Text = r.Text, Type = r.Type.Name, TypeId = r.Type.Id } ).ToList()); }
public RecordController(RecordContext context) { _context = context; if (_context.Records.Count() == 0) { // Create a new TodoItem if collection is empty, // which means you can't delete all TodoItems. _context.Records.Add(new Models.Record { F1 = "Record1-Field1", F2 = "Record1-Field2", F3 = "Record1-Field3" }); _context.SaveChanges(); } }
public (IDatabaseController, Pager) UseDatabase(string databaseName) { // init string dbPath = $"./{databaseName}.minidb"; Pager pager = new Pager(dbPath, 1024 * 8, 400); FreeList freeList = new FreeList(pager); IIndexManager bTreeController = new BTreeController(pager, freeList, 40); IInterpreter interpreter = new Parsing(); ICatalogManager catalogManager = new Catalog(databaseName); IRecordManager recordManager = new RecordContext(pager, bTreeController); IDatabaseController database = new DatabaseController(interpreter, catalogManager, recordManager); return(database, pager); }
public async Task Records([Summary("The type of records to get (mutes, temps, permas)")] string type, [Summary("Target user")] SocketGuildUser user) { using (var context = new RecordContext()) { await context.Database.EnsureCreatedAsync(); var mutes = context.Mutes.Where(m => m.SubjectId == user.Id); var temps = context.TempBans.Where(t => t.SubjectId == user.Id); var permas = context.PermaBans.Where(p => p.SubjectId == user.Id); var response = new StringBuilder("\n"); switch (type.ToLower()) { case "mutes": foreach (var m in mutes) { response.AppendLine($"**({m.Key}) {m.Timestamp.ToString("mm/dd/yy hh:mm:ss UTC")}:** {m.Reason}"); } break; case "temps": foreach (var t in temps) { response.AppendLine($"**({t.Key}) {t.Timestamp.ToString("mm/dd/yy hh:mm:ss UTC")}:** {t.Reason}"); } break; case "permas": foreach (var p in permas) { response.AppendLine($"**({p.Key}) {p.Timestamp.ToString("mm/dd/yy hh:mm:ss UTC")}:** {p.Reason}"); } break; default: await ReplyAsync(":x: Invalid type."); return; } if (response.Length > 2000) { await ReplyAsync(":x: Too many records! The message is over 2000 characters."); return; } await ReplyAsync(response.ToString()); } }
public async Task <Test> RunTest(int id, string type) { using (var db = new RecordContext()) { Test test = db.Tests.Where(t => t.TestId == id).FirstOrDefault(); string input = await new StreamReader(Request.Body, Encoding.UTF8).ReadToEndAsync(); if (!String.IsNullOrEmpty(input)) { test.Type = type; test.Run(input); } db.Tests.Remove(test); db.SaveChanges(); return(test); } }
public async Task <Test> RunRoundtripProducingTest(int id) // TODO: These test routes can probably be combined. { using (var db = new RecordContext()) { Test test = db.Tests.Where(t => t.TestId == id).FirstOrDefault(); string input = await new StreamReader(Request.Body, Encoding.UTF8).ReadToEndAsync(); if (!String.IsNullOrEmpty(input)) { test.Type = "RoundtripProducing"; test.Run(input); } db.Tests.Remove(test); db.SaveChanges(); return(test); } }
private static void TestInsertRandomRecord(int maxCell) { string dbPath = "./testdbfile.minidb"; File.Delete(dbPath); Pager pager = new Pager(dbPath); FreeList freeList = new FreeList(pager); BTreeController controller = new BTreeController(pager, freeList); RecordContext recordManager = new RecordContext(pager, controller); // create new table CreateStatement createStatement = GetCreateStatement(); int newRoot = recordManager.CreateTable(); // insert BTreeNode node; InsertStatement insertStatement; int key; int newRootAfterInsert = newRoot; int i; for (i = 0; i < maxCell; i++) { (insertStatement, key) = GetInsertStatement(1); AtomValue atomValue = GetAtomValue(key); newRootAfterInsert = recordManager.InsertRecord(insertStatement.Values, atomValue, newRootAfterInsert); Console.WriteLine(key); Debug.Assert(newRoot == newRootAfterInsert); } node = BTreeNodeHelper.GetBTreeNode(pager, newRootAfterInsert); BTreeNodeHelper.VisualizeIntegerTree(pager, node); Console.WriteLine(); for (i = 0; i < maxCell; i++) { (insertStatement, key) = GetInsertStatement(1); AtomValue atomValue = GetAtomValue(key); newRootAfterInsert = recordManager.InsertRecord(insertStatement.Values, atomValue, newRootAfterInsert); Console.WriteLine(key); } node = BTreeNodeHelper.GetBTreeNode(pager, newRootAfterInsert); BTreeNodeHelper.VisualizeIntegerTree(pager, node); pager.Close(); }
public int New() { // Find the record in the database and return it using (var db = new RecordContext()) { if (db.Endpoints.Count() > 100) { // Too many endpoints in existance, delete the oldest to prevent someone from abusing this. // TODO: Probably a smoother way to accomplish this. Investigate. db.Endpoints.Remove(db.Endpoints.FirstOrDefault()); } Endpoint endpoint = new Endpoint(); db.Endpoints.Add(endpoint); db.SaveChanges(); return(endpoint.EndpointId); } }