/// <summary> /// Get the number of cameras that we are allowed to use /// </summary> internal static void getLicenseNumber() { try { AureusEdge.GetLicenseInfo(mp_aureus, msg); string info = msg.ToString(); int a = info.IndexOf("=") + 2; int b = info.IndexOf("Time remaining"); info = info.Substring(a, b - a).Trim(); //Try to parse the number numberOfLicense = Int32.Parse(info); } catch { //If it fails, default to 1 numberOfLicense = 1; } }
/// <summary> /// Call the get license info and display it /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LicensePage_Load(object sender, EventArgs e) { AureusEdge.GetLicenseInfo(Program.mp_aureus, Program.msg); this.mainDIsplay.Text = Program.msg.ToString(); this.mainDIsplay.Text = this.mainDIsplay.Text.Replace("\n", "\r\n\r\n"); //string expDate = ""; //Days int a = this.mainDIsplay.Text.IndexOf("Time remaining") + 14; int b = this.mainDIsplay.Text.IndexOf("days"); string days = this.mainDIsplay.Text.Substring(a, b - a).Trim(); ////Hours //a = this.mainDIsplay.Text.IndexOf("days,") + 5; //b = this.mainDIsplay.Text.IndexOf("hours"); //expDate = this.mainDIsplay.Text.Substring(a, b - a).Trim(); //DT = DT.AddHours(Int32.Parse(expDate)); ////Minutes //a = this.mainDIsplay.Text.IndexOf("hours,") + 6; //b = this.mainDIsplay.Text.IndexOf("min"); //expDate = this.mainDIsplay.Text.Substring(a, b - a).Trim(); //DT = DT.AddMinutes(Int32.Parse(expDate)); ////Seconds //a = this.mainDIsplay.Text.IndexOf("min,") + 4; //b = this.mainDIsplay.Text.IndexOf("sec"); //expDate = this.mainDIsplay.Text.Substring(a, b - a).Trim(); //DT = DT.AddSeconds(Int32.Parse(expDate)); DateTime DT = Program.getLicenseExp(Program.msg.ToString()); //Save the License Info string newLicense = "<licenseInformation><dateIssued>" + DateTime.Now.ToString("yyyyMMddHHmmss") + "</dateIssued><daysLeft>" + days + "</daysLeft><dateExpires>" + DT.ToString("yyyyMMddHHmmss") + "</dateExpires></licenseInformation>"; Program.save("LICENSE", newLicense); this.mainDIsplay.Text += "\r\n\r\nExpiration Date:\r\n\t" + DT.ToString(); this.mainDIsplay.Text = this.mainDIsplay.Text.Replace(" = ", ":\r\n\t").Replace("Time remaining ", "Time remaining:\r\n\t"); this.mainDIsplay.Refresh(); }
/// <summary> /// Check if the user has their license. If not, do not let them continue /// This will put the user in essentially an infinite loop until they get their license /// </summary> internal static void checkLicense() { bool canContinue = false; bool firstLoop = true; string failReason = ""; while (!canContinue) { if (File.Exists(licenseFile)) { //File does exist string fileContent = readFromFile(licenseFile).Trim(); if (fileContent == "") { //File exists but is empty failReason = "FILE-EMPTY"; } else { if (!firstLoop) { //Kill it AureusEdge.FreeAureus(mp_aureus, msg); //Re-initilize it mp_aureus = AureusEdge.CreateAndInitializeAureus(msg); } //Check if the license is valid AureusEdge.GetLicenseInfo(mp_aureus, msg); if (msg.ToString().Contains("Error!")) { //Invalid license failReason = "INVALID-CONTENT"; } else { //Do calculation licenseEXP = getLicenseExp(msg.ToString()); if (licenseEXP <= DateTime.Now) { //License has expired failReason = "EXPIRED"; } else { canContinue = true; break; } } } } else { //File does not exist. failReason = "FILE-NOT-FOUND"; } if (!canContinue) { //Display the error form IL = new InvalidLicense(); IL.errorMessage = failReason; IL.loadDisplay(); IL.ShowDialog(); if (killApplication) { canContinue = true; break; } } firstLoop = false; } //Kill the application. We needed to exit the loop first if (canContinue && killApplication) { exitApp(true); } }