Пример #1
0
        public void InitializeSQLControl()
        {
            packetSize = "4096";

            // Try and get our current settings
            string connectionString = "";

            if (MOG_ControllerSystem.GetDB() != null && MOG_ControllerSystem.GetDB().GetConnectionString().Length > 0)
            {
                connectionString = MOG_ControllerSystem.GetDB().GetConnectionString();
                LoadConnectionString(connectionString.Trim("@".ToCharArray()));
            }
            else
            {
                // packet size=4096;integrated security=SSPI;data source="NEMESIS";persist security info=False;initial catalog=mog
                security        = "SSPI";
                persistSecurity = "False";
                dataSource      = "";
                initialCatalog  = "mog";

                SQLServerComboBox.Text   = dataSource;
                SQLDatabaseComboBox.Text = initialCatalog;
            }

            mConnectString = "";
        }
Пример #2
0
        // checks projName against known project names, both those in the repository and in the database
        public static bool DuplicateProjectNameCheck(string projName, bool verbose)
        {
            // make sure we don't have a project called projName locally
            foreach (string existingProjName in MOG_ControllerSystem.GetSystem().GetProjectNames())
            {
                if (existingProjName.ToLower() == projName.ToLower())
                {
                    if (verbose)
                    {
                        Utils.ShowMessageBoxExclamation("Duplicate project name.\nA project called " + projName + " already exists.", "Duplicate Project Name");
                    }

                    return(false);
                }
            }

            // make sure projName doesn't exist in the tables
            if (MOG_ControllerSystem.GetDB().ProjectTablesExist(projName))
            {
                // allow user to overwrite the tables if he wants
                if (Utils.ShowMessageBoxConfirmation("Project information tables for a project named " + projName + " currently exist in the database.\nWould you like to overwrite these tables?", "Overwrite Duplicate Tables?") == MOGPromptResult.No)
                {
                    return(false);
                }

                // remove the tables
                MOG_ControllerSystem.GetDB().DeleteProjectTables(projName);
            }

            return(true);
        }
Пример #3
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public MogControl_TaskEditor()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            mDb = MOG_ControllerSystem.GetDB();
            TaskAsscociatedAssetsListView.SmallImageList = MogUtil_AssetIcons.Images;
        }
Пример #4
0
        public string RefreshConnectionToolText()
        {
            // get SQL server and MOG Repository drive mapping info
            string connectionString = MOG_ControllerSystem.GetDB().GetConnectionString();
            string sqlServerName    = "NONE";

            if (connectionString.ToLower().IndexOf("data source") != -1)
            {
                // parse out sql server name
                //sqlServerName = connectionString.Substring(connectionString.ToLower().IndexOf("data source=")+13,
                string[] substrings = connectionString.Split(";".ToCharArray());

                // look for correct part o' the connection string
                foreach (string substring in substrings)
                {
                    if (substring.ToLower().StartsWith("data source="))
                    {
                        sqlServerName = substring.Substring(substring.IndexOf("=") + 1).ToUpper();
                    }
                }
            }

            try
            {
                // get MOG repository drive and mapping info
                string mogDrive       = MOG_ControllerSystem.GetSystemRepositoryPath();
                char   mogDriveLetter = Path.GetPathRoot(mogDrive)[0];
                string mogDriveTarget = new NetworkDriveMapper().GetDriveMapping(mogDriveLetter);

                // Connected to X-SERVER @IP 192.168.5.5; SQL Server: JBIANCHI; MOG Repository M: mapped to \\GX\MOG
                //ConnectionString=Packet size=4096;integrated security=SSPI;data source=NEMESIS;persist security info=False;initial catalog=mog16;

                return(string.Concat(MOG_ControllerSystem.GetServerComputerName(), " SQL SERVER: ", sqlServerName));
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("RefreshConnectionToolText", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
            }

            return("Connected");
        }
Пример #5
0
        private void Restore_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker      = sender as BackgroundWorker;
            List <string>    args        = e.Argument as List <string>;
            string           projName    = args[0];
            string           iniFilename = args[1];

            // open the ini file
            MOG_Ini ini = new MOG_Ini(iniFilename);

            if (ini != null)
            {
                // make sure projName is a deleted project
                if (ini.SectionExist(projName + ".Deleted"))
                {
                    // Attempt to move the project's directory
                    if (DosUtils.DirectoryMoveFast(MOG_ControllerSystem.GetSystemDeletedProjectsPath() + "\\" + projName, MOG_ControllerSystem.GetSystemProjectsPath() + "\\" + projName, true))
                    {
                        // Restore the project to the active projects list
                        ini.PutString("Projects", projName, "");
                        ini.RemoveString("Projects.Deleted", projName);
                        ini.RenameSection(projName + ".Deleted", projName);

                        // Restore the project's database
                        MOG_ControllerSystem.GetDB().VerifyTables(projName);
                        MOG_Database.ImportProjectTables(projName, this.mogProjectsPath + "\\" + projName);
                    }

                    BlankInfoBox();

                    ini.Save();
                }

                ini.Close();

                LoadIniFile(iniFilename);
            }
        }
