コード例 #1
0
ファイル: DlgSequenceItem.cs プロジェクト: wyerp/openpetra
        private void PopulateList()
        {
            for (NantTask.TaskItem i = NantTask.FirstBasicItem; i <= NantTask.LastBasicItem; i++)
            {
                NantTask t = new NantTask(i);
                listTasks.Items.Add(t.Description);
            }

            for (NantTask.TaskItem i = NantTask.FirstCodeGenItem; i <= NantTask.LastCodeGenItem; i++)
            {
                NantTask t = new NantTask(i);
                listTasks.Items.Add(t.Description);
            }

            for (NantTask.TaskItem i = NantTask.FirstCompileItem; i <= NantTask.LastCompileItem; i++)
            {
                NantTask t = new NantTask(i);
                listTasks.Items.Add(t.Description);
            }

            for (NantTask.TaskItem i = NantTask.FirstMiscItem; i <= NantTask.LastMiscItem; i++)
            {
                NantTask t = new NantTask(i);
                listTasks.Items.Add(t.Description);
            }

            for (NantTask.TaskItem i = NantTask.FirstDatabaseItem; i <= NantTask.LastDatabaseItem; i++)
            {
                NantTask t = new NantTask(i);
                listTasks.Items.Add(t.Description);
            }
        }
コード例 #2
0
ファイル: OutputText.cs プロジェクト: merbst/openpetra
        //
        //
        /// <summary>
        /// The main call to read and parse a log file, given its path.
        /// </summary>
        /// <param name="path">Path to the logfile to parse and append the result to the output streams</param>
        /// <param name="task">The task that is associated with the log</param>
        static public void AddLogFileOutput(string path, NantTask task)
        {
            string result = ReadStreamFile(path);

            if (result == String.Empty)
            {
                AppendText(OutputStream.Both, "\r\n~~~~ Warning!!! No output log file was found for this action.");
                task.NumWarnings++;
            }
            else
            {
                ParseOutput(result, task);

                AppendText(OutputStream.Verbose, result + "\r\n");
                AppendText(OutputStream.Both,
                           String.Format("~~~~~~~ {0} succeeded, {1} failed, {2} warning(s) or error(s)\r\n\r\n", task.NumSucceeded, task.NumFailures,
                                         task.NumWarnings));

                try
                {
                    // we may not be able to delete it at this point - if not the timer will delete it later
                    File.Delete(path);
                }
                catch (Exception)
                {
                }
            }
        }
