Esempio n. 1
0
        public static void HandleError(Exception ex)
        {
            if (ex == null)
            {
                return;
            }
            using (var dialog = new Dialog.MessageDialog())
            {
                var agg = ex as AggregateException;
                if (agg != null && agg.Flatten().InnerExceptions.Count == 1)
                {
                    var inner = agg.Flatten().InnerExceptions[0];
                    dialog.Message = inner.Message;
                    dialog.Details = inner.ToString();
                }
                else
                {
                    dialog.Message = ex.Message;
                    dialog.Details = ex.ToString();
                }

                dialog.OkText       = "&Keep Going";
                dialog.Caption      = "Oops, that error wasn't expected";
                dialog.CaptionColor = System.Drawing.Color.Red;
                dialog.ShowDialog();
            }
        }
Esempio n. 2
0
        public static void HandleError(Exception ex)
        {
            if (ex == null)
            {
                return;
            }
            using (var dialog = new Dialog.MessageDialog())
            {
                if (ex is AggregateException agg &&
                    agg.Flatten().InnerExceptions.Count == 1)
                {
                    ex = agg.Flatten().InnerExceptions[0];
                }

                dialog.Message = ex.Message;
                dialog.Details = ex.ToString();

                if (ex.Data.Count > 0)
                {
                    dialog.Details += Environment.NewLine;
                    foreach (var key in ex.Data.Keys)
                    {
                        dialog.Details += Environment.NewLine + $"{key} = {ex.Data[key]}";
                    }
                }

                dialog.OkText       = "&Keep Going";
                dialog.Caption      = "Oops, that error wasn't expected";
                dialog.CaptionColor = System.Drawing.Color.Red;
                dialog.ShowDialog();
            }
        }
Esempio n. 3
0
 public static DialogResult Show(IWin32Window window, string message, string caption, string okText, string noText, string cancelText)
 {
   using (var dialog = new MessageDialog())
   {
     dialog.Message = message;
     dialog.Caption = caption;
     dialog.OkText = okText;
     dialog.NoText = noText;
     dialog.CancelText = cancelText;
     return dialog.ShowDialog(window);
   }
 }
Esempio n. 4
0
    private void EnsureDataTable()
    {
      if (_outputSet == null && _result != null && tbcOutputView.SelectedTab == pgTableOutput)
      {
        _outputSet = _result.GetDataSet();
        if (_outputSet.Tables.Count > 0)
        {
          var errors = _outputSet.Tables.OfType<DataTable>()
            .SelectMany(t => t.GetErrors().Select(r => new TableError()
            {
              Message = r.RowError,
              Table = t.TableName
            }))
            .GroupBy(e => e.Message)
            .Select(g => g.Key
              + " in tables: "
              + g.GroupBy(t => t.Table)
                .Select(t => t.Key + " (" + t.Count() + " row(s))")
                .GroupConcat(", "));

          if (errors.Any())
          {
            using (var dialog = new Dialog.MessageDialog())
            {
              dialog.Message = errors.GroupConcat(Environment.NewLine);
              dialog.OkText = "&Keep Going";
              dialog.Caption = "Validation Error";
              dialog.CaptionColor = System.Drawing.Color.Red;
              dialog.ShowDialog();
            }
          }

          dgvItems.AutoGenerateColumns = false;
          dgvItems.DataSource = _outputSet.Tables[0];
          FormatDataGrid(dgvItems);
          pgTableOutput.Text = _outputSet.Tables[0].TableName;

          var i = 1;
          foreach (var tbl in _outputSet.Tables.OfType<DataTable>().Skip(1))
          {
            var pg = new TabPage(tbl.TableName);
            pg.Name = GeneratedPage + i.ToString();
            var grid = new Controls.DataGrid();
            grid.AutoGenerateColumns = false;
            grid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            grid.ContextMenuStrip = this.conTable;
            grid.DataSource = tbl;
            grid.Dock = System.Windows.Forms.DockStyle.Fill;
            grid.Location = new System.Drawing.Point(0, 0);
            grid.Margin = new System.Windows.Forms.Padding(0);
            grid.TabIndex = 0;
            grid.MouseDoubleClick += Grid_MouseDoubleClick;
            pg.Controls.Add(grid);
            tbcOutputView.TabPages.Add(pg);
            FormatDataGrid(grid);
            i++;
          }
        }
      }
    }