Beispiel #1
0
        private bool ReadConfigFile()
        {
            if (File.Exists(ConfigFilename))
            {
                Stream stream = null;
                try
                {
                    stream = File.Open(ConfigFilename, FileMode.Open);
                    var xmlSer = new XmlSerializer(typeof(LoginInfo));

                    GlobalInfo.LoginInfo            = (LoginInfo)xmlSer.Deserialize(stream);
                    ProxyProviderLoader.UseProvider = GlobalInfo.LoginInfo.ProviderType;
                    if (GlobalInfo.LoginInfo.RememberLastLogin)
                    {
                        GlobalInfo.LoginInfo.LastPassword = Cryption.Decrypt(GlobalInfo.LoginInfo.LastPassword);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    return(false);
                }
                finally
                {
                    stream.Close();
                }
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        public bool AddUser(string username, string password, string surname, UserType usertype)
        {
            var duUsers = new DRUsers();

            duUsers.Find(username);

            var row = duUsers.AddRecord();

            row.SetValue <string>(EF_Users.Username, username);
            row.SetValue <string>(EF_Users.Password, Cryption.Encrypt(password));
            row.SetValue <string>(EF_Users.Surname, surname);
            row.SetValue <UserType>(EF_Users.UserType, usertype);
            row.SetValue <bool>(EF_Users.Expired, false);
            row.SetValue <DateTime>(EF_Users.ExpireDate, DateTime.Today);
            row.SetValue <bool>(EF_Users.ChangePassword, true);
            row.SetValue <bool>(EF_Users.Blocked, false);

            return(duUsers.Update());
        }
Beispiel #3
0
        public void WriteConfigFile()
        {
            if (!System.IO.Directory.Exists(ConfigDirectory))
            {
                System.IO.Directory.CreateDirectory(ConfigDirectory);
            }
            TextWriter stream = new StreamWriter(ConfigFilename);
            var        xmlSer = new XmlSerializer(typeof(LoginInfo));

            GlobalInfo.LoginInfo.LastPassword = GlobalInfo.LoginInfo.RememberLastLogin
                    ? Cryption.Encrypt(GlobalInfo.LoginInfo.LastPassword)
                    : string.Empty;

            xmlSer.Serialize(stream, GlobalInfo.LoginInfo);
            if (GlobalInfo.LoginInfo.RememberLastLogin)
            {
                GlobalInfo.LoginInfo.LastPassword = Cryption.Decrypt(GlobalInfo.LoginInfo.LastPassword);
            }
            stream.Close();
        }