예제 #1
0
        public Main()
        {
            InitializeComponent();

            // Check if the SEG Database is available
            var sql = new SqlHelper(ConfigurationManager.ConnectionStrings["SEGDatabase"].ConnectionString);
            if (sql.TestSEG())
            {

                inLogin = true;

                // Initialize basic components - Background
                ImageBrush ib = new ImageBrush();
                ib.ImageSource = new BitmapImage(new Uri(@"pack://application:,,,/Media/Cover-background-landscape.png"));
                ib.Stretch = Stretch.UniformToFill;
                cL.Background = ib;

                eUser.Text = "";
                ePass.Password = "";

                cL.Visibility = Visibility.Visible;
                c.Visibility = Visibility.Hidden;

                // Create the content providers here
                panelProjectNew = new Project_New();
                panelProjectList = new Project_List();
                panelAreaList = new ProjectArea_List();
                panelAssetList = new Area_AssetList();
                panelAreaGenDiag = new Area_GenDiag();
                panelAssetEditGeneral = new Asset_Edit_General();
                panelAssetEditMechanical = new Asset_Edit_Mechanical();
                panelAssetEditMechanicalImg = new Asset_Edit_Mechanical_Img();
                panelAssetEditElectrical = new Asset_Edit_Electrical();
                panelAssetEditElectricalImg = new Asset_Edit_Electrical_Img();
                panelAssetEditElectricalInfo = new Asset_Edit_Electrical_Info();
                panelAssetEditRisk = new Asset_Edit_Risk();

                ControlCenter.Instance.wMain = this;
            }
            else
            {
                MessageBox.Show("The database was missing or the SEG.Desktop was not correctly configured.  Please use the SEG.Tools to correct.", "Init Error");
            }

            //// Disables inking in the WPF application and enables us to track touch events to properly trigger the touch keyboard
            //InkInputHelper.DisableWPFTabletSupport();

            //this.Loaded += EnableKeyboard;
        }
예제 #2
0
        public bool SetupDatabase()
        {
            // Try to restore a backed up database file
            bool processOk = false;

            try
            {
                var sql = new SqlHelper(ConnStringSetup());
                string sfile = @"SetupData\seg-cleandb.bak";
                // Obtain absolute path
                string sfilefull = Path.GetFullPath(sfile);

                if(sql.Connect())
                {
                    string UseMaster = "USE master";
                    sql.DoCommandExecute(UseMaster);

                    string Alter1 = @"ALTER DATABASE [seg] SET Single_User WITH Rollback Immediate";
                    sql.DoCommandExecute(Alter1);

                    string Restore = @"RESTORE DATABASE [seg] FROM DISK = N'" + sfilefull + @"' WITH REPLACE";
                    sql.DoCommandExecute(Restore);

                    string Alter2 = @"ALTER DATABASE [seg] SET Multi_User";
                    sql.DoCommandExecute(Alter2);

                    //sql.DoCommandExecute("USE MASTER RESTORE DATABASE seg FROM DISK = '" + sfilefull + "' WITH REPLACE");
                    processOk = CheckDatabase();
                }
                else
                {
                    dbError = sql.errorMessage;
                }
                // Con.ExecuteCmd();
            }
            catch(Exception e)
            {

            }

            return processOk;
        }