From 6fe0dad775bb030e1a4b434d702842a913eb7b68 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 19 Mar 2023 16:02:50 +0000 Subject: [PATCH] got Abstraction --- Makefile | 4 +- global.json | 4 +- omnisharp.json | 3 + src/Yavsc.Abstract/Properties/AssemblyInfo.cs | 12 ---- src/Yavsc.Abstract/Yavsc.Abstract.csproj | 16 +++++ src/Yavsc.Abstract/project.json | 62 ------------------- src/Yavsc/Controllers/Survey/BugController.cs | 32 ++++++++++ src/Yavsc/Services/MailSender.cs | 9 ++- src/Yavsc/Startup/Startup.cs | 1 + src/Yavsc/Views/Bug/DeleteAllLike.cshtml | 53 ++++++++++++++++ test/yavscTests/Startup.cs | 2 +- 11 files changed, 118 insertions(+), 80 deletions(-) delete mode 100644 src/Yavsc.Abstract/Properties/AssemblyInfo.cs create mode 100644 src/Yavsc.Abstract/Yavsc.Abstract.csproj delete mode 100644 src/Yavsc.Abstract/project.json create mode 100644 src/Yavsc/Views/Bug/DeleteAllLike.cshtml diff --git a/Makefile b/Makefile index e2f1f919..23b56ff3 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ MONO_PREFIX=/home/paul/mono46 DNX_USER_HOME=/home/paul/.dnx DNXLIBS=Microsoft.Dnx.Host.Mono.dll Microsoft.Dnx.Host.dll Microsoft.Dnx.ApplicationHost.dll Microsoft.Dnx.Loader.dll Microsoft.Dnx.Compilation.Abstractions.dll Microsoft.Dnx.Compilation.CSharp.Abstractions.dll Microsoft.CodeAnalysis.dll Microsoft.CodeAnalysis.CSharp.dll Microsoft.Dnx.Compilation.CSharp.Common.dll Microsoft.Dnx.Compilation.CSharp.dll Microsoft.Dnx.Compilation.dll Microsoft.Dnx.Runtime.dll Microsoft.Dnx.Runtime.Internals.dll Microsoft.Extensions.PlatformAbstractions.dll System.Collections.Immutable.dll System.Reflection.Metadata.dll -DNXLIBFP:=$(addprefix $(DNX_USER_HOME)/runtimes/dnx-mono.1.0.0-rc1-update2/bin/, $(DNXLIBS)) +DNXLIBFP:=./packages/System.Diagnostics.DiagnosticSource/4.0.0-beta-23516/lib/portable-net45+win8+wp8+wpa81/System.Diagnostics.DiagnosticSource.dll $(addprefix $(DNX_USER_HOME)/runtimes/dnx-mono.1.0.0-rc1-update2/bin/, $(DNXLIBS)) CONFIG=Debug yavscd=yavscd @@ -79,7 +79,7 @@ yavscassemblies: src/Yavsc/bin/$(CONFIG)/dnx451/Yavsc.dll src/Yavsc.Server/bin/$ yavscd: yavscassemblies updatedeps mkdir -p binaries/$(CONFIG) - mkbundle --static $(DNXLIBS) src/Yavsc/bin/$(CONFIG)/dnx451/Yavsc.dll src/Yavsc/bin/$(CONFIG)/dnx451/pt/Yavsc.resources.dll src/Yavsc/bin/$(CONFIG)/dnx451/en/Yavsc.resources.dll src/Yavsc.Server/bin/$(CONFIG)/dnx451/Yavsc.Server.dll src/Yavsc.Server/bin/$(CONFIG)/dnx451/en/Yavsc.Server.resources.dll src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/Yavsc.Abstract.dll src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/en/Yavsc.Abstract.resources.dll src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/pt/Yavsc.Abstract.resources.dll src/OAuth.AspNet.AuthServer/bin/$(CONFIG)/dnx451/OAuth.AspNet.AuthServer.dll src/OAuth.AspNet.Token/bin/$(CONFIG)/dnx451/OAuth.AspNet.Token.dll $(shell ls private/lib/*.dll) -L $(DNX_USER_HOME)/runtimes/dnx-mono.1.0.0-rc1-update2/bin --machine-config $(MONO_PREFIX)/etc/mono/4.5/machine.config -o $(yavscd) + mkbundle --deps $(DNXLIBS) src/Yavsc/bin/$(CONFIG)/dnx451/Yavsc.dll src/Yavsc/bin/$(CONFIG)/dnx451/pt/Yavsc.resources.dll src/Yavsc/bin/$(CONFIG)/dnx451/en/Yavsc.resources.dll src/Yavsc.Server/bin/$(CONFIG)/dnx451/Yavsc.Server.dll src/Yavsc.Server/bin/$(CONFIG)/dnx451/en/Yavsc.Server.resources.dll src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/Yavsc.Abstract.dll src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/en/Yavsc.Abstract.resources.dll src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/pt/Yavsc.Abstract.resources.dll src/OAuth.AspNet.AuthServer/bin/$(CONFIG)/dnx451/OAuth.AspNet.AuthServer.dll src/OAuth.AspNet.Token/bin/$(CONFIG)/dnx451/OAuth.AspNet.Token.dll $(shell ls private/lib/*.dll) -L $(DNX_USER_HOME)/runtimes/dnx-mono.1.0.0-rc1-update2/bin --machine-config $(MONO_PREFIX)/etc/mono/4.5/machine.config -o $(yavscd) strip_yavscd: $(yavscd) strip $(yavscd) diff --git a/global.json b/global.json index e4059e57..b4f05fcf 100644 --- a/global.json +++ b/global.json @@ -5,8 +5,8 @@ "tests" ], "sdk": { - "version": "1.0.0-rc1-update2", - "runtime": "mono", + "version": "7.0.202", + "runtime": "dotnet", "architecture": "x64" }, "packages": "packages" diff --git a/omnisharp.json b/omnisharp.json index f0bb00d3..17454b13 100644 --- a/omnisharp.json +++ b/omnisharp.json @@ -5,6 +5,9 @@ "msbuild": { "enabled": false }, + "scriptcs": { + "enabled": false + }, "Dnx": { "enabled": true, "enablePackageRestore": false, diff --git a/src/Yavsc.Abstract/Properties/AssemblyInfo.cs b/src/Yavsc.Abstract/Properties/AssemblyInfo.cs deleted file mode 100644 index 9324251d..00000000 --- a/src/Yavsc.Abstract/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Resources; -using System.Reflection; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyCopyright("Copyright © Paul Schneider 2014-2019")] -[assembly: AssemblyTrademark("Yavsc")] -[assembly: AssemblyCulture("")] -[assembly: NeutralResourcesLanguage("fr")] - -[assembly: AssemblyVersion("1.0.6.1")] \ No newline at end of file diff --git a/src/Yavsc.Abstract/Yavsc.Abstract.csproj b/src/Yavsc.Abstract/Yavsc.Abstract.csproj new file mode 100644 index 00000000..97f53f0d --- /dev/null +++ b/src/Yavsc.Abstract/Yavsc.Abstract.csproj @@ -0,0 +1,16 @@ + + + + net7.0 + enable + enable + + + + + + + + + + diff --git a/src/Yavsc.Abstract/project.json b/src/Yavsc.Abstract/project.json deleted file mode 100644 index 7bc8623d..00000000 --- a/src/Yavsc.Abstract/project.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "version": "1.0.8-*", - "title": "Yavsc - l'abstrait", - "description": "Yavsc common objects", - "authors": [ - "Paul Schneider " - ], - "packOptions": { - "repository": { - "type": "git", - "url": "https://github.com/pazof/yavsc" - }, - "licenseUrl": "https://github.com/pazof/yavsc/blob/vnext/LICENSE", - "requireLicenseAcceptance": true, - "owners": [ - "Paul Schneider " - ], - "summary": "Yet another very small company", - "projectUrl": "http://yavsc.pschneider.fr", - "tags": [ - "Blog", - "PoS", - "Chat" - ] - }, - "buildOptions": { - "nowarn": ["IDE1006"] - }, - "tooling": { - "defaultNamespace": "Yavsc" - }, - "dependencies": { - "Newtonsoft.Json": "7.0.1" - }, - "frameworks": { - "dnx451": { - "frameworkAssemblies": { - "System.ComponentModel.DataAnnotations": "4.0.0" - } - }, - "net46": { - "frameworkAssemblies": { - "System.ComponentModel.DataAnnotations": "4.0.0" - } - }, - "net461": { - "frameworkAssemblies": { - "System.ComponentModel.DataAnnotations": "4.0.0" - } - }, - "net452": { - "frameworkAssemblies": { - "System.ComponentModel.DataAnnotations": "4.0.0" - } - }, - "net451": { - "frameworkAssemblies": { - "System.ComponentModel.DataAnnotations": "4.0.0" - } - } - } -} diff --git a/src/Yavsc/Controllers/Survey/BugController.cs b/src/Yavsc/Controllers/Survey/BugController.cs index ccc537e8..10525a52 100644 --- a/src/Yavsc/Controllers/Survey/BugController.cs +++ b/src/Yavsc/Controllers/Survey/BugController.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.Extensions.Localization; using Microsoft.AspNet.Authorization; +using System.Linq; namespace Yavsc.Controllers { @@ -148,5 +149,36 @@ namespace Yavsc.Controllers await _context.SaveChangesAsync(); return RedirectToAction("Index"); } + + + [Authorize("AdministratorOnly")] + public async Task DeleteAllLike(long? id) + { + if (id == null) + { + return HttpNotFound(); + } + Bug bugref = await _context.Bug.SingleAsync(m => m.Id == id); + if (bugref == null) + { + return null; + } + var bugs = _context.Bug.Where(b => b.Description == bugref.Description); + return View(bugs); + } + + // POST: Bug/Delete/5 + [HttpPost] + [ValidateAntiForgeryToken] + [Authorize("AdministratorOnly")] + public async Task DeleteAllLikeConfirmed(long id) + { + Bug bug = await _context.Bug.SingleAsync(m => m.Id == id); + var bugs = await _context.Bug.Where(b => b.Description == bug.Description).ToArrayAsync(); + foreach (var btd in bugs) + _context.Bug.Remove(btd); + await _context.SaveChangesAsync(); + return RedirectToAction("Index"); + } } } diff --git a/src/Yavsc/Services/MailSender.cs b/src/Yavsc/Services/MailSender.cs index f16fe236..08773886 100644 --- a/src/Yavsc/Services/MailSender.cs +++ b/src/Yavsc/Services/MailSender.cs @@ -14,14 +14,18 @@ namespace Yavsc.Services { readonly SiteSettings siteSettings; readonly SmtpSettings smtpSettings; + private readonly ILogger logger; public MailSender( IOptions sitesOptions, - IOptions smtpOptions + IOptions smtpOptions, + ILoggerFactory loggerFactory ) { siteSettings = sitesOptions?.Value; smtpSettings = smtpOptions?.Value; + logger = loggerFactory.CreateLogger(); + } /// @@ -40,6 +44,7 @@ namespace Yavsc.Services EmailSentViewModel model = new EmailSentViewModel{ EMail = email }; try { + logger.LogInformation($"SendEmailAsync for {email}: {message}"); MimeMessage msg = new MimeMessage(); msg.From.Add(new MailboxAddress( siteSettings.Owner.Name, @@ -59,6 +64,7 @@ namespace Yavsc.Services smtpSettings.Host, smtpSettings.Port, SecureSocketOptions.Auto); + if (smtpSettings.UserName!=null) { NetworkCredential creds = new NetworkCredential( smtpSettings.UserName, smtpSettings.Password, smtpSettings.Domain); @@ -68,6 +74,7 @@ namespace Yavsc.Services await sc.SendAsync(msg); model.MessageId = msg.MessageId; model.Sent = true; // a duplicate info to remove from the view model, that equals to MessageId == null + logger.LogInformation($"Sent : {msg}"); } } catch (Exception ex) diff --git a/src/Yavsc/Startup/Startup.cs b/src/Yavsc/Startup/Startup.cs index 9e47453b..ac1cb27d 100755 --- a/src/Yavsc/Startup/Startup.cs +++ b/src/Yavsc/Startup/Startup.cs @@ -398,6 +398,7 @@ namespace Yavsc options.AuthenticationDescriptions.Clear(); options.AutomaticAuthentication = false; }); + app.UseSession(); ConfigureOAuthApp(app); diff --git a/src/Yavsc/Views/Bug/DeleteAllLike.cshtml b/src/Yavsc/Views/Bug/DeleteAllLike.cshtml new file mode 100644 index 00000000..8c6d4239 --- /dev/null +++ b/src/Yavsc/Views/Bug/DeleteAllLike.cshtml @@ -0,0 +1,53 @@ +@model IEnumerable +@inject IStringLocalizer SRR + +@{ + ViewData["Title"] = @SR["DeleteAllLike"]; +} + +

@SR["Index"]

+ +

+ @SR["Create New"] +

+ + + + + + + + + + +@foreach (var item in Model) { + + + + + + + +} +
+ @SR[Html.DisplayNameFor(model => model.Id)] + + @SR[Html.DisplayNameFor(model => model.Title)] + + @SR[Html.DisplayNameFor(model => model.FeatureId)] + + @SR[Html.DisplayNameFor(model => model.Status)] +
+ @Html.DisplayFor(model => item.Id) + + @Html.DisplayFor(model => item.Title) + + @Html.DisplayFor(modelItem => item.FeatureId) + + + @SRR[typeof(Yavsc.Models.IT.Fixing.BugStatus).GetEnumNames()[(int)item.Status]] + + @SR["Edit"] | + @SR["Details"] | + @SR["Delete"] +
diff --git a/test/yavscTests/Startup.cs b/test/yavscTests/Startup.cs index 5b442803..655d848f 100644 --- a/test/yavscTests/Startup.cs +++ b/test/yavscTests/Startup.cs @@ -456,7 +456,7 @@ namespace yavscTests app.UseWelcomePage("/welcome"); // before fixing the security protocol, let beleive our lib it's done with it. - var cxmgr = PayPal.Manager.ConnectionManager.Instance; + //var cxmgr = PayPal.Manager.ConnectionManager.Instance; // then, fix it. ServicePointManager.SecurityProtocol = (SecurityProtocolType)0xC00; // Tls12, required by PayPal