private async void ExecuteResetCommand(object parameter) { PasswordBox passwordBox = parameter as PasswordBox; string clearTextPassword = passwordBox.Password; if (IsSaveComplete == true) { IsSaveComplete = false; return; } if (SaveProgress != 0) { return; } var started = DateTime.Now; IsSaving = true; var userDetail = new UserDetail() { UserID = IdentityUtility.GetLoggedInUserId(), Name = this.Name, UserName = this.UserName, Password = clearTextPassword, GroupID = 0 }; var errorInfo = this.dbContext.UpdateUser(userDetail, "RESET", this.UserName); if (errorInfo.Code == 0) { } else { await this.Container.Resolve <IMetroMessageDisplayService>(ServiceNames.MetroMessageDisplayService).ShowMessageAsnyc("Reset Password", errorInfo.Info); } new DispatcherTimer( TimeSpan.FromMilliseconds(50), DispatcherPriority.Normal, new EventHandler((o, e) => { var totalDuration = started.AddSeconds(3).Ticks - started.Ticks; var currentProgress = DateTime.Now.Ticks - started.Ticks; var currentProgressPercent = 100.0 / totalDuration * currentProgress; SaveProgress = currentProgressPercent; if (SaveProgress >= 100) { passwordBox.Password = string.Empty; IsSaveComplete = true; IsSaving = false; SaveProgress = 0; ((DispatcherTimer)o).Stop(); } }), Dispatcher.CurrentDispatcher); }
private void ExecuteActivateLicenseCommand() { string errorMessage; var userId = IdentityUtility.GetLoggedInUserId(); StreamReader reader = new StreamReader(this._licenseFilePath); string encryptedLicenseDetail = reader.ReadToEnd(); reader.Close(); var isUpdated = this.dbContext.UpdateLicense(userId, encryptedLicenseDetail, out errorMessage); if (!string.IsNullOrEmpty(errorMessage)) { this.WarningMessage = errorMessage; this.IsLicenseUpdated = false; } else { if (isUpdated) { this.WarningMessage = string.Empty; var licenseDetails = this.dbContext.GetLicenseDetails(out errorMessage); if (licenseDetails != null && licenseDetails.ContainsKey("ExpiryDate")) { _expiryDate = licenseDetails["ExpiryDate"]; DateTime expiryDate; DateTime.TryParse(_expiryDate, out expiryDate); if (_expiryDate != null && IsDateBeforeOrToday(expiryDate)) { this.WarningMessage = string.Format("Your License expires on {0}", expiryDate.ToShortDateString()); this.IsLicenseUpdated = true; } else { this.WarningMessage = string.Format("Your License was expired on {0}", expiryDate.ToShortDateString()); this.IsLicenseUpdated = false; } } else { this._expiryDate = string.Empty; this.WarningMessage = "Please select a valid License file"; this.IsLicenseUpdated = false; } } else { this._expiryDate = string.Empty; this.WarningMessage = "Please select a valid License file"; this.IsLicenseUpdated = false; } } }