黄贺彬 6 年之前
父节点
当前提交
3fb7334a37

+ 34 - 0
TEAMModelOS.Starter.CloudServer/Controllers/AnalysisControllers/ClassController.cs

@@ -0,0 +1,34 @@
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+using TEAMModelOS.Helper.Common.FileHelper;
+using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
+
+namespace TEAMModelOS.Starter.CloudServer.Controllers.AnalysisControllers
+{
+    [Route("api/[controller]")]
+    [ApiController]
+    public class ClassController: Controller
+    {
+        IHostingEnvironment _hostingEnvironment;
+
+        public ClassController(IHostingEnvironment hostingEnvironment)
+        {
+            _hostingEnvironment = hostingEnvironment;
+        }
+        [HttpGet("getClass")]
+        public BaseJosnRPCResponse getClass(string identity)
+        {
+            string contentRootPath = _hostingEnvironment.ContentRootPath;
+            identity = "json";
+            JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
+            string data = FileTool.getJson(contentRootPath,identity);
+            builder.Data(data);
+            return builder.build();
+        }
+    }
+}

+ 42 - 0
TEAMModelOS.Starter.CloudServer/Controllers/AnalysisControllers/FileTool.cs

@@ -0,0 +1,42 @@
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Hosting;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+namespace TEAMModelOS.Helper.Common.FileHelper
+{
+    public static class FileTool
+    {
+        
+
+        public static string getJson(string contentRootPath, string name)
+        {
+            //string webRootPath = _hostingEnvironment.WebRootPath;
+            
+            try
+            {
+                String path = contentRootPath + "/JsonFiled/" + name + ".json";
+                //获取正在占用的文件
+                FileStream fs = new FileStream(path, System.IO.FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+                StreamReader sr = new StreamReader(fs, System.Text.Encoding.ASCII);
+                String line;
+                StringBuilder builder = new StringBuilder();
+                while ((line = sr.ReadLine()) != null)
+                {
+                    builder.Append(line.ToString());
+                }
+
+                sr.Close();
+                string log = builder.ToString();
+                return log;
+            }
+            catch (Exception e)
+            {
+                var s = e.Message;
+                return s;
+            }
+        }
+    }
+}

二进制
TEAMModelOS.Starter.CloudServer/JsonFiled/json.json


+ 1 - 0
TEAMModelOS.Starter.CloudServer/Program.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
+using System.Text;
 using System.Threading.Tasks;
 using Microsoft.AspNetCore;
 using Microsoft.AspNetCore.Hosting;

+ 5 - 5
TEAMModelOS.sln

@@ -17,15 +17,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TEAMModelOS.Service.Syllabu
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TEAMModelOS.Service.Analysis", "TEAMModelOS.Service.Analysis\TEAMModelOS.Service.Analysis.csproj", "{9E0A942E-B04B-4875-9426-9019737A103B}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TEAMModelOS.Model.Common", "TEAMModelOS.Model.Common\TEAMModelOS.Model.Common.csproj", "{52E89322-019B-485E-AE58-D242C5A2A0D0}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TEAMModelOS.Model.Common", "TEAMModelOS.Model.Common\TEAMModelOS.Model.Common.csproj", "{52E89322-019B-485E-AE58-D242C5A2A0D0}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TEAMModelOS.Model.Analysis", "TEAMModelOS.Model.Analysis\TEAMModelOS.Model.Analysis.csproj", "{D1341054-7A2A-4E33-9167-1CECDA91B590}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TEAMModelOS.Model.Analysis", "TEAMModelOS.Model.Analysis\TEAMModelOS.Model.Analysis.csproj", "{D1341054-7A2A-4E33-9167-1CECDA91B590}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TEAMModelOS.Model.Syllabus", "TEAMModelOS.Model.Syllabus\TEAMModelOS.Model.Syllabus.csproj", "{B1251892-7F33-484F-B908-7DC68F36742F}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TEAMModelOS.Model.Syllabus", "TEAMModelOS.Model.Syllabus\TEAMModelOS.Model.Syllabus.csproj", "{B1251892-7F33-484F-B908-7DC68F36742F}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TEAMModelOS.SDK", "TEAMModelOS.SDK\TEAMModelOS.SDK.csproj", "{CE3C81B8-10DA-460F-AFD4-520F0B4D9CCD}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TEAMModelOS.SDK", "TEAMModelOS.SDK\TEAMModelOS.SDK.csproj", "{CE3C81B8-10DA-460F-AFD4-520F0B4D9CCD}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TEAMModelOS", "TEAMModelOS\TEAMModelOS.csproj", "{E6B83AD9-95EF-4865-BD47-99874EB5A0FD}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TEAMModelOS", "TEAMModelOS\TEAMModelOS.csproj", "{E6B83AD9-95EF-4865-BD47-99874EB5A0FD}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution

+ 34 - 0
TEAMModelOS/Controllers/AnalysisControllers/ClassController.cs

@@ -0,0 +1,34 @@
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+using TEAMModelOS.Helper.Common.FileHelper;
+using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
+
+namespace TEAMModelOS.Starter.CloudServer.Controllers.AnalysisControllers
+{
+    [Route("api/[controller]")]
+    [ApiController]
+    public class ClassController: Controller
+    {
+        IHostingEnvironment _hostingEnvironment;
+
+        public ClassController(IHostingEnvironment hostingEnvironment)
+        {
+            _hostingEnvironment = hostingEnvironment;
+        }
+        [HttpGet("getClass")]
+        public BaseJosnRPCResponse getClass(string identity)
+        {
+            string contentRootPath = _hostingEnvironment.ContentRootPath;
+            identity = "json";
+            JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
+            string data = FileTool.getJson(contentRootPath,identity);
+            builder.Data(data);
+            return builder.build();
+        }
+    }
+}

+ 42 - 0
TEAMModelOS/Controllers/AnalysisControllers/FileTool.cs

@@ -0,0 +1,42 @@
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Hosting;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+namespace TEAMModelOS.Helper.Common.FileHelper
+{
+    public static class FileTool
+    {
+        
+
+        public static string getJson(string contentRootPath, string name)
+        {
+            //string webRootPath = _hostingEnvironment.WebRootPath;
+            
+            try
+            {
+                String path = contentRootPath + "/JsonFiled/" + name + ".json";
+                //获取正在占用的文件
+                FileStream fs = new FileStream(path, System.IO.FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+                StreamReader sr = new StreamReader(fs, System.Text.Encoding.ASCII);
+                String line;
+                StringBuilder builder = new StringBuilder();
+                while ((line = sr.ReadLine()) != null)
+                {
+                    builder.Append(line.ToString());
+                }
+
+                sr.Close();
+                string log = builder.ToString();
+                return log;
+            }
+            catch (Exception e)
+            {
+                var s = e.Message;
+                return s;
+            }
+        }
+    }
+}

二进制
TEAMModelOS/JsonFile/menu.json