Пример #6
0
 private void UpdateAssetVerifyIcon(MOG_Filename verifyFile)
 {
     if (verifyFile.GetType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
     {
         if (MOG_ControllerSystem.GetDB() != null &&
             MOG_DBAssetAPI.GetAssetVersion(verifyFile) != null &&
             MOG_DBAssetAPI.GetAssetVersion(verifyFile).Length != 0)
         {
             // This is a perfect asset that has a prior version
             this.AssetValidPictureBox.Image = new Bitmap(AssetValidImageList.Images[2]);
         }
         else
         {
             // good asset with no prior version
             this.AssetValidPictureBox.Image = new Bitmap(AssetValidImageList.Images[1]);
         }
     }
     else
     {
         // Bad Asset name
         this.AssetValidPictureBox.Image = new Bitmap(AssetValidImageList.Images[0]);
     }
 }
Пример #7
0
        private void SQLTestButton_Click(object sender, System.EventArgs e)
        {
            try
            {
                string OriginalConnectionString = MOG_ControllerSystem.GetDB() != null?MOG_ControllerSystem.GetDB().GetConnectionString() : "";

                // Test the connection string
                // Attempt to open a connection to make sure we will work?
                BuildConnectionStringNoCatalog();
                string databaseName = GetDatabaseName();


                // Is this a 'Create new' database
                if (this.SQLCreateDatabaseRadioButton.Checked)
                {
                    try
                    {
                        // Test to see if we can get to the server
                        if (MOG.DATABASE.MOG_DBAPI.TestServerConnection(mConnectString))
                        {
                            if (MOG.DATABASE.MOG_DBAPI.TestDatabaseConnection(mConnectString, this.SQLDatabaseTextBox.Text) == false)
                            {
                                if (MOG_Prompt.PromptResponse("Create new Database?", "We will need to create this database to test this connection.\n\n\tDATABASE NAME: " + this.SQLDatabaseTextBox.Text + "\n\nIs it ok to proceed?", MOGPromptButtons.OKCancel) == MOGPromptResult.OK)
                                {
                                    if (MOG.DATABASE.MOG_DBAPI.CreateDatabase(mConnectString, this.SQLDatabaseTextBox.Text))
                                    {
                                        databaseName = SQLDatabaseTextBox.Text;
                                    }
                                }
                                else
                                {
                                    return;
                                }
                            }
                        }
                        else
                        {
                            MOG_Prompt.PromptMessage("Create Database", "Unable to access server: " + this.ServerName);
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MOG_Prompt.PromptMessage("Create Database", "Unable to check or create database with the following message:\n\n" + ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.ERROR);
                        return;
                    }
                }


                // Build the full connection string
                BuildConnectionString();

                try
                {
                    if (!MOG_ControllerSystem.InitializeDatabase(mConnectString, "", ""))
                    {
                        MOG_Prompt.PromptResponse("Connection Failure", "Couldn't connect to SQL database " + databaseName + " on server " + SQLServerComboBox.Text);
                        throw new Exception();
                    }
                    else
                    {
                        MOG_Prompt.PromptResponse("Connection Successful", "Successfully connected to SQL database " + databaseName + " on server " + SQLServerComboBox.Text);
                    }
                }
                catch
                {
                }
                finally
                {
                    if (OriginalConnectionString.Length > 0)
                    {
                        // Restore the original DBbase
                        mConnectString = OriginalConnectionString;
                        if (!MOG_ControllerSystem.InitializeDatabase(mConnectString, "", ""))
                        {
                            MOG_Prompt.PromptResponse("Connection Failure", "Couldn't restore to original SQL database (" + mConnectString + ")");
                        }
                    }
                }
            }
            catch (Exception outer)
            {
                MOG_Prompt.PromptMessage("Error", outer.Message, outer.StackTrace, MOG_ALERT_LEVEL.ERROR);
                return;
            }

            // notify others that we clicked the Test button
            OnTestButtonClicked();
        }