Exemplo n.º 1
0
        /// <summary>获取类型</summary>
        /// <param name="name">名称</param>
        /// <returns></returns>
        public Type GetType(String name)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            // 第一次使用时编译
            if (Assembly == null)
            {
                Compile();
            }
            if (Assembly == null)
            {
                throw new Exception("未编译!");
            }

            var asmx = AssemblyX.Create(Assembly);

            if (TypeMaps.TryGetValue(name, out var typeName))
            {
                return(asmx.GetType(typeName));
            }
            else
            {
                return(asmx.GetType(name));
            }
        }
Exemplo n.º 2
0
        public static void WriteVersion(this Assembly asm)
        {
            if (asm == null)
            {
                return;
            }

            var asmx = AssemblyX.Create(asm);

            if (asmx != null)
            {
                var ver = "";
                var tar = asm.GetCustomAttribute <TargetFrameworkAttribute>();
                if (tar != null)
                {
                    ver = tar.FrameworkDisplayName;
                    if (ver.IsNullOrEmpty())
                    {
                        ver = tar.FrameworkName;
                    }
                }

                WriteLine("{0} v{1} Build {2:yyyy-MM-dd HH:mm:ss} {3}", asmx.Name, asmx.FileVersion, asmx.Compile, ver);
                var att = asmx.Asm.GetCustomAttribute <AssemblyCopyrightAttribute>();
                WriteLine("{0} {1}", asmx.Title, att?.Copyright);
            }
        }
Exemplo n.º 3
0
        private static string MakeResponseHeaders(int statusCode, IDictionary <String, String> moreHeaders, int contentLength, bool keepAlive)
        {
            var header = new HttpHeader();

            header.StatusCode        = statusCode;
            header.StatusDescription = HttpWorkerRequest.GetStatusDescription(statusCode);
            if (contentLength >= 0)
            {
                header.ContentLength = contentLength;
            }
            header.Headers["Server"] = typeof(WebServer).FullName + "/" + AssemblyX.Create(Assembly.GetExecutingAssembly()).CompileVersion;
            header.Headers["Date"]   = DateTime.Now.ToUniversalTime().ToString("R", DateTimeFormatInfo.InvariantInfo);
            if (moreHeaders != null)
            {
                foreach (var item in moreHeaders)
                {
                    header.Headers[item.Key] = item.Value;
                }
            }
            if (!keepAlive)
            {
                header.KeepAlive = false;
            }
            return(header.ToText());

            //var builder = new StringBuilder();
            //builder.Append(string.Concat(new object[] { "HTTP/1.1 ", statusCode, " ", HttpWorkerRequest.GetStatusDescription(statusCode), "\r\n" }));
            //builder.Append("Server: ASP.NET Development Server/" + Messages.VersionString + "\r\n");
            //builder.Append("Date: " + DateTime.Now.ToUniversalTime().ToString("R", DateTimeFormatInfo.InvariantInfo) + "\r\n");
            //if (contentLength >= 0) builder.Append("Content-Length: " + contentLength + "\r\n");
            //if (moreHeaders != null) builder.Append(moreHeaders);
            //if (!keepAlive) builder.Append("Connection: Close\r\n");
            //builder.Append("\r\n");
            //return builder.ToString();
        }
Exemplo n.º 4
0
        /// <summary>连接后自动登录</summary>
        /// <param name="client">客户端</param>
        /// <param name="force">强制登录</param>
        protected override async Task <Object> OnLoginAsync(ISocketClient client, Boolean force)
        {
            if (Logined && !force)
            {
                return(null);
            }

            var asm = AssemblyX.Entry ?? AssemblyX.Create(Assembly.GetExecutingAssembly());

            var arg = new
            {
                user      = UserName,
                pass      = Password.MD5(),
                machine   = Environment.MachineName,
                processid = Process.GetCurrentProcess().Id,
                version   = asm?.Version,
                compile   = asm?.Compile,
            };

            var rs = await base.InvokeWithClientAsync <Object>(client, "Login", arg);

            if (NewLife.Setting.Current.Debug)
            {
                XTrace.WriteLine("登录{0}成功!{1}", client, rs.ToJson());
            }

            Logined = true;

            return(Info = rs as IDictionary <String, Object>);
        }
