Ejemplo n.º 1
0
        public IActionResult Index()
        {
            JResponse.Header.Time = "" + dpz.Time.Now.ToTimeStamp();

            //创建控制器类型列表
            List <Type> controllerTypes = new List <Type>();

            //加载程序集
            var assembly = Assembly.Load("Api");

            //获取程序集下所有的类,通过Linq筛选继承IController类的所有类型
            controllerTypes.AddRange(assembly.GetTypes().Where(type => typeof(Controller).IsAssignableFrom(type)));

            JResponse.Data.Apis = new List <dpz.Dynamic>();

            //创建动态字符串,拼接json数据    注:现在json类型传递数据比较流行,比xml简洁
            //StringBuilder jsonBuilder = new StringBuilder();
            //jsonBuilder.Append("[");

            //遍历控制器类
            foreach (var controller in controllerTypes)
            {
                //dynamic dc = new dpz.Dynamic();
                string clrPath = "/" + controller.Name.Substring(0, controller.Name.Length - 10);
                //dcc.Description = (controller.GetCustomAttribute(typeof(DescriptionAttribute)) as DescriptionAttribute) == null ? "" : (controller.GetCustomAttribute(typeof(DescriptionAttribute)) as DescriptionAttribute).Description;
                //dcc.Actions = new List<dpz.Dynamic>();
                //jsonBuilder.Append("{\"name\":\"");
                //jsonBuilder.Append(controller.Name);
                //jsonBuilder.Append("\",\"description\":\"");
                //jsonBuilder.Append();

                //获取对控制器的描述Description
                //jsonBuilder.Append("\",\"action\":[");

                //获取控制器下所有返回类型为ActionResult的方法,对MVC的权限控制只要限制所以的前后台交互请求就行,统一为ActionResult
                var actions = controller.GetMethods().Where(method => method.ReturnType.Name == "IActionResult");
                foreach (var action in actions)
                {
                    dynamic dc = new dpz.Dynamic();
                    JResponse.Data.Apis.Add(dc);

                    dc.Url         = clrPath + "/" + action.Name;
                    dc.Description = (action.GetCustomAttribute(typeof(DescriptionAttribute)) as DescriptionAttribute) == null ? "" : (action.GetCustomAttribute(typeof(DescriptionAttribute)) as DescriptionAttribute).Description;

                    //jsonBuilder.Append("{\"name\":\"");
                    //jsonBuilder.Append(action.Name);
                    //jsonBuilder.Append("\",\"discription\":\"");
                    //jsonBuilder.Append((action.GetCustomAttribute(typeof(DescriptionAttribute)) as DescriptionAttribute) == null ? "" : (action.GetCustomAttribute(typeof(DescriptionAttribute)) as DescriptionAttribute).Description);    //获取对Action的描述
                    //jsonBuilder.Append("\"},");
                }
                //jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
                //jsonBuilder.Append("]},");
            }
            //jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
            //jsonBuilder.Append("]");
            //JResponse.Data["Title"] = base.Title;
            return(JttpContent(1));
            //return View();
        }
Ejemplo n.º 2
0
        //获取用户授权列表
        public IRequestResult GetList()
        {
            if (!this.Verification)
            {
                return(Error("空闲超时或交互标识无效", 0));
            }

            string ip = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
                        .Select(p => p.GetIPProperties())
                        .SelectMany(p => p.UnicastAddresses)
                        .Where(p => p.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork && !System.Net.IPAddress.IsLoopback(p.Address))
                        .FirstOrDefault()?.Address.ToString();

            long uid       = Session["User_ID"].ToLong();
            long desktopId = ((string)JReqData.DesktopID).ToLong();

            if (desktopId <= 0)
            {
                return(Fail("未指定一个有效的云桌面信息"));
            }

            using (dpz.Gdbc.Connection dbc = new dpz.Gdbc.Connection(site.Config.Database.Aos)) {
                var list = dbc.GetGdmlList($"@{{$[AosUserAuthorize]$[AosDesktopAuthorizes]$[AosAuthorize].[*]&[AosUserAuthorize.UserID=='{uid}'&&AosUserAuthorize.AuthID==AosAuthorize.ID&&AosDesktopAuthorizes.AuthID==AosAuthorize.ID&&AosDesktopAuthorizes.DesktopID=='{desktopId}'&&AosDesktopAuthorizes.Compatibility=='1']}}");
                JData.List = new List <dpz.Dynamic>();
                List <dpz.Dynamic> jList = JData.List;
                foreach (var row in list)
                {
                    //进行数据过滤
                    row["UrlEntrance"] = row["UrlEntrance"].Replace("${IP}", ip);
                    long userCreate = row["CreateUserID"].ToLong();
                    //int active = row["Active"].ToInteger();
                    //row["InfoStatus"] = active > 0 ? "√" : "";

                    var jRow = new dpz.Dynamic();
                    foreach (var item in row)
                    {
                        switch (item.Key)
                        {
                        //case "DBType":
                        case "DBIP":
                        case "DBPort":
                        case "DBUser":
                        case "DBPwd":
                        case "DBPath":
                        //case "Code":
                        case "SecurityKey":
                            break;

                        default:
                            jRow[item.Key] = item.Value;
                            break;
                        }
                    }
                    jList.Add(jRow);
                }
            }

            return(Success());
        }
Ejemplo n.º 3
0
        //填充内核信息
        private void FillKernel(dpz.Dynamic obj)
        {
            dynamic dyc = new dpz.Dynamic();

            dyc.Name        = "云谊通核心控制器";
            dyc.Description = "云谊通核心控制器(Yunyitong Core Controller,简称Ycc)是云谊通云应用协作平台的核心组件,是一套基于.Net Core技术研发、包含H5、Web API、Websocket通讯为基础的综合性数据管理系统,为平台提供最基础的用户授权、数据认证和通讯保障。";
            dyc.Version     = "5.0.1901.1";
            obj["Kernel"]   = dyc;
        }
