diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 1326e3a7de..314feb5709 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -6,7 +6,10 @@ services: image: tutum/mongodb environment: - AUTH=no - + ports: + - "27017:27017" + - "28017:28017" + abpidentity_httpapihost: image: abpidentity/httpapihost environment: diff --git a/src/AbpDesk/AbpDesk.MongoBlog/AbpDesk/Blogging/AbpDeskMongoBlogModule.cs b/src/AbpDesk/AbpDesk.MongoBlog/AbpDesk/Blogging/AbpDeskMongoBlogModule.cs index d41acc9a87..b316a4cca2 100644 --- a/src/AbpDesk/AbpDesk.MongoBlog/AbpDesk/Blogging/AbpDeskMongoBlogModule.cs +++ b/src/AbpDesk/AbpDesk.MongoBlog/AbpDesk/Blogging/AbpDeskMongoBlogModule.cs @@ -1,6 +1,7 @@ using System.Linq; using System.Reflection; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using Volo.Abp; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Domain.Repositories; @@ -46,11 +47,16 @@ namespace AbpDesk.Blogging { using (var scope = context.ServiceProvider.CreateScope()) { + var logger = context.ServiceProvider.GetRequiredService>(); + + logger.LogInformation("Running seed data for mongo blog module..."); + using (var uow = scope.ServiceProvider.GetRequiredService().Begin()) { var blogPostRepository = scope.ServiceProvider.GetRequiredService>(); if (blogPostRepository.Any()) { + logger.LogInformation($"No need to seed database since there are already {blogPostRepository.Count()} blog posts!"); return; } @@ -79,7 +85,11 @@ namespace AbpDesk.Blogging } ); + logger.LogInformation("Inserted two blog post. completing the unit of work..."); + uow.Complete(); + + logger.LogInformation("Completed!"); } } } diff --git a/src/AbpDesk/AbpDesk.MongoBlog/Areas/Blog/Views/Posts/Index.cshtml b/src/AbpDesk/AbpDesk.MongoBlog/Areas/Blog/Views/Posts/Index.cshtml index 39c6c5c4ed..fd4730b7e9 100644 --- a/src/AbpDesk/AbpDesk.MongoBlog/Areas/Blog/Views/Posts/Index.cshtml +++ b/src/AbpDesk/AbpDesk.MongoBlog/Areas/Blog/Views/Posts/Index.cshtml @@ -2,7 +2,7 @@

Blog Posts

-
    +
      @foreach (var post in Model) {

      @post.Title

      @@ -13,11 +13,10 @@ } else { -

      Comments

      +
      Comments
      foreach (var comment in post.Comments) { -
      @comment.Name
      -

      @comment.Message

      +

      @comment.Name: @comment.Message

      } } } diff --git a/src/AbpDesk/AbpDesk.MongoBlog/project.json b/src/AbpDesk/AbpDesk.MongoBlog/project.json index 750885ddd4..f034394965 100644 --- a/src/AbpDesk/AbpDesk.MongoBlog/project.json +++ b/src/AbpDesk/AbpDesk.MongoBlog/project.json @@ -21,6 +21,6 @@ }, "scripts": { - "postcompile": [ "xcopy %compile:OutputDir%\\AbpDesk.MongoBlog.dll ..\\Web_PlugIns" ] + "postcompile": [ "xcopy /y %compile:OutputDir%\\AbpDesk.MongoBlog.dll ..\\Web_PlugIns\\" ] } } diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs index 3e040c8914..d2dadb8c46 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs +++ b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs @@ -4,7 +4,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using Volo.Abp; using Volo.Abp.AspNetCore.EmbeddedFiles; using Volo.Abp.AspNetCore.Modularity; @@ -41,6 +40,7 @@ namespace AbpDesk.Web.Mvc services.Configure(configuration.GetSection("AbpIdentity:HttpApiClient")); services.AddMvc(); + services.AddAssemblyOf(); } @@ -48,8 +48,6 @@ namespace AbpDesk.Web.Mvc { var app = context.GetApplicationBuilder(); - context.GetLoggerFactory().AddConsole().AddDebug(); - if (context.GetEnvironment().IsDevelopment()) { app.UseDeveloperExceptionPage(); diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/Startup.cs b/src/AbpDesk/AbpDesk.Web.Mvc/Startup.cs index cb00f5d22c..8269e6ad6b 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/Startup.cs +++ b/src/AbpDesk/AbpDesk.Web.Mvc/Startup.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Serilog; using Volo.Abp.Modularity.PlugIns; namespace AbpDesk.Web.Mvc @@ -20,7 +21,7 @@ namespace AbpDesk.Web.Mvc { services.AddApplication(options => { - /* @halil: I added Abp.MongoDb as a dependency to the main application. + /* @halil: I added Abp.MongoDb package as a dependency to the main application in order to use the blog plugin. * Otherwise, we should add all dependencies (Recursively) into plugin folder * and load in correct order. We should carefully think on that problem in the future. */ @@ -34,6 +35,15 @@ namespace AbpDesk.Web.Mvc public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { + loggerFactory + .AddConsole() + .AddDebug() + .AddSerilog(new LoggerConfiguration() + .Enrich.FromLogContext() + .WriteTo.RollingFile("logs.txt") + .CreateLogger() + ); + app.InitializeApplication(); } } diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/project.json b/src/AbpDesk/AbpDesk.Web.Mvc/project.json index b115de1ed3..2e7fc556f9 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/project.json +++ b/src/AbpDesk/AbpDesk.Web.Mvc/project.json @@ -28,7 +28,9 @@ "Volo.Abp.AspNetCore.EmbeddedFiles": "1.0.0-*", "Volo.Abp.Identity.Web": "1.0.0-*", "Volo.Abp.MongoDB": "1.0.0-*", - "Volo.Abp.Identity.HttpApi.Client": "1.0.0-*" + "Volo.Abp.Identity.HttpApi.Client": "1.0.0-*", + "Serilog.Extensions.Logging": "1.4.0", + "Serilog.Sinks.RollingFile": "3.3.0" }, "tools": { diff --git a/src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll b/src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll index e8df7e2877..11cba1ef03 100644 Binary files a/src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll and b/src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll differ