Beispiel #1
0
        public static void Startup()
        {
            // Start MessageSystem
            string hubUrl = ConfigurationManager.AppSettings.GetValues("MessageHubAddress").FirstOrDefault();

            HubServer.Instance.Start(hubUrl);
            HubClient.Instance.Start(hubUrl);

            // Load Roles and Permissions
            AppVars.rolesAndPermissions = AppLib.LoadAllRolesAndPermissions();

            // Init Accounting Interface
            using (HostDAO dao = new HostDAO())
            {
                Accounting.Init.Startup(dao.GetAccountingSettings());
            }

            // Add System Jobs to Schedule
            JobExpireTokens.AddToSchedule();
            JobExpireLocks.AddToSchedule();
            JobReportNotifications.AddToSchedule();

            // Accounting Interface
            //Invoice invoice = new Invoice();
            //invoice = new InvoiceInterface().InvoiceAdd(invoice);
        }
Beispiel #2
0
 public static bool CheckDatabase()
 {
     using (HostDAO dao = new HostDAO()) {
         dao.CreateTables();
         return dao.VerifySetup();
     }
 }
Beispiel #3
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 #4
0
 public void ShowAdmins()
 {
     if (DbCurrenVersion == 0)
     {
         if (this.hostSettings != null)
         {
             if (hostSettings.ValidateModel())
             {
                 using (HostDAO dao = new HostDAO())
                 {
                     dao.SaveHostSettings(this.hostSettings);
                 }
             }
         }
         ServiceHost.Implementation.Init.GetSettings();
         using (DataBaseDao dao = new DataBaseDao())
         {
             this.DbCurrenVersion = dao.GetDatabaseVersion();
         }
     }
     if (ServiceHost.Update.Init.Update(DbCurrenVersion))
         CurrentView = ManagerViews.Admins;
 }
Beispiel #5
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 #6
0
        public void Save()
        {
            if (this.hostSettings != null) {
                if (hostSettings.ValidateModel()) {
                    using (HostDAO dao = new HostDAO()) {
                        dao.SaveHostSettings(this.hostSettings);
                        AppVars.dbSettings = hostSettings;
                    }
                }
            }

            if (this.hostOptions != null) {
                if (HostOptions.Validate(hostOptions)) {
                    using (HostDAO dao = new HostDAO()) {
                        dao.SaveHostOptions(this.hostOptions);
                    }
                }
            }

            if (this.accountingSettings != null)
            {
                using (HostDAO dao = new HostDAO())
                {
                    dao.SaveAccountingSettings(this.AccountingSettings);
                }
            }

            SaveAdministrators(adminList);

            if (DbCurrenVersion == 0)
            {
                ServiceHost.Implementation.Init.GetSettings();
                using (DataBaseDao dao = new DataBaseDao())
                {
                    this.DbCurrenVersion = dao.GetDatabaseVersion();
                }

                ServiceHost.Update.Init.Update(DbCurrenVersion);
            }
            Environment.Exit(1);
        }
Beispiel #7
0
        public void LoadViewOptions()
        {
            if (this.IsLoadedOptions) return;

            using (HostDAO dao = new HostDAO()) {
                this.HostOptions = dao.GetHostOptions();
            }
            this.IsLoadedOptions = true;
        }
Beispiel #8
0
        public void LoadViewDatabase()
        {
            if (this.IsLoadedDatabase) return;

            using (HostDAO dao = new HostDAO()) {
                this.HostSettings = new SMHostSettings(dao.GetHostSettings());
            }
            this.IsLoadedDatabase = true;
        }
Beispiel #9
0
        public void LoadViewAccounting()
        {
            if (this.IsLoadedAccounting) return;

            using (HostDAO dao = new HostDAO())
            {
                this.AccountingSettings = dao.GetAccountingSettings();
            }
            this.IsLoadedAccounting = true;
        }