v 1.0.5-rc20-alpha5

in order to build 1.0.5-rc20-alpha5, an alpha6

* moves again the db context from server lib to main assembly,
  since migrations are not written correctly in these conditions.
* fixing dep graph, while moving as must as possible code from Yavsc to Yavsc.Server
* impoved topmost Makefile
* cleaned the badly desined, ans system redondant "Action" definiton
* reoganized some source code file locations
This commit is contained in:
2018-06-11 14:43:18 +02:00
parent 7412abdf0d
commit cdc38236e0
52 changed files with 864 additions and 10401 deletions

View File

@ -1,305 +0,0 @@

using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Data.Entity;
using System.Threading;
using Yavsc.Models.Haircut;
using Yavsc.Models.IT.Maintaining;
using Yavsc.Models.IT.Fixing;
using Yavsc.Server.Models.EMailing;
using Yavsc.Server.Models.IT.SourceCode;
namespace Yavsc.Models
{
using Relationship;
using Forms;
using Yavsc;
using Auth;
using Billing;
using Musical;
using OAuth;
using Workflow;
using Identity;
using Market;
using Chat;
using Messaging;
using Access;
using Musical.Profiles;
using Workflow.Profiles;
using Drawing;
using Attributes;
using Bank;
using Payment;
using Yavsc.Models.Calendar;
using Blog;
using Yavsc.Server.Helpers;
using Newtonsoft.Json.Linq;
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Customize the ASP.NET Identity model and override the defaults if needed.
// For example, you can rename the ASP.NET Identity table names and more.
// Add your customizations after calling base.OnModelCreating(builder);
builder.Entity<Relationship.Contact>().HasKey(x => new { x.OwnerId, x.UserId });
builder.Entity<GoogleCloudMobileDeclaration>().Property(x=>x.DeclarationDate).HasDefaultValueSql("LOCALTIMESTAMP");
builder.Entity<BlogTag>().HasKey(x=>new { x.PostId, x.TagId});
builder.Entity<ApplicationUser>().HasMany<ChatConnection>( c=>c.Connections );
builder.Entity<ApplicationUser>().Property(u=>u.Avatar).HasDefaultValue(Constants.DefaultAvatar);
builder.Entity<ApplicationUser>().Property(u=>u.DiskQuota).HasDefaultValue(Constants.DefaultFSQ);
builder.Entity<UserActivity>().HasKey(u=> new { u.DoesCode, u.UserId});
builder.Entity<Instrumentation>().HasKey(u=> new { u.InstrumentId, u.UserId});
builder.Entity<CircleAuthorizationToBlogPost>().HasKey(a=> new { a.CircleId, a.BlogPostId});
builder.Entity<CircleMember>().HasKey(c=> new { MemberId = c.MemberId, CircleId = c.CircleId });
builder.Entity<DimissClicked>().HasKey(c=>new { uid = c.UserId, notid = c.NotificationId});
builder.Entity<HairTaintInstance>().HasKey(ti=>new { ti.TaintId, ti.PrestationId } );
builder.Entity<HyperLink>().HasKey(l=>new { l.HRef, l.Method });
builder.Entity<Period>().HasKey(l=>new { l.Start, l.End });
builder.Entity<Models.Cratie.Option>().HasKey( o => new { o.Code, o.CodeScrutin });
builder.Entity<Notification>().Property(n=> n.icon).HasDefaultValue("exclam");
builder.Entity<ChatRoomPresence>().HasKey(p=>new { room = p.ChannelName, user = p.ChatUserConnectionId });
foreach (var et in builder.Model.GetEntityTypes()) {
if (et.ClrType.GetInterface("IBaseTrackedEntity")!=null)
et.FindProperty("DateCreated").IsReadOnlyAfterSave = true;
}
builder.Entity<GitRepositoryReference>().HasKey(r => r.Path );
}
public DbSet<Client> Applications { get; set; }
public DbSet<RefreshToken> RefreshTokens { get; set; }
/// <summary>
/// Activities referenced on this site
/// </summary>
/// <returns></returns>
public DbSet<Activity> Activities { get; set; }
public DbSet<UserActivity> UserActivities { get; set; }
/// <summary>
/// Users posts
/// </summary>
/// <returns></returns>
public DbSet<Blog.BlogPost> Blogspot { get; set; }
/// <summary>
/// Skills propulsed by this site
/// </summary>
/// <returns></returns>
public DbSet<Skill> SiteSkills { get; set; }
/// <summary>
/// Circle members
/// </summary>
/// <returns></returns>
public DbSet<CircleMember> CircleMembers { get; set; }
/// <summary>
/// Special commands, talking about
/// a given place and date.
/// </summary>
public DbSet<RdvQuery> RdvQueries { get; set; }
public DbSet<HairCutQuery> HairCutQueries { get; set; }
public DbSet<HairPrestation> HairPrestation { get; set; }
public DbSet<HairMultiCutQuery> HairMultiCutQueries { get; set; }
public DbSet<PerformerProfile> Performers { get; set; }
public DbSet<Estimate> Estimates { get; set; }
public DbSet<AccountBalance> BankStatus { get; set; }
public DbSet<BalanceImpact> BankBook { get; set; }
/// <summary>
/// Google Calendar offline
/// open auth tokens
/// </summary>
/// <returns>tokens</returns>
public DbSet<OAuth2Tokens> Tokens { get; set; }
/// <summary>
/// References all declared external GCM devices
/// </summary>
/// <returns></returns>
public DbSet<GoogleCloudMobileDeclaration> GCMDevices { get; set; }
public DbSet<Service> Services { get; set; }
public DbSet<Product> Products { get; set; }
public Task<OAuth2Tokens> GetTokensAsync(string googleUserId)
{
if (string.IsNullOrEmpty(googleUserId))
{
throw new ArgumentException("email MUST have a value");
}
using (var context = new ApplicationDbContext())
{
var item = this.Tokens.FirstOrDefault(x => x.UserId == googleUserId);
// TODO Refresh token
return Task.FromResult(item);
}
}
public Task StoreTokenAsync(string googleUserId, JObject response, string accessToken,
string tokenType, string refreshToken, string expiresIn
)
{
if (string.IsNullOrEmpty(googleUserId))
{
throw new ArgumentException("googleUserId MUST have a value");
}
var item = this.Tokens.SingleOrDefaultAsync(x => x.UserId == googleUserId).Result;
if (item == null)
{
Tokens.Add(new OAuth2Tokens
{
TokenType = "Bearer", // FIXME why value.TokenType would be null?
AccessToken = accessToken,
RefreshToken = refreshToken,
Expiration = DateTime.Now.AddSeconds(int.Parse(expiresIn)),
UserId = googleUserId
});
}
else
{
item.AccessToken = accessToken;
item.Expiration = DateTime.Now.AddMinutes(int.Parse(expiresIn));
if (refreshToken != null)
item.RefreshToken = refreshToken;
Tokens.Update(item);
}
SaveChanges(googleUserId);
return Task.FromResult(0);
}
Client FindApplication(string clientId)
{
return Applications.FirstOrDefault(
app=>app.Id == clientId);
}
public DbSet<ExceptionSIREN> ExceptionsSIREN { get; set; }
public DbSet<Location> Locations { get; set; }
public DbSet<Tag> Tags { get; set; }
public DbSet<BlogTag> TagsDomain { get; set; }
public DbSet<EstimateTemplate> EstimateTemplates { get; set; }
public DbSet<Relationship.Contact> Contacts { get; set; }
public DbSet<ClientProviderInfo> ClientProviderInfo { get; set; }
public DbSet<ChatConnection> Connections { get; set; }
public DbSet<BlackListed> BlackListed { get; set; }
public DbSet<MusicalPreference> MusicalPreferences { get; set; }
public DbSet<MusicalTendency> MusicalTendency { get; set; }
public DbSet<Instrument> Instrument { get; set; }
[ActivitySettings]
public DbSet<DjSettings> DjSettings { get; set; }
[ActivitySettings]
public DbSet<Instrumentation> Instrumentation { get; set; }
[ActivitySettings]
public DbSet<FormationSettings> FormationSettings { get; set; }
[ActivitySettings]
public DbSet<GeneralSettings> GeneralSettings { get; set; }
public DbSet<CoWorking> WorkflowProviders { get; set; }
private void AddTimestamps(string currentUsername)
{
var entities =
ChangeTracker.Entries()
.Where(x => x.Entity.GetType().GetInterface("IBaseTrackedEntity")!=null
&& (x.State == EntityState.Added || x.State == EntityState.Modified));
foreach (var entity in entities)
{
if (entity.State == EntityState.Added)
{
((IBaseTrackedEntity)entity.Entity).DateCreated = DateTime.Now;
((IBaseTrackedEntity)entity.Entity).UserCreated = currentUsername;
}
((IBaseTrackedEntity)entity.Entity).DateModified = DateTime.Now;
((IBaseTrackedEntity)entity.Entity).UserModified = currentUsername;
}
}
public int SaveChanges(string userId) {
AddTimestamps(userId);
return base.SaveChanges();
}
public async Task<int> SaveChangesAsync(string userId, CancellationToken ctoken = default(CancellationToken)) {
AddTimestamps(userId);
return await base.SaveChangesAsync();
}
public DbSet<Circle> Circle { get; set; }
public DbSet<CircleAuthorizationToBlogPost> BlogACL { get; set; }
public DbSet<CommandForm> CommandForm { get; set; }
public DbSet<Form> Form { get; set; }
public DbSet<Ban> Banlist { get ; set; }
public DbSet<HairTaint> HairTaint { get; set; }
public DbSet<Color> Color { get; set; }
public DbSet<Notification> Notification { get; set; }
public DbSet<DimissClicked> DimissClicked { get; set; }
[ActivitySettings]
public DbSet<BrusherProfile> BrusherProfile { get; set; }
public DbSet<BankIdentity> BankIdentity { get; set; }
public DbSet<PayPalPayment> PayPalPayments { get; set; }
public DbSet<HyperLink> Links { get; set; }
public DbSet<Period> Period { get; set; }
public DbSet<BlogTag> BlogTags { get; set; }
public DbSet<ApplicationUser> ApplicationUser { get; set; }
public DbSet<Feature> Feature { get; set; }
public DbSet<Bug> Bug { get; set; }
public DbSet<Comment> Comment { get; set; }
public DbSet<Announce> Announce { get; set; }
public DbSet<ChatConnection> ChatConnection { get; set; }
public DbSet<ChatRoom> ChatRoom { get; set; }
public DbSet<MailingTemplate> MailingTemplate { get; set; }
public DbSet<GitRepositoryReference> GitRepositoryReference { get; set; }
}
}

