principalement du format de code
This commit is contained in:
@ -35,3 +35,10 @@ indent_style = space
|
|||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
|
|
||||||
|
dotnet_naming_rule.locals_should_be_camel_case.severity = none
|
||||||
|
dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters
|
||||||
|
dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style
|
||||||
|
|
||||||
|
dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local
|
||||||
|
|
||||||
|
dotnet_naming_style.camel_case_style.capitalization = camel_case
|
||||||
|
4
Makefile
4
Makefile
@ -13,6 +13,10 @@ clean:
|
|||||||
checklibs:
|
checklibs:
|
||||||
ls $(DNXLIBFP)
|
ls $(DNXLIBFP)
|
||||||
|
|
||||||
|
updatedeps:
|
||||||
|
cp src/Yavsc/bin/output/approot/packages/*/*/lib/*net451*/*.dll private/lib/
|
||||||
|
cp src/Yavsc/bin/output/approot/packages/*/*/lib/*dnx451*/*.dll private/lib/
|
||||||
|
|
||||||
test:
|
test:
|
||||||
make -C src/test
|
make -C src/test
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
"Dnx": {
|
"Dnx": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"enablePackageRestore": false,
|
"enablePackageRestore": false,
|
||||||
"projects": "src/*/project.json;*/project.json;project.json;test/*/project.json"
|
"projects": "src/*/project.json;*/project.json;project.json;test/*/project.json"
|
||||||
},
|
},
|
||||||
"Script": {
|
"Script": {
|
||||||
"enabled": false
|
"enabled": false
|
||||||
|
@ -33,7 +33,7 @@ namespace OAuth.AspNet.AuthServer
|
|||||||
|
|
||||||
MemoryStream stream, memoryStream = null;
|
MemoryStream stream, memoryStream = null;
|
||||||
|
|
||||||
StreamWriter streamWriter = null;
|
StreamWriter streamWriter;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
"defaultNamespace": "Yavsc"
|
"defaultNamespace": "Yavsc"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Newtonsoft.Json": "6.0.1-beta1",
|
"Newtonsoft.Json": "7.0.1",
|
||||||
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-*",
|
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-*",
|
||||||
"OAuth.AspNet.Token": {
|
"OAuth.AspNet.Token": {
|
||||||
"type": "build",
|
"type": "build",
|
||||||
|
@ -27,7 +27,7 @@ namespace OAuth.AspNet.Tokens
|
|||||||
|
|
||||||
#region non-Public Members
|
#region non-Public Members
|
||||||
|
|
||||||
private TicketDataFormat _ticketDataFormat;
|
private readonly TicketDataFormat _ticketDataFormat;
|
||||||
|
|
||||||
private const string _serializationRegex = @"^[A-Za-z0-9-_]*$";
|
private const string _serializationRegex = @"^[A-Za-z0-9-_]*$";
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
"defaultNamespace": "Yavsc"
|
"defaultNamespace": "Yavsc"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Newtonsoft.Json": "6.0.1-beta1",
|
"Newtonsoft.Json": "7.0.1",
|
||||||
"Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-rc1-final",
|
"Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-rc1-final",
|
||||||
"Microsoft.AspNet.DataProtection": "1.0.0-rc1-final"
|
"Microsoft.AspNet.DataProtection": "1.0.0-rc1-final"
|
||||||
},
|
},
|
||||||
|
@ -16,13 +16,14 @@ namespace Yavsc.Authentication
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
string clientId;
|
|
||||||
string clientSecret;
|
readonly string clientId;
|
||||||
string scope;
|
readonly string clientSecret;
|
||||||
Uri authorizeUrl;
|
readonly string scope;
|
||||||
Uri accessTokenUrl;
|
readonly Uri authorizeUrl;
|
||||||
Uri redirectUrl;
|
readonly Uri accessTokenUrl;
|
||||||
GetUsernameAsyncFunc getUsernameAsync;
|
readonly Uri redirectUrl;
|
||||||
|
readonly GetUsernameAsyncFunc getUsernameAsync;
|
||||||
|
|
||||||
string requestState;
|
string requestState;
|
||||||
bool reportedForgery = false;
|
bool reportedForgery = false;
|
||||||
|
@ -48,7 +48,7 @@ namespace Yavsc
|
|||||||
public const string YavscConnectionStringEnvName = "YAVSC_DB_CONNECTION";
|
public const string YavscConnectionStringEnvName = "YAVSC_DB_CONNECTION";
|
||||||
|
|
||||||
// at the end, let 4*4 bytes in peace
|
// at the end, let 4*4 bytes in peace
|
||||||
public const int WebSocketsMaxBufLen = 4 * 1020;
|
public const int WebSocketsMaxBufLen = 4096;
|
||||||
|
|
||||||
public static readonly long DefaultFSQ = 1024 * 1024 * 500;
|
public static readonly long DefaultFSQ = 1024 * 1024 * 500;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ namespace Yavsc.Helpers
|
|||||||
{
|
{
|
||||||
public static string UserBillsDirName { set; get; }
|
public static string UserBillsDirName { set; get; }
|
||||||
public static string UserFilesDirName { set; get; }
|
public static string UserFilesDirName { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Is Valid this Path?
|
/// Is Valid this Path?
|
||||||
/// Return true when given value is a valid user file sub-path,
|
/// Return true when given value is a valid user file sub-path,
|
||||||
@ -37,7 +37,7 @@ namespace Yavsc.Helpers
|
|||||||
{
|
{
|
||||||
return !name.Any(c => !ValidFileNameChars.Contains(c));
|
return !name.Any(c => !ValidFileNameChars.Contains(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure this path is canonical,
|
// Ensure this path is canonical,
|
||||||
// No "dirto/./this", neither "dirt/to/that/"
|
// No "dirto/./this", neither "dirt/to/that/"
|
||||||
// no .. and each char must be listed as valid in constants
|
// no .. and each char must be listed as valid in constants
|
||||||
@ -49,11 +49,11 @@ namespace Yavsc.Helpers
|
|||||||
{
|
{
|
||||||
if (ValidFileNameChars.Contains(c))
|
if (ValidFileNameChars.Contains(c))
|
||||||
sb.Append(c);
|
sb.Append(c);
|
||||||
else sb.Append("#"+((int)c).ToString("D3"));
|
else sb.Append("#" + ((int)c).ToString("D3"));
|
||||||
}
|
}
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UserDirectoryInfo GetUserFiles(string userName, string subdir)
|
public static UserDirectoryInfo GetUserFiles(string userName, string subdir)
|
||||||
{
|
{
|
||||||
UserDirectoryInfo di = new UserDirectoryInfo(UserFilesDirName, userName, subdir);
|
UserDirectoryInfo di = new UserDirectoryInfo(UserFilesDirName, userName, subdir);
|
||||||
@ -71,10 +71,10 @@ namespace Yavsc.Helpers
|
|||||||
|
|
||||||
// Only accept descent remote file names
|
// Only accept descent remote file names
|
||||||
public static char[] ValidFileNameChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_~. %#".ToCharArray();
|
public static char[] ValidFileNameChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_~. %#".ToCharArray();
|
||||||
|
|
||||||
// Estimate signature file name format
|
// Estimate signature file name format
|
||||||
public static Func<string,string,long,string>
|
public static Func<string, string, long, string>
|
||||||
SignFileNameFormat = new Func<string,string,long,string> ((signType,billingCode,estimateId) => $"sign-{billingCode}-{signType}-{estimateId}.png");
|
SignFileNameFormat = new Func<string, string, long, string>((signType, billingCode, estimateId) => $"sign-{billingCode}-{signType}-{estimateId}.png");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ namespace Yavsc.Models.Process
|
|||||||
{
|
{
|
||||||
public class Negation<Exp> : IRequisition where Exp : IRequisition
|
public class Negation<Exp> : IRequisition where Exp : IRequisition
|
||||||
{
|
{
|
||||||
Exp _expression;
|
readonly Exp _expression;
|
||||||
public Negation(Exp expression)
|
public Negation(Exp expression)
|
||||||
{
|
{
|
||||||
_expression = expression;
|
_expression = expression;
|
||||||
|
@ -24,11 +24,14 @@
|
|||||||
"Chat"
|
"Chat"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"buildOptions": {
|
||||||
|
"nowarn": ["IDE1006"]
|
||||||
|
},
|
||||||
"tooling": {
|
"tooling": {
|
||||||
"defaultNamespace": "Yavsc"
|
"defaultNamespace": "Yavsc"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Newtonsoft.Json": "6.0.1-beta1"
|
"Newtonsoft.Json": "7.0.1"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"dnx451": {
|
"dnx451": {
|
||||||
|
@ -31,7 +31,7 @@ namespace Yavsc.Server.Helpers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SimpleJsonPostMethod : IDisposable
|
public class SimpleJsonPostMethod : IDisposable
|
||||||
{
|
{
|
||||||
private HttpWebRequest request=null;
|
private readonly HttpWebRequest request=null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the Yavsc.Helpers.SimpleJsonPostMethod class.
|
/// Initializes a new instance of the Yavsc.Helpers.SimpleJsonPostMethod class.
|
||||||
|
@ -31,7 +31,7 @@ namespace Yavsc.Services
|
|||||||
/// I calendar manager.
|
/// I calendar manager.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ICalendarManager {
|
public interface ICalendarManager {
|
||||||
Task<CalendarList> GetCalendarsAsync (string userId, string pageToken);
|
Task<CalendarList> GetCalendarsAsync (string pageToken);
|
||||||
Task<Events> GetCalendarAsync (string calid, DateTime minDate, DateTime maxDate, string pageToken);
|
Task<Events> GetCalendarAsync (string calid, DateTime minDate, DateTime maxDate, string pageToken);
|
||||||
Task<DateTimeChooserViewModel> CreateViewModelAsync(
|
Task<DateTimeChooserViewModel> CreateViewModelAsync(
|
||||||
string inputId,
|
string inputId,
|
||||||
|
@ -34,19 +34,19 @@ namespace Yavsc.Models.HairCut
|
|||||||
|
|
||||||
public string Sender { get; set; }
|
public string Sender { get; set; }
|
||||||
|
|
||||||
HairCutQuery query;
|
readonly HairCutQuery query;
|
||||||
|
|
||||||
private string invoiceId;
|
private readonly string invoiceId;
|
||||||
private string payerName;
|
private readonly string payerName;
|
||||||
private string phone;
|
private readonly string phone;
|
||||||
private string payerEmail;
|
private readonly string payerEmail;
|
||||||
private string amount;
|
private readonly string amount;
|
||||||
private HairCutGenders gender;
|
private readonly HairCutGenders gender;
|
||||||
private string date;
|
private readonly string date;
|
||||||
private string lieu;
|
private readonly string lieu;
|
||||||
private string clientFinal;
|
private readonly string clientFinal;
|
||||||
private string token;
|
private readonly string token;
|
||||||
private string payerId;
|
private readonly string payerId;
|
||||||
|
|
||||||
public string CreateBody()
|
public string CreateBody()
|
||||||
{
|
{
|
||||||
@ -73,4 +73,4 @@ Le client final: {clientFinal}
|
|||||||
";
|
";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ Prestation.Gender == HairCutGenders.Women ?
|
|||||||
bill.Add(new CommandLine
|
bill.Add(new CommandLine
|
||||||
{
|
{
|
||||||
Name = name,
|
Name = name,
|
||||||
Description = name = name + shorthairsuffix,
|
Description = name + shorthairsuffix,
|
||||||
UnitaryCost = multicolor ? SelectedProfile.ShortMultiColorPrice : SelectedProfile.ShortColorPrice
|
UnitaryCost = multicolor ? SelectedProfile.ShortMultiColorPrice : SelectedProfile.ShortColorPrice
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -36,6 +36,5 @@ namespace Yavsc.Models.Haircut
|
|||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
HairCutQuery Data { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ namespace Yavsc.Server.Models.IT
|
|||||||
[ForeignKey("GitId")]
|
[ForeignKey("GitId")]
|
||||||
public virtual GitRepositoryReference Repository { get; set; }
|
public virtual GitRepositoryReference Repository { get; set; }
|
||||||
|
|
||||||
List<IBillItem> bill = new List<IBillItem>();
|
readonly List<IBillItem> bill = new List<IBillItem>();
|
||||||
public void AddBillItem(IBillItem item)
|
public void AddBillItem(IBillItem item)
|
||||||
{
|
{
|
||||||
bill.Add(item);
|
bill.Add(item);
|
||||||
|
@ -47,7 +47,7 @@ namespace Yavsc.Server.Models.IT.SourceCode
|
|||||||
writer.WriteLine(process.StandardOutput.ReadLine());
|
writer.WriteLine(process.StandardOutput.ReadLine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ResultHandler!=null) ResultHandler(true);
|
ResultHandler?.Invoke(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ namespace Yavsc.Server.Models.IT.SourceCode
|
|||||||
writer.WriteLine(process.StandardOutput.ReadLine());
|
writer.WriteLine(process.StandardOutput.ReadLine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ResultHandler!=null) ResultHandler(true);
|
ResultHandler?.Invoke(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class Announce : BaseEvent, IAnnounce, IOwned
|
|||||||
public string Message { get; set; }
|
public string Message { get; set; }
|
||||||
public override string CreateBody()
|
public override string CreateBody()
|
||||||
{
|
{
|
||||||
return $"Annonce de {Owner.UserName}: {For.ToString()}\n\n{Message}";
|
return $"Annonce de {Owner.UserName}: {For}\n\n{Message}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,14 @@ namespace Yavsc.Models.Messaging
|
|||||||
Sender = perfer.Performer.UserName;
|
Sender = perfer.Performer.UserName;
|
||||||
_localizer = SR;
|
_localizer = SR;
|
||||||
}
|
}
|
||||||
// TODO via e-mail only: Message = string.Format(
|
|
||||||
// SR["EstimationMessageToClient"],perfer.Performer.UserName, estimate.Title,estimate.Bill.Addition());
|
// TODO via e-mail only: Message = string.Format(
|
||||||
//
|
// SR["EstimationMessageToClient"],perfer.Performer.UserName, estimate.Title,estimate.Bill.Addition());
|
||||||
|
|
||||||
ProviderClientInfo ProviderInfo { get; set; }
|
ProviderClientInfo ProviderInfo { get; set; }
|
||||||
Estimate Estimation { get; set; }
|
Estimate Estimation { get; set; }
|
||||||
|
|
||||||
private PerformerProfile perfer;
|
private readonly PerformerProfile perfer;
|
||||||
|
|
||||||
public string Topic
|
public string Topic
|
||||||
{
|
{
|
||||||
@ -46,7 +47,7 @@ namespace Yavsc.Models.Messaging
|
|||||||
|
|
||||||
public string CreateBody()
|
public string CreateBody()
|
||||||
{
|
{
|
||||||
return string.Format( _localizer["EstimationMessageToClient"], perfer.Performer.UserName, this.Estimation.Bill.Addition());
|
return string.Format(_localizer["EstimationMessageToClient"], perfer.Performer.UserName, this.Estimation.Bill.Addition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,8 @@
|
|||||||
"Resources/**/*.resx"
|
"Resources/**/*.resx"
|
||||||
],
|
],
|
||||||
"publicSign": false,
|
"publicSign": false,
|
||||||
"keyFile": "../../../sgKey.snk"
|
"keyFile": "../../../sgKey.snk",
|
||||||
|
"nowarn": ["IDE1006"]
|
||||||
},
|
},
|
||||||
"tooling": {
|
"tooling": {
|
||||||
"defaultNamespace": "Yavsc"
|
"defaultNamespace": "Yavsc"
|
||||||
|
@ -18,10 +18,8 @@ namespace Yavsc.Controllers
|
|||||||
[Route("api/live")]
|
[Route("api/live")]
|
||||||
public class LiveApiController : Controller
|
public class LiveApiController : Controller
|
||||||
{
|
{
|
||||||
|
readonly ILiveProcessor _liveProcessor;
|
||||||
ILiveProcessor _liveProcessor;
|
private readonly ApplicationDbContext _dbContext;
|
||||||
private ApplicationDbContext _dbContext;
|
|
||||||
ILogger _logger;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Live Api Controller
|
/// Live Api Controller
|
||||||
@ -30,13 +28,11 @@ namespace Yavsc.Controllers
|
|||||||
/// <param name="context"></param>
|
/// <param name="context"></param>
|
||||||
|
|
||||||
public LiveApiController(
|
public LiveApiController(
|
||||||
ILoggerFactory loggerFactory,
|
|
||||||
ApplicationDbContext context,
|
ApplicationDbContext context,
|
||||||
ILiveProcessor liveProcessor)
|
ILiveProcessor liveProcessor)
|
||||||
{
|
{
|
||||||
_liveProcessor = liveProcessor;
|
_liveProcessor = liveProcessor;
|
||||||
_dbContext = context;
|
_dbContext = context;
|
||||||
_logger = loggerFactory.CreateLogger<LiveApiController>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("filenamehint/{id}")]
|
[HttpGet("filenamehint/{id}")]
|
||||||
|
@ -16,8 +16,8 @@ namespace Yavsc.ApiControllers
|
|||||||
[Route("~/api/bug")]
|
[Route("~/api/bug")]
|
||||||
public class BugApiController : Controller
|
public class BugApiController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
ILogger _logger;
|
readonly ILogger _logger;
|
||||||
|
|
||||||
public BugApiController(ApplicationDbContext context, ILoggerFactory factory)
|
public BugApiController(ApplicationDbContext context, ILoggerFactory factory)
|
||||||
{
|
{
|
||||||
|
@ -32,4 +32,4 @@ namespace Yavsc.AuthorizationHandlers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ namespace Yavsc.AuthorizationHandlers
|
|||||||
{
|
{
|
||||||
public class SendMessageHandler : AuthorizationHandler<PrivateChatEntryRequirement, string>
|
public class SendMessageHandler : AuthorizationHandler<PrivateChatEntryRequirement, string>
|
||||||
{
|
{
|
||||||
ApplicationDbContext _dbContext ;
|
readonly ApplicationDbContext _dbContext ;
|
||||||
|
|
||||||
public SendMessageHandler(ApplicationDbContext dbContext)
|
public SendMessageHandler(ApplicationDbContext dbContext)
|
||||||
{
|
{
|
||||||
|
@ -5,8 +5,7 @@ using Yavsc.ViewModels.Auth;
|
|||||||
namespace Yavsc.AuthorizationHandlers {
|
namespace Yavsc.AuthorizationHandlers {
|
||||||
|
|
||||||
public class ViewFileHandler : AuthorizationHandler<ViewRequirement, ViewFileContext> {
|
public class ViewFileHandler : AuthorizationHandler<ViewRequirement, ViewFileContext> {
|
||||||
|
readonly IFileSystemAuthManager _authManager;
|
||||||
IFileSystemAuthManager _authManager;
|
|
||||||
|
|
||||||
public ViewFileHandler (IFileSystemAuthManager authManager) {
|
public ViewFileHandler (IFileSystemAuthManager authManager) {
|
||||||
_authManager = authManager;
|
_authManager = authManager;
|
||||||
@ -28,4 +27,4 @@ namespace Yavsc.AuthorizationHandlers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace Yavsc.Auth
|
|||||||
{
|
{
|
||||||
internal class GoogleHandler : OAuthHandler<YavscGoogleOptions>
|
internal class GoogleHandler : OAuthHandler<YavscGoogleOptions>
|
||||||
{
|
{
|
||||||
private ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
public GoogleHandler(HttpClient httpClient,ILogger logger)
|
public GoogleHandler(HttpClient httpClient,ILogger logger)
|
||||||
: base(httpClient)
|
: base(httpClient)
|
||||||
{
|
{
|
||||||
@ -92,9 +92,11 @@ namespace Yavsc.Auth
|
|||||||
{
|
{
|
||||||
|
|
||||||
var scope = FormatScope();
|
var scope = FormatScope();
|
||||||
var queryStrings = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
var queryStrings = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
||||||
queryStrings.Add("response_type", "code");
|
{
|
||||||
queryStrings.Add("client_id", Options.ClientId);
|
{ "response_type", "code" },
|
||||||
|
{ "client_id", Options.ClientId }
|
||||||
|
};
|
||||||
// this runtime may not known this value,
|
// this runtime may not known this value,
|
||||||
// it should be get from config,
|
// it should be get from config,
|
||||||
// And always be using a secure sheme ... since Google won't support anymore insecure ones.
|
// And always be using a secure sheme ... since Google won't support anymore insecure ones.
|
||||||
|
@ -16,8 +16,8 @@ namespace Yavsc.Auth
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class GoogleMiddleware : OAuthMiddleware<YavscGoogleOptions>
|
public class GoogleMiddleware : OAuthMiddleware<YavscGoogleOptions>
|
||||||
{
|
{
|
||||||
private RequestDelegate _next;
|
private readonly RequestDelegate _next;
|
||||||
private ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new <see cref="GoogleMiddleware"/>.
|
/// Initializes a new <see cref="GoogleMiddleware"/>.
|
||||||
|
@ -15,8 +15,9 @@ namespace Yavsc.Auth {
|
|||||||
_googleUserId = googleUserId;
|
_googleUserId = googleUserId;
|
||||||
Principal = ticket.Principal;
|
Principal = ticket.Principal;
|
||||||
}
|
}
|
||||||
AuthenticationTicket _ticket;
|
|
||||||
string _googleUserId;
|
readonly AuthenticationTicket _ticket;
|
||||||
|
readonly string _googleUserId;
|
||||||
|
|
||||||
public AuthenticationTicket Ticket { get { return _ticket; } }
|
public AuthenticationTicket Ticket { get { return _ticket; } }
|
||||||
|
|
||||||
@ -24,4 +25,4 @@ namespace Yavsc.Auth {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,6 @@ namespace Yavsc.Controllers
|
|||||||
[Authorize(Roles = Constants.AdminGroupName)]
|
[Authorize(Roles = Constants.AdminGroupName)]
|
||||||
public IActionResult Index(string page, string len)
|
public IActionResult Index(string page, string len)
|
||||||
{
|
{
|
||||||
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +261,7 @@ namespace Yavsc.Controllers
|
|||||||
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=532713
|
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=532713
|
||||||
// Send an email with this link
|
// Send an email with this link
|
||||||
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
||||||
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: "https", host: Startup.Authority);
|
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code }, protocol: "https", host: Startup.Authority);
|
||||||
var emailSent = await _emailSender.SendEmailAsync(model.UserName, model.Email, _localizer["ConfirmYourAccountTitle"],
|
var emailSent = await _emailSender.SendEmailAsync(model.UserName, model.Email, _localizer["ConfirmYourAccountTitle"],
|
||||||
string.Format(_localizer["ConfirmYourAccountBody"], _siteSettings.Title, callbackUrl, _siteSettings.Slogan, _siteSettings.Audience));
|
string.Format(_localizer["ConfirmYourAccountBody"], _siteSettings.Title, callbackUrl, _siteSettings.Slogan, _siteSettings.Audience));
|
||||||
// No, wait for more than a login pass submission:
|
// No, wait for more than a login pass submission:
|
||||||
@ -317,7 +316,7 @@ namespace Yavsc.Controllers
|
|||||||
{
|
{
|
||||||
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
||||||
var callbackUrl = Url.Action("ConfirmEmail", "Account",
|
var callbackUrl = Url.Action("ConfirmEmail", "Account",
|
||||||
new { userId = user.Id, code = code }, protocol: "https", host: Startup.Authority);
|
new { userId = user.Id, code }, protocol: "https", host: Startup.Authority);
|
||||||
var res = await _emailSender.SendEmailAsync(user.UserName, user.Email,
|
var res = await _emailSender.SendEmailAsync(user.UserName, user.Email,
|
||||||
this._localizer["ConfirmYourAccountTitle"],
|
this._localizer["ConfirmYourAccountTitle"],
|
||||||
string.Format(this._localizer["ConfirmYourAccountBody"],
|
string.Format(this._localizer["ConfirmYourAccountBody"],
|
||||||
|
@ -29,18 +29,18 @@ namespace Yavsc.Controllers
|
|||||||
private readonly SignInManager<ApplicationUser> _signInManager;
|
private readonly SignInManager<ApplicationUser> _signInManager;
|
||||||
private readonly IEmailSender _emailSender;
|
private readonly IEmailSender _emailSender;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private SiteSettings _siteSettings;
|
private readonly SiteSettings _siteSettings;
|
||||||
|
|
||||||
private ApplicationDbContext _dbContext;
|
private readonly ApplicationDbContext _dbContext;
|
||||||
|
|
||||||
private GoogleAuthSettings _googleSettings;
|
private readonly GoogleAuthSettings _googleSettings;
|
||||||
|
|
||||||
private PayPalSettings _payPalSettings;
|
private readonly PayPalSettings _payPalSettings;
|
||||||
private IYavscMessageSender _GCMSender;
|
private readonly IYavscMessageSender _GCMSender;
|
||||||
private SIRENChecker _cchecker;
|
private readonly SIRENChecker _cchecker;
|
||||||
private IStringLocalizer _SR;
|
private readonly IStringLocalizer _SR;
|
||||||
private CompanyInfoSettings _cinfoSettings;
|
private readonly CompanyInfoSettings _cinfoSettings;
|
||||||
ICalendarManager _calendarManager;
|
readonly ICalendarManager _calendarManager;
|
||||||
|
|
||||||
|
|
||||||
public ManageController(
|
public ManageController(
|
||||||
@ -300,7 +300,7 @@ namespace Yavsc.Controllers
|
|||||||
{
|
{
|
||||||
var uid = User.GetUserId();
|
var uid = User.GetUserId();
|
||||||
|
|
||||||
var calendars = await _calendarManager.GetCalendarsAsync(uid, pageToken);
|
var calendars = await _calendarManager.GetCalendarsAsync(pageToken);
|
||||||
return View(new SetGoogleCalendarViewModel {
|
return View(new SetGoogleCalendarViewModel {
|
||||||
ReturnUrl = returnUrl,
|
ReturnUrl = returnUrl,
|
||||||
Calendars = calendars
|
Calendars = calendars
|
||||||
|
@ -20,12 +20,10 @@ namespace Yavsc.Controllers
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public class OAuthController : Controller
|
public class OAuthController : Controller
|
||||||
{
|
{
|
||||||
ApplicationDbContext _context;
|
readonly ApplicationDbContext _context;
|
||||||
UserManager<ApplicationUser> _userManager;
|
readonly UserManager<ApplicationUser> _userManager;
|
||||||
|
readonly SiteSettings _siteSettings;
|
||||||
SiteSettings _siteSettings;
|
readonly ILogger _logger;
|
||||||
|
|
||||||
ILogger _logger;
|
|
||||||
private readonly SignInManager<ApplicationUser> _signInManager;
|
private readonly SignInManager<ApplicationUser> _signInManager;
|
||||||
|
|
||||||
public OAuthController(ApplicationDbContext context, SignInManager<ApplicationUser> signInManager, IKeyManager keyManager,
|
public OAuthController(ApplicationDbContext context, SignInManager<ApplicationUser> signInManager, IKeyManager keyManager,
|
||||||
|
@ -10,7 +10,7 @@ namespace Yavsc.Controllers
|
|||||||
[Authorize("AdministratorOnly")]
|
[Authorize("AdministratorOnly")]
|
||||||
public class UsersController : Controller
|
public class UsersController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public UsersController(ApplicationDbContext context)
|
public UsersController(ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ namespace Yavsc.Controllers
|
|||||||
[Authorize("AdministratorOnly")]
|
[Authorize("AdministratorOnly")]
|
||||||
public class MailingTemplateController : Controller
|
public class MailingTemplateController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public MailingTemplateController(ApplicationDbContext context)
|
public MailingTemplateController(ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
|
@ -21,11 +21,10 @@ namespace Yavsc.Controllers
|
|||||||
{
|
{
|
||||||
public class BlogspotController : Controller
|
public class BlogspotController : Controller
|
||||||
{
|
{
|
||||||
ILogger _logger;
|
readonly ILogger _logger;
|
||||||
private ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
private IAuthorizationService _authorizationService;
|
private readonly IAuthorizationService _authorizationService;
|
||||||
|
readonly RequestLocalizationOptions _localisationOptions;
|
||||||
RequestLocalizationOptions _localisationOptions;
|
|
||||||
|
|
||||||
public BlogspotController(
|
public BlogspotController(
|
||||||
ApplicationDbContext context,
|
ApplicationDbContext context,
|
||||||
|
@ -11,7 +11,7 @@ namespace Yavsc.Controllers
|
|||||||
{
|
{
|
||||||
public class CircleController : Controller
|
public class CircleController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public CircleController(ApplicationDbContext context)
|
public CircleController(ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ namespace Yavsc.Controllers
|
|||||||
{
|
{
|
||||||
public class CircleMembersController : Controller
|
public class CircleMembersController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public CircleMembersController(ApplicationDbContext context)
|
public CircleMembersController(ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ namespace Yavsc.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class CommentsController : Controller
|
public class CommentsController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public CommentsController(ApplicationDbContext context)
|
public CommentsController(ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ namespace Yavsc.Controllers
|
|||||||
using Models.Identity;
|
using Models.Identity;
|
||||||
public class DevicesController : Controller
|
public class DevicesController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public DevicesController(ApplicationDbContext context)
|
public DevicesController(ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ namespace Yavsc.Controllers
|
|||||||
[Authorize("AdministratorOnly")]
|
[Authorize("AdministratorOnly")]
|
||||||
public class HyperLinkController : Controller
|
public class HyperLinkController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public HyperLinkController(ApplicationDbContext context)
|
public HyperLinkController(ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ namespace Yavsc.Controllers
|
|||||||
{
|
{
|
||||||
public class LiveFlowController : Controller
|
public class LiveFlowController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public LiveFlowController(ApplicationDbContext context)
|
public LiveFlowController(ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
|
@ -14,8 +14,8 @@ namespace Yavsc.Controllers
|
|||||||
[Authorize()]
|
[Authorize()]
|
||||||
public class MyFSRulesController : Controller
|
public class MyFSRulesController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
private ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public MyFSRulesController(ApplicationDbContext context,
|
public MyFSRulesController(ApplicationDbContext context,
|
||||||
ILoggerFactory loggerFactory)
|
ILoggerFactory loggerFactory)
|
||||||
|
@ -9,7 +9,7 @@ namespace Yavsc.Controllers
|
|||||||
{
|
{
|
||||||
public class NotificationsController : Controller
|
public class NotificationsController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public NotificationsController(ApplicationDbContext context)
|
public NotificationsController(ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
|
@ -16,9 +16,9 @@ namespace Yavsc.Controllers
|
|||||||
[Authorize("AdministratorOnly")]
|
[Authorize("AdministratorOnly")]
|
||||||
public class ActivityController : Controller
|
public class ActivityController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
IStringLocalizer<Yavsc.YavscLocalisation> SR;
|
readonly IStringLocalizer<Yavsc.YavscLocalisation> SR;
|
||||||
ILogger logger;
|
readonly ILogger logger;
|
||||||
|
|
||||||
public ActivityController(ApplicationDbContext context,
|
public ActivityController(ApplicationDbContext context,
|
||||||
IStringLocalizer<Yavsc.YavscLocalisation> SR,
|
IStringLocalizer<Yavsc.YavscLocalisation> SR,
|
||||||
|
@ -12,7 +12,7 @@ namespace Yavsc.Controllers
|
|||||||
{
|
{
|
||||||
public class ClientController : Controller
|
public class ClientController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public ClientController(ApplicationDbContext context)
|
public ClientController(ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
|
@ -17,9 +17,9 @@ namespace Yavsc.Controllers
|
|||||||
[Authorize]
|
[Authorize]
|
||||||
public class DoController : Controller
|
public class DoController : Controller
|
||||||
{
|
{
|
||||||
private ApplicationDbContext dbContext;
|
private readonly ApplicationDbContext dbContext;
|
||||||
ILogger logger;
|
readonly ILogger logger;
|
||||||
IBillingService billing;
|
readonly IBillingService billing;
|
||||||
public DoController(
|
public DoController(
|
||||||
ApplicationDbContext context,
|
ApplicationDbContext context,
|
||||||
IBillingService billing,
|
IBillingService billing,
|
||||||
|
@ -57,7 +57,7 @@ namespace Yavsc.Models
|
|||||||
builder.Entity<UserActivity>().HasKey(u => new { u.DoesCode, u.UserId });
|
builder.Entity<UserActivity>().HasKey(u => new { u.DoesCode, u.UserId });
|
||||||
builder.Entity<Instrumentation>().HasKey(u => new { u.InstrumentId, u.UserId });
|
builder.Entity<Instrumentation>().HasKey(u => new { u.InstrumentId, u.UserId });
|
||||||
builder.Entity<CircleAuthorizationToBlogPost>().HasKey(a => new { a.CircleId, a.BlogPostId });
|
builder.Entity<CircleAuthorizationToBlogPost>().HasKey(a => new { a.CircleId, a.BlogPostId });
|
||||||
builder.Entity<CircleMember>().HasKey(c => new { MemberId = c.MemberId, CircleId = c.CircleId });
|
builder.Entity<CircleMember>().HasKey(c => new { c.MemberId, c.CircleId });
|
||||||
builder.Entity<DimissClicked>().HasKey(c => new { uid = c.UserId, notid = c.NotificationId });
|
builder.Entity<DimissClicked>().HasKey(c => new { uid = c.UserId, notid = c.NotificationId });
|
||||||
builder.Entity<HairTaintInstance>().HasKey(ti => new { ti.TaintId, ti.PrestationId });
|
builder.Entity<HairTaintInstance>().HasKey(ti => new { ti.TaintId, ti.PrestationId });
|
||||||
builder.Entity<HyperLink>().HasKey(l => new { l.HRef, l.Method });
|
builder.Entity<HyperLink>().HasKey(l => new { l.HRef, l.Method });
|
||||||
@ -79,9 +79,9 @@ namespace Yavsc.Models
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this is not a failback procedure.
|
// this is not a failback procedure.
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
if (optionsBuilder.IsConfigured) return;
|
|
||||||
if (!string.IsNullOrWhiteSpace(Startup.ConnectionString))
|
if (!string.IsNullOrWhiteSpace(Startup.ConnectionString))
|
||||||
{
|
{
|
||||||
optionsBuilder.UseNpgsql(Startup.ConnectionString);
|
optionsBuilder.UseNpgsql(Startup.ConnectionString);
|
||||||
@ -161,12 +161,6 @@ namespace Yavsc.Models
|
|||||||
public DbSet<Service> Services { get; set; }
|
public DbSet<Service> Services { get; set; }
|
||||||
public DbSet<Product> Products { get; set; }
|
public DbSet<Product> Products { get; set; }
|
||||||
|
|
||||||
Client FindApplication(string clientId)
|
|
||||||
{
|
|
||||||
return Applications.FirstOrDefault(
|
|
||||||
app => app.Id == clientId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DbSet<ExceptionSIREN> ExceptionsSIREN { get; set; }
|
public DbSet<ExceptionSIREN> ExceptionsSIREN { get; set; }
|
||||||
|
|
||||||
public DbSet<Location> Locations { get; set; }
|
public DbSet<Location> Locations { get; set; }
|
||||||
@ -231,7 +225,7 @@ namespace Yavsc.Models
|
|||||||
public async Task<int> SaveChangesAsync(string userId, CancellationToken ctoken = default(CancellationToken))
|
public async Task<int> SaveChangesAsync(string userId, CancellationToken ctoken = default(CancellationToken))
|
||||||
{
|
{
|
||||||
AddTimestamps(userId);
|
AddTimestamps(userId);
|
||||||
return await base.SaveChangesAsync();
|
return await base.SaveChangesAsync(ctoken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbSet<Circle> Circle { get; set; }
|
public DbSet<Circle> Circle { get; set; }
|
||||||
|
@ -13,7 +13,6 @@ namespace Yavsc.Services
|
|||||||
public class BillingService : IBillingService
|
public class BillingService : IBillingService
|
||||||
{
|
{
|
||||||
public ApplicationDbContext DbContext { get; private set; }
|
public ApplicationDbContext DbContext { get; private set; }
|
||||||
private ILogger logger;
|
|
||||||
public static Dictionary<string,Func<ApplicationDbContext,long,IDecidableQuery>> Billing =
|
public static Dictionary<string,Func<ApplicationDbContext,long,IDecidableQuery>> Billing =
|
||||||
new Dictionary<string,Func<ApplicationDbContext,long,IDecidableQuery>> ();
|
new Dictionary<string,Func<ApplicationDbContext,long,IDecidableQuery>> ();
|
||||||
public static List<PropertyInfo> UserSettings = new List<PropertyInfo>();
|
public static List<PropertyInfo> UserSettings = new List<PropertyInfo>();
|
||||||
@ -25,9 +24,8 @@ namespace Yavsc.Services
|
|||||||
get { return GlobalBillingMap; }
|
get { return GlobalBillingMap; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public BillingService(ILoggerFactory loggerFactory, ApplicationDbContext dbContext)
|
public BillingService(ApplicationDbContext dbContext)
|
||||||
{
|
{
|
||||||
logger = loggerFactory.CreateLogger<BillingService>();
|
|
||||||
DbContext = dbContext;
|
DbContext = dbContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,24 +31,24 @@ namespace Yavsc.Services
|
|||||||
/// <typeparam name="string"></typeparam>
|
/// <typeparam name="string"></typeparam>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|
||||||
static ConcurrentDictionary<string, string> ChatUserNames = new ConcurrentDictionary<string, string>();
|
static readonly ConcurrentDictionary<string, string> ChatUserNames = new ConcurrentDictionary<string, string>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// by user name
|
/// by user name
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
static ConcurrentDictionary<string, List<string>> ChatCxIds = new ConcurrentDictionary<string, List<string>>();
|
static readonly ConcurrentDictionary<string, List<string>> ChatCxIds = new ConcurrentDictionary<string, List<string>>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// by user name,
|
/// by user name,
|
||||||
/// the list of its chat rooms
|
/// the list of its chat rooms
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
static ConcurrentDictionary<string, List<string>> ChatRoomPresence = new ConcurrentDictionary<string, List<string>>();
|
static readonly ConcurrentDictionary<string, List<string>> ChatRoomPresence = new ConcurrentDictionary<string, List<string>>();
|
||||||
static ConcurrentDictionary<string, bool> _isCop = new ConcurrentDictionary<string, bool>();
|
static readonly ConcurrentDictionary<string, bool> _isCop = new ConcurrentDictionary<string, bool>();
|
||||||
|
|
||||||
public static ConcurrentDictionary<string, ChatRoomInfo> Channels = new ConcurrentDictionary<string, ChatRoomInfo>();
|
public static ConcurrentDictionary<string, ChatRoomInfo> Channels = new ConcurrentDictionary<string, ChatRoomInfo>();
|
||||||
ApplicationDbContext _dbContext;
|
readonly ApplicationDbContext _dbContext;
|
||||||
IStringLocalizer _localizer;
|
readonly IStringLocalizer _localizer;
|
||||||
|
|
||||||
public HubConnectionManager()
|
public HubConnectionManager()
|
||||||
{
|
{
|
||||||
@ -97,7 +97,7 @@ namespace Yavsc.Services
|
|||||||
return ChatRoomPresence[userName].Contains(roomName);
|
return ChatRoomPresence[userName].Contains(roomName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool isCop(string userName)
|
public bool IsCop(string userName)
|
||||||
{
|
{
|
||||||
return _isCop[userName];
|
return _isCop[userName];
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ namespace Yavsc.Services
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (isCop(userName))
|
if (IsCop(userName))
|
||||||
{
|
{
|
||||||
chanInfo.Ops.Add(cxId);
|
chanInfo.Ops.Add(cxId);
|
||||||
}
|
}
|
||||||
@ -320,7 +320,7 @@ namespace Yavsc.Services
|
|||||||
_errorHandler(roomName, _localizer.GetString(ChatHubConstants.HopWontKickOp).ToString());
|
_errorHandler(roomName, _localizer.GetString(ChatHubConstants.HopWontKickOp).ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (isCop(userName))
|
if (IsCop(userName))
|
||||||
{
|
{
|
||||||
_errorHandler(roomName, _localizer.GetString(ChatHubConstants.NoKickOnCop).ToString());
|
_errorHandler(roomName, _localizer.GetString(ChatHubConstants.NoKickOnCop).ToString());
|
||||||
return false;
|
return false;
|
||||||
|
@ -27,14 +27,12 @@ namespace Yavsc.Lib
|
|||||||
const string DefaultBaseClassName = "ATemplate";
|
const string DefaultBaseClassName = "ATemplate";
|
||||||
const string DefaultBaseClass = nameof(UserOrientedTemplate);
|
const string DefaultBaseClass = nameof(UserOrientedTemplate);
|
||||||
const string DefaultNamespace = "CompiledRazorTemplates";
|
const string DefaultNamespace = "CompiledRazorTemplates";
|
||||||
|
readonly RazorTemplateEngine razorEngine;
|
||||||
RazorTemplateEngine razorEngine;
|
readonly IStringLocalizer<EMailer> stringLocalizer;
|
||||||
IStringLocalizer<EMailer> stringLocalizer;
|
readonly ApplicationDbContext dbContext;
|
||||||
|
readonly IEmailSender mailSender;
|
||||||
ApplicationDbContext dbContext;
|
readonly RazorEngineHost host;
|
||||||
IEmailSender mailSender;
|
readonly ILogger logger;
|
||||||
RazorEngineHost host;
|
|
||||||
ILogger logger;
|
|
||||||
|
|
||||||
public EMailer(ApplicationDbContext context, IEmailSender sender,
|
public EMailer(ApplicationDbContext context, IEmailSender sender,
|
||||||
IStringLocalizer<EMailer> localizer,
|
IStringLocalizer<EMailer> localizer,
|
||||||
|
@ -9,8 +9,8 @@ namespace Yavsc.Services
|
|||||||
{
|
{
|
||||||
public class FileSystemAuthManager : IFileSystemAuthManager
|
public class FileSystemAuthManager : IFileSystemAuthManager
|
||||||
{
|
{
|
||||||
ApplicationDbContext _dbContext;
|
readonly ApplicationDbContext _dbContext;
|
||||||
ILogger _logger;
|
readonly ILogger _logger;
|
||||||
|
|
||||||
public FileSystemAuthManager(ApplicationDbContext dbContext, ILoggerFactory loggerFactory)
|
public FileSystemAuthManager(ApplicationDbContext dbContext, ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
@ -70,4 +70,4 @@ namespace Yavsc.Services
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,45 +43,22 @@ namespace Yavsc.Services
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Google Calendar API client.
|
/// Google Calendar API client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CalendarManager : ICalendarManager
|
public class CalendarManager : ICalendarManager
|
||||||
{
|
{
|
||||||
public class ExpiredTokenException : Exception { }
|
public class ExpiredTokenException : Exception { }
|
||||||
protected static string [] scopesCalendar =
|
protected static string[] scopesCalendar =
|
||||||
{ "https://www.googleapis.com/auth/calendar",
|
{ "https://www.googleapis.com/auth/calendar",
|
||||||
"https://www.googleapis.com/auth/calendar.events"
|
"https://www.googleapis.com/auth/calendar.events"
|
||||||
};
|
};
|
||||||
private string _ApiKey;
|
readonly ILogger _logger;
|
||||||
private IAuthorizationCodeFlow _flow;
|
readonly string _client_id;
|
||||||
ApplicationDbContext _dbContext;
|
readonly string _client_secret;
|
||||||
|
|
||||||
IDataStore _dataStore;
|
public CalendarManager(ILoggerFactory loggerFactory)
|
||||||
ILogger _logger;
|
|
||||||
string _client_id;
|
|
||||||
string _client_secret;
|
|
||||||
|
|
||||||
public CalendarManager(
|
|
||||||
ApplicationDbContext dbContext,
|
|
||||||
IDataStore dataStore,
|
|
||||||
ILoggerFactory loggerFactory,
|
|
||||||
IOptions<GoogleAuthSettings> settings)
|
|
||||||
{
|
{
|
||||||
_client_id = Startup.GoogleWebClientConfiguration["web:cient_id"];
|
_client_id = Startup.GoogleWebClientConfiguration["web:cient_id"];
|
||||||
_client_secret = Startup.GoogleWebClientConfiguration["web:cient_secret"];
|
_client_secret = Startup.GoogleWebClientConfiguration["web:cient_secret"];
|
||||||
|
|
||||||
_ApiKey = settings.Value.ApiKey;
|
|
||||||
_dbContext = dbContext;
|
|
||||||
_logger = loggerFactory.CreateLogger<CalendarManager>();
|
_logger = loggerFactory.CreateLogger<CalendarManager>();
|
||||||
_dataStore = dataStore;
|
|
||||||
_flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
|
|
||||||
{
|
|
||||||
ClientSecrets = new ClientSecrets
|
|
||||||
{
|
|
||||||
ClientId = _client_id,
|
|
||||||
ClientSecret = _client_secret
|
|
||||||
},
|
|
||||||
Scopes = scopesCalendar ,
|
|
||||||
DataStore = dataStore
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -98,29 +75,27 @@ namespace Yavsc.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The calendars.</returns>
|
/// <returns>The calendars.</returns>
|
||||||
/// <param name="userId">Yavsc user id</param>
|
/// <param name="userId">Yavsc user id</param>
|
||||||
public async Task<CalendarList> GetCalendarsAsync(string userId, string pageToken)
|
public async Task<CalendarList> GetCalendarsAsync(string pageToken)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(userId))
|
var service = await CreateUserCalendarServiceAsync();
|
||||||
throw new Exception("the user id is not specified");
|
|
||||||
var service = await CreateUserCalendarServiceAsync(userId);
|
|
||||||
#if Debug
|
#if Debug
|
||||||
if (service==null) throw new Exception("Could not get service");
|
if (service==null) throw new Exception("Could not get service");
|
||||||
#endif
|
#endif
|
||||||
_logger.LogInformation("Got a service");
|
_logger.LogInformation("Got a service");
|
||||||
|
|
||||||
#if Debug
|
#if Debug
|
||||||
if (service.CalendarList==null) throw new Exception("Could not get calendar list");
|
if (service.CalendarList==null) throw new Exception("Could not get calendar list");
|
||||||
#endif
|
#endif
|
||||||
CalendarListResource.ListRequest calListReq = service.CalendarList.List ();
|
CalendarListResource.ListRequest calListReq = service.CalendarList.List();
|
||||||
|
|
||||||
#if Debug
|
#if Debug
|
||||||
if (calListReq==null) throw new Exception ("list is null");
|
if (calListReq==null) throw new Exception ("list is null");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
calListReq.PageToken = pageToken;
|
calListReq.PageToken = pageToken;
|
||||||
return calListReq.Execute ();
|
return calListReq.Execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a calendar event list, between the given dates.
|
/// Gets a calendar event list, between the given dates.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -158,16 +133,17 @@ namespace Yavsc.Services
|
|||||||
|
|
||||||
foreach (var ev in eventList.Items)
|
foreach (var ev in eventList.Items)
|
||||||
{
|
{
|
||||||
if (ev.Start.DateTime.HasValue && ev.End.DateTime.HasValue ) {
|
if (ev.Start.DateTime.HasValue && ev.End.DateTime.HasValue)
|
||||||
DateTime start = ev.Start.DateTime.Value;
|
|
||||||
DateTime end = ev.End.DateTime.Value;
|
|
||||||
|
|
||||||
if (ev.Transparency == "transparent")
|
|
||||||
{
|
{
|
||||||
|
DateTime start = ev.Start.DateTime.Value;
|
||||||
|
DateTime end = ev.End.DateTime.Value;
|
||||||
|
|
||||||
free.Add(new Period { Start = start, End = end });
|
if (ev.Transparency == "transparent")
|
||||||
}
|
{
|
||||||
else busy.Add(new Period { Start = start, End = end });
|
|
||||||
|
free.Add(new Period { Start = start, End = end });
|
||||||
|
}
|
||||||
|
else busy.Add(new Period { Start = start, End = end });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +176,7 @@ namespace Yavsc.Services
|
|||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(calid))
|
if (string.IsNullOrWhiteSpace(calid))
|
||||||
throw new Exception("the calendar identifier is not specified");
|
throw new Exception("the calendar identifier is not specified");
|
||||||
|
|
||||||
var service = await GetServiceAsync();
|
var service = await GetServiceAsync();
|
||||||
Event ev = new Event
|
Event ev = new Event
|
||||||
{
|
{
|
||||||
@ -217,15 +193,16 @@ namespace Yavsc.Services
|
|||||||
CalendarService _service = null;
|
CalendarService _service = null;
|
||||||
public async Task<CalendarService> GetServiceAsync()
|
public async Task<CalendarService> GetServiceAsync()
|
||||||
{
|
{
|
||||||
if (_service==null) {
|
if (_service == null)
|
||||||
|
{
|
||||||
GoogleCredential credential = await GoogleCredential.GetApplicationDefaultAsync();
|
GoogleCredential credential = await GoogleCredential.GetApplicationDefaultAsync();
|
||||||
var baseClientService = new BaseClientService.Initializer()
|
var baseClientService = new BaseClientService.Initializer()
|
||||||
{
|
{
|
||||||
HttpClientInitializer = credential
|
HttpClientInitializer = credential
|
||||||
};
|
};
|
||||||
if (credential.IsCreateScopedRequired)
|
if (credential.IsCreateScopedRequired)
|
||||||
{
|
{
|
||||||
credential = credential.CreateScoped( scopesCalendar );
|
credential = credential.CreateScoped(scopesCalendar);
|
||||||
}/*
|
}/*
|
||||||
var credential = await GoogleHelpers.GetCredentialForApi(new string [] { scopeCalendar });
|
var credential = await GoogleHelpers.GetCredentialForApi(new string [] { scopeCalendar });
|
||||||
if (credential.IsCreateScopedRequired)
|
if (credential.IsCreateScopedRequired)
|
||||||
@ -239,26 +216,26 @@ namespace Yavsc.Services
|
|||||||
});
|
});
|
||||||
}*/
|
}*/
|
||||||
_service = new CalendarService(new BaseClientService.Initializer()
|
_service = new CalendarService(new BaseClientService.Initializer()
|
||||||
{
|
{
|
||||||
HttpClientInitializer = credential,
|
HttpClientInitializer = credential,
|
||||||
ApplicationName = "Yavsc"
|
ApplicationName = "Yavsc"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return _service;
|
return _service;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates Google User Credential
|
/// Creates Google User Credential
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userId">Yavsc use id</param>
|
/// <param name="userId">Yavsc use id</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<CalendarService> CreateUserCalendarServiceAsync(string userId)
|
public async Task<CalendarService> CreateUserCalendarServiceAsync()
|
||||||
{
|
{
|
||||||
GoogleCredential credential = await GoogleCredential.GetApplicationDefaultAsync();
|
GoogleCredential credential = await GoogleCredential.GetApplicationDefaultAsync();
|
||||||
|
|
||||||
if (credential.IsCreateScopedRequired)
|
if (credential.IsCreateScopedRequired)
|
||||||
{
|
{
|
||||||
credential = credential.CreateScoped( scopesCalendar);
|
credential = credential.CreateScoped(scopesCalendar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -268,25 +245,32 @@ namespace Yavsc.Services
|
|||||||
ApplicationName = "yavsc-001"
|
ApplicationName = "yavsc-001"
|
||||||
});
|
});
|
||||||
|
|
||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<TokenResponse> RefreshToken(TokenResponse oldResponse)
|
public async Task<TokenResponse> RefreshToken(TokenResponse oldResponse)
|
||||||
{
|
{
|
||||||
string ep = " https://www.googleapis.com/oauth2/v4/token";
|
string ep = " https://www.googleapis.com/oauth2/v4/token";
|
||||||
_logger.LogInformation($"rt:{oldResponse.RefreshToken}");
|
_logger.LogInformation($"rt:{oldResponse.RefreshToken}");
|
||||||
// refresh_token client_id client_secret grant_type=refresh_token
|
// refresh_token client_id client_secret grant_type=refresh_token
|
||||||
try {
|
try
|
||||||
using (var m = new SimpleJsonPostMethod(ep)) {
|
{
|
||||||
|
using (var m = new SimpleJsonPostMethod(ep))
|
||||||
|
{
|
||||||
return await m.Invoke<TokenResponse>(
|
return await m.Invoke<TokenResponse>(
|
||||||
new { refresh_token= oldResponse.RefreshToken, client_id=_client_id,
|
new
|
||||||
client_secret=_client_secret,
|
{
|
||||||
grant_type="refresh_token" }
|
refresh_token = oldResponse.RefreshToken,
|
||||||
|
client_id = _client_id,
|
||||||
|
client_secret = _client_secret,
|
||||||
|
grant_type = "refresh_token"
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex)
|
||||||
throw new Exception ("Quelque chose s'est mal passé à l'envoi",ex);
|
{
|
||||||
|
throw new Exception("Quelque chose s'est mal passé à l'envoi", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,14 +21,15 @@ using Newtonsoft.Json;
|
|||||||
namespace Yavsc.Services
|
namespace Yavsc.Services
|
||||||
{
|
{
|
||||||
|
|
||||||
public class LiveProcessor : ILiveProcessor {
|
public class LiveProcessor : ILiveProcessor
|
||||||
IHubContext _hubContext;
|
{
|
||||||
private ILogger _logger;
|
readonly IHubContext _hubContext;
|
||||||
ApplicationDbContext _dbContext;
|
private readonly ILogger _logger;
|
||||||
public PathString LiveCastingPath {get; set;} = Constants.LivePath;
|
readonly ApplicationDbContext _dbContext;
|
||||||
|
public PathString LiveCastingPath { get; set; } = Constants.LivePath;
|
||||||
|
|
||||||
|
|
||||||
public ConcurrentDictionary<string, LiveCastHandler> Casters {get;} = new ConcurrentDictionary<string, LiveCastHandler>();
|
public ConcurrentDictionary<string, LiveCastHandler> Casters { get; } = new ConcurrentDictionary<string, LiveCastHandler>();
|
||||||
|
|
||||||
public LiveProcessor(ApplicationDbContext dbContext, ILoggerFactory loggerFactory)
|
public LiveProcessor(ApplicationDbContext dbContext, ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
@ -37,7 +38,7 @@ namespace Yavsc.Services
|
|||||||
_logger = loggerFactory.CreateLogger<LiveProcessor>();
|
_logger = loggerFactory.CreateLogger<LiveProcessor>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> AcceptStream (HttpContext context)
|
public async Task<bool> AcceptStream(HttpContext context)
|
||||||
{
|
{
|
||||||
// TODO defer request handling
|
// TODO defer request handling
|
||||||
var liveId = long.Parse(context.Request.Path.Value.Substring(LiveCastingPath.Value.Length + 1));
|
var liveId = long.Parse(context.Request.Path.Value.Substring(LiveCastingPath.Value.Length + 1));
|
||||||
@ -51,22 +52,23 @@ namespace Yavsc.Services
|
|||||||
context.Response.StatusCode = 400;
|
context.Response.StatusCode = 400;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("flow : "+flow.Title+" for "+uname);
|
_logger.LogInformation("flow : " + flow.Title + " for " + uname);
|
||||||
|
|
||||||
|
|
||||||
LiveCastHandler liveHandler = null;
|
LiveCastHandler liveHandler = null;
|
||||||
if (Casters.ContainsKey(uname))
|
if (Casters.ContainsKey(uname))
|
||||||
{
|
{
|
||||||
_logger.LogWarning($"Casters.ContainsKey({uname})");
|
_logger.LogWarning($"Casters.ContainsKey({uname})");
|
||||||
liveHandler = Casters[uname];
|
liveHandler = Casters[uname];
|
||||||
if (liveHandler.Socket.State == WebSocketState.Open || liveHandler.Socket.State == WebSocketState.Connecting )
|
if (liveHandler.Socket.State == WebSocketState.Open || liveHandler.Socket.State == WebSocketState.Connecting)
|
||||||
{
|
{
|
||||||
_logger.LogWarning($"Closing cx");
|
_logger.LogWarning($"Closing cx");
|
||||||
// FIXME loosed connexion should be detected & disposed else where
|
// FIXME loosed connexion should be detected & disposed else where
|
||||||
await liveHandler.Socket.CloseAsync( WebSocketCloseStatus.EndpointUnavailable, "one by user", CancellationToken.None);
|
await liveHandler.Socket.CloseAsync(WebSocketCloseStatus.EndpointUnavailable, "one by user", CancellationToken.None);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!liveHandler.TokenSource.IsCancellationRequested) {
|
if (!liveHandler.TokenSource.IsCancellationRequested)
|
||||||
|
{
|
||||||
liveHandler.TokenSource.Cancel();
|
liveHandler.TokenSource.Cancel();
|
||||||
}
|
}
|
||||||
liveHandler.Socket.Dispose();
|
liveHandler.Socket.Dispose();
|
||||||
@ -81,7 +83,7 @@ namespace Yavsc.Services
|
|||||||
}
|
}
|
||||||
_logger.LogInformation("Accepted web socket");
|
_logger.LogInformation("Accepted web socket");
|
||||||
// Dispatch the flow
|
// Dispatch the flow
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (liveHandler.Socket != null && liveHandler.Socket.State == WebSocketState.Open)
|
if (liveHandler.Socket != null && liveHandler.Socket.State == WebSocketState.Open)
|
||||||
@ -90,33 +92,33 @@ namespace Yavsc.Services
|
|||||||
// TODO: Handle the socket here.
|
// TODO: Handle the socket here.
|
||||||
// Find receivers: others in the chat room
|
// Find receivers: others in the chat room
|
||||||
// send them the flow
|
// send them the flow
|
||||||
var buffer = new byte[Constants.WebSocketsMaxBufLen+16];
|
var buffer = new byte[Constants.WebSocketsMaxBufLen];
|
||||||
var sBuffer = new ArraySegment<byte>(buffer);
|
var sBuffer = new ArraySegment<byte>(buffer);
|
||||||
_logger.LogInformation("Receiving bytes...");
|
_logger.LogInformation("Receiving bytes...");
|
||||||
|
|
||||||
WebSocketReceiveResult received = await liveHandler.Socket.ReceiveAsync(sBuffer, liveHandler.TokenSource.Token);
|
WebSocketReceiveResult received = await liveHandler.Socket.ReceiveAsync(sBuffer, liveHandler.TokenSource.Token);
|
||||||
int count = (received.Count<4)? 0 : buffer[0]*256*1024 +buffer[1]*1024+buffer[2]*256 + buffer[3];
|
|
||||||
|
|
||||||
_logger.LogInformation($"Received bytes : {count}");
|
_logger.LogInformation($"Received bytes : {received.Count}");
|
||||||
_logger.LogInformation($"Is the end : {received.EndOfMessage}");
|
_logger.LogInformation($"Is the end : {received.EndOfMessage}");
|
||||||
const string livePath = "live";
|
const string livePath = "live";
|
||||||
|
|
||||||
string destDir = context.User.InitPostToFileSystem(livePath);
|
string destDir = context.User.InitPostToFileSystem(livePath);
|
||||||
_logger.LogInformation($"Saving flow to {destDir}");
|
_logger.LogInformation($"Saving flow to {destDir}");
|
||||||
|
|
||||||
string fileName = flow.GetFileName();
|
string fileName = flow.GetFileName();
|
||||||
FileInfo destFileInfo = new FileInfo(Path.Combine(destDir, fileName));
|
FileInfo destFileInfo = new FileInfo(Path.Combine(destDir, fileName));
|
||||||
// this should end :-)
|
// this should end :-)
|
||||||
while (destFileInfo.Exists) {
|
while (destFileInfo.Exists)
|
||||||
|
{
|
||||||
flow.SequenceNumber++;
|
flow.SequenceNumber++;
|
||||||
fileName = flow.GetFileName();
|
fileName = flow.GetFileName();
|
||||||
destFileInfo = new FileInfo(Path.Combine(destDir, fileName));
|
destFileInfo = new FileInfo(Path.Combine(destDir, fileName));
|
||||||
}
|
}
|
||||||
var fsInputQueue = new Queue<ArraySegment<byte>>();
|
var fsInputQueue = new Queue<ArraySegment<byte>>();
|
||||||
|
|
||||||
bool endOfInput=false;
|
bool endOfInput = false;
|
||||||
fsInputQueue.Enqueue(sBuffer);
|
fsInputQueue.Enqueue(sBuffer);
|
||||||
var taskWritingToFs = liveHandler.ReceiveUserFile(user, _logger, destDir, fsInputQueue, fileName, flow.MediaType, ()=> endOfInput);
|
var taskWritingToFs = liveHandler.ReceiveUserFile(user, _logger, destDir, fsInputQueue, fileName, flow.MediaType, () => endOfInput);
|
||||||
var hubContext = GlobalHost.ConnectionManager.GetHubContext<ChatHub>();
|
var hubContext = GlobalHost.ConnectionManager.GetHubContext<ChatHub>();
|
||||||
|
|
||||||
hubContext.Clients.All.addPublicStream(new PublicStreamInfo
|
hubContext.Clients.All.addPublicStream(new PublicStreamInfo
|
||||||
@ -132,15 +134,18 @@ namespace Yavsc.Services
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
|
|
||||||
_logger.LogInformation($"Echoing {received.Count} bytes received in a {received.MessageType} message; Fin={received.EndOfMessage}");
|
_logger.LogInformation($"Echoing {received.Count} bytes received in a {received.MessageType} message; Fin={received.EndOfMessage}");
|
||||||
// Echo anything we receive
|
// Echo anything we receive
|
||||||
// and send to all listner found
|
// and send to all listner found
|
||||||
|
_logger.LogInformation($"{liveHandler.Listeners.Count} listeners");
|
||||||
foreach (var cliItem in liveHandler.Listeners)
|
foreach (var cliItem in liveHandler.Listeners)
|
||||||
{
|
{
|
||||||
var listenningSocket = cliItem.Value;
|
var listenningSocket = cliItem.Value;
|
||||||
if (listenningSocket.State == WebSocketState.Open) {
|
if (listenningSocket.State == WebSocketState.Open)
|
||||||
|
{
|
||||||
_logger.LogInformation(cliItem.Key);
|
_logger.LogInformation(cliItem.Key);
|
||||||
await listenningSocket.SendAsync(
|
await listenningSocket.SendAsync(
|
||||||
sBuffer, received.MessageType, received.EndOfMessage, liveHandler.TokenSource.Token);
|
sBuffer, received.MessageType, received.EndOfMessage, liveHandler.TokenSource.Token);
|
||||||
@ -150,43 +155,47 @@ namespace Yavsc.Services
|
|||||||
ToClose.Push(cliItem.Key);
|
ToClose.Push(cliItem.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffer = new byte[Constants.WebSocketsMaxBufLen+16];
|
|
||||||
|
if (!received.CloseStatus.HasValue)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("try and receive new bytes");
|
||||||
|
|
||||||
|
buffer = new byte[Constants.WebSocketsMaxBufLen];
|
||||||
sBuffer = new ArraySegment<byte>(buffer);
|
sBuffer = new ArraySegment<byte>(buffer);
|
||||||
received = await liveHandler.Socket.ReceiveAsync(sBuffer, liveHandler.TokenSource.Token);
|
received = await liveHandler.Socket.ReceiveAsync(sBuffer, liveHandler.TokenSource.Token);
|
||||||
count = (received.Count<4)? 0 : buffer[0]*256*1024 +buffer[1]*1024+buffer[2]*256 + buffer[3];
|
|
||||||
_logger.LogInformation($"Received bytes : {count}");
|
_logger.LogInformation($"Received bytes : {received.Count}");
|
||||||
_logger.LogInformation($"Is the end : {received.EndOfMessage}");
|
_logger.LogInformation($"Is the end : {received.EndOfMessage}");
|
||||||
if (received.Count<=4 || count > Constants.WebSocketsMaxBufLen) {
|
fsInputQueue.Enqueue(sBuffer);
|
||||||
if (received.CloseStatus.HasValue) {
|
if (received.CloseStatus.HasValue)
|
||||||
_logger.LogInformation($"received a close status: {received.CloseStatus.Value.ToString()}: {received.CloseStatusDescription}");
|
{
|
||||||
}
|
endOfInput=true;
|
||||||
else {
|
_logger.LogInformation($"received a close status: {received.CloseStatus.Value}: {received.CloseStatusDescription}");
|
||||||
_logger.LogError("Wrong packet size: "+count.ToString());
|
|
||||||
_logger.LogError(JsonConvert.SerializeObject(received));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else fsInputQueue.Enqueue(sBuffer);
|
}
|
||||||
while (ToClose.Count >0)
|
else endOfInput=true;
|
||||||
|
while (ToClose.Count > 0)
|
||||||
{
|
{
|
||||||
string no = ToClose.Pop();
|
string no = ToClose.Pop();
|
||||||
_logger.LogInformation("Closing follower connection");
|
_logger.LogInformation("Closing follower connection");
|
||||||
WebSocket listenningSocket;
|
WebSocket listenningSocket;
|
||||||
if (liveHandler.Listeners.TryRemove(no, out listenningSocket)) {
|
if (liveHandler.Listeners.TryRemove(no, out listenningSocket))
|
||||||
|
{
|
||||||
await listenningSocket.CloseAsync(WebSocketCloseStatus.EndpointUnavailable,
|
await listenningSocket.CloseAsync(WebSocketCloseStatus.EndpointUnavailable,
|
||||||
"State != WebSocketState.Open", CancellationToken.None);
|
"State != WebSocketState.Open", CancellationToken.None);
|
||||||
listenningSocket.Dispose();
|
listenningSocket.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (!received.CloseStatus.HasValue);
|
while (liveHandler.Socket.State == WebSocketState.Open);
|
||||||
_logger.LogInformation("Closing connection");
|
|
||||||
endOfInput=true;
|
|
||||||
taskWritingToFs.Wait();
|
|
||||||
await liveHandler.Socket.CloseAsync(WebSocketCloseStatus.NormalClosure, received.CloseStatusDescription,liveHandler.TokenSource.Token );
|
|
||||||
|
|
||||||
|
_logger.LogInformation("Closing connection");
|
||||||
|
taskWritingToFs.Wait();
|
||||||
|
await liveHandler.Socket.CloseAsync(WebSocketCloseStatus.NormalClosure, received.CloseStatusDescription, liveHandler.TokenSource.Token);
|
||||||
|
|
||||||
liveHandler.TokenSource.Cancel();
|
liveHandler.TokenSource.Cancel();
|
||||||
liveHandler.Dispose();
|
liveHandler.Dispose();
|
||||||
_logger.LogInformation("Resulting file : " +JsonConvert.SerializeObject(taskWritingToFs.Result));
|
_logger.LogInformation("Resulting file : " + JsonConvert.SerializeObject(taskWritingToFs.Result));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -200,16 +209,16 @@ namespace Yavsc.Services
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Socket was not accepted open ...
|
// Socket was not accepted open ...
|
||||||
// not (meta.Socket != null && meta.Socket.State == WebSocketState.Open)
|
// not (meta.Socket != null && meta.Socket.State == WebSocketState.Open)
|
||||||
if (liveHandler.Socket != null)
|
if (liveHandler.Socket != null)
|
||||||
{
|
{
|
||||||
_logger.LogError($"meta.Socket.State not Open: {liveHandler.Socket.State.ToString()} ");
|
_logger.LogError($"meta.Socket.State not Open: {liveHandler.Socket.State} ");
|
||||||
liveHandler.Socket.Dispose();
|
liveHandler.Socket.Dispose();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_logger.LogError("socket object is null");
|
_logger.LogError("socket object is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveLiveInfo(uname);
|
RemoveLiveInfo(uname);
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
@ -231,11 +240,11 @@ namespace Yavsc.Services
|
|||||||
void RemoveLiveInfo(string userName)
|
void RemoveLiveInfo(string userName)
|
||||||
{
|
{
|
||||||
LiveCastHandler caster;
|
LiveCastHandler caster;
|
||||||
if (Casters.TryRemove(userName, out caster))
|
if (Casters.TryRemove(userName, out caster))
|
||||||
_logger.LogInformation("removed live info");
|
_logger.LogInformation("removed live info");
|
||||||
else
|
else
|
||||||
_logger.LogError("could not remove live info");
|
_logger.LogError("could not remove live info");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,18 +12,14 @@ namespace Yavsc.Services
|
|||||||
{
|
{
|
||||||
public class MailSender : IEmailSender
|
public class MailSender : IEmailSender
|
||||||
{
|
{
|
||||||
private ILogger _logger;
|
readonly SiteSettings siteSettings;
|
||||||
SiteSettings siteSettings;
|
readonly SmtpSettings smtpSettings;
|
||||||
SmtpSettings smtpSettings;
|
|
||||||
|
|
||||||
public MailSender(
|
public MailSender(
|
||||||
ILoggerFactory loggerFactory,
|
|
||||||
IOptions<SiteSettings> sitesOptions,
|
IOptions<SiteSettings> sitesOptions,
|
||||||
IOptions<SmtpSettings> smtpOptions,
|
IOptions<SmtpSettings> smtpOptions
|
||||||
IOptions<GoogleAuthSettings> googleOptions
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_logger = loggerFactory.CreateLogger<MailSender>();
|
|
||||||
siteSettings = sitesOptions?.Value;
|
siteSettings = sitesOptions?.Value;
|
||||||
smtpSettings = smtpOptions?.Value;
|
smtpSettings = smtpOptions?.Value;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ namespace Yavsc.Services
|
|||||||
using Models.societe.com;
|
using Models.societe.com;
|
||||||
public class SIRENChecker
|
public class SIRENChecker
|
||||||
{
|
{
|
||||||
private CompanyInfoSettings _settings;
|
private readonly CompanyInfoSettings _settings;
|
||||||
public SIRENChecker(CompanyInfoSettings settings)
|
public SIRENChecker(CompanyInfoSettings settings)
|
||||||
{
|
{
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
|
@ -16,18 +16,16 @@ namespace Yavsc.Services
|
|||||||
{
|
{
|
||||||
public class YavscMessageSender : IYavscMessageSender
|
public class YavscMessageSender : IYavscMessageSender
|
||||||
{
|
{
|
||||||
private ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
IEmailSender _emailSender;
|
readonly IEmailSender _emailSender;
|
||||||
SiteSettings siteSettings;
|
readonly SiteSettings siteSettings;
|
||||||
private IHubContext hubContext;
|
private readonly IHubContext hubContext;
|
||||||
ApplicationDbContext _dbContext;
|
readonly ApplicationDbContext _dbContext;
|
||||||
|
readonly IConnexionManager _cxManager;
|
||||||
IConnexionManager _cxManager;
|
|
||||||
|
|
||||||
public YavscMessageSender(
|
public YavscMessageSender(
|
||||||
ILoggerFactory loggerFactory,
|
ILoggerFactory loggerFactory,
|
||||||
IOptions<SiteSettings> sitesOptions,
|
IOptions<SiteSettings> sitesOptions,
|
||||||
IOptions<SmtpSettings> smtpOptions,
|
|
||||||
IEmailSender emailSender,
|
IEmailSender emailSender,
|
||||||
ApplicationDbContext dbContext,
|
ApplicationDbContext dbContext,
|
||||||
IConnexionManager cxManager
|
IConnexionManager cxManager
|
||||||
@ -67,8 +65,10 @@ namespace Yavsc.Services
|
|||||||
foreach (var userId in raa)
|
foreach (var userId in raa)
|
||||||
{
|
{
|
||||||
_logger.LogDebug($"For performer id : {userId}");
|
_logger.LogDebug($"For performer id : {userId}");
|
||||||
MessageWithPayloadResponse.Result result = new MessageWithPayloadResponse.Result();
|
MessageWithPayloadResponse.Result result = new MessageWithPayloadResponse.Result
|
||||||
result.registration_id = userId;
|
{
|
||||||
|
registration_id = userId
|
||||||
|
};
|
||||||
|
|
||||||
var user = _dbContext.Users.FirstOrDefault(u => u.Id == userId);
|
var user = _dbContext.Users.FirstOrDefault(u => u.Id == userId);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
@ -125,8 +125,10 @@ namespace Yavsc.Services
|
|||||||
{
|
{
|
||||||
// from usr asp.net Id : var hubClient = hubContext.Clients.User(userId);
|
// from usr asp.net Id : var hubClient = hubContext.Clients.User(userId);
|
||||||
var hubClient = hubContext.Clients.Client(cxid);
|
var hubClient = hubContext.Clients.Client(cxid);
|
||||||
var data = new Dictionary<string, object>();
|
var data = new Dictionary<string, object>
|
||||||
data["event"] = JsonConvert.SerializeObject(ev);
|
{
|
||||||
|
["event"] = JsonConvert.SerializeObject(ev)
|
||||||
|
};
|
||||||
hubClient.push(ev.Topic, JsonConvert.SerializeObject(data));
|
hubClient.push(ev.Topic, JsonConvert.SerializeObject(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,8 +91,7 @@ namespace Yavsc
|
|||||||
//
|
//
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
private void ConfigureOAuthApp(IApplicationBuilder app,
|
private void ConfigureOAuthApp(IApplicationBuilder app)
|
||||||
SiteSettings settingsOptions, ILogger logger)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
app.UseIdentity();
|
app.UseIdentity();
|
||||||
|
@ -13,15 +13,9 @@ namespace Yavsc
|
|||||||
// * an AppData folder
|
// * an AppData folder
|
||||||
public partial class Startup
|
public partial class Startup
|
||||||
{
|
{
|
||||||
public void CheckServices(IServiceCollection services)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CheckApp(IApplicationBuilder app,
|
public void CheckApp(IHostingEnvironment env,
|
||||||
SiteSettings siteSettings, IHostingEnvironment env,
|
ILoggerFactory loggerFactory)
|
||||||
ILoggerFactory loggerFactory
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
var logger = loggerFactory.CreateLogger<Startup>();
|
var logger = loggerFactory.CreateLogger<Startup>();
|
||||||
|
@ -11,8 +11,7 @@ namespace Yavsc
|
|||||||
{
|
{
|
||||||
public partial class Startup
|
public partial class Startup
|
||||||
{
|
{
|
||||||
public void ConfigureWebSocketsApp(IApplicationBuilder app,
|
public void ConfigureWebSocketsApp(IApplicationBuilder app)
|
||||||
SiteSettings siteSettings, IHostingEnvironment env)
|
|
||||||
{
|
{
|
||||||
var webSocketOptions = new WebSocketOptions()
|
var webSocketOptions = new WebSocketOptions()
|
||||||
{
|
{
|
||||||
@ -25,7 +24,7 @@ namespace Yavsc
|
|||||||
app.UseSignalR(PathString.FromUriComponent(Constants.SignalRPath));
|
app.UseSignalR(PathString.FromUriComponent(Constants.SignalRPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Echo(HttpContext context, WebSocket webSocket)
|
private async Task Echo(WebSocket webSocket)
|
||||||
{
|
{
|
||||||
var buffer = new byte[1024 * 4];
|
var buffer = new byte[1024 * 4];
|
||||||
WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
|
WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
|
||||||
|
@ -30,7 +30,7 @@ namespace Yavsc
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly string[] Forms = new string[] { "Profiles", "HairCut" };
|
public static readonly string[] Forms = new string[] { "Profiles", "HairCut" };
|
||||||
|
|
||||||
private void ConfigureWorkflow(IApplicationBuilder app, SiteSettings settings, ILogger logger)
|
private void ConfigureWorkflow()
|
||||||
{
|
{
|
||||||
// System.AppDomain.CurrentDomain.ResourceResolve += OnYavscResourceResolve;
|
// System.AppDomain.CurrentDomain.ResourceResolve += OnYavscResourceResolve;
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ namespace Yavsc
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.LogError(ex.TargetSite.Name);
|
_logger.LogError(ex.TargetSite.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ namespace Yavsc
|
|||||||
// TODO swith () case {}
|
// TODO swith () case {}
|
||||||
if (typeof(IQueryable<ISpecializationSettings>).IsAssignableFrom(propinfo.PropertyType))
|
if (typeof(IQueryable<ISpecializationSettings>).IsAssignableFrom(propinfo.PropertyType))
|
||||||
{// double-bingo
|
{// double-bingo
|
||||||
logger.LogVerbose($"Pro: {propinfo.Name}");
|
_logger.LogVerbose($"Pro: {propinfo.Name}");
|
||||||
BillingService.UserSettings.Add(propinfo);
|
BillingService.UserSettings.Add(propinfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -75,7 +75,7 @@ namespace Yavsc
|
|||||||
base de donnée porte l'attribut [ActivitySetting],
|
base de donnée porte l'attribut [ActivitySetting],
|
||||||
mais n'implemente pas l'interface IQueryable<ISpecializationSettings>
|
mais n'implemente pas l'interface IQueryable<ISpecializationSettings>
|
||||||
({propinfo.MemberType.GetType()})";
|
({propinfo.MemberType.GetType()})";
|
||||||
logger.LogCritical(msg);
|
_logger.LogCritical(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,6 @@ namespace Yavsc
|
|||||||
{
|
{
|
||||||
options.ResourcesPath = "Resources";
|
options.ResourcesPath = "Resources";
|
||||||
});
|
});
|
||||||
CheckServices(services);
|
|
||||||
}
|
}
|
||||||
static ApplicationDbContext _dbContext;
|
static ApplicationDbContext _dbContext;
|
||||||
public static IServiceProvider Services { get; private set; }
|
public static IServiceProvider Services { get; private set; }
|
||||||
@ -288,7 +287,6 @@ namespace Yavsc
|
|||||||
IApplicationBuilder app, IHostingEnvironment env,
|
IApplicationBuilder app, IHostingEnvironment env,
|
||||||
ApplicationDbContext dbContext, IOptions<SiteSettings> siteSettings,
|
ApplicationDbContext dbContext, IOptions<SiteSettings> siteSettings,
|
||||||
IOptions<RequestLocalizationOptions> localizationOptions,
|
IOptions<RequestLocalizationOptions> localizationOptions,
|
||||||
IOptions<OAuth2AppSettings> oauth2SettingsContainer,
|
|
||||||
IAuthorizationService authorizationService,
|
IAuthorizationService authorizationService,
|
||||||
IOptions<PayPalSettings> payPalSettings,
|
IOptions<PayPalSettings> payPalSettings,
|
||||||
IOptions<GoogleAuthSettings> googleSettings,
|
IOptions<GoogleAuthSettings> googleSettings,
|
||||||
@ -355,8 +353,10 @@ namespace Yavsc
|
|||||||
|
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
app.UseRuntimeInfoPage();
|
app.UseRuntimeInfoPage();
|
||||||
var epo = new ErrorPageOptions();
|
var epo = new ErrorPageOptions
|
||||||
epo.SourceCodeLineCount = 20;
|
{
|
||||||
|
SourceCodeLineCount = 20
|
||||||
|
};
|
||||||
app.UseDeveloperExceptionPage(epo);
|
app.UseDeveloperExceptionPage(epo);
|
||||||
app.UseDatabaseErrorPage(
|
app.UseDatabaseErrorPage(
|
||||||
x =>
|
x =>
|
||||||
@ -404,19 +404,22 @@ namespace Yavsc
|
|||||||
});
|
});
|
||||||
app.UseSession();
|
app.UseSession();
|
||||||
|
|
||||||
ConfigureOAuthApp(app, SiteSetup, _logger);
|
ConfigureOAuthApp(app);
|
||||||
ConfigureFileServerApp(app, SiteSetup, env, authorizationService);
|
ConfigureFileServerApp(app, SiteSetup, env, authorizationService);
|
||||||
app.UseRequestLocalization(localizationOptions.Value, (RequestCulture)new RequestCulture((string)"en-US"));
|
app.UseRequestLocalization(localizationOptions.Value, (RequestCulture)new RequestCulture((string)"en-US"));
|
||||||
|
|
||||||
ConfigureWorkflow(app, SiteSetup, _logger);
|
ConfigureWorkflow();
|
||||||
|
|
||||||
// Empty this odd chat user list from db
|
// Empty this odd chat user list from db
|
||||||
|
/*
|
||||||
foreach (var p in dbContext.ChatConnection)
|
foreach (var p in dbContext.ChatConnection)
|
||||||
{
|
{
|
||||||
dbContext.Entry(p).State = EntityState.Deleted;
|
dbContext.Entry(p).State = EntityState.Deleted;
|
||||||
}
|
}
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
|
FIXME */
|
||||||
|
|
||||||
ConfigureWebSocketsApp(app, SiteSetup, env);
|
ConfigureWebSocketsApp(app);
|
||||||
|
|
||||||
app.UseMvc(routes =>
|
app.UseMvc(routes =>
|
||||||
{
|
{
|
||||||
@ -451,7 +454,7 @@ namespace Yavsc
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
CheckApp(app, SiteSetup, env, loggerFactory);
|
CheckApp( env, loggerFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entry point for the application.
|
// Entry point for the application.
|
||||||
|
@ -16,20 +16,17 @@ namespace Yavsc.ViewComponents
|
|||||||
{
|
{
|
||||||
public class BillViewComponent : ViewComponent
|
public class BillViewComponent : ViewComponent
|
||||||
{
|
{
|
||||||
ApplicationDbContext dbContext;
|
readonly ApplicationDbContext dbContext;
|
||||||
IBillingService billing;
|
readonly IBillingService billing;
|
||||||
IStringLocalizer<Yavsc.YavscLocalisation> localizer;
|
readonly IStringLocalizer<Yavsc.YavscLocalisation> localizer;
|
||||||
ILogger logger ;
|
|
||||||
|
|
||||||
public BillViewComponent(ApplicationDbContext dbContext,
|
public BillViewComponent(ApplicationDbContext dbContext,
|
||||||
IStringLocalizer<Yavsc.YavscLocalisation> localizer,
|
IStringLocalizer<Yavsc.YavscLocalisation> localizer,
|
||||||
IBillingService billing,
|
IBillingService billing)
|
||||||
ILoggerFactory loggerFactory)
|
|
||||||
{
|
{
|
||||||
this.billing = billing;
|
this.billing = billing;
|
||||||
this.dbContext = dbContext;
|
this.dbContext = dbContext;
|
||||||
this.localizer = localizer;
|
this.localizer = localizer;
|
||||||
logger = loggerFactory.CreateLogger<BillViewComponent>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IViewComponentResult> InvokeAsync(string code, IBillable billable, OutputFormat format, bool asBill)
|
public async Task<IViewComponentResult> InvokeAsync(string code, IBillable billable, OutputFormat format, bool asBill)
|
||||||
|
@ -13,19 +13,11 @@ namespace Yavsc.ViewComponents
|
|||||||
{
|
{
|
||||||
public class BlogIndexViewComponent: ViewComponent
|
public class BlogIndexViewComponent: ViewComponent
|
||||||
{
|
{
|
||||||
ILogger _logger;
|
private readonly ApplicationDbContext _context;
|
||||||
private ApplicationDbContext _context;
|
|
||||||
private IAuthorizationService _authorizationService;
|
|
||||||
public BlogIndexViewComponent(
|
public BlogIndexViewComponent(
|
||||||
ApplicationDbContext context,
|
ApplicationDbContext context)
|
||||||
UserManager<ApplicationUser> userManager,
|
|
||||||
ILoggerFactory loggerFactory,
|
|
||||||
IAuthorizationService authorizationService,
|
|
||||||
IOptions<SiteSettings> siteSettings)
|
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_logger = loggerFactory.CreateLogger<BlogIndexViewComponent>();
|
|
||||||
_authorizationService = authorizationService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renders blog index ofr the specified user by name
|
// Renders blog index ofr the specified user by name
|
||||||
|
@ -8,8 +8,8 @@ namespace Yavsc.ViewComponents
|
|||||||
{
|
{
|
||||||
public class CalendarViewComponent : ViewComponent
|
public class CalendarViewComponent : ViewComponent
|
||||||
{
|
{
|
||||||
ApplicationDbContext _dbContext;
|
readonly ApplicationDbContext _dbContext;
|
||||||
ICalendarManager _manager;
|
readonly ICalendarManager _manager;
|
||||||
|
|
||||||
public CalendarViewComponent (
|
public CalendarViewComponent (
|
||||||
ApplicationDbContext dbContext,
|
ApplicationDbContext dbContext,
|
||||||
@ -47,4 +47,4 @@ namespace Yavsc.ViewComponents
|
|||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,17 +9,14 @@ namespace Yavsc.ViewComponents
|
|||||||
public class TaggerViewComponent : ViewComponent
|
public class TaggerViewComponent : ViewComponent
|
||||||
|
|
||||||
{
|
{
|
||||||
ApplicationDbContext dbContext;
|
readonly ApplicationDbContext dbContext;
|
||||||
IStringLocalizer<TaggerViewComponent> localizer;
|
readonly IStringLocalizer<TaggerViewComponent> localizer;
|
||||||
ILogger logger ;
|
|
||||||
public TaggerViewComponent(
|
public TaggerViewComponent(
|
||||||
ApplicationDbContext pdbContext,
|
ApplicationDbContext pdbContext,
|
||||||
IStringLocalizer<TaggerViewComponent> pLocalizer,
|
IStringLocalizer<TaggerViewComponent> pLocalizer)
|
||||||
ILoggerFactory loggerFactory)
|
|
||||||
{
|
{
|
||||||
dbContext = pdbContext;
|
dbContext = pdbContext;
|
||||||
this.localizer = pLocalizer;
|
this.localizer = pLocalizer;
|
||||||
this.logger = loggerFactory.CreateLogger<TaggerViewComponent>();
|
|
||||||
}
|
}
|
||||||
public IViewComponentResult Invoke(ITaggable<long> longTaggable)
|
public IViewComponentResult Invoke(ITaggable<long> longTaggable)
|
||||||
{
|
{
|
||||||
@ -29,4 +26,4 @@ namespace Yavsc.ViewComponents
|
|||||||
return View(longTaggable);
|
return View(longTaggable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,12 @@ namespace Yavsc.ViewModels.Streaming
|
|||||||
// this process is not safe at concurrent access.
|
// this process is not safe at concurrent access.
|
||||||
long usage = user.DiskUsage;
|
long usage = user.DiskUsage;
|
||||||
|
|
||||||
var item = new FileRecievedInfo();
|
var item = new FileRecievedInfo
|
||||||
item.FileName = AbstractFileSystemHelpers.FilterFileName (destFileName);
|
{
|
||||||
item.MimeType = contentType;
|
FileName = AbstractFileSystemHelpers.FilterFileName(destFileName),
|
||||||
item.DestDir = root;
|
MimeType = contentType,
|
||||||
|
DestDir = root
|
||||||
|
};
|
||||||
var fi = new FileInfo(Path.Combine(root, item.FileName));
|
var fi = new FileInfo(Path.Combine(root, item.FileName));
|
||||||
if (fi.Exists)
|
if (fi.Exists)
|
||||||
{
|
{
|
||||||
@ -59,26 +61,17 @@ namespace Yavsc.ViewModels.Streaming
|
|||||||
{
|
{
|
||||||
if (queue.Count>0) {
|
if (queue.Count>0) {
|
||||||
var buffer = queue.Dequeue();
|
var buffer = queue.Dequeue();
|
||||||
int count = buffer.Array[0]*256*1024 +buffer.Array[1]*1024+buffer.Array[2]*256 + buffer.Array[3];
|
|
||||||
|
|
||||||
if (count >0 && count <= Constants.WebSocketsMaxBufLen
|
logger.LogInformation($"writing {buffer.Array.Length} bytes...");
|
||||||
&& buffer.Array.Length >= count+4) {
|
|
||||||
logger.LogInformation($"writing {count} bytes from {buffer.Array.Length}.");
|
|
||||||
|
|
||||||
await dest.WriteAsync(buffer.Array, 4, count);
|
await dest.WriteAsync(buffer.Array, 0, buffer.Array.Length);
|
||||||
logger.LogInformation($"wrote {count} bytes.");
|
logger.LogInformation($"done.");
|
||||||
usage += count;
|
usage += buffer.Array.Length;
|
||||||
}
|
|
||||||
else {
|
|
||||||
var packetInfo = JsonConvert.SerializeObject(buffer);
|
|
||||||
logger.LogError($"didn´t wrote {count} bytes from {buffer.Array.Length}!\n{packetInfo}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (usage >= user.DiskQuota) break;
|
if (usage >= user.DiskQuota) break;
|
||||||
if (queue.Count==0 && !isEndOfInput()) {
|
if (queue.Count==0 && !isEndOfInput()) {
|
||||||
logger.LogInformation($"Waitting 200ms.");
|
|
||||||
await Task.Delay(100);
|
await Task.Delay(100);
|
||||||
logger.LogInformation($"Done waiting");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
user.DiskUsage = usage;
|
user.DiskUsage = usage;
|
||||||
@ -93,4 +86,4 @@ namespace Yavsc.ViewModels.Streaming
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,12 @@ namespace cli.Commands
|
|||||||
private CommandOption _secret;
|
private CommandOption _secret;
|
||||||
private CommandOption _scope;
|
private CommandOption _scope;
|
||||||
private CommandOption _save;
|
private CommandOption _save;
|
||||||
|
readonly ILogger _logger;
|
||||||
ILogger _logger;
|
|
||||||
|
|
||||||
public AuthCommander(ILoggerFactory loggerFactory)
|
public AuthCommander(ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
_logger = loggerFactory.CreateLogger<AuthCommander>();
|
_logger = loggerFactory.CreateLogger<AuthCommander>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandLineApplication Integrate(CommandLineApplication rootApp)
|
public CommandLineApplication Integrate(CommandLineApplication rootApp)
|
||||||
{
|
{
|
||||||
@ -32,37 +31,41 @@ namespace cli.Commands
|
|||||||
target.FullName = "Authentication methods";
|
target.FullName = "Authentication methods";
|
||||||
target.Description = "Login, save credentials and get authorized.";
|
target.Description = "Login, save credentials and get authorized.";
|
||||||
target.HelpOption("-? | -h | --help");
|
target.HelpOption("-? | -h | --help");
|
||||||
var loginCommand = target.Command("login", app => {
|
var loginCommand = target.Command("login", app =>
|
||||||
|
{
|
||||||
_login = app.Argument("login", "login to use", true);
|
_login = app.Argument("login", "login to use", true);
|
||||||
_apiKey = app.Option("-a | --api", "API key to use against authorization server", CommandOptionType.SingleValue);
|
_apiKey = app.Option("-a | --api", "API key to use against authorization server", CommandOptionType.SingleValue);
|
||||||
_secret = app.Option( "-e | --secret", "Secret phrase associated to API key", CommandOptionType.SingleValue);
|
_secret = app.Option("-e | --secret", "Secret phrase associated to API key", CommandOptionType.SingleValue);
|
||||||
_scope = app.Option( "-c | --scope", "invoked scope asking for a security token", CommandOptionType.SingleValue);
|
_scope = app.Option("-c | --scope", "invoked scope asking for a security token", CommandOptionType.SingleValue);
|
||||||
_save = app.Option( "-s | --save", "Save authentication token to given file", CommandOptionType.SingleValue);
|
_save = app.Option("-s | --save", "Save authentication token to given file", CommandOptionType.SingleValue);
|
||||||
app.HelpOption("-? | -h | --help");
|
app.HelpOption("-? | -h | --help");
|
||||||
} );
|
});
|
||||||
loginCommand.OnExecute(async ()=>
|
loginCommand.OnExecute(async () =>
|
||||||
{
|
{
|
||||||
var authUrl = Startup.ConnectionSettings.AuthorizeUrl;
|
string authUrl = Startup.ConnectionSettings.AuthorizeUrl;
|
||||||
var redirect = Startup.ConnectionSettings.RedirectUrl;
|
string redirect = Startup.ConnectionSettings.RedirectUrl;
|
||||||
var tokenUrl = Startup.ConnectionSettings.AccessTokenUrl;
|
string tokenUrl = Startup.ConnectionSettings.AccessTokenUrl;
|
||||||
|
|
||||||
var oauthor = new OAuthenticator(_apiKey.HasValue() ? _apiKey.Value() : Startup.ConnectionSettings.ClientId,
|
OAuthenticator oauthor = new OAuthenticator(_apiKey.HasValue() ? _apiKey.Value() : Startup.ConnectionSettings.ClientId,
|
||||||
_secret.HasValue() ? _secret.Value() : Startup.ConnectionSettings.ClientSecret,
|
_secret.HasValue() ? _secret.Value() : Startup.ConnectionSettings.ClientSecret,
|
||||||
_scope.HasValue() ? _scope.Value() : Startup.ConnectionSettings.Scope,
|
_scope.HasValue() ? _scope.Value() : Startup.ConnectionSettings.Scope,
|
||||||
new Uri(authUrl), new Uri(redirect), new Uri(tokenUrl));
|
new Uri(authUrl), new Uri(redirect), new Uri(tokenUrl));
|
||||||
var query = new Dictionary<string, string>();
|
Dictionary<string, string> query = new Dictionary<string, string>
|
||||||
query["username"] = _login.Value;
|
{
|
||||||
query["password"] = GetPassword(_login.Value);
|
["username"] = _login.Value,
|
||||||
query["grant_type"] = "password";
|
["password"] = GetPassword(_login.Value),
|
||||||
try {
|
["grant_type"] = "password"
|
||||||
|
};
|
||||||
|
try
|
||||||
|
{
|
||||||
var result = await oauthor.RequestAccessTokenAsync(query);
|
var result = await oauthor.RequestAccessTokenAsync(query);
|
||||||
Startup.UserConnectionSettings.AccessToken = result["access_token"];
|
Startup.UserConnectionSettings.AccessToken = result["access_token"];
|
||||||
Startup.UserConnectionSettings.ExpiresIn = result["expires_in"];
|
Startup.UserConnectionSettings.ExpiresIn = result["expires_in"];
|
||||||
Startup.UserConnectionSettings.RefreshToken = result["refresh_token"];
|
Startup.UserConnectionSettings.RefreshToken = result["refresh_token"];
|
||||||
Startup.UserConnectionSettings.TokenType = result["token_type"];
|
Startup.UserConnectionSettings.TokenType = result["token_type"];
|
||||||
Startup.UserConnectionSettings.UserName = _login.Value;
|
Startup.UserConnectionSettings.UserName = _login.Value;
|
||||||
Startup.SaveCredentials(_save.HasValue() ? _save.Value() : Startup.UserConnectionsettingsFileName);
|
Startup.SaveCredentials(_save.HasValue() ? _save.Value() : Startup.UserConnectionsettingsFileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -112,6 +115,6 @@ namespace cli.Commands
|
|||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
return pwd.ToString();
|
return pwd.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,10 @@ using System.IO;
|
|||||||
using Yavsc.Server.Models.IT;
|
using Yavsc.Server.Models.IT;
|
||||||
using Yavsc.Server.Models.IT.SourceCode;
|
using Yavsc.Server.Models.IT.SourceCode;
|
||||||
|
|
||||||
public class Builder {
|
public class Builder
|
||||||
string _gitRepository;
|
{
|
||||||
private Project _projectInfo;
|
readonly string _gitRepository;
|
||||||
|
private readonly Project _projectInfo;
|
||||||
|
|
||||||
public Builder()
|
public Builder()
|
||||||
{
|
{
|
||||||
@ -21,4 +22,4 @@ public class Builder {
|
|||||||
clone.Launch(_projectInfo);
|
clone.Launch(_projectInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,6 @@ namespace cli.Commands
|
|||||||
logger.LogInformation($"Using parameters : modelFullName:{modelFullName} nameSpace:{nameSpace} dbContext:{dbContext} controllerName:{controllerName} relativePath:{relativePath}");
|
logger.LogInformation($"Using parameters : modelFullName:{modelFullName} nameSpace:{nameSpace} dbContext:{dbContext} controllerName:{controllerName} relativePath:{relativePath}");
|
||||||
|
|
||||||
generator.Generate(modelFullName,
|
generator.Generate(modelFullName,
|
||||||
nameSpace,
|
|
||||||
dbContext,
|
dbContext,
|
||||||
controllerName,
|
controllerName,
|
||||||
relativePath);
|
relativePath);
|
||||||
@ -70,4 +69,4 @@ namespace cli.Commands
|
|||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,10 @@ using Yavsc.Abstract;
|
|||||||
namespace cli {
|
namespace cli {
|
||||||
|
|
||||||
public class Streamer: ICommander {
|
public class Streamer: ICommander {
|
||||||
private ClientWebSocket _client;
|
private readonly ClientWebSocket _client;
|
||||||
private ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private ConnectionSettings _cxSettings;
|
private readonly ConnectionSettings _cxSettings;
|
||||||
private UserConnectionSettings _userCxSettings;
|
private readonly UserConnectionSettings _userCxSettings;
|
||||||
private CommandOption _fileOption;
|
private CommandOption _fileOption;
|
||||||
private CommandArgument _flowIdArg;
|
private CommandArgument _flowIdArg;
|
||||||
private CancellationTokenSource _tokenSource;
|
private CancellationTokenSource _tokenSource;
|
||||||
@ -83,42 +83,22 @@ namespace cli {
|
|||||||
await _client.ConnectAsync(new Uri(url), _tokenSource.Token);
|
await _client.ConnectAsync(new Uri(url), _tokenSource.Token);
|
||||||
_logger.LogInformation("Connected");
|
_logger.LogInformation("Connected");
|
||||||
const int bufLen = Yavsc.Constants.WebSocketsMaxBufLen;
|
const int bufLen = Yavsc.Constants.WebSocketsMaxBufLen;
|
||||||
byte [] buffer = new byte[bufLen+4*sizeof(int)];
|
byte [] buffer = new byte[bufLen];
|
||||||
const int offset=0;
|
const int offset=0;
|
||||||
int read = 0;
|
int read;
|
||||||
/*
|
bool lastFrame;
|
||||||
var reciving = Task.Run(async ()=> {
|
|
||||||
byte [] readbuffer = new byte[bufLen];
|
|
||||||
var rb = new ArraySegment<byte>(readbuffer, 0, bufLen);
|
|
||||||
bool continueReading = false;
|
|
||||||
do {
|
|
||||||
var result = await _client.ReceiveAsync(rb, _tokenSource.Token);
|
|
||||||
_logger.LogInformation($"received {result.Count} bytes");
|
|
||||||
continueReading = !result.CloseStatus.HasValue;
|
|
||||||
} while (continueReading);
|
|
||||||
} ); */
|
|
||||||
|
|
||||||
do {
|
WebSocketMessageType pckType = WebSocketMessageType.Binary;
|
||||||
read = await stream.ReadAsync(buffer, offset + sizeof(int), bufLen);
|
do
|
||||||
if (read>0) {
|
{
|
||||||
// assert sizeof(int)==4
|
read = await stream.ReadAsync(buffer, offset, bufLen);
|
||||||
buffer[3]= (byte) (read % 256);
|
lastFrame = read < Yavsc.Constants.WebSocketsMaxBufLen;
|
||||||
var left = read / 256;
|
ArraySegment<byte> segment = new ArraySegment<byte>(buffer, offset, read);
|
||||||
buffer[2]= (byte) (left % 256);
|
await _client.SendAsync(new ArraySegment<byte>(buffer), pckType, lastFrame, _tokenSource.Token);
|
||||||
left = left / 256;
|
_logger.LogInformation($"sent {segment.Count} ");
|
||||||
buffer[1] = (byte) (left % 256);
|
} while (!lastFrame);
|
||||||
left = left /256;
|
_logger.LogInformation($"Closing socket");
|
||||||
buffer[0]=(byte) (byte) (left % 256);
|
await _client.CloseAsync(WebSocketCloseStatus.NormalClosure, "EOF", _tokenSource.Token);
|
||||||
var segment = new ArraySegment<byte>(buffer, offset, read+4);
|
|
||||||
|
|
||||||
|
|
||||||
await _client.SendAsync(new ArraySegment<byte>(buffer), WebSocketMessageType.Binary, false, _tokenSource.Token);
|
|
||||||
_logger.LogInformation($"sent {segment.Count} ");
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (read>0);
|
|
||||||
// reciving.Wait();
|
|
||||||
await _client.CloseAsync(WebSocketCloseStatus.NormalClosure, "EOF", _tokenSource.Token);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,15 +13,9 @@ namespace cli.Helpers
|
|||||||
return commander.Integrate(rootApp);
|
return commander.Integrate(rootApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static OAuthenticator OAuthorInstance { get; set; }
|
public static OAuthenticator OAuthorInstance { get; private set; }
|
||||||
public static OAuthenticator InitAuthor(
|
public static OAuthenticator InitAuthor(
|
||||||
this ConnectionSettings settings,
|
this ConnectionSettings settings)
|
||||||
string clientId,
|
|
||||||
string clientSecret,
|
|
||||||
string scope,
|
|
||||||
string authorizeUrl,
|
|
||||||
string redirectUrl,
|
|
||||||
string accessTokenUrl)
|
|
||||||
{
|
{
|
||||||
return OAuthorInstance = new OAuthenticator(settings.ClientId,
|
return OAuthorInstance = new OAuthenticator(settings.ClientId,
|
||||||
settings.ClientSecret,
|
settings.ClientSecret,
|
||||||
@ -71,4 +65,4 @@ namespace cli.Helpers
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ using Microsoft.Extensions.Configuration;
|
|||||||
|
|
||||||
namespace Yavsc.Server
|
namespace Yavsc.Server
|
||||||
{
|
{
|
||||||
public class cliServerFactory : IServerFactory
|
public class CliServerFactory : IServerFactory
|
||||||
{
|
{
|
||||||
public IFeatureCollection Initialize(IConfiguration configuration)
|
public IFeatureCollection Initialize(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
|
@ -65,23 +65,27 @@ namespace cli
|
|||||||
|
|
||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
// create a service provider with the HostEnvironment.
|
// create a service provider with the HostEnvironment.
|
||||||
HostingEnvironment = new HostingEnvironment();
|
HostingEnvironment = new HostingEnvironment
|
||||||
HostingEnvironment.EnvironmentName = appEnv.Configuration;
|
{
|
||||||
|
EnvironmentName = appEnv.Configuration
|
||||||
|
};
|
||||||
|
|
||||||
var startup = new Startup(HostingEnvironment, appEnv);
|
var startup = new Startup(HostingEnvironment, appEnv);
|
||||||
startup.ConfigureServices(services);
|
startup.ConfigureServices(services);
|
||||||
services.AddInstance<IHostingEnvironment>(HostingEnvironment);
|
services.AddInstance<IHostingEnvironment>(HostingEnvironment);
|
||||||
var serviceProvider = services.BuildServiceProvider();
|
var serviceProvider = services.BuildServiceProvider();
|
||||||
|
|
||||||
var app = new ApplicationBuilder(serviceProvider);
|
var app = new ApplicationBuilder(serviceProvider)
|
||||||
app.ApplicationServices = serviceProvider;
|
{
|
||||||
|
ApplicationServices = serviceProvider
|
||||||
|
};
|
||||||
|
|
||||||
var siteSettings = serviceProvider.GetRequiredService<IOptions<SiteSettings>>();
|
var siteSettings = serviceProvider.GetRequiredService<IOptions<SiteSettings>>();
|
||||||
var cxSettings = serviceProvider.GetRequiredService<IOptions<ConnectionSettings>>();
|
var cxSettings = serviceProvider.GetRequiredService<IOptions<ConnectionSettings>>();
|
||||||
var userCxSettings = serviceProvider.GetRequiredService<IOptions<UserConnectionSettings>>();
|
var userCxSettings = serviceProvider.GetRequiredService<IOptions<UserConnectionSettings>>();
|
||||||
var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
|
var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
|
||||||
|
|
||||||
startup.Configure(app, HostingEnvironment, siteSettings, cxSettings, userCxSettings, loggerFactory);
|
startup.Configure(cxSettings, userCxSettings, loggerFactory);
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
@ -95,12 +99,14 @@ namespace cli
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
public static int Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
CommandLineApplication cliapp = new CommandLineApplication(false);
|
CommandLineApplication cliapp = new CommandLineApplication(false)
|
||||||
cliapp.Name = "cli";
|
{
|
||||||
cliapp.FullName = "Yavsc command line interface";
|
Name = "cli",
|
||||||
cliapp.Description = "Dnx console app for yavsc server side";
|
FullName = "Yavsc command line interface",
|
||||||
cliapp.ShortVersionGetter = () => "v1.0";
|
Description = "Dnx console app for yavsc server side",
|
||||||
cliapp.LongVersionGetter = () => "version 1.0 (stable)";
|
ShortVersionGetter = () => "v1.0",
|
||||||
|
LongVersionGetter = () => "version 1.0 (stable)"
|
||||||
|
};
|
||||||
|
|
||||||
// calling a Startup sequence
|
// calling a Startup sequence
|
||||||
var appBuilder = ConfigureApplication();
|
var appBuilder = ConfigureApplication();
|
||||||
|
@ -26,13 +26,12 @@ namespace cli.Services
|
|||||||
const string DefaultBaseClassName = "ATemplate";
|
const string DefaultBaseClassName = "ATemplate";
|
||||||
const string DefaultBaseClass = nameof(UserOrientedTemplate);
|
const string DefaultBaseClass = nameof(UserOrientedTemplate);
|
||||||
const string DefaultNamespace = "CompiledRazorTemplates";
|
const string DefaultNamespace = "CompiledRazorTemplates";
|
||||||
|
readonly RazorTemplateEngine razorEngine;
|
||||||
RazorTemplateEngine razorEngine;
|
readonly IStringLocalizer<EMailer> stringLocalizer;
|
||||||
IStringLocalizer<EMailer> stringLocalizer;
|
readonly ILogger logger;
|
||||||
ILogger logger;
|
readonly ApplicationDbContext dbContext;
|
||||||
ApplicationDbContext dbContext;
|
readonly IEmailSender mailSender;
|
||||||
IEmailSender mailSender;
|
readonly RazorEngineHost host;
|
||||||
RazorEngineHost host;
|
|
||||||
|
|
||||||
public EMailer(ApplicationDbContext context, IEmailSender sender, IStringLocalizer<EMailer> localizer, ILoggerFactory loggerFactory)
|
public EMailer(ApplicationDbContext context, IEmailSender sender, IStringLocalizer<EMailer> localizer, ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
|
@ -7,9 +7,9 @@ namespace cli.Services
|
|||||||
|
|
||||||
public class MvcGenerator : CommandLineGenerator
|
public class MvcGenerator : CommandLineGenerator
|
||||||
{
|
{
|
||||||
CommandLineGeneratorModel _model;
|
readonly CommandLineGeneratorModel _model;
|
||||||
ILogger _logger;
|
readonly ILogger _logger;
|
||||||
public MvcGenerator (IServiceProvider services, ILoggerFactory loggerFactory): base (services)
|
public MvcGenerator(IServiceProvider services, ILoggerFactory loggerFactory) : base(services)
|
||||||
{
|
{
|
||||||
_model = new CommandLineGeneratorModel();
|
_model = new CommandLineGeneratorModel();
|
||||||
_logger = loggerFactory.CreateLogger<MvcGenerator>();
|
_logger = loggerFactory.CreateLogger<MvcGenerator>();
|
||||||
@ -17,7 +17,6 @@ namespace cli.Services
|
|||||||
|
|
||||||
public async void Generate(
|
public async void Generate(
|
||||||
string modelClass,
|
string modelClass,
|
||||||
string ns,
|
|
||||||
string dbContextFullName,
|
string dbContextFullName,
|
||||||
string controllerName,
|
string controllerName,
|
||||||
string relativeFolderPath
|
string relativeFolderPath
|
||||||
@ -33,4 +32,4 @@ namespace cli.Services
|
|||||||
await GenerateCode(_model);
|
await GenerateCode(_model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,8 +250,7 @@ Microsoft.Extensions.CodeGeneration.ICodeGeneratorActionsService),
|
|||||||
Services = services;
|
Services = services;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env,
|
public void Configure(
|
||||||
IOptions<SiteSettings> siteSettings,
|
|
||||||
IOptions<ConnectionSettings> cxSettings,
|
IOptions<ConnectionSettings> cxSettings,
|
||||||
IOptions<UserConnectionSettings> useCxSettings,
|
IOptions<UserConnectionSettings> useCxSettings,
|
||||||
ILoggerFactory loggerFactory)
|
ILoggerFactory loggerFactory)
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
"Microsoft.Extensions.WebEncoders.Core": "1.0.0-rc1-final",
|
"Microsoft.Extensions.WebEncoders.Core": "1.0.0-rc1-final",
|
||||||
"Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
|
"Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
|
||||||
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
|
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
|
||||||
"Newtonsoft.Json": "6.0.1-beta1",
|
"Newtonsoft.Json": "7.0.1",
|
||||||
"NJsonSchema.CodeGeneration.CSharp": "10.0.27",
|
"NJsonSchema.CodeGeneration.CSharp": "10.0.27",
|
||||||
"Yavsc": {
|
"Yavsc": {
|
||||||
"target": "project"
|
"target": "project"
|
||||||
|
@ -15,25 +15,26 @@ namespace testOauthClient.Controllers
|
|||||||
public class HomeController : Controller
|
public class HomeController : Controller
|
||||||
{
|
{
|
||||||
readonly ILogger _logger;
|
readonly ILogger _logger;
|
||||||
|
|
||||||
public class GCMRegistrationRecord {
|
public class GCMRegistrationRecord
|
||||||
public string GCMRegistrationId { get; set; } = "testGoogleRegistrationIdValue";
|
{
|
||||||
public string DeviceId { get; set; }= "TestDeviceId";
|
public string GCMRegistrationId { get; set; } = "testGoogleRegistrationIdValue";
|
||||||
public string Model { get; set; }= "TestModel";
|
public string DeviceId { get; set; } = "TestDeviceId";
|
||||||
public string Platform { get; set; }= "External Web";
|
public string Model { get; set; } = "TestModel";
|
||||||
public string Version { get; set; }= "0.0.1-rc1";
|
public string Platform { get; set; } = "External Web";
|
||||||
}
|
public string Version { get; set; } = "0.0.1-rc1";
|
||||||
|
}
|
||||||
|
|
||||||
public HomeController(ILoggerFactory loggerFactory)
|
public HomeController(ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
_logger=loggerFactory.CreateLogger<HomeController>();
|
_logger = loggerFactory.CreateLogger<HomeController>();
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> GetUserInfo(CancellationToken cancellationToken)
|
public async Task<IActionResult> GetUserInfo(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
@ -54,38 +55,41 @@ namespace testOauthClient.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> PostFiles(string subdir)
|
public async Task<IActionResult> PostFiles(string subdir)
|
||||||
{
|
{
|
||||||
string results = null;
|
string results;
|
||||||
_logger.LogInformation($"{Request.Form.Files.Count} file(s) to send");
|
_logger.LogInformation($"{Request.Form.Files.Count} file(s) to send");
|
||||||
|
|
||||||
// TODO better uri construction in production environment
|
// TODO better uri construction in production environment
|
||||||
List<FormFile> args = new List<FormFile>();
|
List<FormFile> args = new List<FormFile>();
|
||||||
foreach (var formFile in Request.Form.Files)
|
foreach (var formFile in Request.Form.Files)
|
||||||
|
{
|
||||||
|
_logger.LogWarning($"Treating {formFile.ContentDisposition}");
|
||||||
|
MemoryStream memStream = new MemoryStream();
|
||||||
|
const int sz = 1024 * 64;
|
||||||
|
byte[] buffer = new byte[sz];
|
||||||
|
using (var innerStream = formFile.OpenReadStream())
|
||||||
|
{
|
||||||
|
int szRead = 0;
|
||||||
|
do
|
||||||
{
|
{
|
||||||
_logger.LogWarning($"Treating {formFile.ContentDisposition}");
|
szRead = innerStream.Read(buffer, 0, sz);
|
||||||
var memStream = new MemoryStream();
|
memStream.Write(buffer, 0, szRead);
|
||||||
const int sz = 1024*64;
|
} while (szRead > 0);
|
||||||
byte [] buffer = new byte[sz];
|
}
|
||||||
using (var innerStream = formFile.OpenReadStream()) {
|
memStream.Seek(0, SeekOrigin.Begin);
|
||||||
int szRead = 0;
|
args.Add(
|
||||||
do {
|
new FormFile
|
||||||
szRead = innerStream.Read(buffer,0,sz);
|
{
|
||||||
memStream.Write(buffer,0,szRead);
|
ContentDisposition = formFile.ContentDisposition,
|
||||||
} while (szRead>0);
|
ContentType = formFile.ContentType,
|
||||||
}
|
Stream = memStream
|
||||||
memStream.Seek(0,SeekOrigin.Begin);
|
});
|
||||||
args.Add(
|
}
|
||||||
new FormFile {
|
string uri = "http://dev.pschneider.fr/api/fs/" + System.Uri.EscapeDataString(subdir);
|
||||||
ContentDisposition = formFile.ContentDisposition,
|
_logger.LogInformation($"Posting data to '{uri}'...");
|
||||||
ContentType = formFile.ContentType,
|
|
||||||
Stream = memStream
|
results = await RequestHelper.PostMultipart(uri, args.ToArray(), AccessToken);
|
||||||
});
|
_logger.LogInformation("Data posted.");
|
||||||
}
|
|
||||||
string uri = "http://dev.pschneider.fr/api/fs/"+System.Uri.EscapeDataString(subdir);
|
|
||||||
_logger.LogInformation($"Posting data to '{uri}'...");
|
|
||||||
|
|
||||||
results = await RequestHelper.PostMultipart(uri, args.ToArray(), AccessToken);
|
|
||||||
_logger.LogInformation("Data posted.");
|
|
||||||
|
|
||||||
return View("Index", model: results);
|
return View("Index", model: results);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -109,14 +113,16 @@ namespace testOauthClient.Controllers
|
|||||||
GCMRegistrationRecord result = null;
|
GCMRegistrationRecord result = null;
|
||||||
var authHeader = $"Bearer {AccessToken}";
|
var authHeader = $"Bearer {AccessToken}";
|
||||||
_logger.LogWarning($"using authorization Header {authHeader}");
|
_logger.LogWarning($"using authorization Header {authHeader}");
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using (var request = new SimpleJsonPostMethod(
|
using (var request = new SimpleJsonPostMethod(
|
||||||
"http://dev.pschneider.fr/api/gcm/register", authHeader))
|
"http://dev.pschneider.fr/api/gcm/register", authHeader))
|
||||||
{
|
{
|
||||||
result = await request.Invoke<GCMRegistrationRecord>(new
|
result = await request.Invoke<GCMRegistrationRecord>(new
|
||||||
GCMRegistrationRecord {
|
GCMRegistrationRecord
|
||||||
|
{
|
||||||
GCMRegistrationId = "testGoogleRegistrationIdValue",
|
GCMRegistrationId = "testGoogleRegistrationIdValue",
|
||||||
DeviceId = "TestDeviceId",
|
DeviceId = "TestDeviceId",
|
||||||
Model = "TestModel",
|
Model = "TestModel",
|
||||||
@ -125,8 +131,9 @@ namespace testOauthClient.Controllers
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex)
|
||||||
return View("Index", model: new { error = ex.Message });
|
{
|
||||||
|
return View("Index", model: new { error = ex.Message });
|
||||||
}
|
}
|
||||||
return View("Index", model: result?.ToString());
|
return View("Index", model: result?.ToString());
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
|
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
|
||||||
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
|
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
|
||||||
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
|
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
|
||||||
"Newtonsoft.Json": "6.0.1-beta1"
|
"Newtonsoft.Json": "7.0.1"
|
||||||
},
|
},
|
||||||
"commands": {
|
"commands": {
|
||||||
"web": "Microsoft.AspNet.Server.Kestrel --server.urls=http://*:5002"
|
"web": "Microsoft.AspNet.Server.Kestrel --server.urls=http://*:5002"
|
||||||
|
@ -9,7 +9,7 @@ namespace test
|
|||||||
[Trait("regres", "no")]
|
[Trait("regres", "no")]
|
||||||
public class AbstractTests
|
public class AbstractTests
|
||||||
{
|
{
|
||||||
ITestOutputHelper output;
|
readonly ITestOutputHelper output;
|
||||||
public AbstractTests(ITestOutputHelper output)
|
public AbstractTests(ITestOutputHelper output)
|
||||||
{
|
{
|
||||||
this.output = output;
|
this.output = output;
|
||||||
|
@ -60,10 +60,12 @@ namespace test
|
|||||||
[Fact]
|
[Fact]
|
||||||
void AnsiToHtml()
|
void AnsiToHtml()
|
||||||
{
|
{
|
||||||
var procStart = new ProcessStartInfo("ls", "-l --color=always");
|
var procStart = new ProcessStartInfo("ls", "-l --color=always")
|
||||||
procStart.UseShellExecute = false;
|
{
|
||||||
procStart.RedirectStandardInput = false;
|
UseShellExecute = false,
|
||||||
procStart.RedirectStandardOutput = true;
|
RedirectStandardInput = false,
|
||||||
|
RedirectStandardOutput = true
|
||||||
|
};
|
||||||
var proc = Process.Start(procStart);
|
var proc = Process.Start(procStart);
|
||||||
var encoded = AnsiToHtmlEncoder.GetStream(proc.StandardOutput);
|
var encoded = AnsiToHtmlEncoder.GetStream(proc.StandardOutput);
|
||||||
using (var reader = new StreamReader(encoded))
|
using (var reader = new StreamReader(encoded))
|
||||||
@ -99,12 +101,14 @@ namespace test
|
|||||||
|
|
||||||
internal static BeforeCompileContext CreateYavscCompilationContext()
|
internal static BeforeCompileContext CreateYavscCompilationContext()
|
||||||
{
|
{
|
||||||
var projectContext = new ProjectContext();
|
var projectContext = new ProjectContext
|
||||||
projectContext.Name = "Yavsc";
|
{
|
||||||
projectContext.ProjectDirectory = "../Yavsc";
|
Name = "Yavsc",
|
||||||
projectContext.ProjectFilePath = "../Yavsc/project.json";
|
ProjectDirectory = "../Yavsc",
|
||||||
projectContext.TargetFramework = new FrameworkName("DNX", new Version(4, 5, 1));
|
ProjectFilePath = "../Yavsc/project.json",
|
||||||
projectContext.Configuration = Environment.GetEnvironmentVariable("ASPNET_ENV");
|
TargetFramework = new FrameworkName("DNX", new Version(4, 5, 1)),
|
||||||
|
Configuration = Environment.GetEnvironmentVariable("ASPNET_ENV")
|
||||||
|
};
|
||||||
|
|
||||||
return new BeforeCompileContext(
|
return new BeforeCompileContext(
|
||||||
null, projectContext, () => null, () => null, () => null);
|
null, projectContext, () => null, () => null, () => null);
|
||||||
|
@ -9,8 +9,8 @@ namespace test.Mandatory
|
|||||||
[Trait("dev", "wip")]
|
[Trait("dev", "wip")]
|
||||||
public class Database: IClassFixture<ServerSideFixture>, IDisposable
|
public class Database: IClassFixture<ServerSideFixture>, IDisposable
|
||||||
{
|
{
|
||||||
ServerSideFixture _serverFixture;
|
readonly ServerSideFixture _serverFixture;
|
||||||
ITestOutputHelper output;
|
readonly ITestOutputHelper output;
|
||||||
public Database(ServerSideFixture serverFixture, ITestOutputHelper output)
|
public Database(ServerSideFixture serverFixture, ITestOutputHelper output)
|
||||||
{
|
{
|
||||||
this.output = output;
|
this.output = output;
|
||||||
|
@ -11,9 +11,9 @@ namespace test
|
|||||||
public class EMaillingTests : IClassFixture<ServerSideFixture>
|
public class EMaillingTests : IClassFixture<ServerSideFixture>
|
||||||
|
|
||||||
{
|
{
|
||||||
ServerSideFixture _serverFixture;
|
readonly ServerSideFixture _serverFixture;
|
||||||
ITestOutputHelper output;
|
readonly ITestOutputHelper output;
|
||||||
ILogger _logger;
|
readonly ILogger _logger;
|
||||||
public EMaillingTests(ServerSideFixture serverFixture, ITestOutputHelper output)
|
public EMaillingTests(ServerSideFixture serverFixture, ITestOutputHelper output)
|
||||||
{
|
{
|
||||||
this.output = output;
|
this.output = output;
|
||||||
|
@ -12,12 +12,14 @@ namespace test
|
|||||||
[Fact]
|
[Fact]
|
||||||
void TestNodeJsForAnsitohtml ()
|
void TestNodeJsForAnsitohtml ()
|
||||||
{
|
{
|
||||||
var procStart = new ProcessStartInfo("node", "node_modules/ansi-to-html/bin/ansi-to-html");
|
var procStart = new ProcessStartInfo("node", "node_modules/ansi-to-html/bin/ansi-to-html")
|
||||||
procStart.UseShellExecute = false;
|
{
|
||||||
procStart.RedirectStandardInput = true;
|
UseShellExecute = false,
|
||||||
procStart.RedirectStandardOutput = true;
|
RedirectStandardInput = true,
|
||||||
procStart.RedirectStandardError = true;
|
RedirectStandardOutput = true,
|
||||||
var proc = Process.Start(procStart);
|
RedirectStandardError = true
|
||||||
|
};
|
||||||
|
var proc = Process.Start(procStart);
|
||||||
proc.StandardInput.WriteLine("\x001b[30mblack\x1b[37mwhite");
|
proc.StandardInput.WriteLine("\x001b[30mblack\x1b[37mwhite");
|
||||||
proc.StandardInput.Close();
|
proc.StandardInput.Close();
|
||||||
while (!proc.StandardOutput.EndOfStream)
|
while (!proc.StandardOutput.EndOfStream)
|
||||||
@ -29,10 +31,12 @@ namespace test
|
|||||||
[Fact]
|
[Fact]
|
||||||
void AnsiToHtml()
|
void AnsiToHtml()
|
||||||
{
|
{
|
||||||
var procStart = new ProcessStartInfo("ls", "-l --color=always");
|
var procStart = new ProcessStartInfo("ls", "-l --color=always")
|
||||||
procStart.UseShellExecute = false;
|
{
|
||||||
procStart.RedirectStandardInput = false;
|
UseShellExecute = false,
|
||||||
procStart.RedirectStandardOutput = true;
|
RedirectStandardInput = false,
|
||||||
|
RedirectStandardOutput = true
|
||||||
|
};
|
||||||
var proc = Process.Start(procStart);
|
var proc = Process.Start(procStart);
|
||||||
var encoded = GetStream(proc.StandardOutput);
|
var encoded = GetStream(proc.StandardOutput);
|
||||||
var reader = new StreamReader(encoded);
|
var reader = new StreamReader(encoded);
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
"EntityFramework.Commands": "7.0.0-rc1-final",
|
"EntityFramework.Commands": "7.0.0-rc1-final",
|
||||||
"EntityFramework7.Npgsql": "3.1.0-rc1-3",
|
"EntityFramework7.Npgsql": "3.1.0-rc1-3",
|
||||||
"EntityFramework7.Npgsql.Design": "3.1.0-rc1-5",
|
"EntityFramework7.Npgsql.Design": "3.1.0-rc1-5",
|
||||||
"Newtonsoft.Json": "6.0.1-beta1",
|
"Newtonsoft.Json": "7.0.1",
|
||||||
"xunit": "2.1.0",
|
"xunit": "2.1.0",
|
||||||
"xunit.analyzers": "0.9.0",
|
"xunit.analyzers": "0.9.0",
|
||||||
"xunit.assert": "2.1.0",
|
"xunit.assert": "2.1.0",
|
||||||
|
Reference in New Issue
Block a user