Exemplo n.º 5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            var path      = ".".GetFullPath();
            var driveInfo = DriveInfo.GetDrives().FirstOrDefault(e => path.StartsWithIgnoreCase(e.Name));

            var deviceId = Android.Provider.Settings.Secure.GetString(Application.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId);

            var device = DeviceInfo.Model;
            var dic    = new Dictionary <String, Object>();

            foreach (var item in typeof(DeviceInfo).GetProperties())
            {
                dic[item.Name] = item.GetValue(device);
            }
            var js = dic.ToJson(true);

            // 设置入口程序集
            var asm = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly();

            if (asm != null)
            {
                AssemblyX.Entry = AssemblyX.Create(asm);
            }

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            LoadApplication(new App());
        }
Exemplo n.º 6
0
        /// <summary>实例化</summary>
        public StarTracer()
        {
            Period = 60;

            var sys = SysConfig.Current;

            //AppId = sys.Name;
            AppName = sys.DisplayName;

            var set = Setting.Current;

            AppId     = set.AppKey;
            AppSecret = set.Secret;

            if (set.Debug)
            {
                Log = XTrace.Log;
            }

            try
            {
                var executing = AssemblyX.Create(Assembly.GetExecutingAssembly());
                if (executing != null)
                {
                    _version = executing.Version;
                }

                var asm = AssemblyX.Entry ?? executing;
                ClientId = $"{NetHelper.MyIP()}@{Process.GetCurrentProcess().Id}@{asm?.Version}";
            }
            catch { }
        }
Exemplo n.º 7
0
        public Object Info(String state)
        {
            var conn  = HttpContext.Connection;
            var asmx  = AssemblyX.Entry;
            var asmx2 = AssemblyX.Create(Assembly.GetExecutingAssembly());

            var ip = HttpContext.GetUserHost();

            var rs = new
            {
                Server = asmx?.Name,
                asmx?.Version,
                OS          = _OS,
                MachineName = _MachineName,
                UserName    = _UserName,
                ApiVersion  = asmx2?.Version,

                LocalIP = _LocalIP,
                Remote  = ip + "",
                State   = state,
                Time    = DateTime.Now,
            };

            // 转字典
            var dic = rs.ToDictionary();

            dic["Port"] = conn.LocalPort;
            //dic["Online"] = nsvr.SessionCount;
            //dic["MaxOnline"] = nsvr.MaxSessionCount;

            // 进程
            dic["Process"] = GetProcess();

            return(dic);
        }
Exemplo n.º 8
0
        private void FrmMain_Shown(object sender, EventArgs e)
        {
            var asm = AssemblyX.Create(Assembly.GetExecutingAssembly());

            Text = String.Format("新生命代码生成器 V{0} {1:HH:mm:ss}编译", asm.CompileVersion, asm.Compile);
            Template.BaseClassName = typeof(XCoderBase).FullName;
        }
Exemplo n.º 9
0
        private void SharpApp_Shown(System.Object sender, System.EventArgs e)
        {
            var set = XConfig.Current;

            if (set.Width > 0 || set.Height > 0)
            {
                DefaultWidth  = set.Width;
                DefaultHeight = set.Height;
                //SetDefaultSize(set.Width, set.Height);
            }

            SetPosition(WindowPosition.Center);

            AddMenuButton();

            //AddMenu();

            var frm = new FrmMain();

            _windowBox.PackStart(frm, true, true, 0);

            Add(_windowBox);

            var asm = AssemblyX.Create(Assembly.GetExecutingAssembly());

            if (set.Title.IsNullOrEmpty())
            {
                set.Title = asm.Title;
            }
            _title = Title = String.Format("{2} v{0} {1:HH:mm:ss}", asm.CompileVersion, asm.Compile, set.Title);

            _load.ContinueWith(t => LoadForms(t.Result));

            ShowAll();
        }
Exemplo n.º 10
0
        private void 关于ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AssemblyX ax  = AssemblyX.Create(Assembly.GetEntryAssembly());
            String    msg = String.Format("{0} {1} v{2}", ax.Description, ax.Name, ax.Version);

            MessageBox.Show(msg);
        }
Exemplo n.º 11
0
        /// <summary>服务器信息,用户健康检测</summary>
        /// <param name="state">状态信息</param>
        /// <returns></returns>
        public Object Info(String state)
        {
            var ctx   = ControllerContext.Current;
            var ns    = ctx?.Session as INetSession;
            var asmx  = AssemblyX.Entry;
            var asmx2 = AssemblyX.Create(Assembly.GetExecutingAssembly());

            var rs = new
            {
                Server = asmx?.Name,
                asmx?.Version,
                asmx?.Compile,
                OS          = _OS,
                MachineName = _MachineName,
                UserName    = _UserName,
                ApiVersion  = asmx2?.Version,

                LocalIP   = _LocalIP,
                Remote    = ns?.Remote?.EndPoint + "",
                State     = state,
                LastState = Session["State"],
                Time      = DateTime.Now,
            };

            // 记录上一次状态
            Session["State"] = state;

            // 转字典
            var dic = rs.ToDictionary();

            // 令牌
            //var token = ctx.Parameters["Token"] + "";
            //if (ctx.Parameters.TryGetValue("Token", out var token) && token + "" != "") dic["Token"] = token;
            if (!Session.Token.IsNullOrEmpty())
            {
                dic["Token"] = Session.Token;
            }

            // 时间和连接数
            if (Host is ApiHost ah)
            {
                dic["Uptime"] = (DateTime.Now - ah.StartTime).ToString();
            }
            if (Host is ApiServer svr && svr.Server is NetServer nsvr)
            {
                dic["Port"]      = nsvr.Port;
                dic["Online"]    = nsvr.SessionCount;
                dic["MaxOnline"] = nsvr.MaxSessionCount;
            }

            // 进程
            dic["Process"] = GetProcess();

            // 加上统计信息
            dic["Stat"] = GetStat();

            return(dic);
        }
Exemplo n.º 12
0
        /// <summary>服务器信息,用户健康检测</summary>
        /// <param name="state">状态信息</param>
        /// <returns></returns>
        public ActionResult Info(String state)
        {
            var asmx  = AssemblyX.Entry;
            var asmx2 = AssemblyX.Create(Assembly.GetExecutingAssembly());

            var ip = HttpContext.GetUserHost();

            var rs = new
            {
                Server = asmx?.Name,
                asmx?.Version,
                asmx?.Compile,
                OS          = _OS,
                MachineName = _MachineName,
                UserName    = _UserName,
                ApiVersion  = asmx2?.Version,

                UserHost = ip + "",
                Local    = _LocalIP,
                Remote   = ip + "",
                State    = state,
                Time     = DateTime.Now,
            };

            // 转字典
            var dic = rs.ToDictionary();

#if __CORE__
            // 完整显示地址和端口
            var conn = HttpContext.Connection;
            if (conn != null)
            {
                var addr = conn.LocalIpAddress;
                if (addr != null && addr.IsIPv4MappedToIPv6)
                {
                    addr = addr.MapToIPv4();
                }
                dic["Local"] = $"{addr}:{conn.LocalPort}";

                addr = conn.RemoteIpAddress;
                if (addr != null && addr.IsIPv4MappedToIPv6)
                {
                    addr = addr.MapToIPv4();
                }
                dic["Remote"] = $"{addr}:{conn.RemotePort}";
            }
#endif

            // 登录后,系统角色可以看看到进程
            var user = ManageProvider.User;
            if (user != null && user.Roles.Any(r => r.IsSystem))
            {
                dic["Process"] = GetProcess();
            }

            return(Json(0, null, dic));
        }
Exemplo n.º 13
0
        public Object Info(String state)
        {
            var conn  = HttpContext.Connection;
            var asmx  = AssemblyX.Entry;
            var asmx2 = AssemblyX.Create(Assembly.GetExecutingAssembly());

            var ip = HttpContext.GetUserHost();

            var rs = new
            {
                asmx?.Name,
                asmx?.Title,
                asmx?.Version,
                asmx?.Compile,
                OS          = _OS,
                MachineName = _MachineName,
                UserName    = _UserName,
                ApiVersion  = asmx2?.Version,

                UserHost,
                LocalIP   = _LocalIP,
                Remote    = ip + "",
                State     = state,
                LastState = Session?["State"],
                Time      = DateTime.Now,
            };

            // 记录上一次状态
            if (Session != null)
            {
                Session["State"] = state;
            }

            // 转字典
            var dic = rs.ToDictionary();

            // 令牌
            if (!Token.IsNullOrEmpty())
            {
                dic["Token"] = Token;
            }

            // 时间和连接数
            //if (Host is ApiHost ah) dic["Uptime"] = (DateTime.Now - ah.StartTime).ToString();

            dic["Port"] = conn.LocalPort;
            //dic["Online"] = nsvr.SessionCount;
            //dic["MaxOnline"] = nsvr.MaxSessionCount;

            // 进程
            dic["Process"] = GetProcess();

            //// 加上统计信息
            //dic["Stat"] = GetStat();

            return(dic);
        }
Exemplo n.º 14
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            //this.Visible = false;

            AssemblyX ax  = AssemblyX.Create(Assembly.GetEntryAssembly());
            String    msg = String.Format("{0} {1} v{2}", ax.Title, ax.Name, ax.Version);

            this.Text = msg;
        }
Exemplo n.º 15
0
        /// <summary>获取设备信息</summary>
        /// <returns></returns>
        public NodeInfo GetNodeInfo()
        {
            var mi = MachineInfo.Current ?? _task.Result;

            var asm = AssemblyX.Entry ?? AssemblyX.Create(Assembly.GetExecutingAssembly());
            //var ps = System.IO.Ports.SerialPort.GetPortNames();
            var mcs       = NetHelper.GetMacs().Select(e => e.ToHex("-")).OrderBy(e => e).Join(",");
            var driveInfo = new DriveInfo(Path.GetPathRoot(".".GetFullPath()));
            var ip        = NetHelper.GetIPsWithCache().Where(ip => ip.IsIPv4() && !IPAddress.IsLoopback(ip) && ip.GetAddressBytes()[0] != 169).Join();
            var di        = new NodeInfo
            {
                Version = asm?.FileVersion,
                Compile = asm?.Compile ?? DateTime.MinValue,

                OSName    = mi.OSName,
                OSVersion = mi.OSVersion,

                MachineName = Environment.MachineName,
                UserName    = Environment.UserName,
                IP          = ip,

                ProcessorCount     = Environment.ProcessorCount,
                Memory             = mi.Memory,
                AvailableMemory    = mi.AvailableMemory,
                TotalSize          = (UInt64)driveInfo.TotalSize,
                AvailableFreeSpace = (UInt64)driveInfo.AvailableFreeSpace,

                Processor   = mi.Processor,
                CpuID       = mi.CpuID,
                CpuRate     = mi.CpuRate,
                UUID        = mi.UUID,
                MachineGuid = mi.Guid,
                DiskID      = mi.DiskID,

                Macs = mcs,
                //COMs = ps.Join(","),

                InstallPath = ".".GetFullPath(),
                Runtime     = Environment.Version + "",

                Time = DateTime.UtcNow,
            };

#if !__CORE__
            try
            {
                // 收集屏幕相关信息。Mono+Linux无法获取
                var g = System.Drawing.Graphics.FromHwnd(IntPtr.Zero);
                di.Dpi = $"{g.DpiX}*{g.DpiY}";
                var screen = System.Windows.Forms.Screen.PrimaryScreen;
                di.Resolution = $"{screen.Bounds.Width}*{screen.Bounds.Height}";
            }
            catch { }
#endif

            return(di);
        }
Exemplo n.º 16
0
        private void timer1_Tick(Object sender, EventArgs e)
        {
            timer1.Enabled = false;

            var asm = AssemblyX.Create(Assembly.GetExecutingAssembly());

            //webBrowser1.Navigate("http://www.newlifex.com/archiver/showforum-2.aspx", false);
            webBrowser1.Url         = new Uri("http://www.newlifex.com/archiver/showforum-2.aspx?r=XCoder_v" + asm.CompileVersion);
            webBrowser1.Navigating += webBrowser1_Navigating;
        }
Exemplo n.º 17
0
        /// <summary>实例化一个升级对象实例,获取当前应用信息</summary>
        public Upgrade()
        {
            var asm  = Assembly.GetEntryAssembly();
            var asmx = AssemblyX.Create(asm);

            Version = asm.GetName().Version;
            Name    = asm.GetName().Name;
            Time    = asmx.Compile;

            Server = NewLife.Setting.Current.PluginServer;
        }
Exemplo n.º 18
0
        static void InitLog()
        {
            if (hasInited > 0 || Interlocked.CompareExchange(ref hasInited, 1, 0) > 0)
            {
                return;
            }

            Log = TextFileLog.Create(Config.GetConfig <String>("NewLife.LogPath"));

            var asmx = AssemblyX.Create(Assembly.GetExecutingAssembly());

            WriteLine("{0} v{1} Build {2:yyyy-MM-dd HH:mm:ss}", asmx.Name, asmx.FileVersion, asmx.Compile);
        }
Exemplo n.º 19
0
        /// <summary>实例化令牌服务器</summary>
        public LinkServer()
        {
            ShowSessionCount = 60;

            // 初始数据
            var dic = Parameters;

            dic["OS"]    = Runtime.OSName;
            dic["Agent"] = $"{Environment.UserName}_{Environment.MachineName}";

            var asmx = AssemblyX.Create(Assembly.GetCallingAssembly());

            dic["Version"] = asmx.Version;
        }
Exemplo n.º 20
0
        public LinkClient(String uri)
        {
            Remote = uri;

            // 初始数据
            var dic = Parameters;

            dic["OS"]    = Runtime.OSName;
            dic["Agent"] = $"{Environment.UserName}_{Environment.MachineName}";

            var asmx = AssemblyX.Create(Assembly.GetCallingAssembly());

            dic["Version"] = asmx.Version;
        }
Exemplo n.º 21
0
        /// <summary>输出程序集版本</summary>
        /// <param name="asm"></param>
        public static void WriteVersion(this Assembly asm)
        {
            if (asm == null)
            {
                return;
            }

            var asmx = AssemblyX.Create(asm);

            if (asmx != null)
            {
                WriteLine("{0,-12} v{1,-13} Build {2:yyyy-MM-dd HH:mm:ss}", asmx.Name, asmx.FileVersion, asmx.Compile);
            }
        }
Exemplo n.º 22
0
        private void FrmMDI_Shown(object sender, EventArgs e)
        {
            var set = XConfig.Current;

            if (set.Width > 0 || set.Height > 0)
            {
                this.Width  = set.Width;
                this.Height = set.Height;
                this.Top    = set.Top;
                this.Left   = set.Left;
            }

            var asm = AssemblyX.Create(Assembly.GetExecutingAssembly());

            if (set.Title.IsNullOrEmpty())
            {
                set.Title = asm.Title;
            }
            Text = String.Format("{2} v{0} {1:HH:mm:ss}", asm.CompileVersion, asm.Compile, set.Title);

            //var name = Path.GetFileNameWithoutExtension(Application.ExecutablePath);
            var name = XConfig.Current.LastTool + "";

            switch (name.ToLower())
            {
            case "xcoder":
                CreateForm <FrmMain>();
                break;

            case "xcom":
            case "com":
                CreateForm <XCom.FrmMain>();
                break;

            case "xregex":
            case "regex":
                CreateForm <NewLife.XRegex.FrmMain>();
                break;

            case "xico":
            case "ico":
                CreateForm <XICO.FrmMain>();
                break;

            default:
                //CreateForm<FrmMain>();
                break;
            }
        }
Exemplo n.º 23
0
        /// <summary>实例化Http配置提供者,对接星尘和阿波罗等配置中心</summary>
        public HttpConfigProvider()
        {
            try
            {
                var executing = AssemblyX.Create(Assembly.GetExecutingAssembly());
                var asm       = AssemblyX.Entry ?? executing;
                if (asm != null)
                {
                    AppId = asm.Name;
                }

                ValidClientId();
            }
            catch { }
        }
Exemplo n.º 24
0
        /// <summary>实例化Http配置提供者,对接星尘和阿波罗等配置中心</summary>
        public HttpConfigProvider()
        {
            try
            {
                var executing = AssemblyX.Create(Assembly.GetExecutingAssembly());
                var asm       = AssemblyX.Entry ?? executing;
                if (asm != null)
                {
                    AppId = asm.Name;
                }

                ClientId = $"{NetHelper.MyIP()}@{Process.GetCurrentProcess().Id}";
            }
            catch { }
        }
Exemplo n.º 25
0
        public static void Delete(String name)
        {
            var dir  = Environment.GetFolderPath(Environment.SpecialFolder.SendTo);
            var asmx = AssemblyX.Create(Assembly.GetExecutingAssembly());

            if (!String.IsNullOrEmpty(name))
            {
                name = "(" + name + ")";
            }
            var file = dir.CombinePath(asmx.Title + name + ".lnk");

            if (File.Exists(file))
            {
                File.Delete(file);
            }
        }