View File

@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Billing;
using Yavsc.Models.Billing;
using Yavsc.Server.Models.IT.SourceCode;
namespace Yavsc.Server.Models.IT
{
public class Project : NominativeServiceCommand
{
[Key]
public override long Id { get; set ; }
public string OwnerId { get; set; }
public string LocalRepo { get; set; }
[ForeignKey("LocalRepo")]
public virtual GitRepositoryReference Repository { get; set; }
public override List<IBillItem> GetBillItems()
{
throw new System.NotImplementedException();
}
public string Description { get; set; }
public override string GetDescription()
{
return Description;
}
public Project()
{
}
}
}

View File

@ -1,15 +1,21 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Models;
namespace Yavsc.Server.Models.IT.SourceCode
{
public class GitRepositoryReference
{
public string Url { get; set; }
{
[Key]
public string Path { get; set; }
[StringLength(2048)]
public string Url { get; set; }
[StringLength(512)]
public string Branch { get; set; }
[StringLength(1024)]
public string OwnerId { get; set; }
[ForeignKey("OwnerId")]

View File

@ -1,9 +0,0 @@
using System.Threading.Tasks;
namespace Yavsc.Models.Process
{
public abstract class Action<TResult,TInput>
{
public abstract Task<TResult> GetTask(TInput data);
}
}

View File

@ -1,16 +0,0 @@
using System.Collections.Generic;
namespace Yavsc.Models.Process
{
public class Conjonction : List<IRequisition>, IRequisition
{
public bool Eval()
{
foreach (var req in this)
if (!req.Eval())
return false;
return true;
}
}
}

View File

@ -1,16 +0,0 @@
using System.Collections.Generic;
namespace Yavsc.Models.Process
{
public class Disjonction : List<IRequisition>, IRequisition
{
public bool Eval()
{
foreach (var req in this)
if (req.Eval())
return true;
return false;
}
}
}

View File

@ -1,12 +0,0 @@
namespace Yavsc.Models.Process
{
public class ConstInputValue : NamedRequisition
{
public bool Value { get; set; }
public override bool Eval()
{
return Value;
}
}
}

View File

@ -1,10 +0,0 @@
using Yavsc.Interfaces;
namespace Yavsc.Models.Process
{
public abstract class NamedRequisition : IRequisition, INamedObject
{
public string Name { get; set; }
public abstract bool Eval();
}
}

View File

@ -1,16 +0,0 @@
namespace Yavsc.Models.Process
{
public class Negation<Exp> : IRequisition where Exp : IRequisition
{
Exp _expression;
public Negation(Exp expression)
{
_expression = expression;
}
public bool Eval()
{
return !_expression.Eval();
}
}
}

View File

@ -1,34 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Yavsc.Models.Process
{
/// <summary>
/// An abstract, identified rule
/// </summary>
public class Rule<TResult,TInput>
{
[Key]
public string Id { get; set; }
/// <summary>
/// Left part for this rule, a conjonction.
/// All of these requisitions must be true
/// in order to begin any related process.
/// </summary>
/// <returns></returns>
public Conjonction Left { get; set; }
/// <summary>
/// Right part of this rule, a disjonction.
/// That is, only one of these post requisitions
/// has to be true in order for this rule
/// to expose a success.
/// </summary>
/// <returns></returns>
public Disjonction Right { get; set; }
public string Description { get; set; }
public Action<TResult,TInput> Execution { get; set; }
}
}

View File

@ -1,17 +0,0 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Yavsc.Models
{
public partial class Projet
{
[Key(),DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
[ForeignKeyAttribute("AspNetUsers.Id")]
public string ManagerId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}
}

View File

@ -1,9 +0,0 @@
namespace Yavsc.Models
{
public partial class taskdeps
{
public long taskId { get; set; }
public long deptask { get; set; }
}
}

View File

@ -1,14 +0,0 @@
using System;
namespace Yavsc.Models
{
public partial class tasks
{
public long id { get; set; }
public DateTime endd { get; set; }
public string name { get; set; }
public long prid { get; set; }
public DateTime start { get; set; }
public string tdesc { get; set; }
}
}