Beispiel #1
0
        /// <summary>
        /// Choose a new result folder
        /// </summary>
        /// <returns></returns>
        private bool ChooseResDir()
        {
            try
            {
                QAFolder newfolder = new QAFolder();
                FolderBrowserDialog fnd = new FolderBrowserDialog();
                fnd.Description = "Select the results folder (need write access)";
                if (fnd.ShowDialog() == DialogResult.OK)
                {
                    if (fnd.SelectedPath.EndsWith("\\"))
                    {  //newfolder.path = fnd.SelectedPath;
                        newfolder = new QAFolder(fnd.SelectedPath, "Local results folder", FolderType.ResultFolder);
                        //return true;//Melek
                    }
                    else
                    {   //newfolder.path = fnd.SelectedPath + "\\";
                        newfolder = new QAFolder(fnd.SelectedPath + "\\", "Local results folder", FolderType.ResultFolder);
                       // return true;//Melek
                    }
                }
                else
                    return false; // exit if cancelled by user

              //  the stream monitor thread needs to know the new result dir
                try
                {
                    if (qatool.SetNewResDir(newfolder))
                    {
                        MessageBox.Show("Results folder changed to " + newfolder.path); //Melek
                        return true;
                    }
                    else
                        return false;
                }
                catch (Exception ex)
                {
                    Global.log("Error while changing to a new result folder.\n" + ex);
                    return false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception occurred when choosing a result folder.\n" + ex);
                return false;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Apply changes made to the monitored folders : settings + folder manager
        /// by scanning through all datagridview rows.
        ///
        /// TO IMPROVE
        /// USE DATABINDING
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ApplyFolderSettingsBox_Click(object sender, EventArgs e)
        {
            SourceFolder Streamdir;
            DataGridViewRow row = new DataGridViewRow();
            string tmpstr = "";
            bool appliedchangesonlyfolders = true;//Melek
            bool nochangesappliedsourcefolder = true; //Melek
            bool nochangesappliedresfolder = true;//Melek
            bool nochangesappliedrepfolder = true;//Melek
            // go through each folder in the list of folder
            for (int j = 0; j < StreamFoldersBox.Rows.Count; j++) // When the new Priority values are selected set priority values
            {
                row = StreamFoldersBox.Rows[j];

                if ((string)row.Cells[5].Value == "1-Hot") //Set Priority Values and Hot - Melek
                {
                    row.Cells[3].Value = 0;
                    row.Cells[2].Value = true; //hot true

                }
                else if ((string)row.Cells[5].Value == "2-High")
                {
                    row.Cells[3].Value = 64;
                    row.Cells[2].Value = false; //hot false
                }
                else if ((string)row.Cells[5].Value == "3-Medium")
                {
                    row.Cells[3].Value = 128;
                    row.Cells[2].Value = false; //hot false
                }
                else if ((string)row.Cells[5].Value == "4-Low")
                {
                    row.Cells[3].Value = 255;
                    row.Cells[2].Value = false; //hot false
                }

                QAFolder qaf = new QAFolder((string)row.Cells[1].Value, "XML source folder", FolderType.SourceFolder);
                Streamdir = new SourceFolder(qaf, (bool)row.Cells[2].Value, Convert.ToInt16(row.Cells[3].Value), (string)row.Cells[4].Value, (string)row.Cells[5].Value);
                // Streamdir = new SourceFolder(qaf, Convert.ToInt16(row.Cells[3].Value), (string)row.Cells[4].Value, (string)row.Cells[5].Value);

                // check each folder in the GUI with the actual list of source folders
                // and update it if a difference is found
                if (qatool.EditSourceFolder(Streamdir))
                    tmpstr += " " + Streamdir.path + "\n";
            }

            if (tmpstr != "")
            {
                tmpstr = "Applied changes to the following folders:\n" + tmpstr + "\n" + " NOTE: These changes will be applied only to the jobs to be processed on the Process Tab, not to the completed jobs on the Review and Results Tabs."; //Melek - comment is updated
                MessageBox.Show(tmpstr);
                Global.log(tmpstr);
                appliedchangesonlyfolders = false;//Melek

            }

            #region  resultfolderconfig
            //enter results folder info - Melek
            string nf = ResDirTextBox.Text;
               QAFolder newfolder = new QAFolder();

            if (nf == ""||(!Directory.Exists(nf)))
            {
                newfolder = new QAFolder(nf, "Local results folder", FolderType.ResultFolder);
                if (!qatool.SetNewResDir(newfolder))
                {

                    nf = newfolder.path;
                    ResDirTextBox.Text=nf;
                }
            }

            try
            {

                if (nf.EndsWith("\\"))
                  newfolder = new QAFolder(nf, "Local results folder", FolderType.ResultFolder);
                else
                    newfolder = new QAFolder(nf + "\\", "Local results folder", FolderType.ResultFolder);

                if (qatool.SetNewResDir(newfolder))
                {
                    MessageBox.Show("Results folder changed to " + newfolder.path);
                    nochangesappliedresfolder = false;
                }
            }
            catch (Exception ex)
            {
                Global.log("Error while changing to a new result folder.\n" + ex);

            }

            #endregion resultfolderconfig
            #region ReportsConfig - Melek

            if (RepDirTextBox.Text == "")
            {
                MessageBox.Show("Reports Folder section can not be empty, please enter a folder path to save results.");

                if (qaClass.settings.ReportsFolder == "")
                {
                    RepDirTextBox.Text = "Set the folder where the pdf reports will be stored";
                }
                else
                {
                    RepDirTextBox.Text = qaClass.settings.ReportsFolder;
                }

            }
            else if (RepDirTextBox.Text != "Set the folder where the pdf reports will be stored\\" && RepDirTextBox.Text != "Set the folder where the pdf reports will be stored")//MElek
            {
                if (!Directory.Exists(RepDirTextBox.Text))
                {
                    MessageBox.Show("Directory \"" + RepDirTextBox.Text + "\" does not exist!");
                    if (qaClass.settings.ReportsFolder != null)
                    {
                        RepDirTextBox.Text = qaClass.settings.ReportsFolder; //Melek
                    }
                }
            else
            {
                if (!RepDirTextBox.Text.EndsWith("\\")) { RepDirTextBox.Text = RepDirTextBox.Text + "\\"; }
                if (qatool.SetNewRepDir(RepDirTextBox.Text))
                {
                    nochangesappliedrepfolder = false;
                    MessageBox.Show("Reports folder changed to " + RepDirTextBox.Text);
                }
            }
            }
            #endregion Reportconfig

            if (nochangesappliedsourcefolder && nochangesappliedresfolder && nochangesappliedrepfolder && appliedchangesonlyfolders && !reportsfolderchangedtemp) //no changes has done
                MessageBox.Show("No changes applied.");
        }