Interaction logic for Waiting.xaml
Inheritance: Window
Ejemplo n.º 1
0
        /// <summary>
        /// change database location
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditDB(object sender, RoutedEventArgs e)
        {
            bool   accept = false;
            string prompt = "Enter SQL server Name: ", conectstr = "";
            string CompName = System.Environment.MachineName;

            while (!accept)
            {
                //continue till connection is made
                string server = Interaction.InputBox(prompt);
                if (server == string.Empty)
                {
                    return;
                }
                conectstr = @"Data Source=" + CompName + "\\" + server + @";Initial Catalog=ModelDB;Integrated Security=True;Persist Security Info=True";
                string serversection           = @"Data Source=" + CompName + @"\" + server + ";Integrated Security=True;Persist Security Info=True";
                Context.DataContext connection = new Context.DataContext(serversection);
                try
                {
                    connection.Connection.Open();
                    accept = true;
                }
                catch (Exception ex)
                {
                    prompt = "Connection failed.  Enter SQL server name: ";
                }
            }
            Properties.Settings.Default.Connection = conectstr;
            Properties.Settings.Default.Save();

            //set up tables and values
            Waiting load = new Waiting();

            load.Topmost = true;
            load.Show();
            load.Topmost = false;
            DataConnecter.FirstUse();
            load.Close();
            MessageBox.Show("Connection updated.");
            ChangeReportStatus(true);
        }
Ejemplo n.º 2
0
        //set button and run first time set up
        public MainWindow()
        {
            InitializeComponent();

            this.ResizeMode = System.Windows.ResizeMode.CanMinimize;
            TextBlock cap = new TextBlock()
            {
                Text = "This report allows you to choose what capabilities to create a shortened report of these capabilities.", Width = 200, TextWrapping = TextWrapping.Wrap
            };

            this.capReport.ToolTip = new ToolTip()
            {
                Content = cap
            };
            TextBlock cont = new TextBlock()
            {
                Text    = "This report allows you to choose what control to list in the report.  For each, there will be a list of all capabilities it is selected for."
                , Width = 200, TextWrapping = TextWrapping.Wrap
            };

            this.conReport.ToolTip = new ToolTip()
            {
                Content = cont
            };
            TextBlock tic = new TextBlock()
            {
                Text = "This report show every TIC with a list of all capabilities with that marking.", Width = 200, TextWrapping = TextWrapping.Wrap
            };

            this.TICReport.ToolTip = new ToolTip()
            {
                Content = tic
            };

            //setup

            if (Properties.Settings.Default.FirstRun)
            {
                MessageBox.Show(
                    "Welcome to the Cloud Security Manager. \n\tBefore you can use the program, there is some simple set up to do. \n\n\t  First, you must choose where " +
                    "to put the folders that will hold input and output files.  The program will create a containing folder, so just pick a easily accessible place.\n\n "
                    + "Then, you may need to set up database connection.");

                Waiting load = new Waiting();
                SetPath();
                load.Topmost = true;
                load.Show();
                load.Topmost = false;
                try
                {
                    Properties.Settings.Default.FirstRun = false;
                    Properties.Settings.Default.Save();
                    DataConnecter.FirstUse();
                    load.Close();
                }
                catch (Exception e)
                {
                    load.error.Content = e.Message;
                    Console.WriteLine(e.Message);
                }
            }
            else
            {
                apppath = Properties.Settings.Default.appFolders;
            }
            dbContent = new Context.DataContext(DataConnecter.EstablishValidConnection());
            CSRC.Models.Constants.ReadValues();

            var con = from p in dbContent.Controls
                      select p;

            if (!con.Any())
            {
                this.updateCaps.IsEnabled             = false;
                this.updateBaselines.IsEnabled        = false;
                this.menuUpdateCapabilities.IsEnabled = false;
                this.menuUpdateBaseines.IsEnabled     = false;
            }

            var ret = from p in dbContent.Capabilities
                      select new { p.Id };

            if (!(ret.Any()))
            {
                ChangeReportStatus(false);
            }

            var retdata = from p in dbContent.BaselineSecurityMappings
                          select new { p.Id };

            if (!retdata.Any())
            {
                ChangeReportStatus(false);
            }
            CSRC.Models.Constants.ReadValues();
            if (CSRC.Models.Constants.capFile3Cols)
            {
                this.cap3col.IsChecked = true;
                this.cap9col.IsChecked = false;
            }
        }