Beispiel #1
0
        public static void GetSettings()
        {
            AppVars.SmtpServerUseSSL = Convert.ToBoolean(ConfigurationManager.AppSettings["SMTP_UseSSL"]);
            AppVars.SmtpServer = ConfigurationManager.AppSettings["SMTP_Server"];
            AppVars.SmtpAccount = ConfigurationManager.AppSettings["SMTP_Account"];
            AppVars.SmtpPassword = ConfigurationManager.AppSettings["SMTP_Password"];
            AppVars.SmtpPort = Convert.ToInt32(ConfigurationManager.AppSettings["SMTP_Port"]);

            AppVars.ReportNotificationsEnabled = Convert.ToBoolean(ConfigurationManager.AppSettings["Report_Notifications_Enabled"]);

            AppVars.FaxUserName = ConfigurationManager.AppSettings["Fax_UserName"];
            AppVars.FaxPassword = ConfigurationManager.AppSettings["Fax_Password"];

            AppVars.ReportEmailAddress = ConfigurationManager.AppSettings["Report_From_EmailAddress"];
            AppVars.ReportTemplateHtml = ConfigurationManager.AppSettings["Report_Template_Html"];
            AppVars.ReportTemplateText = ConfigurationManager.AppSettings["Report_Template_Text"];

            using (HostDAO dao = new HostDAO())
            {
                AppVars.dbSettings = (HostSettings)dao.GetHostSettings();
                AppVars.baseKey = AppVars.dbSettings.BaseKey;
                AppVars.hostOptions = dao.GetHostOptions();
            }
        }
Beispiel #2
0
        public void SaveAdministrators(SmartCollection<User> admins)
        {
            if (admins == null) return;

            if (this.hostSettings != null) {
                if (hostSettings.ValidateModel()) {
                    using (HostDAO dao = new HostDAO()) {
                        dao.SaveHostSettings(this.hostSettings);
                        AppVars.dbSettings = hostSettings;
                    }
                }
            }

            try {
                int result = -1;
                string sql;
                using (HostDAO dao = new HostDAO()) {
                    this.HostSettings = new SMHostSettings(dao.GetHostSettings());
                    AppVars.dbSettings = hostSettings;

                }
                using (SystemDAO systemDao = new SystemDAO()) {
                    using (systemDao.DbConnection = new MsSqlPersistence(systemDao.DbConnectionSettings)) {
                        if (systemDao.DbConnection.IsConnected()) {
                            using (systemDao.DbCommand) {
                                foreach (User user in admins) {
                                    systemDao.DbCommand.CommandType = System.Data.CommandType.StoredProcedure;
                                    systemDao.DbCommand.Parameters.Clear();
                                    if (user.UserId <= 0 || user.UserId == null) {
                                        systemDao.DbCommand.CommandText = "uspInsertAdministrator";
                                        string hashedPassword = Security.GetSha2Hash(user.Password.Trim(), user.Username.Trim());
                                        systemDao.DbCommand.Parameters.AddWithValue("@Password", hashedPassword);
                                    }else {
                                        systemDao.DbCommand.CommandText = "uspUpdateAdministrator";
                                        systemDao.DbCommand.Parameters.AddWithValue("@UserId", user.UserId);
                                    }
                                    systemDao.DbCommand.Parameters.AddWithValue("@Username", user.Username);
                                    systemDao.DbCommand.Parameters.AddWithValue("@FirstName", user.FirstName);
                                    systemDao.DbCommand.Parameters.AddWithValue("@LastName", user.LastName);
                                    systemDao.DbCommand.Parameters.AddWithValue("@AdministratorYN", true);
                                    string administratorKey = Security.GetSha2Hash(user.Username, hostSettings.BaseKey);
                                    systemDao.DbCommand.Parameters.AddWithValue("@AdministratorKey", administratorKey);
                                    if (user.UserId <= 0 || user.UserId == null) {
                                        result = (int)systemDao.DbConnection.ExecuteCommand(systemDao.DbCommand);
                                    }else result = systemDao.DbConnection.ExecuteCommand(systemDao.DbCommand);
                                }
                            }
                        }else {
                            throw new Exception("Unable to Connect");
                        }
                    }
                }
            }catch {
                throw ;
            }
        }
Beispiel #3
0
        public void LoadViewDatabase()
        {
            if (this.IsLoadedDatabase) return;

            using (HostDAO dao = new HostDAO()) {
                this.HostSettings = new SMHostSettings(dao.GetHostSettings());
            }
            this.IsLoadedDatabase = true;
        }