static void PopQueueAddTelepromptUpdateGraduate(QueueDbContext q, TelepromptDbContext t, GraduateDbContext g) { // remove the top of the queue var itemTopQueue = q.Queue.OrderBy(m => m.Created).FirstOrDefault(); if (itemTopQueue != null) { q.Remove(itemTopQueue); // save don't wait q.SaveChanges(); // add to teleprompt var respectedTime = DateTime.Now.ToString(); var teleprompt = new Teleprompt() { GraduateId = itemTopQueue.GraduateId, Created = itemTopQueue.Created }; t.Add(teleprompt); t.SaveChanges(); var graduate = g.Graduate.FirstOrDefault(m => m.GraduateId == itemTopQueue.GraduateId); if (graduate != null) { graduate.Status = 1; g.Update(graduate); g.SaveChanges(); } } }
public static void SeedHostDb(QueueDbContext context) { context.SuppressAutoSetTenantId = true; // Host seed new InitialHostDbBuilder(context).Create(); // Default tenant seed (in host database). new DefaultTenantBuilder(context).Create(); new TenantRoleAndUserBuilder(context, 1).Create(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, QueueDbContext dbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); // in case we switch branch in loose the DB // this needs to be commented when applying migrations dbContext.Database.EnsureCreated(); } // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. // by default it can be accessed via the / route app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "LeaningQ V1"); c.RoutePrefix = ""; // serve swagger from the root of the domain }); app.UseRouting(); app.UseCors( options => options.WithOrigins("http://example.com", "http://www.example.com").AllowAnyMethod() ); //// global cors policy (unsecure but easy, could be used for a hackathon or smth) //app.UseCors(x => x // .AllowAnyMethod() // .AllowAnyHeader() // .SetIsOriginAllowed(origin => true) // allow any origin // .AllowCredentials()); // allow credentials app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public TransactionApiService(QueueDbContext context) { _context = context; }
public QueueUnitOfWork(QueueDbContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); }
public DefaultTenantBuilder(QueueDbContext context) { _context = context; }
public QueueRepository(QueueDbContext queueDbContext) { _context = queueDbContext ?? throw new ArgumentNullException(nameof(queueDbContext)); }
public HostRoleAndUserCreator(QueueDbContext context) { _context = context; }
public DefaultSettingsCreator(QueueDbContext context) { _context = context; }
public QueueHub(QueueDbContext context) { _context = context; }
public CounterTypeService(QueueDbContext context) { _context = context; }
public TransactionApiRepo(QueueDbContext context) { _context = context; }
public CounterTypeRepo(QueueDbContext context) { _context = context; }
public DefaultLanguagesCreator(QueueDbContext context) { _context = context; }
public InitialHostDbBuilder(QueueDbContext context) { _context = context; }
public SQLiteRepository(QueueDbContext context) //Dependency injection using concrete implementation { _context = context; }
static void OnTagsReported(ImpinjReader sender, TagReport report) { // This event handler is called asynchronously // when tag reports are available. // Loop through each tag in the report // and print the data. foreach (Tag tag in report) { TelepromptDbContext.ConnectionString = configValue; TelepromptDbContext _contextTeleprompt = new TelepromptDbContext(); GraduateDbContext.ConnectionString = configValue; GraduateDbContext _contextGraduate = new GraduateDbContext(); QueueDbContext.ConnectionString = configValue; QueueDbContext _contextQueue = new QueueDbContext(); var searchGraduateId = Regex.Replace(tag.Epc.ToString(), "[^0-9a-zA-Z]+", ""); Console.WriteLine("EPC / GraduateId >>>> {0} ", searchGraduateId); if (searchGraduateId != String.Empty) { Graduate graduate = _contextGraduate.Graduate.SingleOrDefault(m => m.GraduateId == searchGraduateId); // MUST be on the graduate list if (graduate != null) { // Status 1 // Finished with Display if (graduate.Status != 1) { IEnumerable <Teleprompt> teleprompt = _contextTeleprompt.Teleprompt; var isSearchGraduateInTeleprompt = teleprompt.SingleOrDefault(m => m.GraduateId == searchGraduateId); var countTeleprompt = teleprompt.Count(); // check and kick teleprompt screen, if there's a new reading // so that after logics will always // fulfill // isSearchGraduateInTeleprompt is for the NEW Graduate Read // NOTE: He's is not in the Teleprompt, someone is occupying it. // we need to kick the tenant, if he's already past his occupancy Status = 1 if (isSearchGraduateInTeleprompt == null && countTeleprompt > 0) { Teleprompt currentTenantOnTeleprompt = teleprompt.SingleOrDefault(); if (currentTenantOnTeleprompt.Status == 1) { CleanTeleprompt(_contextTeleprompt); countTeleprompt = 0; } } if (isSearchGraduateInTeleprompt != null && countTeleprompt > 0) { Console.WriteLine("\t\t\t\t\t <<<<<<<<<<<<<<< Active >>>>>>>>>>>>>>> "); } // NOT in teleprompt // AND // EMPTY teleprompt if (isSearchGraduateInTeleprompt == null && countTeleprompt <= 0) { Console.WriteLine("\t\t\tTeleprompt Status: In: No, Count: {0}", countTeleprompt); IEnumerable <Queue> queue = _contextQueue.Queue; var isSearchGraduateInQueue = queue.SingleOrDefault(m => m.GraduateId == searchGraduateId); var totalInQueue = queue.Count(); // teleprompt == empty // searchGraduate not in queue // queue == empty if (isSearchGraduateInQueue == null && totalInQueue <= 0) { // clean teleprompt CleanTeleprompt(_contextTeleprompt); // push directly to the teleprompt DisplayTeleprompt(_contextTeleprompt, searchGraduateId); // update graduate status var grad = _contextGraduate.Graduate.FirstOrDefault(m => m.GraduateId == searchGraduateId); if (grad != null) { grad.Status = 1; _contextGraduate.Update(grad); _contextGraduate.SaveChanges(); } } else { // queue is not empty and not in the queue // push in the end if (isSearchGraduateInQueue == null && totalInQueue > 0) { _contextQueue.Queue.Add(new Queue() { GraduateId = searchGraduateId, Created = System.DateTime.Now }); _contextQueue.SaveChanges(); Console.WriteLine("\t\t\t------------------------------------- In Queue"); } CleanTeleprompt(_contextTeleprompt); PopQueueAddTelepromptUpdateGraduate(_contextQueue, _contextTeleprompt, _contextGraduate); Console.WriteLine("\t\t\tTeleprompt Status: In: No, Count: {0}", countTeleprompt); Console.WriteLine("\t\t\tQueue Status: In: Yes, Count: {0}", totalInQueue); } } else { // Teleprompt is not empty // And // Is not the current display on screen if (isSearchGraduateInTeleprompt == null && countTeleprompt > 0) { // queue IEnumerable <Queue> queue = _contextQueue.Queue; var isSearchGraduateInQueue = queue.SingleOrDefault(m => m.GraduateId == searchGraduateId); if (isSearchGraduateInQueue == null) { _contextQueue.Queue.Add(new Queue() { GraduateId = searchGraduateId, Created = System.DateTime.Now }); _contextQueue.SaveChanges(); Console.WriteLine("\t\t\tQueue Status >> In: No, Count: {0}", queue.Count()); } else { Console.WriteLine("\t\t\tQueue Status >> In: Yes, Count: {0}", queue.Count()); } } } } else { Console.WriteLine("\nGraduate Screen Time... Either FINISHED and/or ACTIVE !!!"); Console.WriteLine("Do you want to show this graduate again? Please change Graduate Status to 0\n"); } } else { // Not a Graduate Id string tag Console.WriteLine("Can't find that Id {0}", searchGraduateId); } } else { Console.WriteLine("Invalid string: @0", searchGraduateId); } } }
public DefaultEditionCreator(QueueDbContext context) { _context = context; }
public DeviceApiRepo(QueueDbContext context) { _context = context; }
public DeviceApiService(QueueDbContext context) { _context = context; }
public TenantRoleAndUserBuilder(QueueDbContext context, int tenantId) { _context = context; _tenantId = tenantId; }
public CounterApiService(QueueDbContext context) { _context = context; }
public CounterApiRepo(QueueDbContext context) { _context = context; }