private async void OnSaveAs() { var res = await ShowMessageAsync("Save?", "Are you sure? Save current values to the DataBase", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AnimateShow = false }); if (res == MessageDialogResult.Affirmative) { SessionToSave = new Session(); if (ListARFCNs.Count != 0 && !string.IsNullOrEmpty(SessionNameToSave)) { SessionToSave.ID = Guid.NewGuid(); SessionToSave.Name = SessionNameToSave; SessionToSave.Date = DateTime.Now; SessionsList.Add(SessionToSave); TransferDB.SessionsList = SessionsList; DataDB.AddUpdateSessions(); foreach (ARFCN ARFCN in ListARFCNs) { ARFCN.Session_ID = SessionToSave.ID; } TransferDB.ARFCNs = ListARFCNs; DataDB.AddUpdateARFCN(); } SessionNameToSave = null; SaveVisibility = Visibility.Collapsed; } }
private async void OnSave() { var res = await ShowMessageAsync("Save?", "Are you sure? Save Updated values to the DataBase", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AnimateShow = false }); if (res == MessageDialogResult.Affirmative) { DataDB.UpdateAllStuff(); } }
private async void OnDeleteSelectedSession() { var res = await ShowMessageAsync("Delete?", "Are you sure? Delete all sessions", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AnimateShow = false }); if (res == MessageDialogResult.Affirmative) { DataDB.DeleteSelectedSession(SelectedSession); SessionsList.Remove(SelectedSession); } }
private async void OnLoad() { var res = await ShowMessageAsync("Load?", "Are you sure? Load current values to the DataBase", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AnimateShow = false }); if (res == MessageDialogResult.Affirmative) { if (SelectedSession != null) { DataDB.UpdateARFCNListBySession(SelectedSession); ListARFCNs.Clear(); foreach (ARFCN arfcn in TransferDB.ARFCNs) { ListARFCNs.Add(arfcn); } } } }
private Models.Entity.License GenerateNewLicense(int licensePeriod) { Assembly assembly = Assembly.GetExecutingAssembly(); var attribute = (GuidAttribute)assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0]; string appGuid = attribute.Value; string serialNumber = FingerPrint.GetMAC().Replace(':', '-'); string summary = FingerPrint.GetSummary() + "\nMAC\t" + serialNumber + "\nGUID\t" + appGuid; int numberOfLicenses = Licenses.Count; string authorizationKey = FingerPrint.GetHash(appGuid + numberOfLicenses.ToString()); string registrationNumber = FingerPrint.GetHash(serialNumber + authorizationKey + licensePeriod.ToString()); Models.Entity.License NewLicense = new Models.Entity.License() { ID = Guid.NewGuid(), Count = ++numberOfLicenses, SerialNumber = serialNumber, AuthorizationKey = authorizationKey, RegistrationNumber = registrationNumber, Period = licensePeriod, Start = DateTime.Today, End = DateTime.Today.Add(new TimeSpan(licensePeriod, 0, 0, 0)), LastSession = DateTime.Now, Summary = summary }; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (sender, e) => { e.Result = DatabaseService.AddOrUpdate(e.Argument as Models.Entity.License); }; worker.RunWorkerCompleted += (sender, e) => { int dd = (int)e.Result; DataDB.RefreshLicenses(); }; worker.RunWorkerAsync(NewLicense); string LicenseDir = @"\PHRDR\License"; string documentPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); if (!Directory.Exists(documentPath + LicenseDir)) { Directory.CreateDirectory(documentPath + LicenseDir); } string licenseFile = String.Format(@"{0}\License.lph", documentPath + LicenseDir); File.Create(licenseFile).Close(); string toFile = "Serial Number:\n\t" + serialNumber + "\n" + "Authorization Key:\n\t" + authorizationKey + "\n" + "Registration Number:\n\t" + registrationNumber + "\n" + "Period:\n\t" + licensePeriod + "\n" + "Start:\n\t" + DateTime.Today + "\n" + "Last Session:\n\t" + DateTime.Now + "\n" + "End:\n\t" + DateTime.Today.Add(new TimeSpan(licensePeriod, 0, 0, 0)) + "\n\n" + "Summary PC:\n" + summary; File.WriteAllText(licenseFile, toFile); return(NewLicense); }