Ejemplo n.º 4
0
        //填充内核信息
        private void FillDebug(dpz.Dynamic obj)
        {
            dynamic cfg = new dpz.Dynamic();

            obj["Config"] = cfg;

            dynamic redis = new dpz.Dynamic();

            cfg["Redis"]           = redis;
            redis.ConnectionString = site.Config.Redis.ConnectionString;
        }
Ejemplo n.º 5
0
        //获取用户授权列表
        public IRequestResult GetList()
        {
            if (!this.Verification)
            {
                return(Error("空闲超时或交互标识无效", 0));
            }

            long aid = ((string)JRequest.Data["AuthID"]).ToLong();

            string ip = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
                        .Select(p => p.GetIPProperties())
                        .SelectMany(p => p.UnicastAddresses)
                        .Where(p => p.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork && !System.Net.IPAddress.IsLoopback(p.Address))
                        .FirstOrDefault()?.Address.ToString();

            long uid = Session["User_ID"].ToLong();

            using (dpz.Gdbc.Connection dbc = new dpz.Gdbc.Connection(site.Config.Database.Aos)) {
                var list = dbc.GetGdmlList($"@{{$[AosUserApps]$[AosApps].[*]&[AosUserApps.UserID=='{uid}'&&AosUserApps.AuthID=='{aid}'&&AosUserApps.AppID==AosApps.ID]+[AosApps.Index]}}");
                JData.List = new List <dpz.Dynamic>();
                List <dpz.Dynamic> jList = JData.List;
                foreach (var row in list)
                {
                    //进行数据过滤
                    row["Path"] = row["Path"].Replace("${IP}", ip);

                    var jRow = new dpz.Dynamic();
                    foreach (var item in row)
                    {
                        switch (item.Key)
                        {
                        case "DBType":
                        case "DBIP":
                        case "DBPort":
                        case "DBUser":
                        case "DBPwd":
                        case "DBPath":
                            break;

                        default:
                            jRow[item.Key] = item.Value;
                            break;
                        }
                    }
                    jList.Add(jRow);
                }
            }

            return(Success());
        }
Ejemplo n.º 6
0
        //填充内核信息
        private void FillUpdate(dpz.Dynamic obj)
        {
            var logs = new List <dpz.Dynamic>();

            obj["Update"] = logs;

            dynamic v1 = new dpz.Dynamic();

            v1.Version = "5.0.1901.1";
            List <string> lsV1 = new List <string>();

            v1.Logs = lsV1;
            lsV1.Add("核心技术升级为基于.Net Core 2.2框架,独立进程运行,响应效率更高");
            lsV1.Add("支持跨平台部署,可支持将平台部署至Windows、Linux或MacOS");
            lsV1.Add("核心通讯升级为WebSocket,网络延迟更低,平台响应速度更快");
            logs.Add(v1);
        }
Ejemplo n.º 7
0
        //填充内核信息
        private void FillEnvironment(dpz.Dynamic obj)
        {
            var dc = DependencyContext.Default;
            //Console.WriteLine($"Framework: {dc.Target.Framework}");

            dynamic envir = new dpz.Dynamic();

            obj["Environment"]        = envir;
            envir.OSFullName          = RuntimeInformation.OSDescription;
            envir.OSArchitecture      = RuntimeInformation.OSArchitecture;
            envir.ProcessArchitecture = RuntimeInformation.ProcessArchitecture;
            envir.Framework           = dc.Target.Framework;
            envir.Time      = dpz.Time.Now.ToTimeStamp();
            envir.WorkPath  = Directory.GetCurrentDirectory();
            envir.IPAddress = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
                              .Select(p => p.GetIPProperties())
                              .SelectMany(p => p.UnicastAddresses)
                              .Where(p => p.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork && !System.Net.IPAddress.IsLoopback(p.Address))
                              .FirstOrDefault()?.Address.ToString();
            //envir.RootPath = IServer.MapPath;

            //判断操作系统
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                envir.System = "Windows";
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                envir.System = "Linux";
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                envir.System = "MacOS";
            }
            else
            {
                envir.System = "Unknow";
            }
            //envir.SystemVersion = RuntimeEnvironment.GetSystemVersion();

            //NetworkInfo networkInfo = new NetworkInfo();
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                string eth0 = dpz.IO.UTF8File.ReadAllText(ETH0_CONFIG_FILE_PATH);
                int    idx  = eth0.IndexOf("\n");
                if (idx > 0)
                {
                    eth0 = eth0.Substring(0, idx);
                }
                envir.EthernetMAC = eth0;

                string wlan0 = dpz.IO.UTF8File.ReadAllText(WLAN0_CONFIG_FILE_PATH);
                idx = wlan0.IndexOf("\n");
                if (idx > 0)
                {
                    wlan0 = wlan0.Substring(0, idx);
                }
                envir.WirelessMAC = wlan0;

                string deviceId = "eth0+" + eth0 + "+wlan0+" + wlan0;
                envir.DeviceId = deviceId.GetMD5().ToLower();
            }

            var platforms = new List <dpz.Dynamic>();

            envir.Platforms = platforms;
            dc.RuntimeLibraries
            .Where(x => x.Name.Contains("Microsoft.NETCore.App"))
            .ToList()
            .ForEach(x => {
                //Console.WriteLine($"{x.Name} {x.Version}");
                dynamic platform = new dpz.Dynamic();
                platform.Name    = x.Name;
                platform.Version = x.Version;
                platforms.Add(platform);
            });
        }