public static void SeedEvents(BackOfficeContext context) { if (context.Set <CalendarEventModel>().Any()) { return; // Db has been seeded; } var calendarEvents = new CalendarEventModel[] { CreateEvent("#00abff", "Test title event 1", "Test description event 1", new DateTime(2018, 9, 24), new DateTime(2018, 9, 26), CreateReminder(new DateTime(2018, 9, 24, 8, 40, 0), _activeReminder, ReminderTimeOffset.FifteenMinBefore)), CreateEvent("#00abff", "Test title event 2", "Test description event 2", new DateTime(2018, 9, 27)), CreateEvent("#00abff", "Test title event 3", "Test description event 3", new DateTime(2018, 9, 25), new DateTime(2018, 9, 30)) }; var todos = new TodoModel[] { CreateTodo("Test todo create", false, false), CreateTodo("Test todo completed", true, false), CreateTodo("Test todo uncompleted", false, false), CreateTodo("Test todo archived", true, true), }; context.Set <CalendarEventModel>().AddRange(calendarEvents); context.Set <TodoModel>().AddRange(todos); context.SaveChanges(); }
public async Task WriteAsync(ZipArchive archive, BackOfficeContext context, CancellationToken cancellationToken) { if (archive == null) { throw new ArgumentNullException(nameof(archive)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } var dbfEntry = archive.CreateEntry(_filename); var dbfHeader = new DbaseFileHeader( DateTime.Now, DbaseCodePage.Western_European_ANSI, new DbaseRecordCount(_records.Count), _schema ); using (var dbfEntryStream = dbfEntry.Open()) using (var dbfWriter = new DbaseBinaryWriter( dbfHeader, new BinaryWriter(dbfEntryStream, _encoding, true))) { foreach (var dbfRecord in _records) { dbfWriter.Write(dbfRecord); } dbfWriter.Writer.Flush(); await dbfEntryStream.FlushAsync(cancellationToken); } }
public static void Initialize(BackOfficeContext context) { context.Database.EnsureCreated(); if (context.MeterInfos.Any()) { return; } var meters = new MeterInfo[] { new MeterInfo { EnxpId = 1, PmumId = 1, CityName = "İstanbul", DistrictName = "Bedaş", MeterName = "Meter1", MunicipalityTaxRatio = true }, new MeterInfo { EnxpId = 2, PmumId = 2, CityName = "İstanbul", DistrictName = "Ayedaş", MeterName = "Meter2", MunicipalityTaxRatio = true }, new MeterInfo { EnxpId = 3, PmumId = 3, CityName = "Ankara", DistrictName = "Başkent", MeterName = "Meter3", MunicipalityTaxRatio = true } }; context.AddRange(meters); context.SaveChanges(); }
public UnitOfProducts(IProductRepository productRepository, IStockRepository stockRepository, BackOfficeContext context) : base(context) { ProductRepository = productRepository; StockRepository = stockRepository; }
public RegisteredApplicationAuthenticationSchemaHandler( IOptionsMonitor <AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, BackOfficeContext context) : base(options, logger, encoder, clock) { _context = context; }
public FacebookAccessTokenReceivingService( IExchangeCodeForTokenService exchangeCodeForTokenService, BackOfficeContext context, IMemoryCache memoryCache, ILogger <FacebookAccessTokenReceivingService> logger) { this.exchangeCodeForTokenService = exchangeCodeForTokenService; _context = context; _memoryCache = memoryCache; _logger = logger; }
public async Task <BackOfficeContext> CreateBackOfficeContextAsync(SqlConnectionStringBuilder builder) { var options = new DbContextOptionsBuilder <BackOfficeContext>() .UseSqlServer(builder.ConnectionString) .EnableSensitiveDataLogging() .Options; var context = new BackOfficeContext(options); await context.Database.MigrateAsync(); return(context); }
/// <inheritdoc /> public AdminController( BackOfficeContext backOfficeContext, IAuthServise authService, IRefreshTokenService refreshTokenService, IMemoryCache memoryCache, ILogger <AdminController> logger) { _memoryCache = memoryCache; _logger = logger; _backOfficeContext = backOfficeContext; _authService = authService; _refreshTokenService = refreshTokenService; }
#pragma warning disable 1591 public RedirectController( IUserProfileReceivingServiceContext userProfileReceivingServiceContext, IEnumerable <IAccessTokenReceivingService> tokenReceivingServices, IEnumerable <IProfileManagingService> profileManagingServices, IMemoryCache memoryCache, BackOfficeContext context, ILogger <RedirectController> logger) { _userProfileReceivingServiceContext = userProfileReceivingServiceContext; _tokenReceivingServices = tokenReceivingServices; _profileManagingServices = profileManagingServices; _context = context; _logger = logger; _memoryCache = memoryCache; }
public static void SeedUsers(BackOfficeContext context) { if (context.Set <UserModel>().Any()) { return; // Db has been seeded; } var users = new UserModel[] { CreateUser("admin", "admiN123", "Administrator", string.Empty), }; context.Set <UserModel>().AddRange(users); context.SaveChanges(); }
public async Task WriteAsync(ZipArchive archive, BackOfficeContext context, CancellationToken cancellationToken) { if (archive == null) { throw new ArgumentNullException(nameof(archive)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } foreach (var writer in _writers) { await writer.WriteAsync(archive, context, cancellationToken); } }
public async Task WriteAsync(ZipArchive archive, BackOfficeContext context, CancellationToken cancellationToken) { if (archive == null) { throw new ArgumentNullException(nameof(archive)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } using (await context.Database.BeginTransactionAsync(IsolationLevel.ReadCommitted, cancellationToken)) { await _writer.WriteAsync(archive, context, cancellationToken); } }
private static async Task <object[]> AllRecords(this BackOfficeContext context) { var records = new List <object>(); records.AddRange(await context.RoadNodes.ToArrayAsync()); records.AddRange(await context.RoadSegments.ToArrayAsync()); records.AddRange(await context.RoadSegmentLaneAttributes.ToArrayAsync()); records.AddRange(await context.RoadSegmentWidthAttributes.ToArrayAsync()); records.AddRange(await context.RoadSegmentSurfaceAttributes.ToArrayAsync()); records.AddRange(await context.RoadSegmentEuropeanRoadAttributes.ToArrayAsync()); records.AddRange(await context.RoadSegmentNationalRoadAttributes.ToArrayAsync()); records.AddRange(await context.RoadSegmentNumberedRoadAttributes.ToArrayAsync()); records.AddRange(await context.GradeSeparatedJunctions.ToArrayAsync()); records.AddRange(await context.Organizations.ToArrayAsync()); records.AddRange(await context.RoadNetworkInfo.ToArrayAsync()); records.AddRange(await context.RoadNetworkChanges.ToArrayAsync()); return(records.ToArray()); }
public async Task WriteAsync(ZipArchive archive, BackOfficeContext context, CancellationToken cancellationToken) { if (archive == null) { throw new ArgumentNullException(nameof(archive)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } var count = await context.RoadSegmentEuropeanRoadAttributes.CountAsync(cancellationToken); var dbfEntry = archive.CreateEntry("AttEuropweg.dbf"); var dbfHeader = new DbaseFileHeader( DateTime.Now, DbaseCodePage.Western_European_ANSI, new DbaseRecordCount(count), RoadSegmentEuropeanRoadAttributeDbaseRecord.Schema ); using (var dbfEntryStream = dbfEntry.Open()) using (var dbfWriter = new DbaseBinaryWriter( dbfHeader, new BinaryWriter(dbfEntryStream, _encoding, true))) { var dbfRecord = new RoadSegmentEuropeanRoadAttributeDbaseRecord(); foreach (var data in context.RoadSegmentEuropeanRoadAttributes.OrderBy(_ => _.Id).Select(_ => _.DbaseRecord)) { dbfRecord.FromBytes(data, _manager, _encoding); dbfWriter.Write(dbfRecord); } dbfWriter.Writer.Flush(); await dbfEntryStream.FlushAsync(cancellationToken); } }
public async Task <IActionResult> Get([FromServices] BackOfficeContext context) { var info = await context.RoadNetworkInfo.SingleOrDefaultAsync(HttpContext.RequestAborted); if (info == null || !info.CompletedImport) { return(StatusCode(StatusCodes.Status503ServiceUnavailable)); } return(new FileCallbackResult( new MediaTypeHeaderValue("application/zip"), async(stream, actionContext) => { var encoding = Encoding.GetEncoding(1252); var writer = new RoadNetworkForShapeEditingZipArchiveWriter(_manager, encoding); using (var archive = new ZipArchive(stream, ZipArchiveMode.Create, true, Encoding.UTF8)) { await writer.WriteAsync(archive, context, HttpContext.RequestAborted); } }) { FileDownloadName = "wegenregister.zip" }); }
public async Task WriteAsync(ZipArchive archive, BackOfficeContext context, CancellationToken cancellationToken) { if (archive == null) { throw new ArgumentNullException(nameof(archive)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } var count = await context.RoadNodes.CountAsync(cancellationToken); var dbfEntry = archive.CreateEntry("Wegknoop.dbf"); var dbfHeader = new DbaseFileHeader( DateTime.Now, DbaseCodePage.Western_European_ANSI, new DbaseRecordCount(count), RoadNodeDbaseRecord.Schema ); using (var dbfEntryStream = dbfEntry.Open()) using (var dbfWriter = new DbaseBinaryWriter( dbfHeader, new BinaryWriter(dbfEntryStream, _encoding, true))) { var dbfRecord = new RoadNodeDbaseRecord(); foreach (var data in context.RoadNodes.OrderBy(_ => _.Id).Select(_ => _.DbaseRecord)) { dbfRecord.FromBytes(data, _manager, _encoding); dbfWriter.Write(dbfRecord); } dbfWriter.Writer.Flush(); await dbfEntryStream.FlushAsync(cancellationToken); } var shpBoundingBox = (await context.RoadNodeBoundingBox.SingleOrDefaultAsync(cancellationToken))?.ToBoundingBox3D() ?? new BoundingBox3D(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); var info = await context.RoadNetworkInfo.SingleAsync(cancellationToken); var shpEntry = archive.CreateEntry("Wegknoop.shp"); var shpHeader = new ShapeFileHeader( new WordLength(info.TotalRoadNodeShapeLength), ShapeType.Point, shpBoundingBox); using (var shpEntryStream = shpEntry.Open()) using (var shpWriter = new ShapeBinaryWriter( shpHeader, new BinaryWriter(shpEntryStream, _encoding, true))) { var number = RecordNumber.Initial; foreach (var data in context.RoadNodes.OrderBy(_ => _.Id).Select(_ => _.ShapeRecordContent)) { shpWriter.Write( ShapeContentFactory .FromBytes(data, _manager, _encoding) .RecordAs(number) ); number = number.Next(); } shpWriter.Writer.Flush(); await shpEntryStream.FlushAsync(cancellationToken); } var shxEntry = archive.CreateEntry("Wegknoop.shx"); var shxHeader = shpHeader.ForIndex(new ShapeRecordCount(count)); using (var shxEntryStream = shxEntry.Open()) using (var shxWriter = new ShapeIndexBinaryWriter( shxHeader, new BinaryWriter(shxEntryStream, _encoding, true))) { var offset = ShapeIndexRecord.InitialOffset; var number = RecordNumber.Initial; foreach (var data in context.RoadNodes.OrderBy(_ => _.Id).Select(_ => _.ShapeRecordContent)) { var shpRecord = ShapeContentFactory .FromBytes(data, _manager, _encoding) .RecordAs(number); shxWriter.Write(shpRecord.IndexAt(offset)); number = number.Next(); offset = offset.Plus(shpRecord.Length); } shxWriter.Writer.Flush(); await shxEntryStream.FlushAsync(cancellationToken); } }
public OrderRepository(BackOfficeContext context) : base(context) { }
public async Task <IActionResult> Get([FromServices] BackOfficeContext context) { var entries = new List <ChangeFeedEntry>(); await context .RoadNetworkChanges .OrderByDescending(_ => _.Id) .ForEachAsync(change => { var when = InstantPattern.ExtendedIso.Parse(change.When).GetValueOrThrow(); var localWhen = when.InZone(_localTimeZone).LocalDateTime; var item = new ChangeFeedEntry { Id = change.Id, Title = change.Title, Type = change.Type, Day = localWhen.Day.ToString("00"), Month = _localMonthPattern.Format(localWhen.Date), TimeOfDay = _localTimeOfDayPattern.Format(localWhen.TimeOfDay) }; switch (change.Type) { case nameof(BeganRoadNetworkImport): item.Content = null; break; case nameof(CompletedRoadNetworkImport): item.Content = null; break; case nameof(RoadNetworkChangesArchiveUploaded): item.Content = JsonConvert.DeserializeObject(change.Content, typeof(RoadNetworkChangesArchiveUploadedEntry)); break; case nameof(RoadNetworkChangesArchiveAccepted): item.Content = JsonConvert.DeserializeObject(change.Content, typeof(RoadNetworkChangesArchiveAcceptedEntry)); break; case nameof(RoadNetworkChangesArchiveRejected): item.Content = JsonConvert.DeserializeObject(change.Content, typeof(RoadNetworkChangesArchiveRejectedEntry)); break; case nameof(RoadNetworkChangesBasedOnArchiveAccepted): item.Content = JsonConvert.DeserializeObject(change.Content, typeof(RoadNetworkChangesBasedOnArchiveAcceptedEntry)); break; case nameof(RoadNetworkChangesBasedOnArchiveRejected): item.Content = JsonConvert.DeserializeObject(change.Content, typeof(RoadNetworkChangesBasedOnArchiveRejectedEntry)); break; } entries.Add(item); }, HttpContext.RequestAborted); return(new JsonResult(new ChangeFeedResponse { Entries = entries.ToArray() }) { StatusCode = StatusCodes.Status200OK }); }
/// <summary> /// SocialsController constructor /// </summary> /// <param name="context">BackOfficeContext</param> /// <param name="cache"></param> public SocialsController(BackOfficeContext context, IMemoryCache cache) { this.context = context; this.cache = cache; }
public StockRepository(BackOfficeContext context) : base(context) { }
public AuthService(BackOfficeContext backOfficeContext) { this._backOfficeContext = backOfficeContext; }
public UnitOfWork(BackOfficeContext context) { _context = context; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, BackOfficeContext backOfficeContext) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseApplicationInsightsRequestTelemetry(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseApplicationInsightsExceptionTelemetry(); app.UseStaticFiles(); app.UseIdentity(); // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715 app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); BackOfficeDBInitializer.Initialize(backOfficeContext); }
public ProductRepository(BackOfficeContext context) : base(context) { }
public RefreshTokenService(BackOfficeContext backOfficeContext) { _backOfficeContext = backOfficeContext; }
public async Task <IActionResult> Get([FromServices] BackOfficeContext context) { var info = await context.RoadNetworkInfo.SingleOrDefaultAsync(HttpContext.RequestAborted); return(new JsonResult(RoadNetworkInformationResponse.From(info))); }
public Task WriteAsync(ZipArchive archive, BackOfficeContext context, CancellationToken cancellationToken) { return(_writer.WriteAsync(archive, context, cancellationToken)); }
public static void Initialize(BackOfficeContext context) { context.Database.Migrate(); context.Database.EnsureCreated(); }