This commit is contained in:
2023-01-09 00:32:32 +00:00
parent 92392d23e3
commit ae40f8e46b

View File

@@ -29,7 +29,7 @@ namespace Sockeye.Biz
public const string PLUGIN_RI_KEY = "RI - Responsive Interface";
private static Dictionary<string, DateTime> _plugins;
//private static Dictionary<string, DateTime> _plugins;
//Generate a key message reply from a key selection object
//CALLED BY LicenseController Generate route
@@ -170,7 +170,7 @@ namespace Sockeye.Biz
// Extra info to display about key at top of key message
private static string LicenseInfo(dtoKeyOptions ko)
private static string LicenseInfo(License l)
{
StringBuilder sb = new StringBuilder();
sb.Append("LICENSE DETAILS\r\n");
@@ -184,36 +184,36 @@ namespace Sockeye.Biz
// sb.Append("This license will expire and AyaNova usage will be restricted after: " + kg.Expires.ToLongDateString() + "\r\n\r\n");
//}
if (ko.keyWillLockout)
if (l.LicenseExpire != null)
{
sb.Append("*** This temporary license key is provided for evaluation use only pending payment ***\r\n");
sb.Append("This license will expire and AyaNova usage will be restricted after: " + DateUtil.EpochToString(ko.lockoutDate) + "\r\n");
sb.Append($"This license will expire and AyaNova usage will be restricted after: {l.LicenseExpire}\r\n");
sb.Append("\r\n");
sb.Append("A permanent license key will be sent to you when payment \r\n" +
"has been received and processed. There will be no extensions or \r\n" +
"exceptions. Please send in payment early enough to allow for \r\n" +
"mail and processing time to ensure uninterrupted use of AyaNova" + (ko.isLite ? " Lite" : "") + ". \r\n\r\n");
"mail and processing time to ensure uninterrupted use of AyaNova. \r\n\r\n");
}
sb.Append("Registered to: ");
sb.Append(ko.registeredTo);
sb.Append(l.RegTo);
sb.Append("\r\n");
//case 3233
sb.Append("Fetch address: ");
sb.Append(ko.emailAddress);
sb.Append(l.FetchEmail);
sb.Append("\r\n");
sb.Append("Fetch code: ");
sb.Append(ko.fetchCode);
sb.Append(l.FetchCode);
sb.Append("\r\n");
sb.Append("Scheduleable resources: ");
switch (ko.users)
switch (l.Users)
{
case 1:
sb.AppendLine("1");
@@ -238,13 +238,13 @@ namespace Sockeye.Biz
break;
}
sb.AppendLine("Support and updates until: " + DateUtil.EpochToString(ko.supportExpiresDate) + "\r\n");
if (_plugins.Count > 0)
sb.AppendLine($"Support and updates until: {l.MaintenanceExpire}\r\n");
var Plugs=LicenseToPluginsArray(l);
if (Plugs.Count > 0)
{
sb.Append("\r\n");
sb.Append("Plugins:\r\n");
foreach (KeyValuePair<string, DateTime> kv in _plugins)
foreach (KeyValuePair<string, DateTime> kv in Plugs)
{
sb.Append("\t");
sb.Append(kv.Key);
@@ -279,30 +279,59 @@ namespace Sockeye.Biz
}
private static Dictionary<string, DateTime> LicenseToPluginsArray(License l)
{
Dictionary<string, DateTime> Plugs = new Dictionary<string, DateTime>();
if (l.MBI)
Plugs.Add(PLUGIN_MBI_KEY, (DateTime)l.MBIExpires);
if (l.WBI)
Plugs.Add(PLUGIN_WBI_KEY, (DateTime)l.WBIExpires);
if (l.QBI)
Plugs.Add(PLUGIN_QBI_KEY, (DateTime)l.QBIExpires);
if (l.QBOI)
Plugs.Add(PLUGIN_QBOI_KEY, (DateTime)l.QBOIExpires);
if (l.PTI)
Plugs.Add(PLUGIN_PTI_KEY, (DateTime)l.PTIExpires);
if (l.QuickNotification)
Plugs.Add(PLUGIN_QUICK_NOTIFICATION_KEY, (DateTime)l.QuickNotificationExpires);
if (l.ExportToXLS)
Plugs.Add(PLUGIN_EXPORT_TO_XLS_KEY, (DateTime)l.ExportToXLSExpires);
if (l.OutlookSchedule)
Plugs.Add(PLUGIN_OUTLOOK_SCHEDULE_KEY, (DateTime)l.OutlookScheduleExpires);
if (l.OLI)
Plugs.Add(PLUGIN_OLI_KEY, (DateTime)l.OLIExpires);
if (l.ImportExportCSVDuplicate)
Plugs.Add(PLUGIN_IMPORT_EXPORT_CSV_DUPLICATE_KEY, (DateTime)l.ImportExportCSVDuplicateExpires);
if (l.RI)
Plugs.Add(PLUGIN_RI_KEY, (DateTime)l.RIExpires);
return Plugs;
}
/// <summary>
/// Generate keycode based on passed in data
/// This is called by both regular and trial license key routes
/// </summary>
/// <returns></returns>
private static string genKey(License l)
{
_plugins = new Dictionary<string, DateTime>();
try
private static void genKey(License l)
{
StringBuilder sbKey = new StringBuilder();
StringWriter sw = new StringWriter(sbKey);
l.FetchCode = GenFetchCode();
using (Newtonsoft.Json.JsonWriter w = new Newtonsoft.Json.JsonTextWriter(sw))
{
w.Formatting = Newtonsoft.Json.Formatting.Indented;
//outer object start
w.WriteStartObject();
w.WritePropertyName("AyaNovaLicenseKey");
@@ -354,7 +383,7 @@ namespace Sockeye.Biz
w.WritePropertyName("Expires");
w.WriteValue(l.MaintenanceExpire);
if (l.LicenseExpire!=null)
if (l.LicenseExpire != null)
{
w.WritePropertyName("LockDate");
w.WriteValue(l.LicenseExpire);
@@ -473,25 +502,12 @@ oArP0E2Vbow3JMxq/oeXmHbrLMLQfYyXwFmciLFigOtkd45bfHdrbA==
sbOut.AppendLine(signature);
sbOut.AppendLine("SIGNATURE]");
// //case 3233 insert into db
// License l = new License();
// l.DtCreated = DateUtil.NowAsEpoch();
// l.Code = ko.fetchCode;
// l.CustomerId = ko.customerId;
// l.Email = ko.emailAddress.ToLowerInvariant();
// l.Key = sbOut.ToString();
// l.RegTo = ko.registeredTo;
// ct.License.Add(l);
// ct.SaveChanges();
return sbOut.ToString();
l.Key = sbOut.ToString();
}
catch (Exception ex)
{
return (ex.Message);
}
}
@@ -499,9 +515,7 @@ oArP0E2Vbow3JMxq/oeXmHbrLMLQfYyXwFmciLFigOtkd45bfHdrbA==
private static void AddLicensePlugin(Newtonsoft.Json.JsonWriter w, string pluginName, DateTime? pluginExpires)
{
//this dictionary is used by the additional message code to
//make the human readable portion of the license
_plugins.Add(pluginName, (DateTime)pluginExpires);
//this is adding it to the actual key
w.WriteStartObject();