Пример #1
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            var form = new SubscriptionForm(Globals.AMPSAddin.Application.ActiveWorkbook);
            var sd   = _subs[e.RowIndex];

            form.SubscriptionName = sd.Name;
            // don't let the user modify this name.
            form.txtName.Enabled = false;
            form.ServerName      = sd.ServerName;
            form.Topic           = sd.Topic;
            form.Filter          = sd.Filter;
            form.WorksheetRange  = sd.WorksheetRange;
            bool wasActive = ActiveSub.isActive(sd);

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                sd.Name           = form.SubscriptionName;
                sd.ServerName     = form.ServerName;
                sd.Topic          = form.Topic;
                sd.Filter         = form.Filter;
                sd.WorksheetRange = form.WorksheetRange;
                DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
                if (wasActive)
                {
                    row.Cells[0].Value = false;
                    deactivate(e.RowIndex);
                    var wbInfo = Globals.AMPSAddin.getWorkbookInfo(
                        Globals.AMPSAddin.Application.ActiveWorkbook);
                    wbInfo.createOrUpdate(sd);
                    if (activate(e.RowIndex))
                    {
                        row.Cells[0].Value = true;
                    }
                }
                row.Cells[1].Value = sd.Name;
                row.Cells[2].Value = sd.ServerName;
                row.Cells[3].Value = sd.Topic;
                row.Cells[4].Value = sd.Filter;
                row.Cells[5].Value = sd.WorksheetRange;
            }
        }
Пример #2
0
        private void button1_Click(object sender, RibbonControlEventArgs e)
        {
            //var topicStore = Globals.AMPSAddin.GetTopicStoreForActiveWorkbook();
            Excel.Range activeCell = Globals.AMPSAddin.Application.ActiveWindow.ActiveCell;

            try
            {
                Excel.Workbook activeWorkbook = Globals.AMPSAddin.Application.ActiveWorkbook;
                var            form           = new SubscriptionForm(activeWorkbook);
                form.WorksheetRange = Globals.AMPSAddin.Application.ActiveWindow.ActiveSheet.Name + "!" + activeCell.Address;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    AMPSAddin.ServerDefinition serverDef = Globals.AMPSAddin.getWorkbookInfo(activeWorkbook).Servers[form.ServerName];
                    Client c = new Client(Guid.NewGuid().ToString());
                    c.connect(serverDef.URL);
                    c.logon();
                    string[] worksheetNames = form.WorksheetRange.Split('!');
                    AMPSAddin.SubscriptionDefinition def = new AMPSAddin.SubscriptionDefinition
                    {
                        Name           = form.SubscriptionName,
                        ServerName     = form.ServerName,
                        Topic          = form.Topic,
                        WorksheetRange = form.WorksheetRange,
                        Filter         = form.Filter
                    };

                    Globals.AMPSAddin.getWorkbookInfo(activeWorkbook).createOrUpdate(def);

                    ActiveSub.activate(def, c, serverDef.MessageType, Globals.AMPSAddin.Application.ActiveWorkbook);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #3
0
        private void button1_Click(object sender, RibbonControlEventArgs e)
        {
            //var topicStore = Globals.AMPSAddin.GetTopicStoreForActiveWorkbook();
            Excel.Range activeCell = Globals.AMPSAddin.Application.ActiveWindow.ActiveCell;

            try
            {
                Excel.Workbook activeWorkbook = Globals.AMPSAddin.Application.ActiveWorkbook;
                var form = new SubscriptionForm(activeWorkbook);
                form.WorksheetRange = Globals.AMPSAddin.Application.ActiveWindow.ActiveSheet.Name+"!"+ activeCell.Address;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    AMPSAddin.ServerDefinition serverDef = Globals.AMPSAddin.getWorkbookInfo(activeWorkbook).Servers[form.ServerName];
                    Client c = new Client(Guid.NewGuid().ToString());
                    c.connect(serverDef.URL);
                    c.logon();
                    string[] worksheetNames = form.WorksheetRange.Split('!');
                    AMPSAddin.SubscriptionDefinition def = new AMPSAddin.SubscriptionDefinition
                    {
                        Name = form.SubscriptionName,
                        ServerName = form.ServerName,
                        Topic = form.Topic,
                        WorksheetRange = form.WorksheetRange,
                        Filter = form.Filter
                    };

                    Globals.AMPSAddin.getWorkbookInfo(activeWorkbook).createOrUpdate(def);

                    ActiveSub.activate(def, c, serverDef.MessageType, Globals.AMPSAddin.Application.ActiveWorkbook);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #4
0
 private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     var form = new SubscriptionForm(Globals.AMPSAddin.Application.ActiveWorkbook);
     var sd = _subs[e.RowIndex];
     form.SubscriptionName = sd.Name;
     // don't let the user modify this name.
     form.txtName.Enabled = false;
     form.ServerName = sd.ServerName;
     form.Topic = sd.Topic;
     form.Filter = sd.Filter;
     form.WorksheetRange = sd.WorksheetRange;
     bool wasActive = ActiveSub.isActive(sd);
     if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         sd.Name = form.SubscriptionName;
         sd.ServerName = form.ServerName;
         sd.Topic = form.Topic;
         sd.Filter = form.Filter;
         sd.WorksheetRange = form.WorksheetRange;
         DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
         if (wasActive)
         {
             row.Cells[0].Value = false;
             deactivate(e.RowIndex);
             var wbInfo = Globals.AMPSAddin.getWorkbookInfo(
                 Globals.AMPSAddin.Application.ActiveWorkbook);
             wbInfo.createOrUpdate(sd);
             if (activate(e.RowIndex))
             {
                 row.Cells[0].Value = true;
             }
         }
         row.Cells[1].Value = sd.Name;
         row.Cells[2].Value = sd.ServerName;
         row.Cells[3].Value = sd.Topic;
         row.Cells[4].Value = sd.Filter;
         row.Cells[5].Value = sd.WorksheetRange;
     }
 }