global support license and validation

This commit is contained in:
Gary Sharp
2024-01-26 16:23:26 +11:00
parent f90eda4101
commit d8eb8fec83
8 changed files with 739 additions and 196 deletions
@@ -42,6 +42,26 @@ namespace Disco.Web.Areas.API.Controllers
return RedirectToAction(MVC.Config.Logging.TaskStatus(ts.SessionId));
}
[DiscoAuthorize(Claims.Config.System.Show)]
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult LicenseCheck(string license)
{
if (string.IsNullOrWhiteSpace(license))
{
Database.DiscoConfiguration.LicenseKey = null;
Database.DiscoConfiguration.LicenseExpiresOn = null;
Database.DiscoConfiguration.LicenseError = null;
Database.SaveChanges();
return RedirectToAction(MVC.Config.SystemConfig.Index());
}
else
{
var ts = Disco.Services.Interop.DiscoServices.LicenseValidationTask.ScheduleNow(license);
ts.SetFinishedUrl(Url.Action(MVC.Config.SystemConfig.Index()));
return RedirectToAction(MVC.Config.Logging.TaskStatus(ts.SessionId));
}
}
[DiscoAuthorize(Claims.Config.System.Show)]
public virtual ActionResult UpdateCheck()
{
@@ -112,6 +112,11 @@ namespace Disco.Web.Areas.Config.Models.SystemConfig
public bool EmailIsConfigured { get; set; }
#endregion
public ScheduledTaskStatus LicenseValidationRunningStatus { get; set; }
public string License { get; set; }
public DateTime? LicenseExpires { get; set; }
public string LicenseError { get; set; }
public ScheduledTaskStatus UpdateRunningStatus { get; set; }
public DateTime? UpdateNextScheduled { get; set; }
public UpdateResponseV2 UpdateLatestResponse { get; set; }
@@ -136,6 +141,10 @@ namespace Disco.Web.Areas.Config.Models.SystemConfig
EmailUsername = config.EmailUsername,
EmailPassword = null,
EmailIsConfigured = EmailService.IsConfigured,
License = config.LicenseKey,
LicenseExpires = config.LicenseExpiresOn,
LicenseError = config.LicenseError,
LicenseValidationRunningStatus = LicenseValidationTask.RunningStatus,
UpdateLatestResponse = config.UpdateLastCheckResponse,
UpdateRunningStatus = UpdateQueryTask.RunningStatus,
UpdateNextScheduled = UpdateQueryTask.NextScheduled,
@@ -69,6 +69,86 @@
</tr>
</table>
</div>
<div class="form" style="width: 450px; margin-top: 15px;">
<h2>License</h2>
<table>
@{
<tr>
<th style="width: 135px">
License:
</th>
<td>
@using (Html.BeginForm(MVC.API.System.LicenseCheck(), FormMethod.Post))
{
@Html.AntiForgeryToken();
<input id="license" type="text" name="license" value="@Model.License" />
<button type="submit" class="button small">Activate</button>
}
<script type="text/javascript">
$(function () {
const $element = $('#license');
const original = $element.val();
$element.on('keyup', function (e) {
const $button = $element.next('button');
const value = $element.val();
if (!original) {
$element.prop('required', true);
$button.text('Activate');
} else {
if (original === value) {
$button.text('Validate');
} else {
if (!value) {
$button.text('Clear');
} else {
$button.text('Activate');
}
}
}
}).trigger('keyup');
});
</script>
</td>
</tr>
if (Model.License != null)
{
<tr>
<th style="width: 135px">
Status:
</th>
<td>
@if (Model.LicenseError != null)
{
<div class="error"><i class="fa fa-exclamation-circle fa-lg"></i> @Model.LicenseError</div>
}
else
{
<span>Expires @CommonHelpers.FriendlyDate(Model.LicenseExpires)</span>
}
</td>
</tr>
}
else
{
<tr>
<td colspan="2">
<strong>Official support is available</strong>
<ul>
<li>Initial implementation assistance.</li>
<li>Commitment to maintaining Disco ICT functionality and associated plugins.</li>
<li>Direct support.</li>
<li>Access to additional functionality.</li>
<li>Ability to suggest additional functionality, with a voice in feature prioritisation.</li>
</ul>
<div style="text-align: right; margin-top: 4px;">
<a href="https://discoict.com.au/support.aspx" target="_blank" class="button small">Request More Information</a>
</div>
</td>
</tr>
}
}
</table>
</div>
<div class="form" style="width: 450px; margin-top: 15px;">
<h2>Updates</h2>
<table>
File diff suppressed because it is too large Load Diff
@@ -59,6 +59,12 @@ namespace Disco.Web.Areas.API.Controllers
return RedirectToActionPermanent(taskResult.Result);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult LicenseCheck()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.LicenseCheck);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult UpdateOrganisationName()
@@ -162,6 +168,7 @@ namespace Disco.Web.Areas.API.Controllers
public readonly string UpdateLastNetworkLogonDates = "UpdateLastNetworkLogonDates";
public readonly string UpdateAttachmentThumbnails = "UpdateAttachmentThumbnails";
public readonly string UpdateADDeviceDescriptions = "UpdateADDeviceDescriptions";
public readonly string LicenseCheck = "LicenseCheck";
public readonly string UpdateCheck = "UpdateCheck";
public readonly string UpdateOrganisationName = "UpdateOrganisationName";
public readonly string OrganisationLogo = "OrganisationLogo";
@@ -187,6 +194,7 @@ namespace Disco.Web.Areas.API.Controllers
public const string UpdateLastNetworkLogonDates = "UpdateLastNetworkLogonDates";
public const string UpdateAttachmentThumbnails = "UpdateAttachmentThumbnails";
public const string UpdateADDeviceDescriptions = "UpdateADDeviceDescriptions";
public const string LicenseCheck = "LicenseCheck";
public const string UpdateCheck = "UpdateCheck";
public const string UpdateOrganisationName = "UpdateOrganisationName";
public const string OrganisationLogo = "OrganisationLogo";
@@ -207,6 +215,14 @@ namespace Disco.Web.Areas.API.Controllers
}
static readonly ActionParamsClass_LicenseCheck s_params_LicenseCheck = new ActionParamsClass_LicenseCheck();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_LicenseCheck LicenseCheckParams { get { return s_params_LicenseCheck; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_LicenseCheck
{
public readonly string license = "license";
}
static readonly ActionParamsClass_UpdateOrganisationName s_params_UpdateOrganisationName = new ActionParamsClass_UpdateOrganisationName();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_UpdateOrganisationName UpdateOrganisationNameParams { get { return s_params_UpdateOrganisationName; } }
@@ -404,6 +420,18 @@ namespace Disco.Web.Areas.API.Controllers
return callInfo;
}
[NonAction]
partial void LicenseCheckOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string license);
[NonAction]
public override System.Web.Mvc.ActionResult LicenseCheck(string license)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.LicenseCheck);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "license", license);
LicenseCheckOverride(callInfo, license);
return callInfo;
}
[NonAction]
partial void UpdateCheckOverride(T4MVC_System_Web_Mvc_ActionResult callInfo);