public void Configure(IApplicationBuilder app) { app.UseDeveloperExceptionPage(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseStatusCodePages(); app.UseRouting(); app.UseSession(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); //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()) { AppDbContext content = scope.ServiceProvider.GetRequiredService <AppDbContext>(); DbObj.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.UseRouting(); using (var scope = app.ApplicationServices.CreateScope()) { AppDbContent content = scope.ServiceProvider.GetRequiredService <AppDbContent>(); DbObj.Initial(content); } app.UseMvc(routes => { routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id}"); routes.MapRoute(name: "CategoryFilter", template: "News/{action}/{category}", defaults: new { Controller = "News", action = "List" }); routes.MapRoute(name: "Add", template: "AddNews/{Add}", defaults: new { Controller = "AddNews", action = "Add" }); }); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}"); }); }
/// <summary> /// ユーザ情報取得処理 /// </summary> public void Get_UserInfo() { SqlCommand dbCmd = null; try { // ストアド設定 String userId = "takeda"; String usrDomain = "INSTOK"; dbCmd = DbObj.GetCmd(); dbCmd.CommandText = SP_GET_USER_INFO; dbCmd.Parameters.Add("@UserNo", SqlDbType.NVarChar).Value = userId; dbCmd.Parameters.Add("@UserDomain", SqlDbType.NVarChar).Value = usrDomain; SqlDataAdapter dbAdapter = new SqlDataAdapter(dbCmd); DataSet ds = new DataSet(); dbAdapter.Fill(ds); // 権限の取得 if (ds.Tables[0].Rows.Count == 0) { // エラーメッセージをセッションへ設定し、エラーページへ遷移 // 権限が付与されていません。 //Session[CommonConst.SESSON_KEY_ERROR] = this.GetMessage(CommonConst.ERRMSG_E0002); //Response.Redirect("~/C0000_ErrorPage.aspx", false); //return false; } Name = ds.Tables[0].Rows[0].ItemArray[0].ToString(); } finally { if (dbCmd != null) { dbCmd.Dispose(); } if (DbObj != null) { DbObj.RemoveConn(); } } }
// 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.UseAuthentication(); //app.UseAutherization(); //app.UseMvcWithDefaultRoute(); //default controller 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>(); DbObj.Initial(content); } }
/// <summary> /// KITリストデータ取得 /// </summary> public void Get_KitList() { SqlCommand dbCmd = null; DtKitList = new DataTable(); try { dbCmd = DbObj.GetCmd(); dbCmd.CommandText = SP_GET_KIT_LIST; SqlDataAdapter dbAdapter = new SqlDataAdapter(dbCmd); dbAdapter.Fill(DtKitList); // 権限の取得 if (DtKitList.Rows.Count == 0) { // エラーメッセージをセッションへ設定し、エラーページへ遷移 // 権限が付与されていません。 //Session[CommonConst.SESSON_KEY_ERROR] = this.GetMessage(CommonConst.ERRMSG_E0002); //Response.Redirect("~/C0000_ErrorPage.aspx", false); //return false; } //return dtKitList; } finally { if (dbCmd != null) { dbCmd.Dispose(); } if (DbObj != null) { DbObj.RemoveConn(); } } }
/** * Facilitate testing of data layer */ public static void Main(string[] args) { var accGateway = AccountGateway.GetInstance(DbObj.GetInstance()); var metadataGateway = MetadataGateway.GetInstance(DbObj.GetInstance()); string email = "*****@*****.**"; ObjectId objId; AccountModel acc; while (true) { Console.WriteLine("\nSelect an operation:"); Console.WriteLine("0. Exit."); Console.WriteLine("1. Create 4 new users."); Console.WriteLine("2. View all users."); Console.WriteLine("3. Update a user's name."); Console.WriteLine("4. Delete a user's account."); Console.WriteLine("5. View name & password of a user."); Console.WriteLine("6. Create sample file and folders."); Console.WriteLine("7. View content of user's root folder."); string cmd = Console.ReadLine(); switch (cmd) { case "0": Console.WriteLine("\nExit ok."); return; case "1": // CREATE objId = ObjectId.GenerateNewId(); accGateway.Insert(new AccountModel(objId, "Ng Cai Feng", "Mr", "*****@*****.**", "password1", DateTime.Now, true, "", "Bio")); objId = ObjectId.GenerateNewId(); accGateway.Insert(new AccountModel(objId, "Chua Xiang Wei, Jerahmeel", "Mr", "*****@*****.**", "password2", DateTime.Now, true, "", "Bio")); objId = ObjectId.GenerateNewId(); accGateway.Insert(new AccountModel(objId, "Ryan Chia Dong Yi", "Mr", "*****@*****.**", "password3", DateTime.Now, true, "", "Bio")); objId = ObjectId.GenerateNewId(); accGateway.Insert(new AccountModel(objId, "Lim Jing Pei", "Ms", "*****@*****.**", "password4", DateTime.Now, true, "", "Bio")); accGateway.Save(); break; case "2": // READ all accounts var readResults = accGateway.SelectAll().GetEnumerator(); while (readResults.MoveNext()) { Console.WriteLine(readResults.Current?.Email + " " + readResults.Current?.Name); } break; case "3": // UPDATE account by email Console.WriteLine("Enter the email of the user whose name you want to update:"); email = Console.ReadLine(); Console.WriteLine("Enter the new name:"); String name = Console.ReadLine(); acc = accGateway.SelectByEmail(email); if (acc != null) { acc.Name = name; accGateway.Update(acc); accGateway.Save(); } else { Console.WriteLine("Email not found."); } break; case "4": // DELETE account by email Console.WriteLine("Enter the email of the user to delete:"); email = Console.ReadLine(); acc = accGateway.SelectByEmail(email); if (acc != null) { accGateway.Delete(acc); accGateway.Save(); } else { Console.WriteLine("Email not found."); } break; case "5": // SELECT ACCOUNT MODEL BY EMAIL Console.WriteLine("Enter the email of the user you want to view:"); email = Console.ReadLine(); acc = accGateway.SelectByEmail(email); if (acc != null) { Console.WriteLine("Name of " + email + ": " + acc.Name); Console.WriteLine("Password of " + email + ": " + acc.Password); } else { Console.WriteLine("Email not found."); } break; case "6": // CREATE FILES AND FOLDERS AccessControlsModel acModel1 = new AccessControlsModel("*****@*****.**", true, true); AccessControlsModel acModel2 = new AccessControlsModel("*****@*****.**", true, true); List <AccessControlsModel> acList = new List <AccessControlsModel>(); acList.Add(acModel1); acList.Add(acModel2); ObjectId userRootId = ObjectId.GenerateNewId(); ObjectId folderAId = ObjectId.GenerateNewId(); ObjectId folderBId = ObjectId.GenerateNewId(); ObjectId folderCId = ObjectId.GenerateNewId(); // userRoot metadataGateway.Insert(new MetadataModel(userRootId, email, email, 0, DateTime.Now, "", "", acList)); // folderA in root metadataGateway.Insert(new MetadataModel(folderAId, email, "FolderA", 0, DateTime.Now, "", userRootId.ToString(), acList)); // fileA in folderA metadataGateway.Insert(new MetadataModel(ObjectId.GenerateNewId(), email, "FileA", 1, DateTime.Now, "", folderAId.ToString(), acList)); // fileB in folderA metadataGateway.Insert(new MetadataModel(ObjectId.GenerateNewId(), email, "FileB", 1, DateTime.Now, "", folderAId.ToString(), acList)); // fileC in folderA metadataGateway.Insert(new MetadataModel(ObjectId.GenerateNewId(), email, "FileC", 1, DateTime.Now, "", folderAId.ToString(), acList)); // folderB in folderA metadataGateway.Insert(new MetadataModel(folderBId, email, "FolderB", 0, DateTime.Now, "", folderAId.ToString(), acList)); // fileD in folderB metadataGateway.Insert(new MetadataModel(ObjectId.GenerateNewId(), email, "FileD", 1, DateTime.Now, "", folderBId.ToString(), acList)); // folderC in root metadataGateway.Insert(new MetadataModel(folderCId, email, "FolderC", 0, DateTime.Now, "", userRootId.ToString(), acList)); // fileE in folderC metadataGateway.Insert(new MetadataModel(ObjectId.GenerateNewId(), email, "FileE", 1, DateTime.Now, "", folderCId.ToString(), acList)); // fileF in root metadataGateway.Insert(new MetadataModel(ObjectId.GenerateNewId(), email, "FileF", 1, DateTime.Now, "", userRootId.ToString(), acList)); // fileG in root metadataGateway.Insert(new MetadataModel(ObjectId.GenerateNewId(), email, "FileG", 1, DateTime.Now, "", userRootId.ToString(), acList)); metadataGateway.Save(); break; case "7": // View content of user's root folder Console.WriteLine("Enter the email of the user:"******"\nTop level files and folders:\n"); var contentEnumerator = content.GetEnumerator(); while (contentEnumerator.MoveNext()) { Console.WriteLine(contentEnumerator.Current?.name); } } else { Console.WriteLine("Email not found."); } break; default: Console.WriteLine("Invalid command."); break; } } }