Beispiel #1
0
        private void Connect()
        {
            try
            {
                Retry.Execute(() =>
                {
                    EnsureClient();

                    MyClients.Add(serviceType, m_WsDualClient);
                    client.Register(serviceType);

                    Initialize();

                    SetRequestParameters(client.GetRequestParameter(ServiceType));
                }, TimeSpan.FromSeconds(2), 1);
                InitialSuccess = true;
            }
            catch (AggregateException ex)
            {
                var msg = "连接不上服务器:" + ex.InnerExceptions.First().Message;
                MessageBox.Show(msg);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
            }
        }
Beispiel #2
0
        private void btnSample_Click(object sender, EventArgs e)
        {
            var btn = sender as Button;

            var serviceType = ((EServiceType)btn.Tag);

            if (!MyClients.HasAddTagPage(serviceType))
            {
                var service = new ucServiceConfig(serviceType);

                service.Dock = DockStyle.Fill;
                var newTabPage = new TabPage();
                newTabPage.Text = serviceType.ServiceName;
                newTabPage.Controls.Add(service);
                tabControlMain.TabPages.Add(newTabPage);

                if (!service.InitialSuccess)
                {
                    tabControlMain.TabPages.Remove(newTabPage);
                    return;
                }

                MyClients.Add(serviceType, newTabPage);
                tabControlMain.SelectedTab = newTabPage;
            }
            else
            {
                tabControlMain.SelectedTab = MyClients.GetTabPage(serviceType);
            }
        }