/// <summary> /// Do the login validation and log in the user if successfull /// </summary> /// <param name="password"></param> /// <returns></returns> public bool Login(SecureString password) { this.Password = password; if (RememberMe && !string.IsNullOrEmpty(this.UserName) && this.Password.Length > 0) { SecureStorage.StorePerUserCredentials(this.UserName, this.Password, CREDENTIAL_FILE, CREDENTIAL_FILE_KEYNAME); ViewModelTools.Logger.InfoFormat("Stored encrypted credentials"); } else { if (File.Exists(CREDENTIAL_FILE)) { File.Delete(CREDENTIAL_FILE); ViewModelTools.Logger.InfoFormat("Deleted stored encrypted credentials"); } } ApplicationTools.SetAppRegisteredToLaunchOnStartup("Sun.Plasma", LaunchOnStartup, Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Sun.Plasma.exe")); // TODO: Validate User Credentials if (UserName == "test" && Sun.Core.Security.SecureStringUtility.SecureStringToString(password) == "test") { return(true); } this.ErrorMsg = "Invalid username or password provided. Please try again."; return(false); }
static void Main(string[] args) { if (args != null && args.Length > 0) { //ServiceBase[] ServicesToRun; //ServicesToRun = new ServiceBase[] //{ // new Service1() //}; //ServiceBase.Run(ServicesToRun); } else { //检查程序是否已经启动过一次 var programStarted = ApplicationTools.StartOnece(mutexName); if (programStarted == null)//判断已经启动一次则唤醒程序退出第二次启动。 { return; } else { var app = new App(); app.ProgramStarted = programStarted; app.Run(); } } }
public ViewModelLogin() { // Check if the user has stored his credentials using "Rememeber me" if (File.Exists(CREDENTIAL_FILE)) { SecureStorage.RestorePerUserCredentials(out _userName, out _password, CREDENTIAL_FILE, CREDENTIAL_FILE_KEYNAME); this.RememberMe = true; } LaunchOnStartup = ApplicationTools.IsAppRegisteredToLaunchOnStartUp("Sun.Plasma"); }
/// <summary> /// Method to create a database file. /// </summary> /// <param name="filename">A database file name (full path).</param> public static void CreateFile(string filename) { SQLiteConnection.CreateFile(filename); ApplicationTools.GrantAccess(filename); }