refactoring
This commit is contained in:
2
Makefile
2
Makefile
@ -2,7 +2,7 @@ include versioning.mk
|
||||
|
||||
SUBDIRS=Yavsc Yavsc.Server Yavsc.Abstract cli test
|
||||
|
||||
all: deploy-pkgs
|
||||
all: $(SUBDIRS)
|
||||
|
||||
Yavsc.Abstract:
|
||||
$(MAKE) -C Yavsc.Abstract VERSION=$(VERSION)
|
||||
|
14
Yavsc.Abstract/IT/IProject.cs
Normal file
14
Yavsc.Abstract/IT/IProject.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Yavsc.Abstract.IT
|
||||
{
|
||||
public interface IProject
|
||||
{
|
||||
long Id { get; set ; }
|
||||
string OwnerId { get; set; }
|
||||
string Name { get; set; }
|
||||
string Version { get; set; }
|
||||
|
||||
IEnumerable<string> GetConfigurations();
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ namespace Yavsc.Services
|
||||
/// <param name="billingCode">Identifiant du type de facturation</param>
|
||||
/// <param name="queryId">Identifiant de la demande du client</param>
|
||||
/// <returns>La facture</returns>
|
||||
Task<INominativeQuery> GetBillAsync(string billingCode, long queryId);
|
||||
Task<IDecidableQuery> GetBillAsync(string billingCode, long queryId);
|
||||
|
||||
/// <summary>
|
||||
/// All performer setting in this activity
|
||||
|
@ -2,7 +2,7 @@ using System;
|
||||
|
||||
namespace Yavsc.Abstract.Workflow
|
||||
{
|
||||
public interface INominativeQuery: IQuery
|
||||
public interface IDecidableQuery: IQuery
|
||||
{
|
||||
bool Rejected { get; set; }
|
||||
DateTime RejectedAt { get; set; }
|
||||
|
@ -13,7 +13,7 @@ namespace Yavsc.Models.Billing
|
||||
using Yavsc.Abstract.Workflow;
|
||||
using Yavsc.Services;
|
||||
|
||||
public abstract class NominativeServiceCommand : IBaseTrackedEntity, INominativeQuery, IIdentified<long>
|
||||
public abstract class NominativeServiceCommand : IBaseTrackedEntity, IDecidableQuery, IIdentified<long>
|
||||
{
|
||||
public string GetInvoiceId() { return GetType().Name + "/" + Id; }
|
||||
|
||||
|
@ -1,37 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using Yavsc.Abstract.IT;
|
||||
using Yavsc.Billing;
|
||||
using Yavsc.Models.Billing;
|
||||
using Yavsc.Server.Models.IT.SourceCode;
|
||||
|
||||
namespace Yavsc.Server.Models.IT
|
||||
{
|
||||
|
||||
public class ProjectBuildConfiguration
|
||||
{
|
||||
[Key]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
public long ProjectId { get; set; }
|
||||
|
||||
[ForeignKey("ProjectId")]
|
||||
public virtual Project TargetProject { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public class Project : NominativeServiceCommand
|
||||
public class Project : NominativeServiceCommand, IProject
|
||||
{
|
||||
[Key]
|
||||
public override long Id { get; set ; }
|
||||
public override long Id { get; set; }
|
||||
public string OwnerId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This field is something like a key,
|
||||
/// since it is required non null,
|
||||
@ -51,22 +34,28 @@ namespace Yavsc.Server.Models.IT
|
||||
[ForeignKey("Name")]
|
||||
public virtual GitRepositoryReference Repository { get; set; }
|
||||
|
||||
List<IBillItem> bill = new List<IBillItem> ();
|
||||
List<IBillItem> bill = new List<IBillItem>();
|
||||
public void AddBillItem(IBillItem item)
|
||||
{
|
||||
bill.Add(item);
|
||||
|
||||
|
||||
}
|
||||
public override List<IBillItem> GetBillItems()
|
||||
{
|
||||
return bill;
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetConfigurations()
|
||||
{
|
||||
return Configurations.Select(c => c.Name);
|
||||
}
|
||||
|
||||
string description;
|
||||
public override string Description => description;
|
||||
|
||||
public Project()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
24
Yavsc.Server/Models/IT/ProjectBuildConfiguration.cs
Normal file
24
Yavsc.Server/Models/IT/ProjectBuildConfiguration.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Yavsc.Server.Models.IT
|
||||
{
|
||||
public class ProjectBuildConfiguration
|
||||
{
|
||||
/// <summary>
|
||||
/// A Numerical Id
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[Key]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
public long ProjectId { get; set; }
|
||||
|
||||
[ForeignKey("ProjectId")]
|
||||
public virtual Project TargetProject { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -14,8 +14,8 @@ namespace Yavsc.Services
|
||||
{
|
||||
public ApplicationDbContext DbContext { get; private set; }
|
||||
private ILogger logger;
|
||||
public static Dictionary<string,Func<ApplicationDbContext,long,INominativeQuery>> Billing =
|
||||
new Dictionary<string,Func<ApplicationDbContext,long,INominativeQuery>> ();
|
||||
public static Dictionary<string,Func<ApplicationDbContext,long,IDecidableQuery>> Billing =
|
||||
new Dictionary<string,Func<ApplicationDbContext,long,IDecidableQuery>> ();
|
||||
public static List<PropertyInfo> UserSettings = new List<PropertyInfo>();
|
||||
|
||||
public static Dictionary<string,string> GlobalBillingMap =
|
||||
@ -31,12 +31,12 @@ namespace Yavsc.Services
|
||||
DbContext = dbContext;
|
||||
}
|
||||
|
||||
public Task<INominativeQuery> GetBillAsync(string billingCode, long queryId)
|
||||
public Task<IDecidableQuery> GetBillAsync(string billingCode, long queryId)
|
||||
{
|
||||
return Task.FromResult(GetBillable(DbContext,billingCode,queryId));
|
||||
}
|
||||
|
||||
public static INominativeQuery GetBillable(ApplicationDbContext context, string billingCode, long queryId ) => Billing[billingCode](context, queryId);
|
||||
public static IDecidableQuery GetBillable(ApplicationDbContext context, string billingCode, long queryId ) => Billing[billingCode](context, queryId);
|
||||
public async Task<ISpecializationSettings> GetPerformerSettingsAsync(string activityCode, string userId)
|
||||
{
|
||||
return await (await GetPerformersSettingsAsync(activityCode)).SingleOrDefaultAsync(s=> s.UserId == userId);
|
||||
|
@ -81,7 +81,7 @@ mais n'implemente pas l'interface IQueryable<ISpecializationSettings>
|
||||
}
|
||||
}
|
||||
|
||||
RegisterBilling<HairCutQuery>(BillingCodes.Brush, new Func<ApplicationDbContext,long,INominativeQuery>
|
||||
RegisterBilling<HairCutQuery>(BillingCodes.Brush, new Func<ApplicationDbContext,long,IDecidableQuery>
|
||||
( ( db, id) =>
|
||||
{
|
||||
var query = db.HairCutQueries.Include(q=>q.Prestation).Include(q=>q.Regularisation).Single(q=>q.Id == id) ;
|
||||
@ -89,9 +89,9 @@ mais n'implemente pas l'interface IQueryable<ISpecializationSettings>
|
||||
return query;
|
||||
})) ;
|
||||
|
||||
RegisterBilling<HairMultiCutQuery>(BillingCodes.MBrush,new Func<ApplicationDbContext,long,INominativeQuery>
|
||||
RegisterBilling<HairMultiCutQuery>(BillingCodes.MBrush,new Func<ApplicationDbContext,long,IDecidableQuery>
|
||||
( (db, id) => db.HairMultiCutQueries.Include(q=>q.Regularisation).Single(q=>q.Id == id)));
|
||||
RegisterBilling<RdvQuery>(BillingCodes.Rdv, new Func<ApplicationDbContext,long,INominativeQuery>
|
||||
RegisterBilling<RdvQuery>(BillingCodes.Rdv, new Func<ApplicationDbContext,long,IDecidableQuery>
|
||||
( (db, id) => db.RdvQueries.Include(q=>q.Regularisation).Single(q=>q.Id == id)));
|
||||
}
|
||||
public static System.Reflection.Assembly OnYavscResourceResolve(object sender, ResolveEventArgs ev)
|
||||
@ -99,7 +99,7 @@ mais n'implemente pas l'interface IQueryable<ISpecializationSettings>
|
||||
return AppDomain.CurrentDomain.GetAssemblies()[0];
|
||||
}
|
||||
|
||||
public static void RegisterBilling<T>(string code, Func<ApplicationDbContext,long,INominativeQuery> getter) where T : IBillable
|
||||
public static void RegisterBilling<T>(string code, Func<ApplicationDbContext,long,IDecidableQuery> getter) where T : IBillable
|
||||
{
|
||||
BillingService.Billing.Add(code,getter) ;
|
||||
BillingService.GlobalBillingMap.Add(typeof(T).Name,code);
|
||||
|
26
test/BaseTestContext.cs
Normal file
26
test/BaseTestContext.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using Microsoft.Dnx.Compilation.CSharp;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace test
|
||||
{
|
||||
public class BaseTestContext {
|
||||
|
||||
protected IApplicationEnvironment applicationEnvironment = null;
|
||||
protected IServiceProvider serviceProvider = null;
|
||||
protected IConfigurationRoot configurationRoot;
|
||||
protected BeforeCompileContext beforeCompileContext;
|
||||
protected IServiceProvider provider;
|
||||
protected IConfigurationRoot configuration;
|
||||
protected readonly ITestOutputHelper _output;
|
||||
protected ServerSideFixture _serverFixture;
|
||||
|
||||
public BaseTestContext(ITestOutputHelper output, ServerSideFixture serverFixture)
|
||||
{
|
||||
this._output = output;
|
||||
this._serverFixture = serverFixture;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +1,13 @@
|
||||
using System;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Hosting.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Yavsc.Abstract.Manage;
|
||||
using Yavsc.Lib;
|
||||
using Yavsc.Services;
|
||||
|
||||
namespace test
|
||||
{
|
||||
|
||||
[Collection("EMaillingTeststCollection")]
|
||||
[Trait("regres", "no")]
|
||||
public class EMaillingTests : IClassFixture<ServerSideFixture>
|
||||
|
||||
{
|
@ -1,15 +1,13 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
namespace test
|
||||
{
|
||||
|
||||
[Trait("noregres", "yes")]
|
||||
public class YavscDnxUnitTests
|
||||
|
||||
[Trait("regres", "no")]
|
||||
public class NodeTests
|
||||
{
|
||||
[Fact]
|
||||
void TestNodeJsForAnsitohtml ()
|
@ -6,9 +6,11 @@ using Microsoft.Extensions.OptionsModel;
|
||||
using Yavsc.Lib;
|
||||
using Yavsc.Services;
|
||||
using Yavsc;
|
||||
using Xunit;
|
||||
|
||||
namespace test
|
||||
{
|
||||
[Trait("regres", "no")]
|
||||
public class ServerSideFixture : IDisposable {
|
||||
public SiteSettings _siteSetup;
|
||||
public ILogger _logger;
|
||||
@ -19,13 +21,13 @@ namespace test
|
||||
|
||||
public ServerSideFixture()
|
||||
{
|
||||
InitServices();
|
||||
InitTestHost();
|
||||
_logger = _loggerFactory.CreateLogger<ServerSideFixture> ();
|
||||
_logger.LogInformation("ServerSideFixture");
|
||||
}
|
||||
|
||||
|
||||
void InitServices()
|
||||
[Fact]
|
||||
void InitTestHost()
|
||||
{
|
||||
var host = new WebHostBuilder();
|
||||
|
@ -25,29 +25,17 @@ using System.Linq;
|
||||
|
||||
namespace test
|
||||
{
|
||||
public class BaseTestContext {
|
||||
protected IApplicationEnvironment applicationEnvironment = null;
|
||||
protected IServiceProvider serviceProvider = null;
|
||||
protected IConfigurationRoot configurationRoot;
|
||||
protected BeforeCompileContext beforeCompileContext;
|
||||
protected string testprojectAssetPath = "/home/paul/workspace/yavsc/Yavsc";
|
||||
|
||||
protected IServiceProvider provider;
|
||||
protected IConfigurationRoot configuration;
|
||||
}
|
||||
|
||||
[Collection("Yavsc mandatory success story")]
|
||||
[Trait("noregres", "yes")]
|
||||
[Trait("regres", "no")]
|
||||
public class YavscMandatory: BaseTestContext, IClassFixture<ServerSideFixture>
|
||||
{
|
||||
private readonly ITestOutputHelper _output;
|
||||
ServerSideFixture _serverFixture;
|
||||
public YavscMandatory(ITestOutputHelper output, ServerSideFixture serverFixture)
|
||||
|
||||
public YavscMandatory(ITestOutputHelper output, ServerSideFixture fixture) : base (output, fixture)
|
||||
{
|
||||
this._output = output;
|
||||
this._serverFixture = serverFixture;
|
||||
}
|
||||
|
||||
}
|
||||
[Fact]
|
||||
public void GitClone()
|
||||
{
|
@ -11,7 +11,6 @@ using Yavsc;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Services;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.AspNet.Authentication;
|
||||
using Microsoft.Extensions.WebEncoders;
|
||||
using Yavsc.Lib;
|
||||
|
47
test/WIP/NotWorking.cs
Normal file
47
test/WIP/NotWorking.cs
Normal file
@ -0,0 +1,47 @@
|
||||
// // NotWorking.cs
|
||||
// /*
|
||||
// paul 21/06/2018 10:16 20182018 6 21
|
||||
// */
|
||||
using System;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Xunit;
|
||||
using Yavsc;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.Dnx.TestHost.TestAdapter;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace test
|
||||
{
|
||||
[Collection("Yavsc dropped intents")]
|
||||
[Trait("regres", "yes")]
|
||||
public class NotWorking : BaseTestContext
|
||||
{
|
||||
SourceInformationProvider _sourceInfoProvider;
|
||||
IOptions<LocalizationOptions> _localizationOptions;
|
||||
public NotWorking( IHostingEnvironment env , IOptions<SiteSettings> siteSettings,
|
||||
SourceInformationProvider sourceInfoProvider,
|
||||
IOptions<LocalizationOptions> localizationOptions,
|
||||
ServerSideFixture serverFixture, ITestOutputHelper output
|
||||
) : base (output, serverFixture) {
|
||||
_sourceInfoProvider = sourceInfoProvider;
|
||||
_localizationOptions = localizationOptions;
|
||||
}
|
||||
|
||||
public void StringLocalizer()
|
||||
{
|
||||
// TODO build applicationEnvironment
|
||||
ResourceManagerStringLocalizerFactory strFact = new ResourceManagerStringLocalizerFactory
|
||||
(applicationEnvironment, _localizationOptions);
|
||||
IStringLocalizer stringLocalizer = strFact.Create(typeof(NotWorking));
|
||||
}
|
||||
|
||||
public void NoDnxEnv()
|
||||
{
|
||||
|
||||
IOptions<LocalizationOptions> localOptions = Activator.CreateInstance<IOptions<LocalizationOptions>>();
|
||||
ResourceManagerStringLocalizerFactory strFact = new ResourceManagerStringLocalizerFactory(applicationEnvironment, localOptions);
|
||||
IStringLocalizer stringLocalizer = strFact.Create(typeof(NotWorking));
|
||||
}
|
||||
}
|
||||
}
|
@ -14,19 +14,13 @@ using static OAuth.AspNet.AuthServer.Constants;
|
||||
namespace test
|
||||
{
|
||||
[Collection("Yavsc Work In Progress")]
|
||||
[Trait("noregres", "no")]
|
||||
[Trait("regres", "yes")]
|
||||
public class YavscWorkInProgress : BaseTestContext, IClassFixture<ServerSideFixture>
|
||||
{
|
||||
|
||||
ServerSideFixture _serverFixture;
|
||||
ITestOutputHelper output;
|
||||
public YavscWorkInProgress(ServerSideFixture serverFixture, ITestOutputHelper output)
|
||||
: base (output, serverFixture)
|
||||
{
|
||||
this.output = output;
|
||||
_serverFixture = serverFixture;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData("d9be5e97-c19d-42e4-b444-0e65863b19e1","blouh","profile",
|
@ -3,7 +3,6 @@ using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Hosting.Server;
|
||||
using Microsoft.AspNet.Http.Features;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.Server
|
||||
{
|
@ -1,54 +0,0 @@
|
||||
// // NotWorking.cs
|
||||
// /*
|
||||
// paul 21/06/2018 10:16 20182018 6 21
|
||||
// */
|
||||
using System;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Xunit;
|
||||
using Microsoft.Dnx.Compilation.CSharp;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.AspNet.Builder.Internal;
|
||||
using Yavsc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace test
|
||||
{
|
||||
[Collection("Yavsc dropped intents")]
|
||||
public class NotWorking : BaseTestContext
|
||||
{
|
||||
|
||||
public void StringLocalizer()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
// IHostingEnvironment env = null;
|
||||
// IOptions<SiteSettings> siteSettings;
|
||||
|
||||
services.AddTransient<IRuntimeEnvironment>(
|
||||
svs => PlatformServices.Default.Runtime
|
||||
);
|
||||
beforeCompileContext = YavscMandatory.CreateYavscCompilationContext();
|
||||
var prjDir = beforeCompileContext.ProjectContext.ProjectDirectory;
|
||||
YavscMandatory.ConfigureServices(services, prjDir, out configuration, out provider);
|
||||
|
||||
IApplicationBuilder app = new ApplicationBuilder(provider);
|
||||
var rtd = app.Build();
|
||||
IOptions<LocalizationOptions> localOptions = Activator.CreateInstance<IOptions<LocalizationOptions>>(); ;
|
||||
// TODO build applicationEnvironment
|
||||
ResourceManagerStringLocalizerFactory strFact = new ResourceManagerStringLocalizerFactory
|
||||
(applicationEnvironment, localOptions);
|
||||
IStringLocalizer stringLocalizer = strFact.Create(typeof(NotWorking));
|
||||
}
|
||||
|
||||
public void NoDnxEnv()
|
||||
{
|
||||
|
||||
IOptions<LocalizationOptions> localOptions = Activator.CreateInstance<IOptions<LocalizationOptions>>();
|
||||
ResourceManagerStringLocalizerFactory strFact = new ResourceManagerStringLocalizerFactory(applicationEnvironment, localOptions);
|
||||
IStringLocalizer stringLocalizer = strFact.Create(typeof(NotWorking));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user