bill
This commit is contained in:
parent
08606c106b
commit
a120dae977
144 changed files with 10574 additions and 1527 deletions
|
|
@ -7,65 +7,83 @@ using Microsoft.Extensions.Logging;
|
|||
|
||||
namespace Yavsc
|
||||
{
|
||||
using Exceptions;
|
||||
using Microsoft.Data.Entity;
|
||||
using Models;
|
||||
using Yavsc.Billing;
|
||||
public partial class Startup
|
||||
{
|
||||
/// <summary>
|
||||
/// Lists Available user profile classes,
|
||||
/// populated at startup, using reflexion.
|
||||
/// </summary>
|
||||
public static List<Type> ProfileTypes = new List<Type>() ;
|
||||
public static List<PropertyInfo> UserSettings = new List<PropertyInfo> ();
|
||||
public static List<Type> ProfileTypes = new List<Type>();
|
||||
public static List<PropertyInfo> UserSettings = new List<PropertyInfo>();
|
||||
public static Dictionary<string,Func<ApplicationDbContext,long,IBillable>> Billing =
|
||||
new Dictionary<string,Func<ApplicationDbContext,long,IBillable>> ();
|
||||
|
||||
/// <summary>
|
||||
/// Lists available command forms.
|
||||
/// This is hard coded.
|
||||
/// </summary>
|
||||
public static readonly string [] Forms = new string [] { "Profiles" , "HairCut" };
|
||||
|
||||
public static PropertyInfo GetUserSettingPropertyInfo(string settingsClassName)
|
||||
{
|
||||
return UserSettings.SingleOrDefault(s => s.PropertyType.GenericTypeArguments[0].FullName == settingsClassName ) ;
|
||||
}
|
||||
public static readonly string[] Forms = new string[] { "Profiles", "HairCut" };
|
||||
|
||||
private void ConfigureWorkflow(IApplicationBuilder app, SiteSettings settings, ILogger logger)
|
||||
{
|
||||
System.AppDomain.CurrentDomain.ResourceResolve += OnYavscResourceResolve;
|
||||
|
||||
foreach (var a in System.AppDomain.CurrentDomain.GetAssemblies()) {
|
||||
foreach (var c in a.GetTypes()) {
|
||||
foreach (var a in System.AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
foreach (var c in a.GetTypes())
|
||||
{
|
||||
if (c.IsClass && !c.IsAbstract &&
|
||||
c.GetInterface("ISpecializationSettings")!=null) {
|
||||
c.GetInterface("ISpecializationSettings") != null)
|
||||
{
|
||||
ProfileTypes.Add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var propinfo in typeof(ApplicationDbContext).GetProperties()) {
|
||||
foreach (var attr in propinfo.CustomAttributes) {
|
||||
if (attr.AttributeType == typeof(Yavsc.Attributes.ActivitySettingsAttribute)) {
|
||||
// bingo
|
||||
if (typeof(IQueryable<ISpecializationSettings>).IsAssignableFrom(propinfo.PropertyType))
|
||||
{
|
||||
logger.LogVerbose($"Paramêtres utilisateur déclaré: {propinfo.Name}");
|
||||
UserSettings.Add(propinfo);
|
||||
} else
|
||||
// Design time error
|
||||
{
|
||||
var msg =
|
||||
$@"La propriété {propinfo.Name} du contexte de la
|
||||
|
||||
foreach (var propinfo in typeof(ApplicationDbContext).GetProperties())
|
||||
{
|
||||
foreach (var attr in propinfo.CustomAttributes)
|
||||
{
|
||||
// something like a DbSet?
|
||||
if (attr.AttributeType == typeof(Yavsc.Attributes.ActivitySettingsAttribute))
|
||||
{
|
||||
// TODO swith () case {}
|
||||
if (typeof(IQueryable<ISpecializationSettings>).IsAssignableFrom(propinfo.PropertyType))
|
||||
{// double-bingo
|
||||
logger.LogVerbose($"Pro: {propinfo.Name}");
|
||||
UserSettings.Add(propinfo);
|
||||
}
|
||||
else
|
||||
// Design time error
|
||||
{
|
||||
var msg =
|
||||
$@"La propriété {propinfo.Name} du contexte de la
|
||||
base de donnée porte l'attribut [ActivitySetting],
|
||||
mais n'implemente pas l'interface IQueryable<ISpecializationSettings>
|
||||
({propinfo.MemberType.GetType()})";
|
||||
logger.LogCritical(msg);
|
||||
|
||||
throw new InvalidWorkflowModelException(msg);
|
||||
}
|
||||
logger.LogCritical(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Billing.Add("Brush", new Func<ApplicationDbContext,long,IBillable>
|
||||
( ( db, id) =>
|
||||
{
|
||||
var query = db.HairCutQueries.Include(q=>q.Prestation).Single(q=>q.Id == id) ;
|
||||
query.SelectedProfile = db.BrusherProfile.Single(b=>b.UserId == query.PerformerId);
|
||||
return query;
|
||||
})) ;
|
||||
|
||||
Billing.Add("MBrush",new Func<ApplicationDbContext,long,IBillable>
|
||||
( (db, id) => db.HairMultiCutQueries.Single(q=>q.Id == id)));
|
||||
Billing.Add("Rdv", new Func<ApplicationDbContext,long,IBillable>
|
||||
( (db, id) => db.RdvQueries.Single(q=>q.Id == id)));
|
||||
}
|
||||
public static System.Reflection.Assembly OnYavscResourceResolve (object sender, ResolveEventArgs ev)
|
||||
public static System.Reflection.Assembly OnYavscResourceResolve(object sender, ResolveEventArgs ev)
|
||||
{
|
||||
return AppDomain.CurrentDomain.GetAssemblies()[0];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue