Esempio n. 1
0
        public frmInvoke(ServerNode node, string serviceName, string methodName, IList<ParameterInfo> parameters)
        {
            InitializeComponent();

            this.node = node;
            this.timeout = node.Timeout;
            this.node.Timeout = 30;
            this.serviceName = serviceName;
            this.methodName = methodName;
            this.parameters = parameters;
            this.txtParameters = new Dictionary<string, TextBox>();
        }
        /// <summary>
        /// 实例化ServiceMessage
        /// </summary>
        /// <param name="node"></param>
        /// <param name="logger"></param>
        public ServiceRequest(ServerNode node, ILog logger, bool isTimeoutDisconnect)
        {
            this.logger = logger;
            this.node = node.Key;
            this.ip = node.IP;
            this.port = node.Port;

            this.client = ScsClientFactory.CreateClient(new ScsTcpEndPoint(ip, port));
            this.client.ConnectTimeout = 5000;
            this.client.IsTimeoutDisconnect = isTimeoutDisconnect;
            this.client.Disconnected += client_Disconnected;
            this.client.MessageReceived += client_MessageReceived;
            this.client.MessageSent += client_MessageSent;
            this.client.MessageError += client_MessageError;
            this.client.WireProtocol = new CustomWireProtocol(node.Compress, node.Encrypt);
        }
Esempio n. 3
0
        private void InitService(ServerNode node, bool forceRefresh)
        {
            if (!forceRefresh && defaultNode != null)
            {
                if (node.Key == defaultNode.Key && listAssembly.Items.Count > 0)
                    return;
            }

            listAssembly.Items.Clear();
            listService.Items.Clear();
            listMethod.Items.Clear();
            richTextBox3.Clear();

            listAssembly.SelectedIndex = -1;
            listService.SelectedIndex = -1;
            listMethod.SelectedIndex = -1;

            listAssembly.Invalidate();
            listService.Invalidate();
            listMethod.Invalidate();

            tabPage0.Text = "服务信息";

            try
            {
                services = CastleFactory.Create().GetChannel<IStatusService>(node)
                    .GetServiceList().OrderBy(p => p.Name).ToList();

                methods.Clear();
                foreach (var s in services)
                {
                    foreach (var m in s.Methods)
                    {
                        var methodName = m.FullName;
                        var indexOf = m.FullName.IndexOf(' ');
                        if (indexOf >= 0)
                        {
                            methodName = m.FullName.Substring(indexOf + 1);
                        }

                        string key = string.Format("【{0}】{1}", s.FullName, methodName);
                        methods[key] = new InvokeService
                        {
                            ServiceName = s.FullName,
                            MethodName = m.FullName,
                            Parameters = m.Parameters
                        };
                    }
                }

                //处理自动完成列表
                autoCompleteTextbox1.AutoCompleteList = methods.Select(p => p.Key).ToList();

                this.Text = string.Format("分布式服务监控 v1.0 【当前服务器节点({0}:{1}) 服务数:{2} 接口数:{3}】",
                    node.IP, node.Port, services.Count, services.Sum(p => p.Methods.Count));
            }
            catch (Exception ex)
            {
                SimpleLog.Instance.WriteLogForDir("Client", ex);
                MessageBox.Show(ex.Message, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var assemblies = services.GroupBy(prop => prop.Assembly)
                .Select(p => new { Name = p.Key.Split(',')[0], FullName = p.Key, Services = p.ToList() })
                .OrderBy(p => p.Name).ToList();
            tabPage0.Text = "服务信息(" + assemblies.Count + ")";
            listAssembly.Items.Clear();
            foreach (var assembly in assemblies)
            {
                listAssembly.Items.Add(
                    new ParseMessageEventArgs
                    {
                        MessageType = ParseMessageType.Info,
                        LineHeader = string.Format("{0} => ({1}) services", assembly.Name, assembly.Services.Count),
                        MessageText = string.Format("{0}", assembly.FullName),
                        Source = assembly.Services
                    });
            }

            listAssembly.Invalidate();

            defaultNode = node;
        }
Esempio n. 4
0
        private void frmInvoke_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.node = null;
            this.parameters = null;
            this.txtParameters = null;

            this.Dispose();
        }
Esempio n. 5
0
 public frmInvoke(ServerNode node, string serviceName, string methodName, IList<ParameterInfo> parameters, string paramValue)
     : this(node, serviceName, methodName, parameters)
 {
     this.paramValue = paramValue;
 }