public static bool UpdateLisence(string key) { try { var sn = SnProvider.CalculateSN(); var password = Encryption.MakePassword(sn, AppConfiguration.ApplicationIdentifier); var coreKey = key.Replace("-", string.Empty); if (password.Substring(3, 22) != coreKey.Substring(3, 22)) { throw new Exception("invalid lisence key!"); } var expiredDatetime = GetExpiredDateTime(coreKey); string HideInfo = string.Format("{0};{1};{2}", expiredDatetime.ToString(), coreKey, LisenceType.Full.GetHashCode()); if (File.Exists(GetLisencePath())) { File.Delete(GetLisencePath()); } FileReadWrite.WriteFile(GetLisencePath(), HideInfo); return(true); } catch (Exception ex) { Log.Error(ex); return(false); } }
public static bool ApplyTrialLisence() { try { if (GetLicense() != null) { throw new Exception("Already has lisence key!"); } var sn = SnProvider.CalculateSN(softwareName); var password = "******" + sn.Substring(3, 22); // trial version.. var expiredDatetime = GetExpiredDateTime(password); string HideInfo = string.Format("{0};{1};{2}", expiredDatetime.ToString(), password, LisenceType.Trial.GetHashCode()); FileReadWrite.WriteFile(GetLisencePath(), HideInfo); return(true); } catch (Exception ex) { Log.Error(ex); return(false); } }