// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseDeveloperExceptionPage(); app.UseStatusCodePages(); app.UseStaticFiles(); app.UseSession(); //app.UseMvcWithDefaultRoute(); app.UseMvc(routes => { routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{Id?}"); routes.MapRoute(name: "categoryFilter", template: "RentItem/{action}/{category?}", defaults: new { Controller = "RentItem", action = "List" }); }); using (var scope = app.ApplicationServices.CreateScope()) { AppDbContent content = scope.ServiceProvider.GetRequiredService <AppDbContent>(); DbObjects.Initial(content); } //if (env.IsDevelopment()) //{ // app.UseDeveloperExceptionPage(); //} //app.Run(async (context) => //{ // await context.Response.WriteAsync("Hello World on Net.Core MVC!"); //}); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } using (var scope = app.ApplicationServices.CreateScope()) { ArticleContext context = scope.ServiceProvider.GetRequiredService <ArticleContext>(); DbObjects.Init(context); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Comment}/{action=Index}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseDeveloperExceptionPage(); app.UseStatusCodePages(); app.UseStaticFiles(); app.UseSession(); //app.UseMvcWithDefaultRoute(); using (var scope = app.ApplicationServices.CreateScope()) { ShopDb content = scope.ServiceProvider.GetRequiredService <ShopDb>(); DbObjects.Initial(content); }; app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); //routes.MapRoute( // Bu yazilis formasi da var!!! // name: "CategoryFilter", // template: "{controller=Car}/{action=Index}/{category?}", defaults: new { controller = "Car", action = "Index"}); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSession(); app.UseAuthorization(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Login}/{action=Authorization}/{id?}"); }); using (var scope = app.ApplicationServices.CreateScope()) { CarsStoreContext content = scope.ServiceProvider.GetRequiredService <CarsStoreContext>(); DbObjects.Initialize(content); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); using (var scope = app.ApplicationServices.CreateScope()) { AppDBContent context = scope.ServiceProvider.GetRequiredService <AppDBContent>(); DbObjects.Initial(context); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseDeveloperExceptionPage(); app.UseStatusCodePages(); app.UseStaticFiles(); app.UseSession(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "categoryFilter", pattern: "car/{action}/{category?}", defaults: new { Controller = "Car", action = "List" }); }); using (var scope = app.ApplicationServices.CreateScope()) { AppDbContent content = scope.ServiceProvider.GetRequiredService <AppDbContent>(); DbObjects.Initial(content); } }
public static void Initialize(TestContext context) { using (var cn = LocalDb.GetConnection(dbName)) { LocalDb.ExecuteInitializeStatements(cn, DbObjects.CreateObjects()); } }
private void DoRemove(DbObjects item) { int x = Console.CursorLeft; int y = Console.CursorTop; if (!item.Checked) { foreach (var depend in item.Dependencies) { DoRemove(depend); } Console.SetCursorPosition(x, y); _log.Message($" - {item.Name.Insert(item.Name.Length, C_EMPTY_TABLE_NAME)}"); try { item.ExecOrder = _log.GetExecOrder(); item.SQL = GetDeleteSQL(item); item.RevertSQL = GetRollbackSQL(item); _connection.Execute(item.SQL); item.Checked = true; Console.SetCursorPosition(x, y); } catch (Exception e) { _log.ErrorLn($"{strings.error}> {item.Name.Trim()} : {e.Message}"); x = Console.CursorLeft; y = Console.CursorTop; } } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseDeveloperExceptionPage(); // відображає сторінку з помилками app.UseStatusCodePages(); // дозволяє відображати коди сторінок app.UseStaticFiles(); // можна використовувати фотографії/файли css і тд app.UseSession(); //app.UseMvcWithDefaultRoute(); // можна переходити на дефолтну сторінку, якщо такої немає app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=index}/{id?}"); routes.MapRoute( name: "categoryFilter", template: "Book/{action}/{category?}", defaults: new { Controller = "Book", action = "List" }); }); using (var scope = app.ApplicationServices.CreateScope()) { AppDbContext content = scope.ServiceProvider.GetRequiredService <AppDbContext>(); DbObjects.Initial(content); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { //отображаем ошибки app.UseDeveloperExceptionPage(); //отображать коды страничек(таких как 404 или 200) app.UseStatusCodePages(); //разрешаем подлючение статических файлов app.UseStaticFiles(); app.UseSession(); //Благодаря этой функции мы сможем отслеживать URL адресс //app.UseMvcWithDefaultRoute(); app.UseMvc(routes => { routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapRoute(name: "categoryFilter", template: "{Car}/{action}/{category?}", defaults: new { Controller = "Car", action = "List" }); }); using (var scope = app.ApplicationServices.CreateScope()) { AppDBContent content = scope.ServiceProvider.GetRequiredService <AppDBContent>(); DbObjects.Initial(content); } }
public static void Initialize(TestContext context) { LocalDb.TryDropDatabase("DapperCX", out _); using (var cn = LocalDb.GetConnection("DapperCX")) { LocalDb.ExecuteInitializeStatements(cn, DbObjects.CreateObjects()); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseDeveloperExceptionPage(); app.UseStatusCodePages(); app.UseStaticFiles(); app.UseMvcWithDefaultRoute(); using (var scope = app.ApplicationServices.CreateScope()) { AddDBContent content = scope.ServiceProvider.GetRequiredService <AddDBContent>(); DbObjects.Initial(content); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseDeveloperExceptionPage(); app.UseStaticFiles(); app.UseStatusCodePages(); app.UseSession(); //app.UseMvcWithDefaultRoute(); app.UseMvc(routes => { routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapRoute(name: "categoryFilter", template: "Car/{action}/{category?}", defaults: new { Controller = "Car", action = "List" }); }); using (var scope = app.ApplicationServices.CreateScope()) { AppDBContent content = scope.ServiceProvider.GetRequiredService <AppDBContent>(); DbObjects.Initial(content); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseDeveloperExceptionPage(); app.UseStatusCodePages(); app.UseStaticFiles(); app.UseSession(); app.UseAuthentication(); app.UseAuthorization(); app.UseMvc(routes => { routes.MapRoute("default", "{controller=Home}/{action=Index}"); }); using (var scope = app.ApplicationServices.CreateScope()) { var content = scope.ServiceProvider.GetRequiredService <AppDbContext>(); DbObjects.Initial(content, _configuration); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseSession(); // добавляем механизм работы с сессиями app.UseDeveloperExceptionPage(); app.UseRouting(); app.UseAuthentication(); // аутентификация app.UseAuthorization(); // авторизация app.UseStaticFiles(); app.UseStatusCodePages(); app.UseMvc(routes => { routes.MapRoute("View", "{controller=Heroes}/{action=List}"); }); using (var scope = app.ApplicationServices.CreateScope()) { HeroesContext content = scope.ServiceProvider.GetRequiredService <HeroesContext>(); DbObjects.Initial(content); } }
/// <summary> /// Liefert das spezifizierte DB-Objekt aus der internen Collection zurück. Wenn es nicht enthalten ist, /// wird das Objekt neu erzeugt, in die Collection eingefügt, und die neue Referenz zurückgegeben. /// </summary> /// <param name="objectType">Objekttyp-Bezeichnung</param> /// <param name="objectOwner">Owner des DB-Objektes</param> /// <param name="objectName">Name des DB-Objektes</param> /// <returns></returns> public DbObject GetDbObject(string objectType, string objectOwner, string objectName) { var dbObject = DbObjects .FirstOrDefault( o => o.OwnerName == objectOwner && o.TypeName == objectType && o.ObjectName == objectName); if (null == dbObject) { DbObjects.Add( dbObject = new DbObject { OwnerName = objectOwner, TypeName = objectType, ObjectName = objectName }); } return(dbObject); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}" ); }); using (var scope = app.ApplicationServices.CreateScope()) { AppDbContext context = scope.ServiceProvider.GetRequiredService <AppDbContext>(); DbObjects.Initial(context); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseSession(); app.UseRouting(); app.UseEndpoints(endpoint => { endpoint.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}"); endpoint.MapControllerRoute("categoryFitler", "Phone/{action}/{category?}", defaults: new { Controller = "Phone", action = "List" }); }); app.UseStatusCodePages(); using (var scope = app.ApplicationServices.CreateScope()) { AppDbContent content = scope.ServiceProvider.GetRequiredService <AppDbContent>(); DbObjects.CreateStartedTablesDb(content); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStatusCodePages(); app.UseStaticFiles(); app.UseSession(); app.UseRouting(); app.UseMvc(routes => { routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapRoute(name: "categoryFilter", template: "laptop/{action}/{category?}", defaults: new { Controller = "laptop", action = "list" }); routes.MapRoute(name: "Order", template: "order/{action=Checkout}"); }); using (var scope = app.ApplicationServices.CreateScope()) { AppDbContext content = scope.ServiceProvider.GetRequiredService <AppDbContext>(); DbObjects.Initial(content); } }
public abstract string GetDeleteSQL(DbObjects item);
public override string GetRollbackSQL(DbObjects item) { return(_schema.Keys.GetCreateSQLForItem(item.Name.Trim())); }
public override string GetDeleteSQL(DbObjects item) { return($"drop index {item.Name.Trim()};"); }
/// <summary> /// Initializes a new instance of <see cref="ProjectFeature{TProjectSettings}"/> class /// </summary> /// <param name="name">Feature name</param> /// <param name="dbObjects">Sequence of <see cref="IDbObject"/> for the feature</param> /// <param name="project">Project to which it belongs</param> public ProjectFeature(string name, IEnumerable <IDbObject> dbObjects, IProject <TProjectSettings> project) { Name = name; DbObjects.AddRange(dbObjects); Project = project; }
/// <summary> /// Gets Db objects by schema /// </summary> /// <param name="schema">Schema name</param> /// <returns>A list of DbObject</returns> public virtual List <DbObject> GetDbObjectsBySchema(string schema) => DbObjects.Where(item => item.Schema == schema).ToList();
public ProjectFeature(string name, IEnumerable <IDbObject> dbObjects) { Name = name; DbObjects.AddRange(dbObjects); }
public override string GetDeleteSQL(DbObjects item) { throw new System.NotImplementedException(); }
public DataSourse GetData(string constr) { DataSourse dataSourse = new DataSourse(); string dbName = constr.Substring(0, constr.IndexOf(";")).Substring(constr.IndexOf("=") + 1); IDbObject dbObject = (IDbObject) new DataAccess(); dbObject.DbConnectStr = constr; List<string> tables = dbObject.GetTables(dbName); List<TableData> list1 = new List<TableData>(); List<Reference> list2 = new List<Reference>(); if (tables != null && tables.Count > 0) { foreach (string tableName in tables) { TableData tableData = new TableData(); tableData.Code = tableName; tableData.Name = tableName; tableData.Id = tableName; List<string> list3 = new List<string>(); DataTable columnInfoList = dbObject.GetColumnInfoList(dbName, tableName); List<Column> list4 = new List<Column>(); foreach (DataRow row in (InternalDataCollectionBase) columnInfoList.Rows) { Column column1 = new Column(); column1.Code = DataRowExtensions.Field<string>(row, 1).Trim(); column1.Comment = DataRowExtensions.Field<string>(row, 15).Trim(); column1.DataType = DataRowExtensions.Field<string>(row, 2).Trim(); column1.Displayed = "true"; Column column2 = column1; string str1 = tableName; int num = DataRowExtensions.Field<int>(row, 0); string str2 = num.ToString(); string str3 = str1 + str2; column2.Id = str3; Column column3 = column1; num = DataRowExtensions.Field<int>(row, 3); string str4 = num.ToString(); column3.Length = str4; column1.Mandatory = DataRowExtensions.Field<string>(row, 13).Trim() == "√" ? "" : "1"; column1.Name = DataRowExtensions.Field<string>(row, 1).Trim(); column1.TableCode = tableName; column1.TableId = tableData.Id; if (DataRowExtensions.Field<string>(row, 7).Trim() != "d") list3.Add(column1.Id); list4.Add(column1); } tableData.Columns = list4; if (list3.Count > 0) tableData.PrimaryKey = new Key() { KeyId = Guid.NewGuid().ToString(), ColumnRef = list3.ToArray() }; list1.Add(tableData); } } if (list1 != null && list1.Count > 0) { foreach (TableData tableData in list1) { TableData tab = tableData; foreach (DataRow dataRow in (InternalDataCollectionBase) dbObject.GetTableRefrence(dbName, tab.Code).Rows) { DataRow item = dataRow; Reference r = new Reference(); r.ParentTable = Enumerable.SingleOrDefault<string>(Enumerable.Select<TableData, string>(Enumerable.Where<TableData>((IEnumerable<TableData>) list1, (Func<TableData, bool>) (t => t.Code == DataRowExtensions.Field<string>(item, 1).Trim())), (Func<TableData, string>) (t => t.Id))); r.ParentTableColumnRef = Enumerable.SingleOrDefault<string>(Enumerable.Select(Enumerable.Where(Enumerable.Where(Enumerable.SelectMany((IEnumerable<TableData>) list1, (Func<TableData, IEnumerable<Column>>) (t => (IEnumerable<Column>) t.Columns), (t, f) => { var fAnonymousType2 = new { t = t, f = f }; return fAnonymousType2; }), param0 => param0.t.Id == r.ParentTable), param0 => param0.f.Code == DataRowExtensions.Field<string>(item, 2).Trim()), param0 => param0.f.Id)); r.Id = Guid.NewGuid().ToString(); r.ChildTable = tab.Id; r.ChildTableColumnRef = Enumerable.SingleOrDefault<string>(Enumerable.Select(Enumerable.Where(Enumerable.Where(Enumerable.SelectMany((IEnumerable<TableData>) list1, (Func<TableData, IEnumerable<Column>>) (t => (IEnumerable<Column>) t.Columns), (t, f) => { var fAnonymousType2 = new { t = t, f = f }; return fAnonymousType2; }), param0 => param0.t.Id == tab.Id), param0 => param0.f.Code == DataRowExtensions.Field<string>(item, 0).Trim()), param0 => param0.f.Id)); list2.Add(r); } } } dataSourse.ListTable = list1; dataSourse.ListReference = list2; DataTable vieWs = dbObject.GetVIEWs(dbName); List<ViewData> list5 = new List<ViewData>(); if (vieWs != null && vieWs.Rows != null && vieWs.Rows.Count > 0) { foreach (DataRow row in (InternalDataCollectionBase) vieWs.Rows) { string str = DataRowExtensions.Field<string>(row, 0); if (!string.IsNullOrWhiteSpace(str)) { string objectViewInfo = dbObject.GetObjectViewInfo(dbName, str); DataTable dataTable = dbObject.QueryViewInfo(dbName, str); ViewData viewData = new ViewData(); viewData.Code = str; viewData.Name = str; viewData.Id = str; viewData.SQLQuery = objectViewInfo; List<Column> list3 = new List<Column>(); foreach (DataColumn dataColumn in (InternalDataCollectionBase) dataTable.Columns) list3.Add(new Column() { Name = dataColumn.ColumnName, Code = dataColumn.ColumnName, Id = Guid.NewGuid().ToString() }); viewData.Columns = list3; list5.Add(viewData); } } } dataSourse.ListView = list5; return dataSourse; }
public override void RemoveAll() { _log.MessageLn($"{strings.removing} {GetName()}..."); DbObjects proc; foreach (var item in Items) { // antes de remover as chaves do item, vai nas dependencias e remove as FKs com o item foreach (var dep in item.Dependencies) { foreach (var fk in _connection.Query <string>(GetFKRelationSQL(item.Name, dep.Name))) { _log.Message($"-{item.Name}->{dep.Name} = {fk}"); try { proc = new DbObjects { Checked = false, ExecOrder = _log.GetExecOrder(), RevertSQL = _schema.Keys.GetCreateSQLForItem(fk.Trim()), SQL = $"alter table {dep.Name.Trim()} drop constraint {fk.Trim()};", Name = $"{ item.Name }->{ dep.Name} = { fk}" }; ProcItems.Add(proc); _connection.Execute(proc.SQL); _log.MessageLn(" | OK"); } catch (Exception e) { _log.ErrorLn($"FK {strings.error} {e.Message}"); } } } // depois de remover as FK, remove a PK foreach (var pk in _connection.Query <string>(GetPKSQL(item.Name))) { _log.Message($"-{item.Name} = {pk}"); try { proc = new DbObjects { Checked = false, ExecOrder = _log.GetExecOrder(), RevertSQL = _schema.Keys.GetCreateSQLForItem(pk.Trim()), SQL = $"alter table {item.Name} drop constraint {pk.Trim()};", Name = $"{item.Name} = {pk}" }; ProcItems.Add(proc); _connection.Execute(proc.SQL); _log.MessageLn(" | OK"); } catch (Exception e) { _log.ErrorLn($"PK {strings.error} {e.Message}"); } } } _log.MessageLn(""); }
public abstract string GetRollbackSQL(DbObjects item);
public ObjectDefDbObject GetDbObject(ObjectDefDbObjectType type) { return(DbObjects.Where(p => p.Type == type).FirstOrDefault()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseDeveloperExceptionPage(); app.UseHttpsRedirection(); app.UseStaticFiles(); //app.UseMvcWithDefaultRoute(); app.UseRouting(); app.UseSession(); // set up the middleware components that implement the security policy app.UseAuthentication(); app.UseAuthorization(); app.UseStatusCodePages(); // For Pages with codes 404, 200 etc.. app.UseEndpoints(endpoints => { endpoints.MapControllerRoute("catpage", "{category}/Page{productPage:int}", new { Controller = "Product", action = "List" }); endpoints.MapControllerRoute("page", "Page{productPage:int}", new { Controller = "Product", action = "List", productPage = 1 }); endpoints.MapControllerRoute("category", "{category}", new { Controller = "Product", action = "List", productPage = 1 }); endpoints.MapControllerRoute("pagination", "Products/Page{productPage}", new { Controller = "Product", action = "List", productPage = 1 }); endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapDefaultControllerRoute(); endpoints.MapRazorPages(); // registers Razor Pages as endpoints that the URL routing system can use to handle requests. endpoints.MapBlazorHub(); // registers the Blazor middleware components endpoints.MapFallbackToPage("/admin/{*catchall}", "/Admin/Index"); // Addition is to finesse the routing system to ensure that Blazor works seamlessly with the rest of the application. }); DbObjects.Initial(app); DbIdentityObjects.EnsurePopulated(app); /* * using (var scope = app.ApplicationServices.CreateScope()) * { * ApplicationDbContext context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>(); * DbObjects.Initial(context); * } * */ }