コード例 #3
0
        // Handle the close action.  Save the current sequence of tasks in the public form variable
        private void btnOK_Click(object sender, EventArgs e)
        {
            ExitSequence = new List <NantTask.TaskItem>();

            for (int i = 0; i < lstSequence.Items.Count; i++)
            {
                NantTask task = new NantTask(lstSequence.Items[i].ToString());
                ExitSequence.Add(task.Item);
            }

            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #4
0
        /// <summary>
        /// Call this before ShowDialog to initialise the dialog with entry values to be edited
        /// </summary>
        /// <param name="Sequence"></param>
        public void InitializeList(List <NantTask.TaskItem> Sequence)
        {
            lstSequence.Items.Clear();

            for (int i = 0; i < Sequence.Count; i++)
            {
                NantTask task = new NantTask(Sequence[i]);
                lstSequence.Items.Add(task.Description);
            }

            if (lstSequence.Items.Count > 0)
            {
                lstSequence.SelectedIndex = 0;
            }

            SetEnabledStates();
        }
コード例 #5
0
ファイル: DlgSequence.cs プロジェクト: Davincier/openpetra
        /// <summary>
        /// Call this before ShowDialog to initialise the dialog with entry values to be edited
        /// </summary>
        /// <param name="Sequence"></param>
        public void InitializeList(List <NantTask.TaskItem>Sequence)
        {
            lstSequence.Items.Clear();

            for (int i = 0; i < Sequence.Count; i++)
            {
                NantTask task = new NantTask(Sequence[i]);
                lstSequence.Items.Add(task.Description);
            }

            if (lstSequence.Items.Count > 0)
            {
                lstSequence.SelectedIndex = 0;
            }

            SetEnabledStates();
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: Davincier/openpetra
        // Generic method to run previewWinform because it is in a different disk location to all the rest and takes additional parameters.
        private void RunPreviewWinform(ref int NumFailures, ref int NumWarnings)
        {
            NantTask task = new NantTask(NantTask.TaskItem.previewWinform);

            ProgressDialog dlg = new ProgressDialog();

            dlg.lblStatus.Text = task.StatusText;
            dlg.Show();

            NumFailures = 0;
            NumWarnings = 0;
            OutputText.AppendText(OutputText.OutputStream.Both, String.Format("~~~~~~~~~~~~~~~~ {0} ...\r\n", task.LogText));
            dlg.Refresh();

            if (NantExecutor.RunPreviewWinform(BranchLocation, txtYAMLPath.Text))
            {
                // It ran successfully - let us check the output ...
                OutputText.AddLogFileOutput(BranchLocation + @"\csharp\ICT\Petra\Client\opda.txt", ref NumFailures, ref NumWarnings);
            }
            else
            {
                NumFailures++;
            }

            dlg.Close();
        }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: Davincier/openpetra
        private void btnCodeGeneration_Click(object sender, EventArgs e)
        {
            DateTime dtStart = DateTime.UtcNow;

            OutputText.ResetOutput();
            TickTimer.Enabled = false;
            NantTask task = new NantTask(cboCodeGeneration.Items[cboCodeGeneration.SelectedIndex].ToString());
            int NumFailures = 0;
            int NumWarnings = 0;

            if (chkAutoStopServer.Checked && (task.Item == NantTask.TaskItem.generateSolution))
            {
                // This is a case where we need to auto-stop the server first
                GetServerState();

                if (_serverIsRunning)
                {
                    RunSimpleNantTarget(new NantTask(NantTask.TaskItem.stopPetraServer), ref NumFailures, ref NumWarnings);
                }
            }

            // Now we are ready to perform the original task
            if (NumFailures == 0)
            {
                if (task.Item == NantTask.TaskItem.generateSolutionNoCompile)
                {
                    Environment.SetEnvironmentVariable("OPDA_StopServer", (_localSettings.DoPreBuildOnIctCommon) ? "1" : null);
                    Environment.SetEnvironmentVariable("OPDA_StartServer", (_localSettings.DoPostBuildOnPetraClient) ? "1" : null);
                }

                RunSimpleNantTarget(task, ref NumFailures, ref NumWarnings);
            }

            Environment.SetEnvironmentVariable("OPDA_StopServer", null);
            Environment.SetEnvironmentVariable("OPDA_StartServer", null);

            txtOutput.Text = (chkVerbose.Checked) ? OutputText.VerboseOutput : OutputText.ConciseOutput;

            if ((NumFailures > 0) || ((NumWarnings > 0) && chkTreatWarningsAsErrors.Checked))
            {
                tabControl.SelectedTab = OutputPage;
                chkVerbose.Checked = true;
            }

            PrepareWarnings();

            if ((DateTime.UtcNow - dtStart > TimeSpan.FromSeconds(Convert.ToUInt32(txtFlashAfterSeconds.Text))) && !Focused)
            {
                FlashWindow.Flash(this, 5);
            }

            TickTimer.Enabled = true;
        }
コード例 #8
0
ファイル: MainForm.cs プロジェクト: Davincier/openpetra
        private void btnMiscellaneous_Click(object sender, EventArgs e)
        {
            DateTime dtStart = DateTime.UtcNow;

            OutputText.ResetOutput();
            TickTimer.Enabled = false;
            NantTask task = new NantTask(cboMiscellaneous.Items[cboMiscellaneous.SelectedIndex].ToString());
            int NumFailures = 0;
            int NumWarnings = 0;

            if (task.Item == NantTask.TaskItem.uncrustify)
            {
                FolderBrowserDialog dlg = new FolderBrowserDialog();
                dlg.Description = "Select a folder to Uncrustify";
                dlg.SelectedPath = BranchLocation;
                dlg.RootFolder = Environment.SpecialFolder.MyComputer;
                dlg.ShowNewFolderButton = false;

                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                // check the selection is based on teh current branch
                if (!dlg.SelectedPath.StartsWith(BranchLocation, StringComparison.InvariantCultureIgnoreCase))
                {
                    MessageBox.Show("You must choose a folder within the current branch.", Program.APP_TITLE);
                    return;
                }

                // check that the folder contains a .build file
                string[] files = Directory.GetFiles(dlg.SelectedPath, "*.build", SearchOption.TopDirectoryOnly);

                if (files.Length == 0)
                {
                    MessageBox.Show("The selected folder cannot be Uncrustified.  You must choose a folder that contains a BUILD file.",
                        Program.APP_TITLE);
                    return;
                }

                // Ready to run - overriding the usual root location with the specified folder
                RunSimpleNantTarget(task, dlg.SelectedPath, ref NumFailures, ref NumWarnings);
            }
            else if ((task.Item == NantTask.TaskItem.test) || (task.Item == NantTask.TaskItem.testWithoutDisplay)
                     || (task.Item == NantTask.TaskItem.mainNavigationTests))
            {
                BuildConfiguration dbBldConfig = new BuildConfiguration(BranchLocation, _localSettings);
                string dbName = dbBldConfig.CurrentDBName;

                if (String.Compare(dbName, "nantTest", true) != 0)
                {
                    string msg = String.Format(
                        "You are about to run tests using the '{0}' database.  This is a friendly reminder that all the data in the database will be lost.\r\n\r\n",
                        dbName);
                    msg +=
                        "Click OK to continue, or 'Cancel' if you want to select a different database for testing (by moving to the 'database' tab of the Assistant).\r\n\r\n";
                    msg += "The best advice is to create a specific database for testing purposes using PgAdmin or equivalent.\r\n\r\n";
                    msg += "Tip: if you call your test database 'nantTest', it will be used without displaying this message!";

                    if (MessageBox.Show(msg, Program.APP_TITLE, MessageBoxButtons.OKCancel,
                            MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return;
                    }
                }

                RunSimpleNantTarget(task, ref NumFailures, ref NumWarnings);
            }
            else
            {
                RunSimpleNantTarget(task, ref NumFailures, ref NumWarnings);
            }

            txtOutput.Text = (chkVerbose.Checked) ? OutputText.VerboseOutput : OutputText.ConciseOutput;

            if ((NumFailures > 0) || ((NumWarnings > 0) && chkTreatWarningsAsErrors.Checked))
            {
                tabControl.SelectedTab = OutputPage;
                chkVerbose.Checked = true;
            }

            PrepareWarnings();

            if ((DateTime.UtcNow - dtStart > TimeSpan.FromSeconds(Convert.ToUInt32(txtFlashAfterSeconds.Text))) && !Focused)
            {
                FlashWindow.Flash(this, 5);
            }

            TickTimer.Enabled = true;
        }
コード例 #9
0
ファイル: DlgSequence.cs プロジェクト: Davincier/openpetra
        // Handle the close action.  Save the current sequence of tasks in the public form variable
        private void btnOK_Click(object sender, EventArgs e)
        {
            ExitSequence = new List <NantTask.TaskItem>();

            for (int i = 0; i < lstSequence.Items.Count; i++)
            {
                NantTask task = new NantTask(lstSequence.Items[i].ToString());
                ExitSequence.Add(task.Item);
            }

            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #10
0
ファイル: MainForm.cs プロジェクト: Davincier/openpetra
        private void ShowSequence(TextBox tb, List <NantTask.TaskItem>sequence)
        {
            string s = "";

            for (int i = 0; i < sequence.Count; i++)
            {
                if (s != String.Empty)
                {
                    s += "\r\n";
                }

                NantTask task = new NantTask(sequence[i]);
                s += task.Description;
            }

            tb.Text = s;
        }
コード例 #11
0
ファイル: DlgSequenceItem.cs プロジェクト: wyerp/openpetra
 private void btnOK_Click(object sender, EventArgs e)
 {
     SelectedTask = new NantTask(listTasks.Items[listTasks.SelectedIndex].ToString());
     DialogResult = DialogResult.OK;
     Close();
 }
コード例 #12
0
ファイル: MainForm.cs プロジェクト: Davincier/openpetra
        // Generic method to run a sequence of tasks
        private void RunSequence(List <NantTask.TaskItem>Sequence)
        {
            DateTime dtStart = DateTime.UtcNow;

            OutputText.ResetOutput();
            TickTimer.Enabled = false;
            bool bShowOutputTab = false;

            for (int i = 0; i < Sequence.Count; i++)
            {
                NantTask task = new NantTask(Sequence[i]);
                int NumFailures = 0;
                int NumWarnings = 0;

                switch (task.Item)
                {
                    case NantTask.TaskItem.generateWinform:

                        if (btnGenerateWinform.Enabled)
                        {
                            RunGenerateWinform(ref NumFailures, ref NumWarnings);
                        }
                        else
                        {
                            OutputText.AppendText(OutputText.OutputStream.Both,
                                "\r\n\r\n~~~~~~~~~ Cannot generate Winform: No YAML file specified!\r\n\r\n");
                            NumFailures++;
                        }

                        break;

                    case NantTask.TaskItem.startPetraServer:
                        GetServerState();

                        if (!_serverIsRunning)
                        {
                            RunSimpleNantTarget(task, ref NumFailures, ref NumWarnings);
                        }
                        else
                        {
                            OutputText.AppendText(OutputText.OutputStream.Both,
                                "\r\n\r\n~~~~~~~~~ Skipping 'start server'.  The server is already running.\r\n\r\n");
                        }

                        break;

                    case NantTask.TaskItem.stopPetraServer:
                        GetServerState();

                        if (_serverIsRunning)
                        {
                            RunSimpleNantTarget(task, ref NumFailures, ref NumWarnings);
                        }
                        else
                        {
                            OutputText.AppendText(OutputText.OutputStream.Both,
                                "\r\n\r\n~~~~~~~~~ Skipping 'stop server'.  The server is already not running.\r\n\r\n");
                        }

                        break;

                    default:
                        RunSimpleNantTarget(task, ref NumFailures, ref NumWarnings);
                        break;
                }

                if ((NumFailures > 0) || ((NumWarnings > 0) && chkTreatWarningsAsErrors.Checked))
                {
                    bShowOutputTab = true;
                }

                if (NumFailures > 0)
                {
                    break;
                }
            }

            txtOutput.Text = (chkVerbose.Checked) ? OutputText.VerboseOutput : OutputText.ConciseOutput;

            if (bShowOutputTab)
            {
                tabControl.SelectedTab = OutputPage;
                chkVerbose.Checked = true;
            }

            PrepareWarnings();

            if ((DateTime.UtcNow - dtStart > TimeSpan.FromSeconds(Convert.ToUInt32(txtFlashAfterSeconds.Text))) && !Focused)
            {
                FlashWindow.Flash(this, 5);
            }

            TickTimer.Enabled = true;
        }
コード例 #13
0
ファイル: MainForm.cs プロジェクト: Davincier/openpetra
        private void PopulateCombos()
        {
            // Code generation
            for (NantTask.TaskItem i = NantTask.FirstCodeGenItem; i <= NantTask.LastCodeGenItem; i++)
            {
                NantTask t = new NantTask(i);
                cboCodeGeneration.Items.Add(t.ShortDescription);
            }

            // Compile
            for (NantTask.TaskItem i = NantTask.FirstCompileItem; i <= NantTask.LastCompileItem; i++)
            {
                NantTask t = new NantTask(i);
                cboCompilation.Items.Add(t.ShortDescription);
            }

            // Misc
            for (NantTask.TaskItem i = NantTask.FirstMiscItem; i <= NantTask.LastMiscItem; i++)
            {
                NantTask t = new NantTask(i);
                cboMiscellaneous.Items.Add(t.ShortDescription);
            }

            // Database
            for (NantTask.TaskItem i = NantTask.FirstDatabaseItem; i <= NantTask.LastDatabaseItem; i++)
            {
                NantTask t = new NantTask(i);
                cboDatabase.Items.Add(t.ShortDescription);
            }

            // Source Code Control
            for (BazaarTask.TaskItem i = BazaarTask.FirstBazaarItem; i <= BazaarTask.LastBazaarItem; i++)
            {
                BazaarTask t = new BazaarTask(i);
                cboSourceCode.Items.Add(t.Description);
            }
        }
コード例 #14
0
ファイル: MainForm.cs プロジェクト: Davincier/openpetra
        /// <summary>
        /// Method that will run a task inside the context of another task
        /// </summary>
        /// <param name="NestedTask">Task to run</param>
        /// <param name="SplashDialog">Reference to the splash dialog that the parent task launched</param>
        /// <param name="NumFailures">Ongoing number of failures</param>
        /// <param name="NumWarnings">Ongoing number of errors/warnings</param>
        private void RunNestedTask(NantTask.TaskItem NestedTask, ProgressDialog SplashDialog, ref int NumFailures, ref int NumWarnings)
        {
            NantTask nestedTask = new NantTask(NestedTask);

            OutputText.AppendText(OutputText.OutputStream.Both, String.Format("~~~~~~~~~~~~~~~~ {0} ...\r\n", nestedTask.LogText));
            SplashDialog.lblStatus.Text = nestedTask.StatusText;
            SplashDialog.lblStatus.Refresh();

            if (NestedTask == NantTask.TaskItem.startPetraServer)
            {
                if (NantExecutor.StartServer(BranchLocation, chkMinimizeServer.Checked))
                {
                    // It ran successfully - let us check the output ...
                    OutputText.AddLogFileOutput(BranchLocation + @"\opda.txt", ref NumFailures, ref NumWarnings);
                    GetServerState();
                    SetEnabledStates();
                }
                else
                {
                    NumFailures++;
                }
            }
            else
            {
                if (NantExecutor.RunGenericNantTarget(BranchLocation, nestedTask.TargetName))
                {
                    // It ran successfully - let us check the output ...
                    OutputText.AddLogFileOutput(BranchLocation + @"\opda.txt", ref NumFailures, ref NumWarnings);
                }
                else
                {
                    NumFailures++;
                }
            }
        }
コード例 #15
0
ファイル: OutputText.cs プロジェクト: merbst/openpetra
        // Parse the text, looking for specific strings that indicate success, failure, errors, exceptions or warnings
        static private void ParseOutput(string TextToParse, NantTask Task)
        {
            Task.NumSucceeded = 0;

            // We note the number of successes
            int p = 0;

            while (p >= 0)
            {
                p = TextToParse.IndexOf("BUILD SUCCEEDED", p, StringComparison.InvariantCultureIgnoreCase);

                if (p > 0)
                {
                    Task.NumSucceeded++;
                    p++;
                }
            }

            // We note the number of failed builds
            p = 0;

            while (p >= 0)
            {
                p = TextToParse.IndexOf("BUILD FAILED", p, StringComparison.InvariantCultureIgnoreCase);

                if (p > 0)
                {
                    Task.NumFailures++;
                    p++;
                }
            }

            // Finally we note the number of 'suspicious' entries
            string[] candidates =
            {
                "error", "warning", "exception"
            };
            int itemID = 0;

            foreach (string lookFor in candidates)
            {
                p = 0;

                while (p >= 0)
                {
                    p = TextToParse.IndexOf(lookFor, p, StringComparison.InvariantCultureIgnoreCase);

                    if (p > 0)
                    {
                        if ((itemID == 0) || (itemID == 1))
                        {
                            // error and warning must not be plural.  We also need to ignore s_error_log
                            if ((TextToParse.Substring(p + lookFor.Length, 3).CompareTo("(s)") != 0) &&
                                (TextToParse.Substring(p + lookFor.Length, 1).CompareTo("s") != 0) &&
                                (TextToParse.Substring(p - 2, 8).CompareTo("s_error_") != 0) &&
                                (TextToParse.Substring(p - 1, 12).CompareTo("\\ErrorLog.cs") != 0) &&
                                (TextToParse.Substring(p - 1, 22).CompareTo("\\ErrorCodeInventory.cs") != 0) &&
                                (TextToParse.Substring(p - 1, 20).CompareTo("\\ErrorCodesHelper.cs") != 0) &&
                                (TextToParse.Substring(p - 1, 14).CompareTo("\\ErrorCodes.cs") != 0) &&
                                (TextToParse.Substring(p, 15).CompareTo("ErrorCodeDoc.cs") != 0))
                            {
                                Task.NumWarnings++;
                            }
                        }
                        else if (itemID == 2)
                        {
                            // exception must not refer to ExceptionDetailsDialog or ExceptionLogFileDialog
                            if ((TextToParse.LastIndexOf('\\', p, 24) == -1) &&
                                (TextToParse.IndexOf("DetailsDialog", p, 24) == -1) &&
                                (TextToParse.IndexOf("LogFileDialog", p, 24) == -1))
                            {
                                Task.NumWarnings++;
                            }
                        }
                        else
                        {
                            Task.NumWarnings++;
                        }

                        p++;
                    }
                }

                itemID++;
            }
        }
コード例 #16
0
ファイル: MainForm.cs プロジェクト: Davincier/openpetra
        // Generic method to run generateWinform because it is in a different disk location to all the rest and takes additional parameters.
        private void RunGenerateWinform(ref int NumFailures, ref int NumWarnings)
        {
            NantTask task = new NantTask(NantTask.TaskItem.generateWinform);

            ProgressDialog dlg = new ProgressDialog();

            dlg.lblStatus.Text = task.StatusText;
            dlg.Show();

            NumFailures = 0;
            NumWarnings = 0;
            OutputText.AppendText(OutputText.OutputStream.Both, String.Format("~~~~~~~~~~~~~~~~ {0} ...\r\n", task.LogText));
            dlg.Refresh();

            if (NantExecutor.RunGenerateWinform(BranchLocation, txtYAMLPath.Text))
            {
                // It ran successfully - let us check the output ...
                OutputText.AddLogFileOutput(BranchLocation + @"\csharp\ICT\Petra\Client\opda.txt", ref NumFailures, ref NumWarnings);
            }
            else
            {
                NumFailures++;
            }

            if ((NumFailures == 0) && ((NumWarnings == 0) || !chkTreatWarningsAsErrors.Checked) && chkCompileWinform.Checked)
            {
                RunNestedTask(NantTask.TaskItem.quickCompileClient, dlg, ref NumFailures, ref NumWarnings);

                if ((NumFailures == 0) && ((NumWarnings == 0) || !chkTreatWarningsAsErrors.Checked) && chkStartClientAfterGenerateWinform.Checked)
                {
                    GetServerState();

                    if (!_serverIsRunning)
                    {
                        RunNestedTask(NantTask.TaskItem.startPetraServer, dlg, ref NumFailures, ref NumWarnings);
                    }

                    RunNestedTask(NantTask.TaskItem.startPetraClient, dlg, ref NumFailures, ref NumWarnings);
                }
            }

            dlg.Close();
        }
コード例 #17
0
ファイル: MainForm.cs プロジェクト: Davincier/openpetra
        private void RunSimpleNantTarget(NantTask Task, string WorkingFolder, ref int NumFailures, ref int NumWarnings)
        {
            // Basic routine that runs a simple target with no parameters
            ProgressDialog dlg = new ProgressDialog();

            dlg.lblStatus.Text = Task.StatusText;
            dlg.Show();

            NumFailures = 0;
            NumWarnings = 0;
            OutputText.AppendText(OutputText.OutputStream.Both, String.Format("~~~~~~~~~~~~~~~~ {0} ...\r\n", Task.LogText));
            dlg.Refresh();

            bool bOk;

            switch (Task.Item)
            {
                case NantTask.TaskItem.startPetraServer:
                    bOk = NantExecutor.StartServer(WorkingFolder, chkMinimizeServer.Checked);
                    break;

                case NantTask.TaskItem.stopPetraServer:
                    bOk = NantExecutor.StopServer(WorkingFolder);
                    break;

                case NantTask.TaskItem.runAdminConsole:
                    bOk = NantExecutor.RunServerAdminConsole(WorkingFolder, String.Empty);
                    break;

                case NantTask.TaskItem.refreshCachedTables:
                    bOk = NantExecutor.RunServerAdminConsole(WorkingFolder, "-Command:RefreshAllCachedTables");
                    break;

                default:
                    bOk = NantExecutor.RunGenericNantTarget(WorkingFolder, Task.TargetName);
                    break;
            }

            if (bOk)
            {
                // It ran successfully - let us check the output ...
                OutputText.AddLogFileOutput(WorkingFolder + @"\opda.txt", ref NumFailures, ref NumWarnings);

                if ((Task.Item == NantTask.TaskItem.startPetraServer) || (Task.Item == NantTask.TaskItem.stopPetraServer))
                {
                    GetServerState();
                    SetEnabledStates();
                }
            }
            else
            {
                NumFailures++;
            }

            dlg.Close();
        }
コード例 #18
0
ファイル: MainForm.cs プロジェクト: Davincier/openpetra
        /******************************************************************************************************************************************
        *
        * Helper functions
        *
        * ****************************************************************************************************************************************/

        // Generic method that runs most tasks.
        // It reads and parses the log file for errors/warnings and returns the number of errors and warnings found.
        // It handles the display of the splash dialog and the text that will end up in the output window
        private void RunSimpleNantTarget(NantTask Task, ref int NumFailures, ref int NumWarnings)
        {
            RunSimpleNantTarget(Task, BranchLocation, ref NumFailures, ref NumWarnings);
        }
コード例 #19
0
ファイル: MainForm.cs プロジェクト: Davincier/openpetra
        private void btnStartClient_Click(object sender, EventArgs e)
        {
            OutputText.ResetOutput();
            TickTimer.Enabled = false;
            DateTime dtStart = DateTime.UtcNow;
            NantTask task = new NantTask(NantTask.TaskItem.startPetraClient);
            int NumFailures = 0;
            int NumWarnings = 0;

            if (chkAutoStartServer.Checked)
            {
                // This is a case where we need to auto-start the server first
                GetServerState();

                if (!_serverIsRunning)
                {
                    RunSimpleNantTarget(new NantTask(NantTask.TaskItem.startPetraServer), ref NumFailures, ref NumWarnings);
                }
            }

            // Now we are ready to perform the original task
            if (NumFailures == 0)
            {
                RunSimpleNantTarget(task, ref NumFailures, ref NumWarnings);
            }

            txtOutput.Text = (chkVerbose.Checked) ? OutputText.VerboseOutput : OutputText.ConciseOutput;

            if ((NumFailures > 0) || ((NumWarnings > 0) && chkTreatWarningsAsErrors.Checked))
            {
                tabControl.SelectedTab = OutputPage;
                chkVerbose.Checked = true;
            }

            PrepareWarnings();

            if ((DateTime.UtcNow - dtStart > TimeSpan.FromSeconds(Convert.ToUInt32(txtFlashAfterSeconds.Text))) && !Focused)
            {
                FlashWindow.Flash(this, 5);
            }

            TickTimer.Enabled = true;
        }
コード例 #20
0
ファイル: MainForm.cs プロジェクト: Davincier/openpetra
        private void btnDatabase_Click(object sender, EventArgs e)
        {
            BuildConfiguration dbBldConfig = new BuildConfiguration(BranchLocation, _localSettings);
            string dbName = dbBldConfig.CurrentDBName;
            NantTask task = new NantTask(cboDatabase.Items[cboDatabase.SelectedIndex].ToString());

            if ((task.Item == NantTask.TaskItem.resetDatabase) || (task.Item == NantTask.TaskItem.recreateDatabase))
            {
                if (String.Compare(dbName, "nantTest", true) != 0)
                {
                    // We don't mind nantTest, but any other database name (including demo) gives rise to a warning
                    string msg = String.Format("Warning!  Your current database is '{0}'.  " +
                        "If you proceed you will lose all the information in this database." +
                        "\r\nAre you sure that you want to continue?", dbName);

                    if (MessageBox.Show(msg, Program.APP_TITLE, MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
                    {
                        return;
                    }
                }
            }

            DateTime dtStart = DateTime.UtcNow;

            OutputText.ResetOutput();
            TickTimer.Enabled = false;
            int NumFailures = 0;
            int NumWarnings = 0;

            if (chkAutoStopServer.Checked && (task.Item == NantTask.TaskItem.recreateDatabase))
            {
                // This is a case where we need to auto-stop the server first
                GetServerState();

                if (_serverIsRunning)
                {
                    RunSimpleNantTarget(new NantTask(NantTask.TaskItem.stopPetraServer), ref NumFailures, ref NumWarnings);
                }
            }

            // Now we are ready to perform the original task
            if (NumFailures == 0)
            {
                RunSimpleNantTarget(task, ref NumFailures, ref NumWarnings);
            }

            txtOutput.Text = (chkVerbose.Checked) ? OutputText.VerboseOutput : OutputText.ConciseOutput;

            if ((NumFailures > 0) || ((NumWarnings > 0) && chkTreatWarningsAsErrors.Checked))
            {
                tabControl.SelectedTab = OutputPage;
                chkVerbose.Checked = true;
            }

            PrepareWarnings();

            if ((DateTime.UtcNow - dtStart > TimeSpan.FromSeconds(Convert.ToUInt32(txtFlashAfterSeconds.Text))) && !Focused)
            {
                FlashWindow.Flash(this, 5);
            }

            TickTimer.Enabled = true;
        }