Exemplo n.º 26
0
        /// <summary>输出程序集版本</summary>
        /// <param name="asm"></param>
        public static void WriteVersion(this Assembly asm)
        {
            if (asm == null)
            {
                return;
            }

            var asmx = AssemblyX.Create(asm);

            if (asmx != null)
            {
                WriteLine("{0} v{1} Build {2:yyyy-MM-dd HH:mm:ss}", asmx.Name, asmx.FileVersion, asmx.Compile);
                var att = asmx.Asm.GetCustomAttribute <AssemblyCopyrightAttribute>();
                WriteLine("{0} {1}", asmx.Title, att?.Copyright);
            }
        }
Exemplo n.º 27
0
        /// <summary>实例化一个升级对象实例,获取当前应用信息</summary>
        public Upgrade()
        {
            var asm  = Assembly.GetEntryAssembly();
            var asmx = AssemblyX.Create(asm);

            Version = asm.GetName().Version;
            Name    = asm.GetName().Name;
            Compile = asmx.Compile;

            AutoStart  = true;
            UpdatePath = "Update";
            Server     = Setting.Current.PluginServer;

            TempPath = XTrace.TempPath;
            Links    = new Link[0];
        }
Exemplo n.º 28
0
        /// <summary>显示状态</summary>
        protected virtual void ShowStatus()
        {
            var color = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Red;

            var name = ServiceName;

            if (name != DisplayName)
            {
                Console.WriteLine("服务:{0}({1})", DisplayName, name);
            }
            else
            {
                Console.WriteLine("服务:{0}", name);
            }
            Console.WriteLine("描述:{0}", Description);
            Console.Write("状态:{0} ", Host.GetType().Name);

            if (!Host.IsInstalled(name))
            {
                Console.WriteLine("未安装");
            }
            else if (Host.IsRunning(name))
            {
                Console.WriteLine("运行中");
            }
            else
            {
                Console.WriteLine("未启动");
            }

            var asm = AssemblyX.Create(Assembly.GetExecutingAssembly());

            Console.WriteLine();
            Console.WriteLine("{0}\t版本:{1}\t发布:{2:yyyy-MM-dd HH:mm:ss}", asm.Name, asm.FileVersion, asm.Compile);

            var asm2 = AssemblyX.Create(Assembly.GetEntryAssembly());

            if (asm2 != asm)
            {
                Console.WriteLine("{0}\t版本:{1}\t发布:{2:yyyy-MM-dd HH:mm:ss}", asm2.Name, asm2.FileVersion, asm2.Compile);
            }

            Console.ForegroundColor = color;
        }
Exemplo n.º 29
0
        /// <summary>服务器信息,用户健康检测</summary>
        /// <param name="state">状态信息</param>
        /// <returns></returns>
        public Object Info(String state)
        {
            var ctx   = ControllerContext.Current;
            var ns    = ctx?.Session as INetSession;
            var asmx  = AssemblyX.Entry;
            var asmx2 = AssemblyX.Create(Assembly.GetExecutingAssembly());

            var rs = new
            {
                Server = asmx?.Name,
                asmx?.Version,
                OS          = _OS,
                MachineName = _MachineName,
                UserName    = _UserName,
                ApiVersion  = asmx2?.Version,

                LocalIP = _LocalIP,
                Remote  = ns?.Remote?.EndPoint + "",
                State   = state,
                Time    = DateTime.Now,
            };

            // 转字典
            var dic = rs.ToDictionary();

            // 时间和连接数
            if (Host is ApiHost ah)
            {
                dic["Uptime"] = (DateTime.Now - ah.StartTime).ToString();
            }
            if (Host is ApiServer svr && svr.Server is NetServer nsvr)
            {
                dic["Port"]      = nsvr.Port;
                dic["Online"]    = nsvr.SessionCount;
                dic["MaxOnline"] = nsvr.MaxSessionCount;
            }

            // 进程
            dic["Process"] = GetProcess();

            // 加上统计信息
            dic["Stat"] = GetStat();

            return(dic);
        }
Exemplo n.º 30
0
        public DeviceClient(String uri)
        {
            Remote = uri;

            // 初始数据
            var dic = Parameters;

            dic["OS"]    = Runtime.OSName;
            dic["Agent"] = $"{Environment.UserName}_{Environment.MachineName}";

            var asmx = AssemblyX.Create(Assembly.GetCallingAssembly());

            dic["Version"] = asmx.Version;

            // 注册当前类所有接口
            Manager.Register(this, null, true);
            //Register(this, nameof(OnWrite));
        }