Finkit.ManicTime.Client.Main.Views.LicenseViewModel.OnOkCommand() : Void
private
void
OnOkCommand()
{
try
{
Finkit.ManicTime.Common.Licensing.License license = Finkit.ManicTime.Common.Licensing.License.Current;[color=#008000]
if
(license !=
null
&& license.LicenseType ==
this
.LicenseType &&
this
._licenseService.IsLicenseValidForThisVersion(license) && (
this
.LicenseType != LicenseType.Professional || !
this
.IsLicenseEditable))
{
this
.CloseWindow(
true
);
}
else
if
(license ==
null
|| license.LicenseType != LicenseType.Professional || ViewHelper.ShowMessage(
base
.WindowHost, Translation.Current[
"RemoveLicense"
], Translation.Current[
"RemoveLicenseConfirmation"
],
new
MessageButton[]
{
MessageButtons.Yes,
MessageButtons.No
}, MessageButtons.Yes, MessageButtons.No) != MessageButtons.No)
{
if
(
this
.LicenseType == LicenseType.Standard)
{
using
(FreeLicenseWarningViewModel freeLicenseWarningViewModel =
this
._freeLicenseWarningViewModelFunc())
{
ViewHelper.ShowViewModelWindow(
base
.WindowHost, freeLicenseWarningViewModel);
LicenseType? selectedLicenseType = freeLicenseWarningViewModel.SelectedLicenseType;
if
(selectedLicenseType != LicenseType.Standard)
{
if
(selectedLicenseType == LicenseType.Trial)
{
this
.CloseWindow(
true
);
}
else
if
(selectedLicenseType == LicenseType.Professional)
{
this
.LicenseType = LicenseType.Professional;
}
return
;
}
}
}
if
(license !=
null
&& license.LicenseType == LicenseType.Professional &&
this
.LicenseType == LicenseType.Trial &&
this
._trialProvider.TrialDaysLeft <= 0 &&
this
._trialProvider.CanActivateLicenseExtendedTrial(license))[color=#008000]
{
this
._trialProvider.ActivateLicenseExtendedTrial(license);
}
string
licenseName = (
this
.LicenseType == LicenseType.Professional) ?
this
.LicenseName :
null
;[color=#008000]
string
licenseKey = (
this
.LicenseType == LicenseType.Professional) ?
this
.LicenseKey :
null
;[color=#008000]
string
text =
this
._licenseService.SaveLicense(
this
.LicenseType, licenseName, licenseKey);[color=#008000]
if
(text ==
null
)
{
if
(
this
.LicenseType == LicenseType.Professional)[color=#008000]
{
ViewHelper.ShowMessage(
base
.WindowHost, Translation.Current[
"ThankYou"
], Translation.Current[
"ThankYouLicense"
], MessageButtons.Ok);[color=#008000]
}
this
.CloseWindow(
true
);
}
else
{
ViewHelper.ShowMessage(
base
.WindowHost, Translation.Current[
"InvalidLicenseTitle"
], text, MessageButtons.Ok);[color=#008000]
}
}
}
catch
(Exception ex)
{
ApplicationLog.WriteError(ex);
ViewHelper.ShowMessage(
base
.WindowHost, Translation.Current[
"Error"
], Translation.Current[
"ErrorCheckingLicense"
], MessageButtons.Ok);
}
}