예제 #1
0
        private static void InitializeConnectionString()
        {
            var config           = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            var connectionString = config.ConnectionStrings.ConnectionStrings["EntityDataModelESB2Container"];

            if (connectionString.ConnectionString.Contains("xxxxx"))
            {
                var findDatabase = new OpenFileDialog()
                {
                    Title           = "Select/Create Equipment Status Board Database",
                    Multiselect     = false,
                    AddExtension    = true,
                    DefaultExt      = "sdf",
                    Filter          = "SQL CE|*.sdf",
                    CheckFileExists = false
                };

                findDatabase.ShowDialog();

                try
                {
                    connectionString.ConnectionString = connectionString.ConnectionString.Replace("xxxxx", findDatabase.FileName);
                    config.Save(ConfigurationSaveMode.Modified);
                    ConfigurationManager.RefreshSection("connectionStrings");
                }catch (Exception e)
                {
                    ESB2ExceptionEventLog.LogExceptionEvent(e);
                }
            }
        }
예제 #2
0
파일: ESB2Login.cs 프로젝트: dsbjax/ESB2
        public static User Login()
        {
            var  loginDialog = new UserLoginDialog();
            User user        = null;

            try
            {
                loginDialog.ShowDialog();
                if ((bool)loginDialog.DialogResult)
                {
                    user = users.FirstOrDefault(u => u.Username.Equals(loginDialog.Username.ToLower()));

                    if (user != null)
                    {
                        user = ProcessLogin((UserLogin)user, loginDialog.Password);
                    }
                    else
                    {
                        new InvalidUsernameDialog().ShowDialog();
                        ESB2UserEventLog.LogUserEvent(loginDialog.Username, EventLoggerEvents.InvalidUsername);
                    }
                }
            }catch (Exception e)
            {
                ESB2ExceptionEventLog.LogExceptionEvent(e);
            }

            return(user);
        }
예제 #3
0
        public static bool ChangePassword(UserLogin user, string password)
        {
            try
            {
                user.Password = PasswordEncrypter.EncryptPassword(user.Username.ToLower(), password);
                database.SaveChanges();
            }
            catch (Exception e)
            {
                ESB2ExceptionEventLog.LogExceptionEvent(e);
                return(false);
            }

            return(true);
        }
예제 #4
0
 public static void LogUserEvent(string username, EventLoggerEvents userEvent)
 {
     try
     {
         database.EventLogLog.Add(new EventLoggerEvent()
         {
             Timestamp = DateTime.Now,
             User      = username,
             Event     = userEvent
         });
         database.SaveChanges();
     }
     catch (Exception e)
     {
         ESB2ExceptionEventLog.LogExceptionEvent(e);
     }
 }