Esempio n. 1
0
        private async Task ExecuteScriptInBackground(ExecScriptAsync e, bool needScript = true)
        {
            if (IsRuningCmd)
            {
                return;
            }

            string dateFormat = "yyyy-MM-dd HH:mm:ss.fff";

            try
            {
                string script = null;
                if (needScript)
                {
                    script = GetScriptString();
                    if (string.IsNullOrWhiteSpace(script))
                    {
                        return;
                    }
                }

                IsRuningCmd = true;
                DateTime before = DateTime.Now;
                AppendLineToScriptResultBox(before.ToString(dateFormat) + ": executing code...");
                SetEnabledRunScriptAbality(false);

                string output = await e(script, EnviromentCfg);

                if (!string.IsNullOrEmpty(output))
                {
                    AppendLineToScriptResultBox(output);
                }

                DateTime after     = DateTime.Now;
                TimeSpan span      = after - before;
                string   finishMsg = string.Format("{0}: execution was completed [{1}]", after.ToString(dateFormat), Util.ConvTimeSpanToString(span));
                AppendLineToScriptResultBox(finishMsg);
            }
            catch (Exception ex)
            {
                AppendLineToScriptResultBox(DateTime.Now.ToString(dateFormat) + ": execution was completed with exception");
                AppendLineToScriptResultBox(ex.GetBaseException().Message);
            }
            finally
            {
                IsRuningCmd = false;
                SetEnabledRunScriptAbality(true);
                ScriptResultTextBox.ScrollToEnd();
            }

            AppendLineToScriptResultBox("");
            objectViewTreeHelper.UpdateObjectViewItem(conn, objectViewItemSource);
        }
Esempio n. 2
0
 private void ResultBoxClean_Click(object sender, RoutedEventArgs e)
 {
     ScriptResultTextBox.Clear();
 }
Esempio n. 3
0
 public void AppendLineToScriptResultBox(string s)
 {
     ScriptResultTextBox.AppendText(s);
     ScriptResultTextBox.AppendText(Environment.NewLine);
 }