diff --git a/src/Yavsc.Abstract/Attributes/Validation/YaStringLength.cs b/src/Yavsc.Abstract/Attributes/Validation/YaStringLength.cs
index 45bb2255..c4c7b19f 100644
--- a/src/Yavsc.Abstract/Attributes/Validation/YaStringLength.cs
+++ b/src/Yavsc.Abstract/Attributes/Validation/YaStringLength.cs
@@ -5,7 +5,7 @@ namespace Yavsc.Attributes.Validation
public partial class YaStringLength: YaValidationAttribute
{
public long MinimumLength { get; set; } = 0;
- private long maxLen;
+ private readonly long maxLen;
public YaStringLength(long maxLen) : base( ()=> "BadStringLength")
{
this.maxLen = maxLen;
@@ -50,4 +50,4 @@ namespace Yavsc.Attributes.Validation
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc.Abstract/Authentication/OAuthenticator.cs b/src/Yavsc.Abstract/Authentication/OAuthenticator.cs
index 61a26d37..5701ea80 100644
--- a/src/Yavsc.Abstract/Authentication/OAuthenticator.cs
+++ b/src/Yavsc.Abstract/Authentication/OAuthenticator.cs
@@ -24,8 +24,7 @@ namespace Yavsc.Authentication
readonly Uri accessTokenUrl;
readonly Uri redirectUrl;
readonly GetUsernameAsyncFunc getUsernameAsync;
-
- string requestState;
+ readonly string requestState;
bool reportedForgery = false;
///
diff --git a/src/Yavsc.Abstract/FileSystem/IFileRecieved.Info.cs b/src/Yavsc.Abstract/FileSystem/IFileRecieved.Info.cs
index ffe7a00f..9fadaa14 100644
--- a/src/Yavsc.Abstract/FileSystem/IFileRecieved.Info.cs
+++ b/src/Yavsc.Abstract/FileSystem/IFileRecieved.Info.cs
@@ -2,7 +2,6 @@ namespace Yavsc.Abstract.FileSystem
{
public interface IFileRecievedInfo
{
- string MimeType { get; set; }
string DestDir { get; set; }
@@ -12,4 +11,4 @@ namespace Yavsc.Abstract.FileSystem
bool QuotaOffensed { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc.Abstract/FileSystem/UserDirectoryInfo.cs b/src/Yavsc.Abstract/FileSystem/UserDirectoryInfo.cs
index ad5a8db0..ce3589f1 100644
--- a/src/Yavsc.Abstract/FileSystem/UserDirectoryInfo.cs
+++ b/src/Yavsc.Abstract/FileSystem/UserDirectoryInfo.cs
@@ -16,7 +16,7 @@ namespace Yavsc.ViewModels.UserFiles
public DirectoryShortInfo [] SubDirectories {
get; set;
}
- private DirectoryInfo dInfo;
+ private readonly DirectoryInfo dInfo;
// for deserialization
public UserDirectoryInfo()
diff --git a/src/Yavsc.Server/Models/FileSystem/FileRecievedInfo.cs b/src/Yavsc.Server/Models/FileSystem/FileRecievedInfo.cs
index d8609404..66edbcc0 100644
--- a/src/Yavsc.Server/Models/FileSystem/FileRecievedInfo.cs
+++ b/src/Yavsc.Server/Models/FileSystem/FileRecievedInfo.cs
@@ -30,14 +30,13 @@ namespace Yavsc.Models.FileSystem
public FileRecievedInfo()
{
QuotaOffensed = Overriden = false;
- MimeType = DestDir = FileName = null;
+ DestDir = FileName = null;
}
- public string MimeType { get; set; }
public string DestDir { get; set; }
public string FileName { get; set; }
public bool Overriden { get; set; }
public bool QuotaOffensed { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc.Server/Settings/SiteSettings.cs b/src/Yavsc.Server/Settings/SiteSettings.cs
index 00bf5453..ede3c086 100644
--- a/src/Yavsc.Server/Settings/SiteSettings.cs
+++ b/src/Yavsc.Server/Settings/SiteSettings.cs
@@ -65,5 +65,17 @@ namespace Yavsc
/// the supported activity code
public string OnlyOneActivityCode { get; set; }
+ ///
+ /// Disk usage user list maximum length in memory
+ ///
+ ///
+ public int DUUserListLen { get; set; } = 256;
+
+ ///
+ /// Default acl file name
+ ///
+ ///
+ public string AccessListFileName { get; set; } = ".access";
+
}
}
diff --git a/src/Yavsc/ApiControllers/Blogspot/BlogApiController.cs b/src/Yavsc/ApiControllers/Blogspot/BlogApiController.cs
index ca80f6d4..dcf59100 100644
--- a/src/Yavsc/ApiControllers/Blogspot/BlogApiController.cs
+++ b/src/Yavsc/ApiControllers/Blogspot/BlogApiController.cs
@@ -16,7 +16,7 @@ namespace Yavsc.Controllers
public class BlogApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public BlogApiController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/ApiControllers/Blogspot/BlogTagsApiController.cs b/src/Yavsc/ApiControllers/Blogspot/BlogTagsApiController.cs
index 48244149..bac327e1 100644
--- a/src/Yavsc/ApiControllers/Blogspot/BlogTagsApiController.cs
+++ b/src/Yavsc/ApiControllers/Blogspot/BlogTagsApiController.cs
@@ -12,7 +12,7 @@ namespace Yavsc.Controllers
[Route("api/blogtags")]
public class BlogTagsApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public BlogTagsApiController(ApplicationDbContext context)
{
@@ -144,4 +144,4 @@ namespace Yavsc.Controllers
return _context.TagsDomain.Count(e => e.PostId == id) > 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/Blogspot/CommentsApiController.cs b/src/Yavsc/ApiControllers/Blogspot/CommentsApiController.cs
index b25ce76c..07108689 100644
--- a/src/Yavsc/ApiControllers/Blogspot/CommentsApiController.cs
+++ b/src/Yavsc/ApiControllers/Blogspot/CommentsApiController.cs
@@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/blogcomments")]
public class CommentsApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public CommentsApiController(ApplicationDbContext context)
{
@@ -158,4 +158,4 @@ namespace Yavsc.Controllers
return _context.Comment.Count(e => e.Id == id) > 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/Blogspot/FileSystemApiController.cs b/src/Yavsc/ApiControllers/Blogspot/FileSystemApiController.cs
index 09d04f94..1ad8dd17 100644
--- a/src/Yavsc/ApiControllers/Blogspot/FileSystemApiController.cs
+++ b/src/Yavsc/ApiControllers/Blogspot/FileSystemApiController.cs
@@ -20,9 +20,9 @@ namespace Yavsc.ApiControllers
[Authorize,Route("api/fs")]
public partial class FileSystemApiController : Controller
{
- ApplicationDbContext dbContext;
- private IAuthorizationService AuthorizationService;
- private ILogger _logger;
+ readonly ApplicationDbContext dbContext;
+ private readonly IAuthorizationService AuthorizationService;
+ private readonly ILogger _logger;
public FileSystemApiController(ApplicationDbContext context,
IAuthorizationService authorizationService,
diff --git a/src/Yavsc/ApiControllers/Business/BillingController.cs b/src/Yavsc/ApiControllers/Business/BillingController.cs
index b3f6b6af..4994ca8f 100644
--- a/src/Yavsc/ApiControllers/Business/BillingController.cs
+++ b/src/Yavsc/ApiControllers/Business/BillingController.cs
@@ -25,15 +25,15 @@ namespace Yavsc.ApiControllers
[Route("api/bill"), Authorize]
public class BillingController : Controller
{
- ApplicationDbContext dbContext;
- private IStringLocalizer _localizer;
- private GoogleAuthSettings _googleSettings;
- private IYavscMessageSender _GCMSender;
- private IAuthorizationService authorizationService;
+ readonly ApplicationDbContext dbContext;
+ private readonly IStringLocalizer _localizer;
+ private readonly GoogleAuthSettings _googleSettings;
+ private readonly IYavscMessageSender _GCMSender;
+ private readonly IAuthorizationService authorizationService;
- private ILogger logger;
- private IBillingService billingService;
+ private readonly ILogger logger;
+ private readonly IBillingService billingService;
public BillingController(
IAuthorizationService authorizationService,
diff --git a/src/Yavsc/ApiControllers/Business/EstimateApiController.cs b/src/Yavsc/ApiControllers/Business/EstimateApiController.cs
index 63cd3dba..5e9e2719 100644
--- a/src/Yavsc/ApiControllers/Business/EstimateApiController.cs
+++ b/src/Yavsc/ApiControllers/Business/EstimateApiController.cs
@@ -13,11 +13,11 @@ using Yavsc.Models.Billing;
namespace Yavsc.Controllers
{
[Produces("application/json")]
- [Route("api/estimate"),Authorize()]
+ [Route("api/estimate"), Authorize()]
public class EstimateApiController : Controller
{
- private ApplicationDbContext _context;
- private ILogger _logger;
+ private readonly ApplicationDbContext _context;
+ private readonly ILogger _logger;
public EstimateApiController(ApplicationDbContext context, ILoggerFactory loggerFactory)
{
_context = context;
@@ -28,21 +28,21 @@ namespace Yavsc.Controllers
if (User.IsInRole(Constants.AdminGroupName)) return true;
return uid == User.GetUserId();
}
- bool UserIsAdminOrInThese (string oid, string uid)
+ bool UserIsAdminOrInThese(string oid, string uid)
{
if (User.IsInRole(Constants.AdminGroupName)) return true;
var cuid = User.GetUserId();
- return cuid == uid || cuid == oid;
+ return cuid == uid || cuid == oid;
}
// GET: api/Estimate{?ownerId=User.GetUserId()}
[HttpGet]
- public IActionResult GetEstimates(string ownerId=null)
+ public IActionResult GetEstimates(string ownerId = null)
{
- if ( ownerId == null ) ownerId = User.GetUserId();
+ if (ownerId == null) ownerId = User.GetUserId();
else if (!UserIsAdminOrThis(ownerId)) // throw new Exception("Not authorized") ;
- // or just do nothing
- return new HttpStatusCodeResult(StatusCodes.Status403Forbidden);
- return Ok(_context.Estimates.Include(e=>e.Bill).Where(e=>e.OwnerId == ownerId));
+ // or just do nothing
+ return new HttpStatusCodeResult(StatusCodes.Status403Forbidden);
+ return Ok(_context.Estimates.Include(e => e.Bill).Where(e => e.OwnerId == ownerId));
}
// GET: api/Estimate/5
[HttpGet("{id}", Name = "GetEstimate")]
@@ -53,20 +53,20 @@ namespace Yavsc.Controllers
return HttpBadRequest(ModelState);
}
- Estimate estimate = _context.Estimates.Include(e=>e.Bill).Single(m => m.Id == id);
+ Estimate estimate = _context.Estimates.Include(e => e.Bill).Single(m => m.Id == id);
if (estimate == null)
{
return HttpNotFound();
}
- if (UserIsAdminOrInThese(estimate.ClientId,estimate.OwnerId))
- return Ok(estimate);
+ if (UserIsAdminOrInThese(estimate.ClientId, estimate.OwnerId))
+ return Ok(estimate);
return new HttpStatusCodeResult(StatusCodes.Status403Forbidden);
}
// PUT: api/Estimate/5
- [HttpPut("{id}"),Produces("application/json")]
+ [HttpPut("{id}"), Produces("application/json")]
public IActionResult PutEstimate(long id, [FromBody] Estimate estimate)
{
@@ -84,11 +84,11 @@ namespace Yavsc.Controllers
{
if (uid != estimate.OwnerId)
{
- ModelState.AddModelError("OwnerId","You can only modify your own estimates");
+ ModelState.AddModelError("OwnerId", "You can only modify your own estimates");
return HttpBadRequest(ModelState);
}
}
-
+
var entry = _context.Attach(estimate);
try
{
@@ -106,27 +106,30 @@ namespace Yavsc.Controllers
}
}
- return Ok( new { Id = estimate.Id });
+ return Ok(new { estimate.Id });
}
// POST: api/Estimate
- [HttpPost,Produces("application/json")]
+ [HttpPost, Produces("application/json")]
public IActionResult PostEstimate([FromBody] Estimate estimate)
{
var uid = User.GetUserId();
- if (estimate.OwnerId==null) estimate.OwnerId = uid;
-
- if (!User.IsInRole(Constants.AdminGroupName)) {
+ if (estimate.OwnerId == null) estimate.OwnerId = uid;
+
+ if (!User.IsInRole(Constants.AdminGroupName))
+ {
if (uid != estimate.OwnerId)
{
- ModelState.AddModelError("OwnerId","You can only create your own estimates");
+ ModelState.AddModelError("OwnerId", "You can only create your own estimates");
return HttpBadRequest(ModelState);
}
}
-
- if (estimate.CommandId!=null) {
+
+ if (estimate.CommandId != null)
+ {
var query = _context.RdvQueries.FirstOrDefault(q => q.Id == estimate.CommandId);
- if (query == null) {
+ if (query == null)
+ {
return HttpBadRequest(ModelState);
}
query.ValidationDate = DateTime.Now;
@@ -136,18 +139,18 @@ namespace Yavsc.Controllers
if (!ModelState.IsValid)
{
_logger.LogError(JsonConvert.SerializeObject(ModelState));
- return Json(ModelState);
+ return Json(ModelState);
}
_context.Estimates.Add(estimate);
-
-
- /* _context.AttachRange(estimate.Bill);
- _context.Attach(estimate);
- _context.Entry(estimate).State = EntityState.Added;
- foreach (var line in estimate.Bill)
- _context.Entry(line).State = EntityState.Added;
- // foreach (var l in estimate.Bill) _context.Attach(l);
- */
+
+
+ /* _context.AttachRange(estimate.Bill);
+ _context.Attach(estimate);
+ _context.Entry(estimate).State = EntityState.Added;
+ foreach (var line in estimate.Bill)
+ _context.Entry(line).State = EntityState.Added;
+ // foreach (var l in estimate.Bill) _context.Attach(l);
+ */
try
{
_context.SaveChanges(User.GetUserId());
@@ -163,7 +166,7 @@ namespace Yavsc.Controllers
throw;
}
}
- return Ok( new { Id = estimate.Id, Bill = estimate.Bill });
+ return Ok(new { estimate.Id, estimate.Bill });
}
// DELETE: api/Estimate/5
@@ -175,8 +178,8 @@ namespace Yavsc.Controllers
return HttpBadRequest(ModelState);
}
- Estimate estimate = _context.Estimates.Include(e=>e.Bill).Single(m => m.Id == id);
-
+ Estimate estimate = _context.Estimates.Include(e => e.Bill).Single(m => m.Id == id);
+
if (estimate == null)
{
return HttpNotFound();
@@ -186,7 +189,7 @@ namespace Yavsc.Controllers
{
if (uid != estimate.OwnerId)
{
- ModelState.AddModelError("OwnerId","You can only create your own estimates");
+ ModelState.AddModelError("OwnerId", "You can only create your own estimates");
return HttpBadRequest(ModelState);
}
}
@@ -195,8 +198,8 @@ namespace Yavsc.Controllers
return Ok(estimate);
}
-
- protected override void Dispose (bool disposing)
+
+ protected override void Dispose(bool disposing)
{
if (disposing)
{
@@ -210,4 +213,4 @@ namespace Yavsc.Controllers
return _context.Estimates.Count(e => e.Id == id) > 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/Business/FrontOfficeApiController.cs b/src/Yavsc/ApiControllers/Business/FrontOfficeApiController.cs
index 8eff06a8..13ac327c 100644
--- a/src/Yavsc/ApiControllers/Business/FrontOfficeApiController.cs
+++ b/src/Yavsc/ApiControllers/Business/FrontOfficeApiController.cs
@@ -9,9 +9,10 @@ using Yavsc.ViewModels.FrontOffice;
namespace Yavsc.ApiControllers
{
[Route("api/front")]
- public class FrontOfficeApiController: Controller
+ public class FrontOfficeApiController : Controller
{
ApplicationDbContext dbContext;
+
private IBillingService billing;
public FrontOfficeApiController(ApplicationDbContext context, IBillingService billing)
@@ -20,19 +21,19 @@ namespace Yavsc.ApiControllers
this.billing = billing;
}
- [HttpGet("profiles/{actCode}")]
- IEnumerable Profiles (string actCode)
+ [HttpGet("profiles/{actCode}")]
+ IEnumerable Profiles(string actCode)
{
return dbContext.ListPerformers(billing, actCode);
}
[HttpPost("query/reject")]
- public IActionResult RejectQuery (string billingCode, long queryId)
+ public IActionResult RejectQuery(string billingCode, long queryId)
{
- if (billingCode==null) return HttpBadRequest("billingCode");
- if (queryId==0) return HttpBadRequest("queryId");
- var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
- if (billing==null) return HttpBadRequest();
+ if (billingCode == null) return HttpBadRequest("billingCode");
+ if (queryId == 0) return HttpBadRequest("queryId");
+ var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
+ if (billing == null) return HttpBadRequest();
billing.Rejected = true;
billing.RejectedAt = DateTime.Now;
dbContext.SaveChanges();
diff --git a/src/Yavsc/ApiControllers/Business/PaymentApiController.cs b/src/Yavsc/ApiControllers/Business/PaymentApiController.cs
index 71c3ba4c..32699c24 100644
--- a/src/Yavsc/ApiControllers/Business/PaymentApiController.cs
+++ b/src/Yavsc/ApiControllers/Business/PaymentApiController.cs
@@ -11,8 +11,8 @@ namespace Yavsc.ApiControllers
[Route("api/payment")]
public class PaymentApiController : Controller
{
- private ApplicationDbContext dbContext;
- private SiteSettings siteSettings;
+ private readonly ApplicationDbContext dbContext;
+ private readonly SiteSettings siteSettings;
private readonly ILogger _logger;
public PaymentApiController(
ApplicationDbContext dbContext,
diff --git a/src/Yavsc/ApiControllers/Business/PerformersApiController.cs b/src/Yavsc/ApiControllers/Business/PerformersApiController.cs
index 7001e116..9e825861 100644
--- a/src/Yavsc/ApiControllers/Business/PerformersApiController.cs
+++ b/src/Yavsc/ApiControllers/Business/PerformersApiController.cs
@@ -16,7 +16,7 @@ namespace Yavsc.Controllers
public class PerformersApiController : Controller
{
ApplicationDbContext dbContext;
- private IBillingService billing;
+ private readonly IBillingService billing;
public PerformersApiController(ApplicationDbContext context, IBillingService billing)
{
diff --git a/src/Yavsc/ApiControllers/Business/ProductApiController.cs b/src/Yavsc/ApiControllers/Business/ProductApiController.cs
index c50bf868..fd4f5fb0 100644
--- a/src/Yavsc/ApiControllers/Business/ProductApiController.cs
+++ b/src/Yavsc/ApiControllers/Business/ProductApiController.cs
@@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/ProductApi")]
public class ProductApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public ProductApiController(ApplicationDbContext context)
{
@@ -146,4 +146,4 @@ namespace Yavsc.Controllers
return _context.Products.Count(e => e.Id == id) > 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/DimissClicksApiController.cs b/src/Yavsc/ApiControllers/DimissClicksApiController.cs
index 9e405474..e64ed7b2 100644
--- a/src/Yavsc/ApiControllers/DimissClicksApiController.cs
+++ b/src/Yavsc/ApiControllers/DimissClicksApiController.cs
@@ -15,7 +15,7 @@ namespace Yavsc.Controllers
[Route("api/dimiss")]
public class DimissClicksApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public DimissClicksApiController(ApplicationDbContext context)
{
@@ -174,4 +174,4 @@ namespace Yavsc.Controllers
return _context.DimissClicked.Count(e => e.UserId == id) > 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/FileCircleApiController.cs b/src/Yavsc/ApiControllers/FileCircleApiController.cs
index 6807791f..0c16f4e3 100644
--- a/src/Yavsc/ApiControllers/FileCircleApiController.cs
+++ b/src/Yavsc/ApiControllers/FileCircleApiController.cs
@@ -16,7 +16,7 @@ namespace Yavsc.Controllers
[Authorize]
public class FileCircleApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public FileCircleApiController(ApplicationDbContext context)
{
@@ -185,4 +185,4 @@ namespace Yavsc.Controllers
return _context.CircleAuthorizationToFile.Count(e => e.CircleId == id) > 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/HairCut/BursherProfilesApiController.cs b/src/Yavsc/ApiControllers/HairCut/BursherProfilesApiController.cs
index 92b706db..a0d98f0b 100644
--- a/src/Yavsc/ApiControllers/HairCut/BursherProfilesApiController.cs
+++ b/src/Yavsc/ApiControllers/HairCut/BursherProfilesApiController.cs
@@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/bursherprofiles")]
public class BursherProfilesApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public BursherProfilesApiController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/ApiControllers/HairCut/HairCutController.cs b/src/Yavsc/ApiControllers/HairCut/HairCutController.cs
index d01bb2c2..55dd3718 100644
--- a/src/Yavsc/ApiControllers/HairCut/HairCutController.cs
+++ b/src/Yavsc/ApiControllers/HairCut/HairCutController.cs
@@ -26,37 +26,12 @@ namespace Yavsc.ApiControllers
[Route("api/haircut")]
public class HairCutController : Controller
{
- private ApplicationDbContext _context;
- private IEmailSender _emailSender;
- private IYavscMessageSender _GCMSender;
- private GoogleAuthSettings _googleSettings;
- private IStringLocalizer _localizer;
- private ILogger _logger;
- private SiteSettings _siteSettings;
- private SmtpSettings _smtpSettings;
- private UserManager _userManager;
-
- PayPalSettings _paymentSettings;
+ private readonly ApplicationDbContext _context;
+ private readonly ILogger _logger;
public HairCutController(ApplicationDbContext context,
- IOptions googleSettings,
- IYavscMessageSender GCMSender,
- UserManager userManager,
- IStringLocalizer localizer,
- IEmailSender emailSender,
- IOptions smtpSettings,
- IOptions siteSettings,
- IOptions payPalSettings,
ILoggerFactory loggerFactory)
{
_context = context;
- _GCMSender = GCMSender;
- _emailSender = emailSender;
- _googleSettings = googleSettings.Value;
- _userManager = userManager;
- _smtpSettings = smtpSettings.Value;
- _siteSettings = siteSettings.Value;
- _paymentSettings = payPalSettings.Value;
- _localizer = localizer;
_logger = loggerFactory.CreateLogger();
}
diff --git a/src/Yavsc/ApiControllers/Musical/DjProfileApiController.cs b/src/Yavsc/ApiControllers/Musical/DjProfileApiController.cs
index cb576870..cd9cdbc8 100644
--- a/src/Yavsc/ApiControllers/Musical/DjProfileApiController.cs
+++ b/src/Yavsc/ApiControllers/Musical/DjProfileApiController.cs
@@ -5,8 +5,8 @@ namespace Yavsc.ApiControllers
public class DjProfileApiController : ProfileApiController
{
- public DjProfileApiController(ApplicationDbContext context) : base(context)
+ public DjProfileApiController() : base()
{
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/Musical/MusicalPreferencesApiController.cs b/src/Yavsc/ApiControllers/Musical/MusicalPreferencesApiController.cs
index b8622869..6730d5bf 100644
--- a/src/Yavsc/ApiControllers/Musical/MusicalPreferencesApiController.cs
+++ b/src/Yavsc/ApiControllers/Musical/MusicalPreferencesApiController.cs
@@ -13,7 +13,7 @@ namespace Yavsc.Controllers
[Route("api/museprefs")]
public class MusicalPreferencesApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public MusicalPreferencesApiController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/ApiControllers/Musical/MusicalTendenciesApiController.cs b/src/Yavsc/ApiControllers/Musical/MusicalTendenciesApiController.cs
index 64a028f2..ac85b4cf 100644
--- a/src/Yavsc/ApiControllers/Musical/MusicalTendenciesApiController.cs
+++ b/src/Yavsc/ApiControllers/Musical/MusicalTendenciesApiController.cs
@@ -13,7 +13,7 @@ namespace Yavsc.Controllers
[Route("api/MusicalTendenciesApi")]
public class MusicalTendenciesApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public MusicalTendenciesApiController(ApplicationDbContext context)
{
@@ -145,4 +145,4 @@ namespace Yavsc.Controllers
return _context.MusicalTendency.Count(e => e.Id == id) > 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/NativeConfidentialController.cs b/src/Yavsc/ApiControllers/NativeConfidentialController.cs
index c814c4b3..2b273561 100644
--- a/src/Yavsc/ApiControllers/NativeConfidentialController.cs
+++ b/src/Yavsc/ApiControllers/NativeConfidentialController.cs
@@ -11,8 +11,8 @@ using Yavsc.Models.Identity;
[Authorize, Route("~/api/gcm")]
public class NativeConfidentialController : Controller
{
- ILogger _logger;
- ApplicationDbContext _context;
+ readonly ILogger _logger;
+ readonly ApplicationDbContext _context;
public NativeConfidentialController(ApplicationDbContext context,
ILoggerFactory loggerFactory)
diff --git a/src/Yavsc/ApiControllers/PostRateApiController.cs b/src/Yavsc/ApiControllers/PostRateApiController.cs
index 2c902d28..5ee73234 100644
--- a/src/Yavsc/ApiControllers/PostRateApiController.cs
+++ b/src/Yavsc/ApiControllers/PostRateApiController.cs
@@ -10,7 +10,7 @@ namespace Yavsc.Controllers
[Route("~/api/PostRateApi")]
public class PostRateApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public PostRateApiController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/ApiControllers/ProfileApiController.cs b/src/Yavsc/ApiControllers/ProfileApiController.cs
index e7d21f9e..c854f7c5 100644
--- a/src/Yavsc/ApiControllers/ProfileApiController.cs
+++ b/src/Yavsc/ApiControllers/ProfileApiController.cs
@@ -9,12 +9,9 @@ namespace Yavsc.ApiControllers
///
[Produces("application/json"),Route("api/profile")]
public abstract class ProfileApiController : Controller
- {
- ApplicationDbContext dbContext;
- public ProfileApiController(ApplicationDbContext context)
+ { public ProfileApiController()
{
- dbContext = context;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/Relationship/BlackListApiController.cs b/src/Yavsc/ApiControllers/Relationship/BlackListApiController.cs
index 101d136f..5672932b 100644
--- a/src/Yavsc/ApiControllers/Relationship/BlackListApiController.cs
+++ b/src/Yavsc/ApiControllers/Relationship/BlackListApiController.cs
@@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/blacklist"), Authorize]
public class BlackListApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public BlackListApiController(ApplicationDbContext context)
{
@@ -162,4 +162,4 @@ namespace Yavsc.Controllers
return _context.BlackListed.Count(e => e.Id == id) > 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/Relationship/BlogAclApiController.cs b/src/Yavsc/ApiControllers/Relationship/BlogAclApiController.cs
index 8881b029..e5ea753c 100644
--- a/src/Yavsc/ApiControllers/Relationship/BlogAclApiController.cs
+++ b/src/Yavsc/ApiControllers/Relationship/BlogAclApiController.cs
@@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/blogacl")]
public class BlogAclApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public BlogAclApiController(ApplicationDbContext context)
{
@@ -164,4 +164,4 @@ namespace Yavsc.Controllers
return _context.CircleAuthorizationToBlogPost.Count(e => e.CircleId == id) > 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/Relationship/ChatApiController.cs b/src/Yavsc/ApiControllers/Relationship/ChatApiController.cs
index e63789ed..a806251d 100644
--- a/src/Yavsc/ApiControllers/Relationship/ChatApiController.cs
+++ b/src/Yavsc/ApiControllers/Relationship/ChatApiController.cs
@@ -15,9 +15,9 @@ namespace Yavsc.Controllers
[Route("api/chat")]
public class ChatApiController : Controller
{
- ApplicationDbContext dbContext;
- UserManager userManager;
- private IConnexionManager _cxManager;
+ readonly ApplicationDbContext dbContext;
+ readonly UserManager userManager;
+ private readonly IConnexionManager _cxManager;
public ChatApiController(ApplicationDbContext dbContext,
UserManager userManager,
IConnexionManager cxManager)
diff --git a/src/Yavsc/ApiControllers/Relationship/ChatRoomAccessApiController.cs b/src/Yavsc/ApiControllers/Relationship/ChatRoomAccessApiController.cs
index 86a6580a..1eb49ee2 100644
--- a/src/Yavsc/ApiControllers/Relationship/ChatRoomAccessApiController.cs
+++ b/src/Yavsc/ApiControllers/Relationship/ChatRoomAccessApiController.cs
@@ -15,7 +15,7 @@ namespace Yavsc.Controllers
[Route("api/ChatRoomAccessApi")]
public class ChatRoomAccessApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public ChatRoomAccessApiController(ApplicationDbContext context)
{
@@ -183,4 +183,4 @@ namespace Yavsc.Controllers
return _context.ChatRoomAccess.Count(e => e.ChannelName == id) > 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/Relationship/ChatRoomApiController.cs b/src/Yavsc/ApiControllers/Relationship/ChatRoomApiController.cs
index 03876e90..3add911f 100644
--- a/src/Yavsc/ApiControllers/Relationship/ChatRoomApiController.cs
+++ b/src/Yavsc/ApiControllers/Relationship/ChatRoomApiController.cs
@@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/ChatRoomApi")]
public class ChatRoomApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public ChatRoomApiController(ApplicationDbContext context)
{
@@ -164,4 +164,4 @@ namespace Yavsc.Controllers
return _context.ChatRoom.Count(e => e.Name == id) > 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/Relationship/CircleApiController.cs b/src/Yavsc/ApiControllers/Relationship/CircleApiController.cs
index 508417cd..1e19d036 100644
--- a/src/Yavsc/ApiControllers/Relationship/CircleApiController.cs
+++ b/src/Yavsc/ApiControllers/Relationship/CircleApiController.cs
@@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/cirle")]
public class CircleApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public CircleApiController(ApplicationDbContext context)
{
@@ -146,4 +146,4 @@ namespace Yavsc.Controllers
return _context.Circle.Count(e => e.Id == id) > 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/Relationship/ContactsApiController.cs b/src/Yavsc/ApiControllers/Relationship/ContactsApiController.cs
index 5e340286..a17f2a14 100644
--- a/src/Yavsc/ApiControllers/Relationship/ContactsApiController.cs
+++ b/src/Yavsc/ApiControllers/Relationship/ContactsApiController.cs
@@ -12,7 +12,7 @@ namespace Yavsc.Controllers
[Route("api/ContactsApi")]
public class ContactsApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public ContactsApiController(ApplicationDbContext context)
{
@@ -125,4 +125,4 @@ namespace Yavsc.Controllers
return _context.ClientProviderInfo.Count(e => e.UserId == id) > 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/ServiceApiController.cs b/src/Yavsc/ApiControllers/ServiceApiController.cs
index 9dbaa224..8958e050 100644
--- a/src/Yavsc/ApiControllers/ServiceApiController.cs
+++ b/src/Yavsc/ApiControllers/ServiceApiController.cs
@@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/ServiceApi")]
public class ServiceApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public ServiceApiController(ApplicationDbContext context)
{
@@ -146,4 +146,4 @@ namespace Yavsc.Controllers
return _context.Services.Count(e => e.Id == id) > 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/ApiControllers/accounting/AccountController.cs b/src/Yavsc/ApiControllers/accounting/AccountController.cs
index 2f089670..5d1fc6e3 100644
--- a/src/Yavsc/ApiControllers/accounting/AccountController.cs
+++ b/src/Yavsc/ApiControllers/accounting/AccountController.cs
@@ -22,9 +22,8 @@ namespace Yavsc.WebApi.Controllers
private UserManager _userManager;
private readonly SignInManager _signInManager;
-
- ApplicationDbContext _dbContext;
- private ILogger _logger;
+ readonly ApplicationDbContext _dbContext;
+ private readonly ILogger _logger;
public ApiAccountController(UserManager userManager,
SignInManager signInManager, ILoggerFactory loggerFactory, ApplicationDbContext dbContext)
diff --git a/src/Yavsc/ApiControllers/accounting/ApplicationUserApiController.cs b/src/Yavsc/ApiControllers/accounting/ApplicationUserApiController.cs
index e2db68d5..b46e751b 100644
--- a/src/Yavsc/ApiControllers/accounting/ApplicationUserApiController.cs
+++ b/src/Yavsc/ApiControllers/accounting/ApplicationUserApiController.cs
@@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/users")]
public class ApplicationUserApiController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public ApplicationUserApiController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/ApiControllers/accounting/ProfileApiController.cs b/src/Yavsc/ApiControllers/accounting/ProfileApiController.cs
index 0c781a04..01e74265 100644
--- a/src/Yavsc/ApiControllers/accounting/ProfileApiController.cs
+++ b/src/Yavsc/ApiControllers/accounting/ProfileApiController.cs
@@ -11,8 +11,8 @@ namespace Yavsc.ApiControllers.accounting
[Route("~/api/profile")]
public class ProfileApiController: Controller
{
- UserManager _userManager;
- ApplicationDbContext _dbContext;
+ readonly UserManager _userManager;
+ readonly ApplicationDbContext _dbContext;
public ProfileApiController(ApplicationDbContext dbContext, UserManager userManager)
{
_dbContext = dbContext;
@@ -36,4 +36,4 @@ namespace Yavsc.ApiControllers.accounting
.Take(10).ToArray();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/AuthorizationServer/GoogleMiddleWare.cs b/src/Yavsc/AuthorizationServer/GoogleMiddleWare.cs
index 9957b803..dc91d168 100644
--- a/src/Yavsc/AuthorizationServer/GoogleMiddleWare.cs
+++ b/src/Yavsc/AuthorizationServer/GoogleMiddleWare.cs
@@ -16,7 +16,6 @@ namespace Yavsc.Auth
///
public class GoogleMiddleware : OAuthMiddleware
{
- private readonly RequestDelegate _next;
private readonly ILogger _logger;
///
@@ -37,11 +36,6 @@ namespace Yavsc.Auth
YavscGoogleOptions options)
: base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options)
{
- if (next == null)
- {
- throw new ArgumentNullException(nameof(next));
- }
- _next = next;
if (dataProtectionProvider == null)
{
diff --git a/src/Yavsc/AuthorizationServer/MonoJwtSecurityTokenHandler.cs b/src/Yavsc/AuthorizationServer/MonoJwtSecurityTokenHandler.cs
index d0f0b4ba..48f26127 100644
--- a/src/Yavsc/AuthorizationServer/MonoJwtSecurityTokenHandler.cs
+++ b/src/Yavsc/AuthorizationServer/MonoJwtSecurityTokenHandler.cs
@@ -12,10 +12,8 @@ namespace Yavsc.Auth
public class MonoJwtSecurityTokenHandler : JwtSecurityTokenHandler
{
- MonoDataProtectionProvider protectionProvider;
- public MonoJwtSecurityTokenHandler(MonoDataProtectionProvider prpro)
+ public MonoJwtSecurityTokenHandler()
{
- protectionProvider = prpro;
}
public override JwtSecurityToken CreateToken(
string issuer,
@@ -39,4 +37,4 @@ namespace Yavsc.Auth
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/AuthorizationServer/UserTokenProvider.cs b/src/Yavsc/AuthorizationServer/UserTokenProvider.cs
index cd20786b..28a13b4f 100644
--- a/src/Yavsc/AuthorizationServer/UserTokenProvider.cs
+++ b/src/Yavsc/AuthorizationServer/UserTokenProvider.cs
@@ -10,11 +10,6 @@ namespace Yavsc.Auth {
public class UserTokenProvider : Microsoft.AspNet.Identity.IUserTokenProvider
{
- private MonoDataProtector protector=null;
- public MonoDataProtector Protector {
- get { return protector; }
- }
-
public Task CanGenerateTwoFactorTokenAsync(UserManager manager, ApplicationUser user)
{
return Task.FromResult(true);
diff --git a/src/Yavsc/AuthorizationServer/XmlEncryptor.cs b/src/Yavsc/AuthorizationServer/XmlEncryptor.cs
index d22c373d..92b322fd 100644
--- a/src/Yavsc/AuthorizationServer/XmlEncryptor.cs
+++ b/src/Yavsc/AuthorizationServer/XmlEncryptor.cs
@@ -9,7 +9,7 @@ namespace Yavsc.Auth {
public class MonoXmlEncryptor : IXmlEncryptor
{
- public MonoXmlEncryptor (IServiceProvider serviceProvider)
+ public MonoXmlEncryptor ()
{
}
public EncryptedXmlInfo Encrypt(XElement plaintextElement)
@@ -20,4 +20,4 @@ namespace Yavsc.Auth {
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/Controllers/Accounting/AccountController.cs b/src/Yavsc/Controllers/Accounting/AccountController.cs
index 2c75843f..5b4dc53c 100644
--- a/src/Yavsc/Controllers/Accounting/AccountController.cs
+++ b/src/Yavsc/Controllers/Accounting/AccountController.cs
@@ -69,7 +69,7 @@ namespace Yavsc.Controllers
[Authorize(Roles = Constants.AdminGroupName)]
- public IActionResult Index(string page, string len)
+ public IActionResult Index()
{
return View();
}
@@ -591,7 +591,7 @@ namespace Yavsc.Controllers
// GET: /Account/ResetPassword
[HttpGet]
[AllowAnonymous]
- public async Task ResetPassword(string UserId, string code = null)
+ public async Task ResetPassword(string UserId)
{
var user = await _userManager.FindByIdAsync(UserId);
if (user==null) return new BadRequestResult();
diff --git a/src/Yavsc/Controllers/Accounting/ManageController.cs b/src/Yavsc/Controllers/Accounting/ManageController.cs
index d473779e..c7d71654 100644
--- a/src/Yavsc/Controllers/Accounting/ManageController.cs
+++ b/src/Yavsc/Controllers/Accounting/ManageController.cs
@@ -195,9 +195,9 @@ namespace Yavsc.Controllers
// Generate the token and send it
var user = await GetCurrentUserAsync();
var code = await _userManager.GenerateChangePhoneNumberTokenAsync(user, model.PhoneNumber);
- // TODO await _smsSender.SendSmsAsync(_twilioSettings, model.PhoneNumber, "Your security code is: " + code);
+ // TODO ? await _smsSender.SendSmsAsync(_twilioSettings, model.PhoneNumber, "Your security code is: " + code);
- return RedirectToAction(nameof(VerifyPhoneNumber), new { PhoneNumber = model.PhoneNumber });
+ return RedirectToAction(nameof(VerifyPhoneNumber), new { model.PhoneNumber });
}
//
diff --git a/src/Yavsc/Controllers/Accounting/OAuthController.cs b/src/Yavsc/Controllers/Accounting/OAuthController.cs
index feea1fc7..446fc372 100644
--- a/src/Yavsc/Controllers/Accounting/OAuthController.cs
+++ b/src/Yavsc/Controllers/Accounting/OAuthController.cs
@@ -20,25 +20,12 @@ namespace Yavsc.Controllers
[AllowAnonymous]
public class OAuthController : Controller
{
- readonly ApplicationDbContext _context;
- readonly UserManager _userManager;
- readonly SiteSettings _siteSettings;
readonly ILogger _logger;
- private readonly SignInManager _signInManager;
- public OAuthController(ApplicationDbContext context, SignInManager signInManager, IKeyManager keyManager,
- UserManager userManager,
- IOptions siteSettings,
- ILoggerFactory loggerFactory
- )
+ public OAuthController(ILoggerFactory loggerFactory)
{
- _siteSettings = siteSettings.Value;
- _context = context;
- _signInManager = signInManager;
- _userManager = userManager;
_logger = loggerFactory.CreateLogger();
}
-
[HttpGet("~/api/getclaims"), Produces("application/json")]
diff --git a/src/Yavsc/Controllers/Communicating/AnnouncesController.cs b/src/Yavsc/Controllers/Communicating/AnnouncesController.cs
index 169732ad..79b0a6cf 100644
--- a/src/Yavsc/Controllers/Communicating/AnnouncesController.cs
+++ b/src/Yavsc/Controllers/Communicating/AnnouncesController.cs
@@ -13,10 +13,9 @@ namespace Yavsc.Controllers
{
public class AnnouncesController : Controller
{
- private ApplicationDbContext _context;
- IStringLocalizer _localizer;
-
- IAuthorizationService _authorizationService;
+ private readonly ApplicationDbContext _context;
+ readonly IStringLocalizer _localizer;
+ readonly IAuthorizationService _authorizationService;
public AnnouncesController(ApplicationDbContext context,
IAuthorizationService authorizationService,
@@ -61,9 +60,7 @@ namespace Yavsc.Controllers
{
ViewBag.IsAdmin = User.IsInRole(Constants.AdminGroupName);
ViewBag.IsPerformer = User.IsInRole(Constants.PerformerGroupName);
- ViewBag.AllowEdit = (announce!=null && announce.Id>0) ?
- await _authorizationService.AuthorizeAsync(User,announce,new EditRequirement()) :
- true;
+ ViewBag.AllowEdit = announce==null || announce.Id<=0 || await _authorizationService.AuthorizeAsync(User,announce,new EditRequirement());
List dl = new List();
var rnames = System.Enum.GetNames(typeof(Reason));
var rvalues = System.Enum.GetValues(typeof(Reason));
diff --git a/src/Yavsc/Controllers/Communicating/BlogspotController.cs b/src/Yavsc/Controllers/Communicating/BlogspotController.cs
index 5dfce6cc..2e16cf07 100644
--- a/src/Yavsc/Controllers/Communicating/BlogspotController.cs
+++ b/src/Yavsc/Controllers/Communicating/BlogspotController.cs
@@ -40,7 +40,7 @@ namespace Yavsc.Controllers
// GET: Blog
[AllowAnonymous]
- public async Task Index(string id, int skip=0, int maxLen=25)
+ public async Task Index(string id)
{
if (!string.IsNullOrEmpty(id)) {
return await UserPosts(id);
diff --git a/src/Yavsc/Controllers/Contracting/CoWorkingController.cs b/src/Yavsc/Controllers/Contracting/CoWorkingController.cs
index 4d2e8747..905ea0ce 100644
--- a/src/Yavsc/Controllers/Contracting/CoWorkingController.cs
+++ b/src/Yavsc/Controllers/Contracting/CoWorkingController.cs
@@ -11,7 +11,7 @@ namespace Yavsc.Controllers
{
public class CoWorkingController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public CoWorkingController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/Controllers/Contracting/CommandController.cs b/src/Yavsc/Controllers/Contracting/CommandController.cs
index 80551787..32375680 100644
--- a/src/Yavsc/Controllers/Contracting/CommandController.cs
+++ b/src/Yavsc/Controllers/Contracting/CommandController.cs
@@ -90,7 +90,7 @@ namespace Yavsc.Controllers
///
///
[HttpGet]
- public IActionResult Create(string proId, string activityCode, string billingCode)
+ public IActionResult Create(string proId, string activityCode)
{
if (string.IsNullOrWhiteSpace(proId))
throw new InvalidOperationException(
@@ -159,7 +159,7 @@ namespace Yavsc.Controllers
_context.RdvQueries.Add(command, GraphBehavior.IncludeDependents);
_context.SaveChanges(User.GetUserId());
- var yaev = command.CreateEvent(_localizer, "NewCommand");
+ var yaev = command.CreateEvent("NewCommand");
MessageWithPayloadResponse nrep = null;
diff --git a/src/Yavsc/Controllers/Contracting/CommandFormsController.cs b/src/Yavsc/Controllers/Contracting/CommandFormsController.cs
index ad7b764e..d0f03df8 100644
--- a/src/Yavsc/Controllers/Contracting/CommandFormsController.cs
+++ b/src/Yavsc/Controllers/Contracting/CommandFormsController.cs
@@ -11,7 +11,7 @@ namespace Yavsc.Controllers
{
public class CommandFormsController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public CommandFormsController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/Controllers/Contracting/DjSettingsController.cs b/src/Yavsc/Controllers/Contracting/DjSettingsController.cs
index 8d424aa2..35e82851 100644
--- a/src/Yavsc/Controllers/Contracting/DjSettingsController.cs
+++ b/src/Yavsc/Controllers/Contracting/DjSettingsController.cs
@@ -8,7 +8,7 @@ namespace Yavsc.Controllers
{
public class DjSettingsController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public DjSettingsController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/Controllers/Contracting/EstimateController.cs b/src/Yavsc/Controllers/Contracting/EstimateController.cs
index 64e6b655..3555ab71 100644
--- a/src/Yavsc/Controllers/Contracting/EstimateController.cs
+++ b/src/Yavsc/Controllers/Contracting/EstimateController.cs
@@ -21,10 +21,9 @@ namespace Yavsc.Controllers
[Authorize]
public class EstimateController : Controller
{
- private ApplicationDbContext _context;
- private SiteSettings _site;
-
- IAuthorizationService authorizationService;
+ private readonly ApplicationDbContext _context;
+ private readonly SiteSettings _site;
+ readonly IAuthorizationService authorizationService;
public EstimateController(ApplicationDbContext context, IAuthorizationService authorizationService, IOptions siteSettings)
{
@@ -143,10 +142,6 @@ namespace Yavsc.Controllers
}
- private void Save(ICollection newGraphics,
- ICollection newFiles) {
-
- }
// GET: Estimate/Edit/5
public IActionResult Edit(long? id)
{
diff --git a/src/Yavsc/Controllers/Contracting/FormsController.cs b/src/Yavsc/Controllers/Contracting/FormsController.cs
index 2c2ffde6..62dafd53 100644
--- a/src/Yavsc/Controllers/Contracting/FormsController.cs
+++ b/src/Yavsc/Controllers/Contracting/FormsController.cs
@@ -9,7 +9,7 @@ namespace Yavsc.Controllers
{
public class FormsController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public FormsController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/Controllers/Contracting/FrontOfficeController.cs b/src/Yavsc/Controllers/Contracting/FrontOfficeController.cs
index 619c3b74..9e8be648 100644
--- a/src/Yavsc/Controllers/Contracting/FrontOfficeController.cs
+++ b/src/Yavsc/Controllers/Contracting/FrontOfficeController.cs
@@ -18,13 +18,11 @@ namespace Yavsc.Controllers
public class FrontOfficeController : Controller
{
- ApplicationDbContext _context;
- UserManager _userManager;
-
- ILogger _logger;
-
- IStringLocalizer _SR;
- private IBillingService _billing;
+ readonly ApplicationDbContext _context;
+ readonly UserManager _userManager;
+ readonly ILogger _logger;
+ readonly IStringLocalizer _SR;
+ private readonly IBillingService _billing;
public FrontOfficeController(ApplicationDbContext context,
UserManager userManager,
diff --git a/src/Yavsc/Controllers/Contracting/GeneralSettingsController.cs b/src/Yavsc/Controllers/Contracting/GeneralSettingsController.cs
index ef7da395..0fb778d4 100644
--- a/src/Yavsc/Controllers/Contracting/GeneralSettingsController.cs
+++ b/src/Yavsc/Controllers/Contracting/GeneralSettingsController.cs
@@ -8,7 +8,7 @@ namespace Yavsc.Controllers
{
public class GeneralSettingsController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public GeneralSettingsController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/Controllers/Contracting/MusicalTendenciesController.cs b/src/Yavsc/Controllers/Contracting/MusicalTendenciesController.cs
index 6c8421ea..7f11523e 100644
--- a/src/Yavsc/Controllers/Contracting/MusicalTendenciesController.cs
+++ b/src/Yavsc/Controllers/Contracting/MusicalTendenciesController.cs
@@ -8,7 +8,7 @@ namespace Yavsc.Controllers
using Models.Musical;
public class MusicalTendenciesController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public MusicalTendenciesController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/Controllers/Contracting/SIRENExceptionsController.cs b/src/Yavsc/Controllers/Contracting/SIRENExceptionsController.cs
index e3e511d1..bf8efc83 100644
--- a/src/Yavsc/Controllers/Contracting/SIRENExceptionsController.cs
+++ b/src/Yavsc/Controllers/Contracting/SIRENExceptionsController.cs
@@ -10,7 +10,7 @@ namespace Yavsc.Controllers
[Authorize(Roles="Administrator")]
public class SIRENExceptionsController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public SIRENExceptionsController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/Controllers/FileSystemController.cs b/src/Yavsc/Controllers/FileSystemController.cs
index 47569342..96eaf210 100644
--- a/src/Yavsc/Controllers/FileSystemController.cs
+++ b/src/Yavsc/Controllers/FileSystemController.cs
@@ -6,10 +6,8 @@ namespace Yavsc.Controllers
{
public class FileSystemController : Controller
{
- ILogger _logger;
- public FileSystemController(ILoggerFactory loggerFactory)
+ public FileSystemController()
{
- _logger = loggerFactory.CreateLogger();
}
public IActionResult Index(string subdir="")
@@ -21,4 +19,4 @@ namespace Yavsc.Controllers
return View(files);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/Controllers/Haircut/ColorsController.cs b/src/Yavsc/Controllers/Haircut/ColorsController.cs
index 914a5930..0b4606e1 100644
--- a/src/Yavsc/Controllers/Haircut/ColorsController.cs
+++ b/src/Yavsc/Controllers/Haircut/ColorsController.cs
@@ -9,7 +9,7 @@ namespace Yavsc.Controllers
{
public class ColorsController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public ColorsController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/Controllers/Haircut/HairCutCommandController.cs b/src/Yavsc/Controllers/Haircut/HairCutCommandController.cs
index 0bee463e..f5e787be 100644
--- a/src/Yavsc/Controllers/Haircut/HairCutCommandController.cs
+++ b/src/Yavsc/Controllers/Haircut/HairCutCommandController.cs
@@ -29,6 +29,7 @@ namespace Yavsc.Controllers
public class HairCutCommandController : CommandController
{
+ readonly PayPalSettings payPalSettings;
public HairCutCommandController(ApplicationDbContext context,
IOptions payPalSettings,
IOptions googleSettings,
@@ -44,7 +45,7 @@ namespace Yavsc.Controllers
{
this.payPalSettings = payPalSettings.Value;
}
- PayPalSettings payPalSettings;
+
private async Task GetQuery(long id)
{
diff --git a/src/Yavsc/Controllers/Haircut/HairPrestationsController.cs b/src/Yavsc/Controllers/Haircut/HairPrestationsController.cs
index 4294a686..21df3da0 100644
--- a/src/Yavsc/Controllers/Haircut/HairPrestationsController.cs
+++ b/src/Yavsc/Controllers/Haircut/HairPrestationsController.cs
@@ -8,7 +8,7 @@ namespace Yavsc.Controllers
{
public class HairPrestationsController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public HairPrestationsController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/Controllers/Haircut/HairTaintsController.cs b/src/Yavsc/Controllers/Haircut/HairTaintsController.cs
index 9384d110..01537a81 100644
--- a/src/Yavsc/Controllers/Haircut/HairTaintsController.cs
+++ b/src/Yavsc/Controllers/Haircut/HairTaintsController.cs
@@ -12,7 +12,7 @@ namespace Yavsc.Controllers
[Authorize("AdministratorOnly")]
public class HairTaintsController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public HairTaintsController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/Controllers/HomeController.cs b/src/Yavsc/Controllers/HomeController.cs
index 2c5b163e..6ee8b78d 100644
--- a/src/Yavsc/Controllers/HomeController.cs
+++ b/src/Yavsc/Controllers/HomeController.cs
@@ -21,22 +21,19 @@ namespace Yavsc.Controllers
[AllowAnonymous]
public class HomeController : Controller
{
- IHostingEnvironment _hosting;
-
- ApplicationDbContext _dbContext;
+ readonly ApplicationDbContext _dbContext;
readonly IHtmlLocalizer _localizer;
- public HomeController(IHtmlLocalizer localizer, IHostingEnvironment hosting,
- ApplicationDbContext context, UserManager userManager)
+ public HomeController(IHtmlLocalizer localizer,
+ ApplicationDbContext context)
{
_localizer = localizer;
- _hosting = hosting;
_dbContext = context;
}
public async Task Index(string id)
{
- ViewBag.IsFromSecureProx = (Request.Headers.ContainsKey(Constants.SshHeaderKey)) ? Request.Headers[Constants.SshHeaderKey] == "on" : false;
+ ViewBag.IsFromSecureProx = Request.Headers.ContainsKey(Constants.SshHeaderKey) && Request.Headers[Constants.SshHeaderKey] == "on";
ViewBag.SecureHomeUrl = "https://" + Request.Headers["X-Forwarded-Host"];
ViewBag.SshHeaderKey = Request.Headers[Constants.SshHeaderKey];
var uid = User.GetUserId();
diff --git a/src/Yavsc/Controllers/IT/GitController.cs b/src/Yavsc/Controllers/IT/GitController.cs
index 917eb1ae..0eeb3ee1 100644
--- a/src/Yavsc/Controllers/IT/GitController.cs
+++ b/src/Yavsc/Controllers/IT/GitController.cs
@@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Authorize("AdministratorOnly")]
public class GitController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public GitController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/Controllers/IT/ProjectController.cs b/src/Yavsc/Controllers/IT/ProjectController.cs
index 6ca12b11..ab627739 100644
--- a/src/Yavsc/Controllers/IT/ProjectController.cs
+++ b/src/Yavsc/Controllers/IT/ProjectController.cs
@@ -17,13 +17,11 @@ namespace Yavsc.Controllers
[Authorize("AdministratorOnly")]
public class ProjectController : Controller
{
- private ApplicationDbContext _context;
- ILogger _logger;
- IStringLocalizer _localizer;
- IStringLocalizer _bugLocalizer;
+ private readonly ApplicationDbContext _context;
+ readonly IStringLocalizer _localizer;
+ readonly IStringLocalizer _bugLocalizer;
public ProjectController(ApplicationDbContext context,
- ILoggerFactory loggerFactory,
IStringLocalizer localizer,
IStringLocalizer bugLocalizer
)
@@ -31,14 +29,11 @@ namespace Yavsc.Controllers
_context = context;
_localizer = localizer;
_bugLocalizer = bugLocalizer;
- _logger = loggerFactory.CreateLogger();
-
}
// GET: Project
public async Task Index()
{
-
var applicationDbContext = _context.Project.Include(p => p.Client).Include(p => p.Context).Include(p => p.PerformerProfile).Include(p => p.Regularisation).Include(p => p.Repository);
return View(await applicationDbContext.ToListAsync());
}
diff --git a/src/Yavsc/Controllers/Musical/InstrumentRatingController.cs b/src/Yavsc/Controllers/Musical/InstrumentRatingController.cs
index cd74aaea..57a98d3a 100644
--- a/src/Yavsc/Controllers/Musical/InstrumentRatingController.cs
+++ b/src/Yavsc/Controllers/Musical/InstrumentRatingController.cs
@@ -12,7 +12,7 @@ namespace Yavsc.Controllers
{
public class InstrumentRatingController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public InstrumentRatingController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/Controllers/Musical/InstrumentationController.cs b/src/Yavsc/Controllers/Musical/InstrumentationController.cs
index e5f321e5..a9237f15 100644
--- a/src/Yavsc/Controllers/Musical/InstrumentationController.cs
+++ b/src/Yavsc/Controllers/Musical/InstrumentationController.cs
@@ -13,7 +13,7 @@ namespace Yavsc.Controllers
[Authorize]
public class InstrumentationController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public InstrumentationController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/Controllers/Musical/InstrumentsController.cs b/src/Yavsc/Controllers/Musical/InstrumentsController.cs
index 2a9e018b..e4e79cd6 100644
--- a/src/Yavsc/Controllers/Musical/InstrumentsController.cs
+++ b/src/Yavsc/Controllers/Musical/InstrumentsController.cs
@@ -8,7 +8,7 @@ namespace Yavsc.Controllers
using Models.Musical;
public class InstrumentsController : Controller
{
- private ApplicationDbContext _context;
+ private readonly ApplicationDbContext _context;
public InstrumentsController(ApplicationDbContext context)
{
diff --git a/src/Yavsc/Controllers/Survey/BugController.cs b/src/Yavsc/Controllers/Survey/BugController.cs
index ecda8f73..ccc537e8 100644
--- a/src/Yavsc/Controllers/Survey/BugController.cs
+++ b/src/Yavsc/Controllers/Survey/BugController.cs
@@ -14,9 +14,9 @@ namespace Yavsc.Controllers
{
public class BugController : Controller
{
- ApplicationDbContext _context;
- IStringLocalizer _localizer;
- IStringLocalizer _statusLocalizer;
+ readonly ApplicationDbContext _context;
+ readonly IStringLocalizer _localizer;
+ readonly IStringLocalizer _statusLocalizer;
public BugController(ApplicationDbContext context,
IStringLocalizer localizer,
diff --git a/src/Yavsc/Controllers/Survey/FeatureController.cs b/src/Yavsc/Controllers/Survey/FeatureController.cs
index 48592253..1c385161 100644
--- a/src/Yavsc/Controllers/Survey/FeatureController.cs
+++ b/src/Yavsc/Controllers/Survey/FeatureController.cs
@@ -14,8 +14,8 @@ namespace Yavsc.Controllers
public class FeatureController : Controller
{
- private ApplicationDbContext _context;
- private IStringLocalizer _bugLocalizer;
+ private readonly ApplicationDbContext _context;
+ private readonly IStringLocalizer _bugLocalizer;
IEnumerable Statuses(FeatureStatus ?status) =>
_bugLocalizer.CreateSelectListItems(typeof(FeatureStatus), status);
diff --git a/src/Yavsc/Extensions/OAuthAuthorizationServerExtensions.cs b/src/Yavsc/Extensions/OAuthAuthorizationServerExtensions.cs
index c8089209..12112e9b 100644
--- a/src/Yavsc/Extensions/OAuthAuthorizationServerExtensions.cs
+++ b/src/Yavsc/Extensions/OAuthAuthorizationServerExtensions.cs
@@ -49,9 +49,8 @@ namespace Microsoft.AspNet.Builder
var options = new OAuthAuthorizationServerOptions();
- if (configureOptions != null)
- configureOptions(options);
+ configureOptions?.Invoke(options);
return app.UseOAuthAuthorizationServer(options);
}
diff --git a/src/Yavsc/Helpers/Ansi2HtmlEncoder.cs b/src/Yavsc/Helpers/Ansi2HtmlEncoder.cs
index 06d7e434..4ff26f85 100644
--- a/src/Yavsc/Helpers/Ansi2HtmlEncoder.cs
+++ b/src/Yavsc/Helpers/Ansi2HtmlEncoder.cs
@@ -18,11 +18,13 @@ namespace Yavsc.Helpers
public static Stream GetStream(StreamReader reader)
{
- var procStart = new ProcessStartInfo("node", "node_modules/ansi-to-html/bin/ansi-to-html");
- procStart.UseShellExecute = false;
- procStart.RedirectStandardInput = true;
- procStart.RedirectStandardOutput = true;
- // procStart.RedirectStandardError = true;
+ var procStart = new ProcessStartInfo("node", "node_modules/ansi-to-html/bin/ansi-to-html")
+ {
+ UseShellExecute = false,
+ RedirectStandardInput = true,
+ RedirectStandardOutput = true
+ };
+ // procStart.RedirectStandardError = true;
var mem = new MemoryStream();
var writer = new StreamWriter(mem);
var proc = Process.Start(procStart);
@@ -54,4 +56,4 @@ namespace Yavsc.Helpers
return GetStream(reader);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Yavsc/Helpers/EventHelpers.cs b/src/Yavsc/Helpers/EventHelpers.cs
index 2297c690..56cf047f 100644
--- a/src/Yavsc/Helpers/EventHelpers.cs
+++ b/src/Yavsc/Helpers/EventHelpers.cs
@@ -11,8 +11,7 @@ namespace Yavsc.Helpers
public static class EventHelpers
{
- public static RdvQueryEvent CreateEvent(this RdvQuery query,
- IStringLocalizer SR, string subtopic)
+ public static RdvQueryEvent CreateEvent(this RdvQuery query, string subtopic)
{
var yaev = new RdvQueryEvent(subtopic)
{
diff --git a/src/Yavsc/Helpers/FileSystemHelpers.cs b/src/Yavsc/Helpers/FileSystemHelpers.cs
index 3d1f60d0..5348b969 100644
--- a/src/Yavsc/Helpers/FileSystemHelpers.cs
+++ b/src/Yavsc/Helpers/FileSystemHelpers.cs
@@ -21,10 +21,11 @@ namespace Yavsc.Helpers
{
public static FileRecievedInfo ReceiveProSignature(this ClaimsPrincipal user, string billingCode, long estimateId, IFormFile formFile, string signtype)
{
- var item = new FileRecievedInfo();
- item.FileName = AbstractFileSystemHelpers.SignFileNameFormat("pro",billingCode,estimateId);
- item.MimeType = formFile.ContentDisposition;
-
+ var item = new FileRecievedInfo
+ {
+ FileName = AbstractFileSystemHelpers.SignFileNameFormat("pro", billingCode, estimateId)
+ };
+
var destFileName = Path.Combine(Startup.SiteSetup.Bills, item.FileName);
var fi = new FileInfo(destFileName);
@@ -200,10 +201,11 @@ namespace Yavsc.Helpers
// this process is not safe at concurrent access.
long usage = user.DiskUsage;
- var item = new FileRecievedInfo();
- item.FileName = AbstractFileSystemHelpers.FilterFileName (destFileName);
- item.MimeType = contentType;
- item.DestDir = root;
+ var item = new FileRecievedInfo
+ {
+ FileName = AbstractFileSystemHelpers.FilterFileName(destFileName),
+ DestDir = root
+ };
var fi = new FileInfo(Path.Combine(root, item.FileName));
if (fi.Exists)
{
@@ -251,8 +253,10 @@ namespace Yavsc.Helpers
public static FileRecievedInfo ReceiveAvatar(this ApplicationUser user, IFormFile formFile)
{
- var item = new FileRecievedInfo();
- item.FileName = user.UserName + ".png";
+ var item = new FileRecievedInfo
+ {
+ FileName = user.UserName + ".png"
+ };
var destFileName = Path.Combine(Startup.SiteSetup.Avatars, item.FileName);
diff --git a/src/Yavsc/Interfaces/IDiskUsageTracker.cs b/src/Yavsc/Interfaces/IDiskUsageTracker.cs
new file mode 100644
index 00000000..6066e94c
--- /dev/null
+++ b/src/Yavsc/Interfaces/IDiskUsageTracker.cs
@@ -0,0 +1,12 @@
+
+using System;
+
+namespace Yavsc.Services
+{
+
+ public interface IDiskUsageTracker
+ {
+ bool GetSpace(string userName, long space);
+ void Release(string userName, long space);
+ }
+}
diff --git a/src/Yavsc/Interfaces/ILiveProcessor.cs b/src/Yavsc/Interfaces/ILiveProcessor.cs
index c0793831..ff4d3dc4 100644
--- a/src/Yavsc/Interfaces/ILiveProcessor.cs
+++ b/src/Yavsc/Interfaces/ILiveProcessor.cs
@@ -1,6 +1,7 @@
using System.Collections.Concurrent;
using System.Threading.Tasks;
using Microsoft.AspNet.Http;
+using Yavsc.Models;
using Yavsc.ViewModels.Streaming;
namespace Yavsc.Services
@@ -17,12 +18,9 @@ namespace Yavsc.Services
///
///
///
- Task AcceptStream (HttpContext context);
+ Task AcceptStream (HttpContext context, ApplicationUser user, string destDir, string fileName);
- ///
- /// live cast entry point
- ///
- ///
- PathString LiveCastingPath {get; set;}
}
-}
\ No newline at end of file
+
+
+}
diff --git a/src/Yavsc/Services/DiskUsageTracker.cs b/src/Yavsc/Services/DiskUsageTracker.cs
new file mode 100644
index 00000000..8c01e4ed
--- /dev/null
+++ b/src/Yavsc/Services/DiskUsageTracker.cs
@@ -0,0 +1,106 @@
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.Extensions.OptionsModel;
+using Yavsc;
+using Yavsc.Models;
+using Yavsc.Services;
+
+
+public class DiskUsageTracker : IDiskUsageTracker
+{
+ public class DUTInfo
+ {
+ public DUTInfo()
+ {
+ Creation = DateTime.Now;
+ }
+ public long Usage { get; set; }
+ public long Quota { get; set; }
+ public readonly DateTime Creation;
+ }
+
+ readonly Dictionary DiskUsage;
+ readonly ApplicationDbContext context;
+ readonly int ulistLength;
+ public DiskUsageTracker(IOptions options, ApplicationDbContext context)
+ {
+ ulistLength = options.Value.DUUserListLen;
+ DiskUsage = new Dictionary();
+ this.context = context;
+ }
+
+ readonly static object userInfoLock = new object();
+
+ DUTInfo GetInfo(string username)
+ {
+ lock (userInfoLock)
+ {
+ if (!DiskUsage.ContainsKey(username))
+ {
+ var user = context.Users.SingleOrDefault(u => u.UserName == username);
+ if (user == null) throw new Exception($"Not an user : {username}");
+ DUTInfo usage = new DUTInfo
+ {
+ Usage = user.DiskUsage,
+ Quota = user.DiskQuota
+ };
+ DiskUsage.Add(username, usage);
+ if (DiskUsage.Count > ulistLength)
+ {
+ // remove the oldest
+ var oldestts = DateTime.Now;
+ DUTInfo oinfo = null;
+ string ouname = null;
+ foreach (var diskusage in DiskUsage)
+ {
+ if (oldestts > usage.Creation)
+ {
+ oldestts = diskusage.Value.Creation;
+ ouname = diskusage.Key;
+ oinfo = diskusage.Value;
+ }
+ }
+ var ouser = context.Users.SingleOrDefault(u => u.UserName == ouname);
+ ouser.DiskUsage = oinfo.Usage;
+ context.SaveChanges();
+ DiskUsage.Remove(ouname);
+ }
+ return usage;
+ }
+ return DiskUsage[username];
+ }
+ }
+ public bool GetSpace(string userName, long space)
+ {
+ var info = GetInfo(userName);
+ if (info.Quota < info.Usage + space) return false;
+ info.Usage += space;
+ #pragma warning disable CS4014
+ SaveUserUsage(userName,info.Usage);
+ #pragma warning restore CS4014
+ return true;
+ }
+
+ public void Release(string userName, long space)
+ {
+ var info = GetInfo(userName);
+ info.Usage -= space;
+ #pragma warning disable CS4014
+ SaveUserUsage(userName,info.Usage);
+ #pragma warning restore CS4014
+ }
+
+ async Task SaveUserUsage(string username, long usage)
+ {
+ await Task.Run(() =>
+ {
+ var ouser = context.Users.SingleOrDefault(u => u.UserName == username);
+ ouser.DiskUsage = usage;
+ context.SaveChanges();
+ });
+ }
+
+}
diff --git a/src/Yavsc/Services/FileSystemAuthManager.cs b/src/Yavsc/Services/FileSystemAuthManager.cs
index c613f33f..5c9b96a9 100644
--- a/src/Yavsc/Services/FileSystemAuthManager.cs
+++ b/src/Yavsc/Services/FileSystemAuthManager.cs
@@ -4,6 +4,9 @@ using System.Security.Principal;
using System.Security.Claims;
using Yavsc.Models;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.OptionsModel;
+using System.IO;
+using rules;
namespace Yavsc.Services
{
@@ -12,10 +15,20 @@ namespace Yavsc.Services
readonly ApplicationDbContext _dbContext;
readonly ILogger _logger;
- public FileSystemAuthManager(ApplicationDbContext dbContext, ILoggerFactory loggerFactory)
+ readonly SiteSettings SiteSettings;
+
+ readonly string aclfileName;
+
+ readonly RuleSetParser ruleSetParser;
+
+ public FileSystemAuthManager(ApplicationDbContext dbContext, ILoggerFactory loggerFactory,
+ IOptions sitesOptions)
{
_dbContext = dbContext;
_logger = loggerFactory.CreateLogger();
+ SiteSettings = sitesOptions.Value;
+ aclfileName = SiteSettings.AccessListFileName;
+ ruleSetParser = new RuleSetParser(true);
}
public FileAccessRight GetFilePathAccess(ClaimsPrincipal user, string normalizedFullPath)
@@ -25,38 +38,45 @@ namespace Yavsc.Services
var parts = normalizedFullPath.Split('/');
// below 4 parts, no file name.
- if (parts.Length<4) return FileAccessRight.None;
-
- var filePath = string.Join("/",parts.Skip(3));
+ if (parts.Length < 4) return FileAccessRight.None;
+
+ var fileDir = string.Join("/", parts.Take(parts.Length - 1));
var firstFileNamePart = parts[3];
- if (firstFileNamePart == "pub")
- {
- _logger.LogInformation("Serving public file.");
- return FileAccessRight.Read;
- }
+ if (firstFileNamePart == "pub")
+ {
+ _logger.LogInformation("Serving public file.");
+ return FileAccessRight.Read;
+ }
var funame = parts[2];
- _logger.LogInformation($"{normalizedFullPath} from {funame}");
-
- if (funame == user?.GetUserName())
- {
- _logger.LogInformation("Serving file to owner.");
- return FileAccessRight.Read | FileAccessRight.Write;
- }
+ _logger.LogInformation($"Accessing {normalizedFullPath} from {funame}");
+ if (funame == user?.GetUserName())
+ {
+ _logger.LogInformation("Serving file to owner.");
+ return FileAccessRight.Read | FileAccessRight.Write;
+ }
+ var aclfi = new FileInfo(Path.Combine(Environment.CurrentDirectory, fileDir, aclfileName));
+ // TODO default user scoped file access policy
+ if (!aclfi.Exists) return FileAccessRight.Read;
+ ruleSetParser.Reset();
+ ruleSetParser.ParseFile(aclfi.FullName);
+ if (ruleSetParser.Rules.Allow(user.GetUserName()))
+ return FileAccessRight.Read;
var ucl = user.Claims.Where(c => c.Type == YavscClaimTypes.CircleMembership).Select(c => long.Parse(c.Value)).Distinct().ToArray();
-
+
var uclString = string.Join(",", ucl);
_logger.LogInformation($"{uclString} ");
foreach (
var cid in ucl
- ) {
- var ok = _dbContext.CircleAuthorizationToFile.Any(a => a.CircleId == cid && a.FullPath == filePath);
+ )
+ {
+ var ok = _dbContext.CircleAuthorizationToFile.Any(a => a.CircleId == cid && a.FullPath == fileDir);
if (ok) return FileAccessRight.Read;
}
-
+
return FileAccessRight.None;
}
diff --git a/src/Yavsc/Services/LiveProcessor.cs b/src/Yavsc/Services/LiveProcessor.cs
index 1f6da1e1..330a0d87 100644
--- a/src/Yavsc/Services/LiveProcessor.cs
+++ b/src/Yavsc/Services/LiveProcessor.cs
@@ -26,7 +26,6 @@ namespace Yavsc.Services
readonly IHubContext _hubContext;
private readonly ILogger _logger;
readonly ApplicationDbContext _dbContext;
- public PathString LiveCastingPath { get; set; } = Constants.LivePath;
public ConcurrentDictionary Casters { get; } = new ConcurrentDictionary();
@@ -38,23 +37,12 @@ namespace Yavsc.Services
_logger = loggerFactory.CreateLogger();
}
- public async Task AcceptStream(HttpContext context)
+ public async Task AcceptStream(HttpContext context, ApplicationUser user, string destDir, string fileName)
{
// TODO defer request handling
- var liveId = long.Parse(context.Request.Path.Value.Substring(LiveCastingPath.Value.Length + 1));
- var userId = context.User.GetUserId();
- var user = await _dbContext.Users.FirstAsync(u => u.Id == userId);
- var uname = user.UserName;
- var flow = _dbContext.LiveFlow.Include(f => f.Owner).SingleOrDefault(f => (f.OwnerId == userId && f.Id == liveId));
- if (flow == null)
- {
- _logger.LogWarning("Aborting. Flow info was not found.");
- context.Response.StatusCode = 400;
- return false;
- }
- _logger.LogInformation("flow : " + flow.Title + " for " + uname);
-
+
+ string uname = user.UserName;
LiveCastHandler liveHandler = null;
if (Casters.ContainsKey(uname))
{
@@ -100,35 +88,15 @@ namespace Yavsc.Services
_logger.LogInformation($"Received bytes : {received.Count}");
_logger.LogInformation($"Is the end : {received.EndOfMessage}");
- const string livePath = "live";
+
- string destDir = context.User.InitPostToFileSystem(livePath);
- _logger.LogInformation($"Saving flow to {destDir}");
-
- string fileName = flow.GetFileName();
- FileInfo destFileInfo = new FileInfo(Path.Combine(destDir, fileName));
- // this should end :-)
- while (destFileInfo.Exists)
- {
- flow.SequenceNumber++;
- fileName = flow.GetFileName();
- destFileInfo = new FileInfo(Path.Combine(destDir, fileName));
- }
+
var fsInputQueue = new Queue>();
bool endOfInput = false;
fsInputQueue.Enqueue(sBuffer);
- var taskWritingToFs = liveHandler.ReceiveUserFile(user, _logger, destDir, fsInputQueue, fileName, flow.MediaType, () => endOfInput);
- var hubContext = GlobalHost.ConnectionManager.GetHubContext();
-
- hubContext.Clients.All.addPublicStream(new PublicStreamInfo
- {
- id = flow.Id,
- sender = flow.Owner.UserName,
- title = flow.Title,
- url = flow.GetFileUrl(),
- mediaType = flow.MediaType
- }, $"{flow.Owner.UserName} is starting a stream!");
+ var taskWritingToFs = liveHandler.ReceiveUserFile(user, _logger, destDir, fsInputQueue, fileName, () => endOfInput);
+
Stack ToClose = new Stack();
@@ -136,7 +104,6 @@ namespace Yavsc.Services
{
do
{
-
_logger.LogInformation($"Echoing {received.Count} bytes received in a {received.MessageType} message; Fin={received.EndOfMessage}");
// Echo anything we receive
// and send to all listner found
diff --git a/src/Yavsc/Startup/Startup.cs b/src/Yavsc/Startup/Startup.cs
index dc6df702..f7c4b1aa 100755
--- a/src/Yavsc/Startup/Startup.cs
+++ b/src/Yavsc/Startup/Startup.cs
@@ -24,12 +24,14 @@ using Newtonsoft.Json;
namespace Yavsc
{
using System.Collections.Generic;
+ using System.Linq;
using System.Net;
using System.Security.Claims;
using Formatters;
using Google.Apis.Util.Store;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Identity;
+ using Microsoft.AspNet.SignalR;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Models;
@@ -37,6 +39,7 @@ namespace Yavsc
using Yavsc.Abstract.FileSystem;
using Yavsc.AuthorizationHandlers;
using Yavsc.Helpers;
+ using Yavsc.Models.Messaging;
using static System.Environment;
public partial class Startup
@@ -59,12 +62,12 @@ namespace Yavsc
/// generating reset password and confirmation tokens
///
public IUserTokenProvider UserTokenProvider { get; set; }
-
+
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
AppDomain.CurrentDomain.UnhandledException += OnUnHandledException;
-
+
var devtag = env.IsDevelopment() ? "D" : "";
var prodtag = env.IsProduction() ? "P" : "";
var stagetag = env.IsStaging() ? "S" : "";
@@ -103,7 +106,7 @@ namespace Yavsc
GServiceAccount = JsonConvert.DeserializeObject(safile.OpenText().ReadToEnd());
}
}
-
+
// never hit ...
private void OnUnHandledException(object sender, UnhandledExceptionEventArgs e)
{
@@ -141,8 +144,9 @@ namespace Yavsc
services.Add(ServiceDescriptor.Singleton(typeof(IOptions), typeof(OptionsManager)));
services.Add(ServiceDescriptor.Singleton(typeof(IOptions), typeof(OptionsManager)));
services.Add(ServiceDescriptor.Singleton(typeof(IOptions), typeof(OptionsManager)));
+
+ services.Add(ServiceDescriptor.Singleton(typeof(IDiskUsageTracker), typeof(DiskUsageTracker)));
-
services.Configure(options =>
{
var supportedCultures = new[]
@@ -430,7 +434,8 @@ namespace Yavsc
_logger.LogInformation("LocalApplicationData: " + Environment.GetFolderPath(SpecialFolder.LocalApplicationData, SpecialFolderOption.DoNotVerify));
app.Use(async (context, next) =>
{
- var liveCasting = context.Request.Path.StartsWithSegments(_liveProcessor.LiveCastingPath);
+ const string livePath = "live";
+ var liveCasting = context.Request.Path.StartsWithSegments(Constants.LivePath);
if (liveCasting)
{
@@ -441,10 +446,49 @@ namespace Yavsc
context.Response.StatusCode = 403;
else
{
- await _liveProcessor.AcceptStream(context);
+ var liveId = long.Parse(context.Request.Path.Value.Substring(Constants.LivePath.Length + 1));
+ var userId = context.User.GetUserId();
+ var user = await _dbContext.Users.FirstAsync(u => u.Id == userId);
+ var uname = user.UserName;
+ var flow = _dbContext.LiveFlow.Include(f => f.Owner).SingleOrDefault(f => (f.OwnerId == userId && f.Id == liveId));
+
+ if (flow == null)
+ {
+ _logger.LogWarning("Aborting. Flow info was not found.");
+ context.Response.StatusCode = 400;
+ return;
+ }
+ var hubContext = GlobalHost.ConnectionManager.GetHubContext();
+
+ hubContext.Clients.All.addPublicStream(new PublicStreamInfo
+ {
+ id = flow.Id,
+ sender = flow.Owner.UserName,
+ title = flow.Title,
+ url = flow.GetFileUrl(),
+ mediaType = flow.MediaType
+ }, $"{flow.Owner.UserName} is starting a stream!");
+
+ string destDir = context.User.InitPostToFileSystem(livePath);
+ _logger.LogInformation($"Saving flow to {destDir}");
+
+ string fileName = flow.GetFileName();
+
+ _logger.LogInformation("flow : " + flow.Title + " for " + uname);
+ FileInfo destFileInfo = new FileInfo(Path.Combine(destDir, fileName));
+ // this should end :-)
+ while (destFileInfo.Exists)
+ {
+ flow.SequenceNumber++;
+ fileName = flow.GetFileName();
+ destFileInfo = new FileInfo(Path.Combine(destDir, fileName));
+ }
+
+ await _liveProcessor.AcceptStream(context, user, destDir, fileName);
}
}
- else {
+ else
+ {
context.Response.StatusCode = 400;
}
}
@@ -454,7 +498,7 @@ namespace Yavsc
}
});
- CheckApp( env, loggerFactory);
+ CheckApp(env, loggerFactory);
}
// Entry point for the application.
diff --git a/src/Yavsc/ViewModels/Streaming/LiveCastHandler.cs b/src/Yavsc/ViewModels/Streaming/LiveCastHandler.cs
index 610f6064..3ecd4514 100644
--- a/src/Yavsc/ViewModels/Streaming/LiveCastHandler.cs
+++ b/src/Yavsc/ViewModels/Streaming/LiveCastHandler.cs
@@ -13,12 +13,14 @@ using Yavsc.Models.FileSystem;
namespace Yavsc.ViewModels.Streaming
{
- public class LiveCastClient {
+ public class LiveCastClient
+ {
public string UserName { get; set; }
public WebSocket Socket { get; set; }
}
- public class LiveEntryViewModel {
+ public class LiveEntryViewModel
+ {
public string UserName { get; set; }
public string FlowId { get; set; }
}
@@ -29,22 +31,21 @@ namespace Yavsc.ViewModels.Streaming
public WebSocket Socket { get; set; }
public ConcurrentDictionary Listeners { get; set; } = new ConcurrentDictionary();
- public CancellationTokenSource TokenSource { get; set; } = new CancellationTokenSource();
+ public CancellationTokenSource TokenSource { get; set; } = new CancellationTokenSource();
public void Dispose()
{
}
- public async Task ReceiveUserFile(ApplicationUser user, ILogger logger, string root, Queue> queue, string destFileName, string contentType, Func isEndOfInput)
+ public async Task ReceiveUserFile(ApplicationUser user, ILogger logger, string root, Queue> queue, string destFileName, Func isEndOfInput)
{
- // TODO lock user's disk usage for this scope,
+ // TODO lock user's disk usage for this scope,
// this process is not safe at concurrent access.
long usage = user.DiskUsage;
var item = new FileRecievedInfo
{
FileName = AbstractFileSystemHelpers.FilterFileName(destFileName),
- MimeType = contentType,
DestDir = root
};
var fi = new FileInfo(Path.Combine(root, item.FileName));
@@ -52,36 +53,39 @@ namespace Yavsc.ViewModels.Streaming
{
item.Overriden = true;
usage -= fi.Length;
- }
+ }
logger.LogInformation("Opening the file");
using (var dest = fi.Open(FileMode.Create, FileAccess.Write, FileShare.Read))
{
logger.LogInformation("Appening to file");
- while (!isEndOfInput() || queue.Count>0)
+ while (!isEndOfInput() || queue.Count > 0)
+ {
+ if (queue.Count > 0)
{
- if (queue.Count>0) {
- var buffer = queue.Dequeue();
-
- logger.LogInformation($"writing {buffer.Array.Length} bytes...");
+ var buffer = queue.Dequeue();
- await dest.WriteAsync(buffer.Array, buffer.Offset, buffer.Count);
- logger.LogInformation($"done.");
- usage += buffer.Count;
- }
- if (usage >= user.DiskQuota) break;
- if (queue.Count==0 && !isEndOfInput()) {
- await Task.Delay(100);
- }
+ logger.LogInformation($"writing {buffer.Array.Length} bytes...");
+
+ await dest.WriteAsync(buffer.Array, buffer.Offset, buffer.Count);
+ logger.LogInformation($"done.");
+ usage += buffer.Count;
}
- user.DiskUsage = usage;
- dest.Close();
+ if (usage >= user.DiskQuota) break;
+ if (queue.Count == 0 && !isEndOfInput())
+ {
+ await Task.Delay(100);
+ }
+ }
+ user.DiskUsage = usage;
+ dest.Close();
}
- if (usage >= user.DiskQuota) {
+ if (usage >= user.DiskQuota)
+ {
item.QuotaOffensed = true;
}
user.DiskUsage = usage;
return item;
- }
+ }
}
diff --git a/src/Yavsc/project.json b/src/Yavsc/project.json
index dead6b03..bca84f92 100644
--- a/src/Yavsc/project.json
+++ b/src/Yavsc/project.json
@@ -37,12 +37,12 @@
"compile": {
"include": "*.cs",
"exclude": [
- "wwwroot",
- "node_modules",
- "bower_components",
- "contrib",
- "Blog-Dev",
- "Temp-Dev"
+ "wwwroot",
+ "node_modules",
+ "bower_components",
+ "contrib",
+ "Blog-Dev",
+ "Temp-Dev"
]
},
"embed": [
@@ -152,7 +152,8 @@
"Yavsc.Server": {
"target": "project",
"type": "build"
- }
+ },
+ "rules": "1.1.0"
},
"commands": {
"ef": "EntityFramework.Commands",
diff --git a/src/Yavsc/wwwroot/js/yavsc-remote-fs.js b/src/Yavsc/wwwroot/js/yavsc-remote-fs.js
index a8f14b67..10b036a1 100644
--- a/src/Yavsc/wwwroot/js/yavsc-remote-fs.js
+++ b/src/Yavsc/wwwroot/js/yavsc-remote-fs.js
@@ -156,7 +156,7 @@ if (typeof XMLHttpRequest === 'undefined') {
}
}
};
- xmlhttp.open('DELETE', '/api/fs/' + dfilep, true);
+ xmlhttp.open('DELETE', '/api/fs/' + encodeURIComponent(dfilep), true);
xmlhttp.send();
});
},