Ejemplo n.º 1
0
        public string FormatResult(DebugResult result)
        {
            var           now     = DateTime.Now;
            StringBuilder builder = new StringBuilder();
            string        ipv4    = LocalInfoUtil.GetLocalIPv4();
            string        pcName  = LocalInfoUtil.GetLocalUsername();

            builder.Append("\r\n");
            builder.Append("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\r\n");
            builder.Append("┃******************* Gossip Debug Info *********************\r\n");
            builder.AppendFormat("┃ Operator	:{0}	\r\n", pcName);
            builder.AppendFormat("┃ LocalIP	:{0}	\r\n", ipv4);
            builder.Append("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\r\n");
            //builder.AppendFormat("{0} :\r\n", result.Result);
            try
            {
                viewInfos infos = result.InputViews;
                int       len   = result.InputViews.Views.Count;
                builder.AppendFormat("#####>>>{0}:{1}>>>Begin:\r\n", "IN", result.InputViews.Views.Count);

                for (int i = 0; i < len; i++)
                {
                    string s = result.InputViews.Views[i];
                    builder.Append(s);
                    builder.AppendLine();
                }
                viewInfos outviews = result.OutputViews;
                builder.AppendFormat("#####>>>{0}:{1}>>>Begin:\r\n", "OUT", outviews.Views.Count);
                for (int j = 0; j < outviews.Views.Count; j++)
                {
                    string s = outviews.Views[j];
                    builder.Append(s);
                    builder.AppendLine();
                }
                builder.AppendFormat("############## {0} #############\r\n", now.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            catch (Exception e)
            {
                builder.AppendFormat("Error:{0} \r\n {1}", now.ToString("yyyy-MM-dd HH:mm:ss"), e.Message);
            }

            return(builder.ToString());
        }
Ejemplo n.º 2
0
        public string RestartGossip()
        {
            string  res     = "重启成功";
            Channel channel = helper.NewChannel();

            try
            {
                GossipTask.GossipTaskClient gClient = new GossipTask.GossipTaskClient(channel);
                DateTime      opTime  = DateTime.Now;
                string        name    = LocalInfoUtil.GetLocalUsername();
                StringBuilder sb      = new StringBuilder();
                string        content = "-----{0}-----{1} at {2} gossip restarting ... ";
                WriteLog(String.Format(content,
                                       opTime.ToLongTimeString(),
                                       name,
                                       opTime.ToString("yyyy-MM-dd HH:mm:ss")),
                         "restart Gossip");
                gClient.stopService(new StopRequest {
                });

                Thread.Sleep(500);
                gClient.startServiceAsync(new StartRequest {
                });
            }
            catch (Exception e)
            {
                WriteLog(String.Format("重启Gossip发生错误,请重试!\r\n 可能原因:{0}", e.Message), "");
                return(String.Format("重启Gossip发生错误,请重试!\r\n 可能原因:{0}", e.Message));
            }
            finally
            {
                channel.ShutdownAsync().Wait();
            }
            WriteLog(String.Format("############ {0} ############\r\n", res), "");
            return(res);
        }