Exemple #1
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var errors      = new StringBuilder();
            var deletedRows = new List <DataGridViewRow>();

            foreach (DataGridViewRow row in dataGridView1.SelectedRows)
            {
                try
                {
                    var uri = (string)row.Cells["Uri"].Value;
                    ConnectionInfo.DoWithExceptionTranslation(() => connectionInfo.Proxy.Delete(uri));
                    deletedRows.Add(row);
                }
                catch (Exception ex)
                {
                    errors.AppendLine(ex.Message);
                }
            }

            deletedRows.ForEach(dataGridView1.Rows.Remove);

            if (errors.Length > 0)
            {
                MessageBox.Show(this, errors.ToString(), "SWQL Studio", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemple #2
0
 private void menuFileNew_Click(object sender, EventArgs e)
 {
     try
     {
         ConnectionInfo.DoWithExceptionTranslation(() => connectionsManager.CreateConnection());
     }
     catch (Exception ex)
     {
         log.Error("Failed to connect", ex);
         var msg = $"Unable to connect to Information Service.\n{ex.Message}";
         MessageBox.Show(msg, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #3
0
 private void dataGridView1_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
 {
     try
     {
         var uri = (string)e.Row.Cells["Uri"].Value;
         ConnectionInfo.DoWithExceptionTranslation(() => connectionInfo.Proxy.Delete(uri));
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "SWQL Studio", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         e.Cancel = true;
     }
 }
Exemple #4
0
        private void subscriptionWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            var arg = (QueryArguments)e.Argument;

            subscriptionWorker.ReportProgress(0, "Waiting for subscriber host to be opened...");

            Func <Subscription> action;
            SubscriberInfo      subscriberInfo;

            if (arg.Connection.ServerType.Equals("Java over HTTP"))
            {
                subscriberInfo = ApplicationService.GetHttpSubscriberInfo();
                action         = () => SubscribeHttp(arg.Connection.Proxy, arg.Query, subscriberInfo);
            }
            else
            {
                if (Settings.Default.UseActiveSubscriber)
                {
                    subscriberInfo = arg.Connection.GetActiveSubscriberInfo();
                }
                else
                {
                    subscriberInfo = ApplicationService.GetSubscriberInfo();
                }

                action = () => SubscribeNetTcp(arg.Connection.Proxy, arg.Query, subscriberInfo);
            }

            if (subscriberInfo.OpenedSuccessfully)
            {
                subscriptionWorker.ReportProgress(0, "Starting subscription...");
                try
                {
                    subscription = ConnectionInfo.DoWithExceptionTranslation(action);
                    subscriptionWorker.ReportProgress(0, "Waiting for notifications");
                }
                catch (ApplicationException ex)
                {
                    e.Result = new QueryErrorResult {
                        ErrorMessage = ex.Message, Log = ex.ToString()
                    };
                }
            }
            else
            {
                e.Result = new QueryErrorResult {
                    ErrorMessage = subscriberInfo.ErrorMessage
                };
            }
        }
Exemple #5
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            var row    = dataGridView1.Rows[e.RowIndex];
            var column = dataGridView1.Columns[e.ColumnIndex];

            try
            {
                var uri   = (string)row.Cells["Uri"].Value;
                var props = new PropertyBag {
                    { column.DataPropertyName, row.Cells[e.ColumnIndex].Value }
                };
                ConnectionInfo.DoWithExceptionTranslation(() => connectionInfo.Proxy.Update(uri, props));
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "SWQL Studio", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemple #6
0
 public void OpenQueryTab(string text, ConnectionInfo info)
 {
     try
     {
         var connection = info ?? ConnectionInfo.DoWithExceptionTranslation(() => connectionsManager.ResolveConnection());
         if (connection != null)
         {
             string title    = CreateQueryTitle();
             var    queryTab = CreateQueryTab(title, connection);
             queryTab.QueryText = text;
         }
     }
     catch (Exception ex)
     {
         log.Error("Failed to connect", ex);
         var msg = $"Unable to connect to Information Service.\n{ex.Message}";
         MessageBox.Show(msg, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }