Naming conventions
This commit is contained in:
parent
7feee22b32
commit
ab3f0853a7
|
@ -70,7 +70,9 @@
|
||||||
string _permissions;
|
string _permissions;
|
||||||
string _pageId;
|
string _pageId;
|
||||||
|
|
||||||
|
#pragma warning disable 649
|
||||||
PermissionGrid _permissionGrid;
|
PermissionGrid _permissionGrid;
|
||||||
|
#pragma warning restore 649
|
||||||
|
|
||||||
RenderFragment DynamicComponent { get; set; }
|
RenderFragment DynamicComponent { get; set; }
|
||||||
object _settings;
|
object _settings;
|
||||||
|
|
|
@ -24,18 +24,18 @@
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||||
|
|
||||||
private async Task DeletePage(Page Page)
|
private async Task DeletePage(Page page)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Page.IsDeleted = true;
|
page.IsDeleted = true;
|
||||||
await PageService.UpdatePageAsync(Page);
|
await PageService.UpdatePageAsync(page);
|
||||||
await logger.LogInformation("Page Deleted {Page}", Page);
|
await logger.LogInformation("Page Deleted {Page}", page);
|
||||||
NavigationManager.NavigateTo(NavigateUrl("admin/pages"));
|
NavigationManager.NavigateTo(NavigateUrl("admin/pages"));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Deleting Page {Page} {Error}", Page, ex.Message);
|
await logger.LogError(ex, "Error Deleting Page {Page} {Error}", page, ex.Message);
|
||||||
AddModuleMessage("Error Deleting Page", MessageType.Error);
|
AddModuleMessage("Error Deleting Page", MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<label class="control-label">Name: </label>
|
<label class="control-label">Name: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@name" />
|
<input class="form-control" @bind="@_name" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
<label class="control-label">Title: </label>
|
<label class="control-label">Title: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@title" />
|
<input class="form-control" @bind="@_title" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
<label class="control-label">Description: </label>
|
<label class="control-label">Description: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<textarea class="form-control" @bind="@description" rows="5" />
|
<textarea class="form-control" @bind="@_description" rows="5"></textarea>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
<label class="control-label">Category: </label>
|
<label class="control-label">Category: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@category" />
|
<input class="form-control" @bind="@_category" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
<label class="control-label">Order: </label>
|
<label class="control-label">Order: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@vieworder" />
|
<input class="form-control" @bind="@_vieworder" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
<label class="control-label">Length: </label>
|
<label class="control-label">Length: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@maxlength" />
|
<input class="form-control" @bind="@_maxlength" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
<label class="control-label">Default Value: </label>
|
<label class="control-label">Default Value: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@defaultvalue" />
|
<input class="form-control" @bind="@_defaultvalue" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
<label class="control-label">Required? </label>
|
<label class="control-label">Required? </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @bind="@isrequired">
|
<select class="form-control" @bind="@_isrequired">
|
||||||
<option value="True">Yes</option>
|
<option value="True">Yes</option>
|
||||||
<option value="False">No</option>
|
<option value="False">No</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
<label class="control-label">Private? </label>
|
<label class="control-label">Private? </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @bind="@isprivate">
|
<select class="form-control" @bind="@_isprivate">
|
||||||
<option value="True">Yes</option>
|
<option value="True">Yes</option>
|
||||||
<option value="False">No</option>
|
<option value="False">No</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -90,16 +90,16 @@
|
||||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||||
public override string Actions { get { return "Add,Edit"; } }
|
public override string Actions { get { return "Add,Edit"; } }
|
||||||
|
|
||||||
int profileid = -1;
|
int _profileid = -1;
|
||||||
string name = "";
|
string _name = "";
|
||||||
string title = "";
|
string _title = "";
|
||||||
string description = "";
|
string _description = "";
|
||||||
string category = "";
|
string _category = "";
|
||||||
string vieworder = "0";
|
string _vieworder = "0";
|
||||||
string maxlength = "0";
|
string _maxlength = "0";
|
||||||
string defaultvalue = "";
|
string _defaultvalue = "";
|
||||||
string isrequired = "False";
|
string _isrequired = "False";
|
||||||
string isprivate = "False";
|
string _isprivate = "False";
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
@ -107,25 +107,25 @@
|
||||||
{
|
{
|
||||||
if (PageState.QueryString.ContainsKey("id"))
|
if (PageState.QueryString.ContainsKey("id"))
|
||||||
{
|
{
|
||||||
profileid = Int32.Parse(PageState.QueryString["id"]);
|
_profileid = Int32.Parse(PageState.QueryString["id"]);
|
||||||
Profile profile = await ProfileService.GetProfileAsync(profileid);
|
Profile profile = await ProfileService.GetProfileAsync(_profileid);
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
{
|
{
|
||||||
name = profile.Name;
|
_name = profile.Name;
|
||||||
title = profile.Title;
|
_title = profile.Title;
|
||||||
description = profile.Description;
|
_description = profile.Description;
|
||||||
category = profile.Category;
|
_category = profile.Category;
|
||||||
vieworder = profile.ViewOrder.ToString();
|
_vieworder = profile.ViewOrder.ToString();
|
||||||
maxlength = profile.MaxLength.ToString();
|
_maxlength = profile.MaxLength.ToString();
|
||||||
defaultvalue = profile.DefaultValue;
|
_defaultvalue = profile.DefaultValue;
|
||||||
isrequired = profile.IsRequired.ToString();
|
_isrequired = profile.IsRequired.ToString();
|
||||||
isprivate = profile.IsPrivate.ToString();
|
_isprivate = profile.IsPrivate.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Loading Profile {ProfileId} {Error}", profileid, ex.Message);
|
await logger.LogError(ex, "Error Loading Profile {ProfileId} {Error}", _profileid, ex.Message);
|
||||||
AddModuleMessage("Error Loading Profile", MessageType.Error);
|
AddModuleMessage("Error Loading Profile", MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,30 +135,30 @@
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Profile profile;
|
Profile profile;
|
||||||
if (profileid != -1)
|
if (_profileid != -1)
|
||||||
{
|
{
|
||||||
profile = await ProfileService.GetProfileAsync(profileid);
|
profile = await ProfileService.GetProfileAsync(_profileid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
profile = new Profile();
|
profile = new Profile();
|
||||||
}
|
}
|
||||||
profile.Name = name;
|
profile.Name = _name;
|
||||||
profile.Title = title;
|
profile.Title = _title;
|
||||||
profile.Description = description;
|
profile.Description = _description;
|
||||||
profile.Category = category;
|
profile.Category = _category;
|
||||||
profile.ViewOrder = int.Parse(vieworder);
|
profile.ViewOrder = int.Parse(_vieworder);
|
||||||
profile.MaxLength = int.Parse(maxlength);
|
profile.MaxLength = int.Parse(_maxlength);
|
||||||
profile.DefaultValue = defaultvalue;
|
profile.DefaultValue = _defaultvalue;
|
||||||
profile.IsRequired = (isrequired == null ? false : Boolean.Parse(isrequired));
|
profile.IsRequired = (_isrequired == null ? false : Boolean.Parse(_isrequired));
|
||||||
profile.IsPrivate = (isprivate == null ? false : Boolean.Parse(isprivate));
|
profile.IsPrivate = (_isprivate == null ? false : Boolean.Parse(_isprivate));
|
||||||
profile = await ProfileService.UpdateProfileAsync(profile);
|
profile = await ProfileService.UpdateProfileAsync(profile);
|
||||||
await logger.LogInformation("Profile Saved {Profile}", profile);
|
await logger.LogInformation("Profile Saved {Profile}", profile);
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Saving Profile {ProfleId} {Error}", profileid, ex.Message);
|
await logger.LogError(ex, "Error Saving Profile {ProfleId} {Error}", _profileid, ex.Message);
|
||||||
AddModuleMessage("Error Saving Profile", MessageType.Error);
|
AddModuleMessage("Error Saving Profile", MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IProfileService ProfileService
|
@inject IProfileService ProfileService
|
||||||
|
|
||||||
@if (Profiles == null)
|
@if (_profiles == null)
|
||||||
{
|
{
|
||||||
<p><em>Loading...</em></p>
|
<p><em>Loading...</em></p>
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ else
|
||||||
{
|
{
|
||||||
<ActionLink Action="Add" Security="SecurityAccessLevel.Admin" Text="Add Profile" />
|
<ActionLink Action="Add" Security="SecurityAccessLevel.Admin" Text="Add Profile" />
|
||||||
|
|
||||||
<Pager Items="@Profiles">
|
<Pager Items="@_profiles">
|
||||||
<Header>
|
<Header>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
|
@ -27,24 +27,24 @@ else
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||||
|
|
||||||
List<Profile> Profiles;
|
List<Profile> _profiles;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
Profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId);
|
_profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DeleteProfile(int ProfileId)
|
private async Task DeleteProfile(int profileId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await ProfileService.DeleteProfileAsync(ProfileId);
|
await ProfileService.DeleteProfileAsync(profileId);
|
||||||
await logger.LogInformation("Profile Deleted {ProfileId}", ProfileId);
|
await logger.LogInformation("Profile Deleted {ProfileId}", profileId);
|
||||||
AddModuleMessage("Profile Deleted", MessageType.Success);
|
AddModuleMessage("Profile Deleted", MessageType.Success);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Deleting Profile {ProfileId} {Error}", ProfileId, ex.Message);
|
await logger.LogError(ex, "Error Deleting Profile {ProfileId} {Error}", profileId, ex.Message);
|
||||||
AddModuleMessage("Error Deleting Profile", MessageType.Error);
|
AddModuleMessage("Error Deleting Profile", MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,14 @@
|
||||||
|
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div id="Pages" class="tab-pane fade show active" role="tabpanel">
|
<div id="Pages" class="tab-pane fade show active" role="tabpanel">
|
||||||
@if (pages == null)
|
@if (_pages == null)
|
||||||
{
|
{
|
||||||
<br />
|
<br />
|
||||||
<p>No Deleted Pages</p>
|
<p>No Deleted Pages</p>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<Pager Items="@pages">
|
<Pager Items="@_pages">
|
||||||
<Header>
|
<Header>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
|
@ -49,14 +49,14 @@
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div id="Modules" class="tab-pane fade" role="tabpanel">
|
<div id="Modules" class="tab-pane fade" role="tabpanel">
|
||||||
@if (modules == null)
|
@if (_modules == null)
|
||||||
{
|
{
|
||||||
<br />
|
<br />
|
||||||
<p>No Deleted Modules</p>
|
<p>No Deleted Modules</p>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<Pager Items="@modules">
|
<Pager Items="@_modules">
|
||||||
<Header>
|
<Header>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
|
@ -83,8 +83,8 @@
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||||
|
|
||||||
List<Page> pages;
|
List<Page> _pages;
|
||||||
List<Module> modules;
|
List<Module> _modules;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
@ -101,84 +101,84 @@
|
||||||
|
|
||||||
private async Task Load()
|
private async Task Load()
|
||||||
{
|
{
|
||||||
pages = await PageService.GetPagesAsync(PageState.Site.SiteId);
|
_pages = await PageService.GetPagesAsync(PageState.Site.SiteId);
|
||||||
pages = pages.Where(item => item.IsDeleted).ToList();
|
_pages = _pages.Where(item => item.IsDeleted).ToList();
|
||||||
|
|
||||||
modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId);
|
_modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId);
|
||||||
modules = modules.Where(item => item.IsDeleted).ToList();
|
_modules = _modules.Where(item => item.IsDeleted).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RestorePage(Page Page)
|
private async Task RestorePage(Page page)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Page.IsDeleted = false;
|
page.IsDeleted = false;
|
||||||
await PageService.UpdatePageAsync(Page);
|
await PageService.UpdatePageAsync(page);
|
||||||
await logger.LogInformation("Page Restored {Page}", Page);
|
await logger.LogInformation("Page Restored {Page}", page);
|
||||||
await Load();
|
await Load();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Restoring Deleted Page {Page} {Error}", Page, ex.Message);
|
await logger.LogError(ex, "Error Restoring Deleted Page {Page} {Error}", page, ex.Message);
|
||||||
AddModuleMessage("Error Restoring Deleted Page", MessageType.Error);
|
AddModuleMessage("Error Restoring Deleted Page", MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DeletePage(Page Page)
|
private async Task DeletePage(Page page)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await PageService.DeletePageAsync(Page.PageId);
|
await PageService.DeletePageAsync(page.PageId);
|
||||||
await logger.LogInformation("Page Permanently Deleted {Page}", Page);
|
await logger.LogInformation("Page Permanently Deleted {Page}", page);
|
||||||
await Load();
|
await Load();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
NavigationManager.NavigateTo(NavigateUrl());
|
NavigationManager.NavigateTo(NavigateUrl());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Permanently Deleting Page {Page} {Error}", Page, ex.Message);
|
await logger.LogError(ex, "Error Permanently Deleting Page {Page} {Error}", page, ex.Message);
|
||||||
AddModuleMessage(ex.Message, MessageType.Error);
|
AddModuleMessage(ex.Message, MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RestoreModule(Module Module)
|
private async Task RestoreModule(Module module)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(Module.PageModuleId);
|
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(module.PageModuleId);
|
||||||
pagemodule.IsDeleted = false;
|
pagemodule.IsDeleted = false;
|
||||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||||
await logger.LogInformation("Module Restored {Module}", Module);
|
await logger.LogInformation("Module Restored {Module}", module);
|
||||||
await Load();
|
await Load();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Restoring Deleted Module {Module} {Error}", Module, ex.Message);
|
await logger.LogError(ex, "Error Restoring Deleted Module {Module} {Error}", module, ex.Message);
|
||||||
AddModuleMessage("Error Restoring Deleted Module", MessageType.Error);
|
AddModuleMessage("Error Restoring Deleted Module", MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DeleteModule(Module Module)
|
private async Task DeleteModule(Module module)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await PageModuleService.DeletePageModuleAsync(Module.PageModuleId);
|
await PageModuleService.DeletePageModuleAsync(module.PageModuleId);
|
||||||
// check if there are any remaining module instances in the site
|
// check if there are any remaining module instances in the site
|
||||||
modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId);
|
_modules = await ModuleService.GetModulesAsync(PageState.Site.SiteId);
|
||||||
if (!modules.Exists(item => item.ModuleId == Module.ModuleId))
|
if (!_modules.Exists(item => item.ModuleId == module.ModuleId))
|
||||||
{
|
{
|
||||||
await ModuleService.DeleteModuleAsync(Module.ModuleId);
|
await ModuleService.DeleteModuleAsync(module.ModuleId);
|
||||||
}
|
}
|
||||||
await logger.LogInformation("Module Permanently Deleted {Module}", Module);
|
await logger.LogInformation("Module Permanently Deleted {Module}", module);
|
||||||
await Load();
|
await Load();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Permanently Deleting Module {Module} {Error}", Module, ex.Message);
|
await logger.LogError(ex, "Error Permanently Deleting Module {Module} {Error}", module, ex.Message);
|
||||||
AddModuleMessage("Error Permanently Deleting Module", MessageType.Error);
|
AddModuleMessage("Error Permanently Deleting Module", MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,31 +3,31 @@
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
|
||||||
@if (Message != "")
|
@if (_message != "")
|
||||||
{
|
{
|
||||||
<ModuleMessage Message="@Message" Type="MessageType.Info" />
|
<ModuleMessage Message="@_message" Type="MessageType.Info" />
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="Username" class="control-label">Username: </label>
|
<label for="Username" class="control-label">Username: </label>
|
||||||
<input type="text" class="form-control" placeholder="Username" @bind="@Username" />
|
<input type="text" class="form-control" placeholder="Username" @bind="@_username" id="Username"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="Password" class="control-label">Password: </label>
|
<label for="Password" class="control-label">Password: </label>
|
||||||
<input type="password" class="form-control" placeholder="Password" @bind="@Password" />
|
<input type="password" class="form-control" placeholder="Password" @bind="@_password" id="Password"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="Password" class="control-label">Confirm Password: </label>
|
<label for="Confirm" class="control-label">Confirm Password: </label>
|
||||||
<input type="password" class="form-control" placeholder="Password" @bind="@Confirm" />
|
<input type="password" class="form-control" placeholder="Password" @bind="@_confirm"id="Confirm" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="Username" class="control-label">Email: </label>
|
<label for="Email" class="control-label">Email: </label>
|
||||||
<input type="text" class="form-control" placeholder="Email" @bind="@Email" />
|
<input type="text" class="form-control" placeholder="Email" @bind="@_email" id="Email"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="DisplayName" class="control-label">Full Name: </label>
|
<label for="DisplayName" class="control-label">Full Name: </label>
|
||||||
<input type="text" class="form-control" placeholder="Full Name" @bind="@DisplayName" />
|
<input type="text" class="form-control" placeholder="Full Name" @bind="@_displayName" id="DisplayName"/>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="btn btn-primary" @onclick="Register">Register</button>
|
<button type="button" class="btn btn-primary" @onclick="Register">Register</button>
|
||||||
<button type="button" class="btn btn-secondary" @onclick="Cancel">Cancel</button>
|
<button type="button" class="btn btn-secondary" @onclick="Cancel">Cancel</button>
|
||||||
|
@ -36,38 +36,40 @@
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Anonymous; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Anonymous; } }
|
||||||
|
|
||||||
string Message = "Please Note That Registration Requires A Valid Email Address In Order To Verify Your Identity";
|
string _message = "Please Note That Registration Requires A Valid Email Address In Order To Verify Your Identity";
|
||||||
string Username = "";
|
string _username = "";
|
||||||
string Password = "";
|
string _password = "";
|
||||||
string Confirm = "";
|
string _confirm = "";
|
||||||
string Email = "";
|
string _email = "";
|
||||||
string DisplayName = "";
|
string _displayName = "";
|
||||||
|
|
||||||
private async Task Register()
|
private async Task Register()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Message = "";
|
_message = "";
|
||||||
if (Username != "" && Password != "" && Confirm != "" && Email != "")
|
if (_username != "" && _password != "" && _confirm != "" && _email != "")
|
||||||
{
|
{
|
||||||
if (Password == Confirm)
|
if (_password == _confirm)
|
||||||
{
|
{
|
||||||
User user = new User();
|
User user = new User
|
||||||
user.SiteId = PageState.Site.SiteId;
|
{
|
||||||
user.Username = Username;
|
SiteId = PageState.Site.SiteId,
|
||||||
user.DisplayName = (DisplayName == "" ? Username : DisplayName);
|
Username = _username,
|
||||||
user.Email = Email;
|
DisplayName = (_displayName == "" ? _username : _displayName),
|
||||||
user.Password = Password;
|
Email = _email,
|
||||||
|
Password = _password
|
||||||
|
};
|
||||||
user = await UserService.AddUserAsync(user);
|
user = await UserService.AddUserAsync(user);
|
||||||
|
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
await logger.LogInformation("User Created {Username} {Email}", Username, Email);
|
await logger.LogInformation("User Created {Username} {Email}", _username, _email);
|
||||||
AddModuleMessage("User Account Created. Please Check Your Email For Verification Instructions.", MessageType.Info);
|
AddModuleMessage("User Account Created. Please Check Your Email For Verification Instructions.", MessageType.Info);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError("Error Adding User {Username} {Email}", Username, Email);
|
await logger.LogError("Error Adding User {Username} {Email}", _username, _email);
|
||||||
AddModuleMessage("Error Adding User. Please Ensure Password Meets Complexity Requirements And Username Is Not Already In Use.", MessageType.Error);
|
AddModuleMessage("Error Adding User. Please Ensure Password Meets Complexity Requirements And Username Is Not Already In Use.", MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +85,7 @@
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Adding User {Username} {Email} {Error}", Username, Email, ex.Message);
|
await logger.LogError(ex, "Error Adding User {Username} {Email} {Error}", _username, _email, ex.Message);
|
||||||
AddModuleMessage("Error Adding User", MessageType.Error);
|
AddModuleMessage("Error Adding User", MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<label class="control-label">Description: </label>
|
<label class="control-label">Description: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<textarea class="form-control" @bind="@description" rows="5" />
|
<textarea class="form-control" @bind="@description" rows="5"></textarea>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<label class="control-label">Name: </label>
|
<label class="control-label">Name: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@name" />
|
<input class="form-control" @bind="@_name" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
<label class="control-label">Description: </label>
|
<label class="control-label">Description: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<textarea class="form-control" @bind="@description" rows="5" />
|
<textarea class="form-control" @bind="@_description" rows="5"></textarea>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
<label class="control-label">Auto Assigned? </label>
|
<label class="control-label">Auto Assigned? </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @bind="@isautoassigned">
|
<select class="form-control" @bind="@_isautoassigned">
|
||||||
<option value="True">Yes</option>
|
<option value="True">Yes</option>
|
||||||
<option value="False">No</option>
|
<option value="False">No</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
<label class="control-label">System Role? </label>
|
<label class="control-label">System Role? </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @bind="@issystem">
|
<select class="form-control" @bind="@_issystem">
|
||||||
<option value="True">Yes</option>
|
<option value="True">Yes</option>
|
||||||
<option value="False">No</option>
|
<option value="False">No</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -49,40 +49,40 @@
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||||
|
|
||||||
int roleid;
|
int _roleid;
|
||||||
string name = "";
|
string _name = "";
|
||||||
string description = "";
|
string _description = "";
|
||||||
string isautoassigned = "False";
|
string _isautoassigned = "False";
|
||||||
string issystem = "False";
|
string _issystem = "False";
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
roleid = Int32.Parse(PageState.QueryString["id"]);
|
_roleid = Int32.Parse(PageState.QueryString["id"]);
|
||||||
Role role = await RoleService.GetRoleAsync(roleid);
|
Role role = await RoleService.GetRoleAsync(_roleid);
|
||||||
if (role != null)
|
if (role != null)
|
||||||
{
|
{
|
||||||
name = role.Name;
|
_name = role.Name;
|
||||||
description = role.Description;
|
_description = role.Description;
|
||||||
isautoassigned = role.IsAutoAssigned.ToString();
|
_isautoassigned = role.IsAutoAssigned.ToString();
|
||||||
issystem = role.IsSystem.ToString();
|
_issystem = role.IsSystem.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Loading Role {RoleId} {Error}", roleid, ex.Message);
|
await logger.LogError(ex, "Error Loading Role {RoleId} {Error}", _roleid, ex.Message);
|
||||||
AddModuleMessage("Error Loading Role", MessageType.Error);
|
AddModuleMessage("Error Loading Role", MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SaveRole()
|
private async Task SaveRole()
|
||||||
{
|
{
|
||||||
Role role = await RoleService.GetRoleAsync(roleid);
|
Role role = await RoleService.GetRoleAsync(_roleid);
|
||||||
role.Name = name;
|
role.Name = _name;
|
||||||
role.Description = description;
|
role.Description = _description;
|
||||||
role.IsAutoAssigned = (isautoassigned == null ? false : Boolean.Parse(isautoassigned));
|
role.IsAutoAssigned = (_isautoassigned != null && Boolean.Parse(_isautoassigned));
|
||||||
role.IsSystem = (issystem == null ? false : Boolean.Parse(issystem));
|
role.IsSystem = (_issystem != null && Boolean.Parse(_issystem));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IRoleService RoleService
|
@inject IRoleService RoleService
|
||||||
|
|
||||||
@if (Roles == null)
|
@if (_roles == null)
|
||||||
{
|
{
|
||||||
<p><em>Loading...</em></p>
|
<p><em>Loading...</em></p>
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ else
|
||||||
{
|
{
|
||||||
<ActionLink Action="Add" Text="Add Role" />
|
<ActionLink Action="Add" Text="Add Role" />
|
||||||
|
|
||||||
<Pager Items="@Roles">
|
<Pager Items="@_roles">
|
||||||
<Header>
|
<Header>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
|
@ -27,24 +27,24 @@ else
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||||
|
|
||||||
List<Role> Roles;
|
List<Role> _roles;
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
Roles = await RoleService.GetRolesAsync(PageState.Site.SiteId);
|
_roles = await RoleService.GetRolesAsync(PageState.Site.SiteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DeleteRole(Role Role)
|
private async Task DeleteRole(Role role)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await RoleService.DeleteRoleAsync(Role.RoleId);
|
await RoleService.DeleteRoleAsync(role.RoleId);
|
||||||
await logger.LogInformation("Role Deleted {Role}", Role);
|
await logger.LogInformation("Role Deleted {Role}", role);
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Deleting Role {Role} {Error}", Role, ex.Message);
|
await logger.LogError(ex, "Error Deleting Role {Role} {Error}", role, ex.Message);
|
||||||
AddModuleMessage("Error Deleting Role", MessageType.Error);
|
AddModuleMessage("Error Deleting Role", MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<label class="control-label">Aliases: </label>
|
<label class="control-label">Aliases: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<textarea class="form-control" @bind="@urls" rows="3" />
|
<textarea class="form-control" @bind="@urls" rows="3"></textarea>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
@inject IThemeService ThemeService
|
@inject IThemeService ThemeService
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
|
||||||
@if (tenants == null)
|
@if (_tenants == null)
|
||||||
{
|
{
|
||||||
<p><em>Loading...</em></p>
|
<p><em>Loading...</em></p>
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ else
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @onchange="(e => TenantChanged(e))">
|
<select class="form-control" @onchange="(e => TenantChanged(e))">
|
||||||
<option value="-1"><Select Tenant></option>
|
<option value="-1"><Select Tenant></option>
|
||||||
@foreach (Tenant tenant in tenants)
|
@foreach (Tenant tenant in _tenants)
|
||||||
{
|
{
|
||||||
<option value="@tenant.TenantId">@tenant.Name</option>
|
<option value="@tenant.TenantId">@tenant.Name</option>
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ else
|
||||||
<label class="control-label">Name: </label>
|
<label class="control-label">Name: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@name" />
|
<input class="form-control" @bind="@_name" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -41,7 +41,7 @@ else
|
||||||
<label class="control-label">Aliases: </label>
|
<label class="control-label">Aliases: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<textarea class="form-control" @bind="@urls" rows="3" />
|
<textarea class="form-control" @bind="@_urls" rows="3"></textarea>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -51,7 +51,7 @@ else
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @onchange="(e => ThemeChanged(e))">
|
<select class="form-control" @onchange="(e => ThemeChanged(e))">
|
||||||
<option value=""><Select Theme></option>
|
<option value=""><Select Theme></option>
|
||||||
@foreach (KeyValuePair<string, string> item in themes)
|
@foreach (KeyValuePair<string, string> item in _themes)
|
||||||
{
|
{
|
||||||
<option value="@item.Key">@item.Value</option>
|
<option value="@item.Key">@item.Value</option>
|
||||||
}
|
}
|
||||||
|
@ -63,9 +63,9 @@ else
|
||||||
<label class="control-label">Default Layout: </label>
|
<label class="control-label">Default Layout: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @bind="@layouttype">
|
<select class="form-control" @bind="@_layouttype">
|
||||||
<option value=""><Select Layout></option>
|
<option value=""><Select Layout></option>
|
||||||
@foreach (KeyValuePair<string, string> panelayout in panelayouts)
|
@foreach (KeyValuePair<string, string> panelayout in _panelayouts)
|
||||||
{
|
{
|
||||||
<option value="@panelayout.Key">@panelayout.Value</option>
|
<option value="@panelayout.Key">@panelayout.Value</option>
|
||||||
}
|
}
|
||||||
|
@ -77,23 +77,23 @@ else
|
||||||
<label class="control-label">Default Container: </label>
|
<label class="control-label">Default Container: </label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" @bind="@containertype">
|
<select class="form-control" @bind="@_containertype">
|
||||||
<option value=""><Select Container></option>
|
<option value=""><Select Container></option>
|
||||||
@foreach (KeyValuePair<string, string>container in containers)
|
@foreach (KeyValuePair<string, string>container in _containers)
|
||||||
{
|
{
|
||||||
<option value="@container.Key">@container.Value</option>
|
<option value="@container.Key">@container.Value</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@if (!isinitialized)
|
@if (!_isinitialized)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label class="control-label">Host Username:</label>
|
<label class="control-label">Host Username:</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input class="form-control" @bind="@username" readonly />
|
<input class="form-control" @bind="@_username" readonly />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -101,7 +101,7 @@ else
|
||||||
<label class="control-label">Host Password:</label>
|
<label class="control-label">Host Password:</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="password" class="form-control" @bind="@password" />
|
<input type="password" class="form-control" @bind="@_password" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
@ -113,50 +113,50 @@ else
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||||
|
|
||||||
Dictionary<string, string> themes = new Dictionary<string, string>();
|
Dictionary<string, string> _themes = new Dictionary<string, string>();
|
||||||
Dictionary<string, string> panelayouts = new Dictionary<string, string>();
|
Dictionary<string, string> _panelayouts = new Dictionary<string, string>();
|
||||||
Dictionary<string, string> containers = new Dictionary<string, string>();
|
Dictionary<string, string> _containers = new Dictionary<string, string>();
|
||||||
|
|
||||||
List<Theme> Themes;
|
List<Theme> _themeList;
|
||||||
List<Tenant> tenants;
|
List<Tenant> _tenants;
|
||||||
string tenantid = "-1";
|
string _tenantid = "-1";
|
||||||
string name = "";
|
string _name = "";
|
||||||
string urls = "";
|
string _urls = "";
|
||||||
string themetype = "";
|
string _themetype = "";
|
||||||
string layouttype = "";
|
string _layouttype = "";
|
||||||
string containertype = "";
|
string _containertype = "";
|
||||||
bool isinitialized = true;
|
bool _isinitialized = true;
|
||||||
string username = "";
|
string _username = "";
|
||||||
string password = "";
|
string _password = "";
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
Themes = await ThemeService.GetThemesAsync();
|
_themeList = await ThemeService.GetThemesAsync();
|
||||||
tenants = await TenantService.GetTenantsAsync();
|
_tenants = await TenantService.GetTenantsAsync();
|
||||||
urls = PageState.Alias.Name;
|
_urls = PageState.Alias.Name;
|
||||||
themes = ThemeService.GetThemeTypes(Themes);
|
_themes = ThemeService.GetThemeTypes(_themeList);
|
||||||
containers = ThemeService.GetContainerTypes(Themes);
|
_containers = ThemeService.GetContainerTypes(_themeList);
|
||||||
username = Constants.HostUser;
|
_username = Constants.HostUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void TenantChanged(ChangeEventArgs e)
|
private async void TenantChanged(ChangeEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tenantid = (string)e.Value;
|
_tenantid = (string)e.Value;
|
||||||
if (tenantid != "-1")
|
if (_tenantid != "-1")
|
||||||
{
|
{
|
||||||
Tenant tenant = tenants.Where(item => item.TenantId == int.Parse(tenantid)).FirstOrDefault();
|
Tenant tenant = _tenants.Where(item => item.TenantId == int.Parse(_tenantid)).FirstOrDefault();
|
||||||
if (tenant != null)
|
if (tenant != null)
|
||||||
{
|
{
|
||||||
isinitialized = tenant.IsInitialized;
|
_isinitialized = tenant.IsInitialized;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Loading Tenant {TenantId} {Error}", tenantid, ex.Message);
|
await logger.LogError(ex, "Error Loading Tenant {TenantId} {Error}", _tenantid, ex.Message);
|
||||||
AddModuleMessage("Error Loading Tenant", MessageType.Error);
|
AddModuleMessage("Error Loading Tenant", MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,31 +165,31 @@ else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
themetype = (string)e.Value;
|
_themetype = (string)e.Value;
|
||||||
if (themetype != "")
|
if (_themetype != "")
|
||||||
{
|
{
|
||||||
panelayouts = ThemeService.GetPaneLayoutTypes(Themes, themetype);
|
_panelayouts = ThemeService.GetPaneLayoutTypes(_themeList, _themetype);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
panelayouts = new Dictionary<string, string>();
|
_panelayouts = new Dictionary<string, string>();
|
||||||
}
|
}
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", themetype, ex.Message);
|
await logger.LogError(ex, "Error Loading Pane Layouts For Theme {ThemeType} {Error}", _themetype, ex.Message);
|
||||||
AddModuleMessage("Error Loading Pane Layouts For Theme", MessageType.Error);
|
AddModuleMessage("Error Loading Pane Layouts For Theme", MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SaveSite()
|
private async Task SaveSite()
|
||||||
{
|
{
|
||||||
if (tenantid != "-1" && name != "" && urls != "" && !string.IsNullOrEmpty(themetype) && (panelayouts.Count == 0 || !string.IsNullOrEmpty(layouttype)) && !string.IsNullOrEmpty(containertype))
|
if (_tenantid != "-1" && _name != "" && _urls != "" && !string.IsNullOrEmpty(_themetype) && (_panelayouts.Count == 0 || !string.IsNullOrEmpty(_layouttype)) && !string.IsNullOrEmpty(_containertype))
|
||||||
{
|
{
|
||||||
bool unique = true;
|
bool unique = true;
|
||||||
List<Alias> aliases = await AliasService.GetAliasesAsync();
|
List<Alias> aliases = await AliasService.GetAliasesAsync();
|
||||||
foreach (string name in urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
foreach (string name in _urls.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
if (aliases.Exists(item => item.Name == name))
|
if (aliases.Exists(item => item.Name == name))
|
||||||
{
|
{
|
||||||
|
@ -200,12 +200,12 @@ else
|
||||||
{
|
{
|
||||||
bool isvalid = true;
|
bool isvalid = true;
|
||||||
|
|
||||||
if (!isinitialized)
|
if (!_isinitialized)
|
||||||
{
|
{
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.SiteId = PageState.Site.SiteId;
|
user.SiteId = PageState.Site.SiteId;
|
||||||
user.Username = username;
|
user.Username = _username;
|
||||||
user.Password = password;
|
user.Password = _password;
|
||||||
user = await UserService.LoginUserAsync(user, false, false);
|
user = await UserService.LoginUserAsync(user, false, false);
|
||||||
isvalid = user.IsAuthenticated;
|
isvalid = user.IsAuthenticated;
|
||||||
}
|
}
|
||||||
|
@ -215,24 +215,24 @@ else
|
||||||
ShowProgressIndicator();
|
ShowProgressIndicator();
|
||||||
|
|
||||||
aliases = new List<Alias>();
|
aliases = new List<Alias>();
|
||||||
urls = urls.Replace("\n", ",");
|
_urls = _urls.Replace("\n", ",");
|
||||||
foreach (string name in urls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
foreach (string name in _urls.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
Alias alias = new Alias();
|
Alias alias = new Alias();
|
||||||
alias.Name = name;
|
alias.Name = name;
|
||||||
alias.TenantId = int.Parse(tenantid);
|
alias.TenantId = int.Parse(_tenantid);
|
||||||
alias.SiteId = -1;
|
alias.SiteId = -1;
|
||||||
alias = await AliasService.AddAliasAsync(alias);
|
alias = await AliasService.AddAliasAsync(alias);
|
||||||
aliases.Add(alias);
|
aliases.Add(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
Site site = new Site();
|
Site site = new Site();
|
||||||
site.TenantId = int.Parse(tenantid);
|
site.TenantId = int.Parse(_tenantid);
|
||||||
site.Name = name;
|
site.Name = _name;
|
||||||
site.LogoFileId = null;
|
site.LogoFileId = null;
|
||||||
site.DefaultThemeType = themetype;
|
site.DefaultThemeType = _themetype;
|
||||||
site.DefaultLayoutType = (layouttype == null ? "" : layouttype);
|
site.DefaultLayoutType = (_layouttype == null ? "" : _layouttype);
|
||||||
site.DefaultContainerType = containertype;
|
site.DefaultContainerType = _containertype;
|
||||||
site = await SiteService.AddSiteAsync(site, aliases[0]);
|
site = await SiteService.AddSiteAsync(site, aliases[0]);
|
||||||
|
|
||||||
foreach (Alias alias in aliases)
|
foreach (Alias alias in aliases)
|
||||||
|
@ -241,19 +241,19 @@ else
|
||||||
await AliasService.UpdateAliasAsync(alias);
|
await AliasService.UpdateAliasAsync(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isinitialized)
|
if (!_isinitialized)
|
||||||
{
|
{
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.SiteId = site.SiteId;
|
user.SiteId = site.SiteId;
|
||||||
user.Username = username;
|
user.Username = _username;
|
||||||
user.Password = password;
|
user.Password = _password;
|
||||||
user.Email = PageState.User.Email;
|
user.Email = PageState.User.Email;
|
||||||
user.DisplayName = PageState.User.DisplayName;
|
user.DisplayName = PageState.User.DisplayName;
|
||||||
user = await UserService.AddUserAsync(user, aliases[0]);
|
user = await UserService.AddUserAsync(user, aliases[0]);
|
||||||
|
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
Tenant tenant = tenants.Where(item => item.TenantId == int.Parse(tenantid)).FirstOrDefault();
|
Tenant tenant = _tenants.FirstOrDefault(item => item.TenantId == int.Parse(_tenantid));
|
||||||
tenant.IsInitialized = true;
|
tenant.IsInitialized = true;
|
||||||
await TenantService.UpdateTenantAsync(tenant);
|
await TenantService.UpdateTenantAsync(tenant);
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ else
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await logger.LogError("Invalid Password Entered For Host {Username}", username);
|
await logger.LogError("Invalid Password Entered For Host {Username}", _username);
|
||||||
AddModuleMessage("Invalid Host Password", MessageType.Error);
|
AddModuleMessage("Invalid Host Password", MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
@inject IModuleService ModuleService
|
@inject IModuleService ModuleService
|
||||||
@inject IModuleDefinitionService ModuleDefinitionService
|
@inject IModuleDefinitionService ModuleDefinitionService
|
||||||
@inject ILogService LogService
|
@inject ILogService LogService
|
||||||
|
@using System.Diagnostics.CodeAnalysis
|
||||||
@implements IHandleAfterRender
|
@implements IHandleAfterRender
|
||||||
|
|
||||||
@DynamicComponent
|
@DynamicComponent
|
||||||
|
@ -65,6 +66,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "StringIndexOfIsCultureSpecific.1")]
|
||||||
private async Task Refresh()
|
private async Task Refresh()
|
||||||
{
|
{
|
||||||
Alias alias = null;
|
Alias alias = null;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
@namespace Oqtane.UI
|
@namespace Oqtane.UI
|
||||||
@inject IJSRuntime jsRuntime
|
@inject IJSRuntime JsRuntime
|
||||||
|
|
||||||
@DynamicComponent
|
@DynamicComponent
|
||||||
|
|
||||||
|
|
|
@ -49,11 +49,11 @@ namespace Oqtane.Controllers
|
||||||
name = WebUtility.UrlDecode(name);
|
name = WebUtility.UrlDecode(name);
|
||||||
List<Alias> aliases = _aliases.GetAliases().ToList();
|
List<Alias> aliases = _aliases.GetAliases().ToList();
|
||||||
Alias alias = null;
|
Alias alias = null;
|
||||||
alias = aliases.Where(item => item.Name == name).FirstOrDefault();
|
alias = aliases.FirstOrDefault(item => item.Name == name);
|
||||||
if (alias == null && name.Contains("/"))
|
if (name != null && (alias == null && name.Contains("/")))
|
||||||
{
|
{
|
||||||
// lookup alias without folder name
|
// lookup alias without folder name
|
||||||
alias = aliases.Find(item => item.Name == name.Substring(0, name.IndexOf("/")));
|
alias = aliases.Find(item => item.Name == name.Substring(0, name.IndexOf("/", StringComparison.Ordinal)));
|
||||||
}
|
}
|
||||||
if (alias == null && aliases.Count > 0)
|
if (alias == null && aliases.Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -71,27 +71,27 @@ namespace Oqtane.Controllers
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = Constants.AdminRole)]
|
||||||
public Alias Post([FromBody] Alias Alias)
|
public Alias Post([FromBody] Alias alias)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
Alias = _aliases.AddAlias(Alias);
|
alias = _aliases.AddAlias(alias);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Alias Added {Alias}", Alias);
|
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Alias Added {Alias}", alias);
|
||||||
}
|
}
|
||||||
return Alias;
|
return alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.AdminRole)]
|
[Authorize(Roles = Constants.AdminRole)]
|
||||||
public Alias Put(int id, [FromBody] Alias Alias)
|
public Alias Put(int id, [FromBody] Alias alias)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
Alias = _aliases.UpdateAlias(Alias);
|
alias = _aliases.UpdateAlias(alias);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Alias Updated {Alias}", Alias);
|
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Alias Updated {Alias}", alias);
|
||||||
}
|
}
|
||||||
return Alias;
|
return alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
|
|
|
@ -61,11 +61,12 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
foreach (string file in Directory.GetFiles(folder))
|
foreach (string file in Directory.GetFiles(folder))
|
||||||
{
|
{
|
||||||
files.Add(new Models.File { Name = Path.GetFileName(file), Extension = Path.GetExtension(file).Replace(".","") });
|
files.Add(new Models.File {Name = Path.GetFileName(file), Extension = Path.GetExtension(file)?.Replace(".", "")});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +96,7 @@ namespace Oqtane.Controllers
|
||||||
HttpContext.Response.StatusCode = 401;
|
HttpContext.Response.StatusCode = 401;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +105,7 @@ namespace Oqtane.Controllers
|
||||||
public Models.File Get(int id)
|
public Models.File Get(int id)
|
||||||
{
|
{
|
||||||
Models.File file = _files.GetFile(id);
|
Models.File file = _files.GetFile(id);
|
||||||
if (_userPermissions.IsAuthorized(User,PermissionNames.View, file.Folder.Permissions))
|
if (_userPermissions.IsAuthorized(User, PermissionNames.View, file.Folder.Permissions))
|
||||||
{
|
{
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
@ -118,20 +120,21 @@ namespace Oqtane.Controllers
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = Constants.RegisteredRole)]
|
[Authorize(Roles = Constants.RegisteredRole)]
|
||||||
public Models.File Put(int id, [FromBody] Models.File File)
|
public Models.File Put(int id, [FromBody] Models.File file)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Folder, File.Folder.FolderId, PermissionNames.Edit))
|
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, EntityNames.Folder, file.Folder.FolderId, PermissionNames.Edit))
|
||||||
{
|
{
|
||||||
File = _files.UpdateFile(File);
|
file = _files.UpdateFile(file);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "File Updated {File}", File);
|
_logger.Log(LogLevel.Information, this, LogFunction.Update, "File Updated {File}", file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update File {File}", File);
|
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update File {File}", file);
|
||||||
HttpContext.Response.StatusCode = 401;
|
HttpContext.Response.StatusCode = 401;
|
||||||
File = null;
|
file = null;
|
||||||
}
|
}
|
||||||
return File;
|
|
||||||
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
// DELETE api/<controller>/5
|
||||||
|
@ -149,6 +152,7 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
System.IO.File.Delete(filepath);
|
System.IO.File.Delete(filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "File Deleted {File}", file);
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "File Deleted {File}", file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -164,11 +168,11 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
Models.File file = null;
|
Models.File file = null;
|
||||||
Folder folder = _folders.GetFolder(int.Parse(folderid));
|
Folder folder = _folders.GetFolder(int.Parse(folderid));
|
||||||
if (folder != null && _userPermissions.IsAuthorized(User,PermissionNames.Edit, folder.Permissions))
|
if (folder != null && _userPermissions.IsAuthorized(User, PermissionNames.Edit, folder.Permissions))
|
||||||
{
|
{
|
||||||
string folderpath = GetFolderPath(folder);
|
string folderpath = GetFolderPath(folder);
|
||||||
CreateDirectory(folderpath);
|
CreateDirectory(folderpath);
|
||||||
string filename = url.Substring(url.LastIndexOf("/") + 1);
|
string filename = url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1);
|
||||||
// check for allowable file extensions
|
// check for allowable file extensions
|
||||||
if (Constants.UploadableFiles.Contains(Path.GetExtension(filename).Replace(".", "")))
|
if (Constants.UploadableFiles.Contains(Path.GetExtension(filename).Replace(".", "")))
|
||||||
{
|
{
|
||||||
|
@ -180,6 +184,7 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
System.IO.File.Delete(folderpath + filename);
|
System.IO.File.Delete(folderpath + filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
client.DownloadFile(url, folderpath + filename);
|
client.DownloadFile(url, folderpath + filename);
|
||||||
_files.AddFile(CreateFile(filename, folder.FolderId, folderpath + filename));
|
_files.AddFile(CreateFile(filename, folder.FolderId, folderpath + filename));
|
||||||
}
|
}
|
||||||
|
@ -199,6 +204,7 @@ namespace Oqtane.Controllers
|
||||||
HttpContext.Response.StatusCode = 401;
|
HttpContext.Response.StatusCode = 401;
|
||||||
file = null;
|
file = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +219,7 @@ namespace Oqtane.Controllers
|
||||||
if (int.TryParse(folder, out folderid))
|
if (int.TryParse(folder, out folderid))
|
||||||
{
|
{
|
||||||
Folder Folder = _folders.GetFolder(folderid);
|
Folder Folder = _folders.GetFolder(folderid);
|
||||||
if (Folder != null && _userPermissions.IsAuthorized(User,PermissionNames.Edit, Folder.Permissions))
|
if (Folder != null && _userPermissions.IsAuthorized(User, PermissionNames.Edit, Folder.Permissions))
|
||||||
{
|
{
|
||||||
folderpath = GetFolderPath(Folder);
|
folderpath = GetFolderPath(Folder);
|
||||||
}
|
}
|
||||||
|
@ -225,6 +231,7 @@ namespace Oqtane.Controllers
|
||||||
folderpath = GetFolderPath(folder);
|
folderpath = GetFolderPath(folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (folderpath != "")
|
if (folderpath != "")
|
||||||
{
|
{
|
||||||
CreateDirectory(folderpath);
|
CreateDirectory(folderpath);
|
||||||
|
@ -232,6 +239,7 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
await file.CopyToAsync(stream);
|
await file.CopyToAsync(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
string upload = await MergeFile(folderpath, file.FileName);
|
string upload = await MergeFile(folderpath, file.FileName);
|
||||||
if (upload != "" && folderid != -1)
|
if (upload != "" && folderid != -1)
|
||||||
{
|
{
|
||||||
|
@ -252,19 +260,19 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// parse the filename which is in the format of filename.ext.part_x_y
|
// parse the filename which is in the format of filename.ext.part_x_y
|
||||||
string token = ".part_";
|
string token = ".part_";
|
||||||
string parts = Path.GetExtension(filename).Replace(token, ""); // returns "x_y"
|
string parts = Path.GetExtension(filename)?.Replace(token, ""); // returns "x_y"
|
||||||
int totalparts = int.Parse(parts.Substring(parts.IndexOf("_") + 1));
|
int totalparts = int.Parse(parts?.Substring(parts.IndexOf("_") + 1));
|
||||||
filename = filename.Substring(0, filename.IndexOf(token)); // base filename
|
filename = filename?.Substring(0, filename.IndexOf(token)); // base filename
|
||||||
string[] fileparts = Directory.GetFiles(folder, filename + token + "*"); // list of all file parts
|
string[] fileParts = Directory.GetFiles(folder, filename + token + "*"); // list of all file parts
|
||||||
|
|
||||||
// if all of the file parts exist ( note that file parts can arrive out of order )
|
// if all of the file parts exist ( note that file parts can arrive out of order )
|
||||||
if (fileparts.Length == totalparts && CanAccessFiles(fileparts))
|
if (fileParts.Length == totalparts && CanAccessFiles(fileParts))
|
||||||
{
|
{
|
||||||
// merge file parts
|
// merge file parts
|
||||||
bool success = true;
|
bool success = true;
|
||||||
using (var stream = new FileStream(Path.Combine(folder, filename + ".tmp"), FileMode.Create))
|
using (var stream = new FileStream(Path.Combine(folder, filename + ".tmp"), FileMode.Create))
|
||||||
{
|
{
|
||||||
foreach (string filepart in fileparts)
|
foreach (string filepart in fileParts)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -283,13 +291,13 @@ namespace Oqtane.Controllers
|
||||||
// delete file parts and rename file
|
// delete file parts and rename file
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
foreach (string filepart in fileparts)
|
foreach (string filepart in fileParts)
|
||||||
{
|
{
|
||||||
System.IO.File.Delete(filepart);
|
System.IO.File.Delete(filepart);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for allowable file extensions
|
// check for allowable file extensions
|
||||||
if (!Constants.UploadableFiles.Contains(Path.GetExtension(filename).Replace(".", "")))
|
if (!Constants.UploadableFiles.Contains(Path.GetExtension(filename)?.Replace(".", "")))
|
||||||
{
|
{
|
||||||
System.IO.File.Delete(Path.Combine(folder, filename + ".tmp"));
|
System.IO.File.Delete(Path.Combine(folder, filename + ".tmp"));
|
||||||
}
|
}
|
||||||
|
@ -300,17 +308,19 @@ namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
System.IO.File.Delete(Path.Combine(folder, filename));
|
System.IO.File.Delete(Path.Combine(folder, filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
// rename file now that the entire process is completed
|
// rename file now that the entire process is completed
|
||||||
System.IO.File.Move(Path.Combine(folder, filename + ".tmp"), Path.Combine(folder, filename));
|
System.IO.File.Move(Path.Combine(folder, filename + ".tmp"), Path.Combine(folder, filename));
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "File Uploaded {File}", Path.Combine(folder, filename));
|
_logger.Log(LogLevel.Information, this, LogFunction.Create, "File Uploaded {File}", Path.Combine(folder, filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
merged = filename;
|
merged = filename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up file parts which are more than 2 hours old ( which can happen if a prior file upload failed )
|
// clean up file parts which are more than 2 hours old ( which can happen if a prior file upload failed )
|
||||||
fileparts = Directory.GetFiles(folder, "*" + token + "*");
|
fileParts = Directory.GetFiles(folder, "*" + token + "*");
|
||||||
foreach (string filepart in fileparts)
|
foreach (string filepart in fileParts)
|
||||||
{
|
{
|
||||||
DateTime createddate = System.IO.File.GetCreationTime(filepart).ToUniversalTime();
|
DateTime createddate = System.IO.File.GetCreationTime(filepart).ToUniversalTime();
|
||||||
if (createddate < DateTime.UtcNow.AddHours(-2))
|
if (createddate < DateTime.UtcNow.AddHours(-2))
|
||||||
|
@ -349,13 +359,16 @@ namespace Oqtane.Controllers
|
||||||
stream.Close();
|
stream.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
attempts += 1;
|
attempts += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (locked && canaccess)
|
if (locked && canaccess)
|
||||||
{
|
{
|
||||||
canaccess = false;
|
canaccess = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return canaccess;
|
return canaccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,7 +377,7 @@ namespace Oqtane.Controllers
|
||||||
public IActionResult Download(int id)
|
public IActionResult Download(int id)
|
||||||
{
|
{
|
||||||
Models.File file = _files.GetFile(id);
|
Models.File file = _files.GetFile(id);
|
||||||
if (file != null && _userPermissions.IsAuthorized(User,PermissionNames.View, file.Folder.Permissions))
|
if (file != null && _userPermissions.IsAuthorized(User, PermissionNames.View, file.Folder.Permissions))
|
||||||
{
|
{
|
||||||
string filepath = GetFolderPath(file.Folder) + file.Name;
|
string filepath = GetFolderPath(file.Folder) + file.Name;
|
||||||
if (System.IO.File.Exists(filepath))
|
if (System.IO.File.Exists(filepath))
|
||||||
|
@ -402,7 +415,7 @@ namespace Oqtane.Controllers
|
||||||
if (!Directory.Exists(folderpath))
|
if (!Directory.Exists(folderpath))
|
||||||
{
|
{
|
||||||
string path = "";
|
string path = "";
|
||||||
string[] folders = folderpath.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
|
string[] folders = folderpath.Split(new char[] {'\\'}, StringSplitOptions.RemoveEmptyEntries);
|
||||||
foreach (string folder in folders)
|
foreach (string folder in folders)
|
||||||
{
|
{
|
||||||
path += folder + "\\";
|
path += folder + "\\";
|
||||||
|
@ -422,7 +435,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
FileInfo fileinfo = new FileInfo(filepath);
|
FileInfo fileinfo = new FileInfo(filepath);
|
||||||
file.Extension = fileinfo.Extension.ToLower().Replace(".", "");
|
file.Extension = fileinfo.Extension.ToLower().Replace(".", "");
|
||||||
file.Size = (int)fileinfo.Length;
|
file.Size = (int) fileinfo.Length;
|
||||||
file.ImageHeight = 0;
|
file.ImageHeight = 0;
|
||||||
file.ImageWidth = 0;
|
file.ImageWidth = 0;
|
||||||
|
|
||||||
|
@ -434,6 +447,7 @@ namespace Oqtane.Controllers
|
||||||
file.ImageHeight = image.Height;
|
file.ImageHeight = image.Height;
|
||||||
file.ImageWidth = image.Width;
|
file.ImageWidth = image.Width;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.Close();
|
stream.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user