AMPSExcel.ActiveSub.activate C# (CSharp) Méthode

activate() public static méthode

public static activate ( AMPSAddin d, Client client, string messageType, Microsoft.Office.Interop.Excel workbook ) : ActiveSub
d AMPSAddin
client Client
messageType string
workbook Microsoft.Office.Interop.Excel
Résultat ActiveSub
        public static ActiveSub activate(AMPSAddin.SubscriptionDefinition d, Client client, string messageType, Excel.Workbook workbook)
        {
            if (!_actives.ContainsKey(d))
            {
                _actives[d] = new ActiveSub(client, messageType, d, workbook);
            }
            return _actives[d];
        }

Usage Example

        private bool activate(int index)
        {
            this.Cursor = Cursors.WaitCursor;
            string subName = dataGridView1.Rows[index].Cells[1].Value.ToString();

            Globals.AMPSAddin.Application.StatusBar = "Activating subscription " + subName + "...";

            // activate
            try
            {
                var    workbook   = Globals.AMPSAddin.Application.ActiveWorkbook;
                var    ampsWBInfo = Globals.AMPSAddin.getWorkbookInfo(workbook);
                Client c          = new Client(Guid.NewGuid().ToString());
                AMPSAddin.ServerDefinition serverDef = ampsWBInfo.Servers[_subs[index].ServerName];
                c.connect(serverDef.URL);
                c.logon();
                ActiveSub.activate(_subs[index], c, serverDef.MessageType, workbook);
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show(string.Format("Error activating: {0}", ex.Message),
                                "Error activating subscription " + subName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Globals.AMPSAddin.Application.StatusBar = false;
                return(false);
            }
            Globals.AMPSAddin.Application.StatusBar = false;
            this.Cursor = Cursors.Default;
            return(true);
        }
All Usage Examples Of AMPSExcel.ActiveSub::activate