Browse Source

sss

Signed-off-by: wangwei <wangwei@persagy.com>
wangwei 3 years ago
parent
commit
cd23585140
2 changed files with 88 additions and 50 deletions
  1. 3 2
      Starter/Starter/App.config
  2. 85 48
      Starter/Starter/Program.cs

+ 3 - 2
Starter/Starter/App.config

@@ -12,14 +12,15 @@
 		</assemblyBinding>
 	</runtime>
 	<appSettings>
+		<add key="FloorServerUrl" value="http://60.205.177.43:8080/revit-algorithm/model-floor/query"/>
 		<add key="RevitSimplifyPath" value="E:\Develop\3DTiles\Usefull\iBimSimplify\bin\netcoreapp3.1\RevitSimplify.exe"/>
-		<add key="Project" value="output/wanda"/>
+		<add key="OutputDir" value="output"/>
 		<add key="UseablePhaseName" value="阶段1"/>
 		<add key="SagaSign" value="-wanda"/>
 		<add key="CheckItems" value="SagaCheck,UnitCheck,FamilyNameCheck,EquipPartLocationCheck,ColumnCheck,ElementRangeCheck,ConnectorCheck,SystemNameCheck,EquipInSpaceCheck,SystemReferEquipCheck,ParameterIntegrityCheck,PipeCheck,XYZOverlapCheck"/>
 		<add key="FacilityParameters" value="设备本地名称,设备本地编码,PropertyID"/>
 		<add key="SpaceParameters" value="名称,编号,2.空间标准类型编码,3.空间标准类型"/>
-		<add key="RoomParameters" value="名称,编号,2.空间标准类型编码,3.空间标准类型"/>
+		<add key="RoomParameters" value="名称,编号,2.房间标准类型编码,3.房间标准类型名称"/>
 		<add key="MEPCurveParameters" value="注释"/>
 		<add key="EquipComponentCode" value="构件分类编码"/>
 	</appSettings>

+ 85 - 48
Starter/Starter/Program.cs

@@ -7,6 +7,7 @@ using SAGA.DotNetUtils.Extend;
 using SAGA.DotNetUtils.Logger;
 using System.Configuration;
 using System.Diagnostics;
+using System.Net;
 
 //using RevitToJBim.Common;
 
@@ -16,7 +17,7 @@ namespace ExportStart
     {
         static Program()
         {
-            RevitCoreContext.Instance.Run();
+            //RevitCoreContext.Instance.Run();
         }
         [STAThread]
         static void Main(string[] args)
@@ -55,7 +56,9 @@ namespace ExportStart
                 //path = @"testdata\龙岗万达2020.12.10\LG-WDGC-B02-ALL.rvt";
                 //path = @"testdata\龙岗万达2020.12.10\LGWDGC-F01-ALL.rvt";
                 //path = @"testdata\龙岗万达2020.12.10\LG-WDGC-F03-ALL.rvt";
-                path = @"E:\LGWDGC-F01-ALL.rvt";
+                //path = @"E:\LGWDGC-F01-ALL.rvt";
+                path = @"E:\Develop\RevitProject\RevitPro\ServiceRevit-wanda\OutputDll\testdata\生命科学园\生命科学园2#地块201号楼B1模型文件v2.rvt";
+
                 //path = @"testdata\龙岗万达2020.12.10\LG-WDGC-F06-ALL.rvt";
                 //path = @"testdata\龙岗万达2020.12.10\LGWDGC-Q-B01-ALL.rvt";
                 //path = @"testdata\龙岗万达2020.12.10\LGWDGC-Q-F02-ALL.rvt";
@@ -70,6 +73,8 @@ namespace ExportStart
                 JObject jObject = new JObject();
                 //jObject.Add("ResultFileName", @"C:\Users\SAGACLOUD\AppData\Local\RevitService\Result_e26be2fd-2097-462b-bdd0-a2a86b616928.txt");
                 jObject.Add("ResultFileName", @"D:\1.txt");
+                jObject.Add("MBIName", "Pj1101051029");
+                jObject.Add("ModelId", "a294b443403911eb9bae4d9eff3fa8d4");
                 param = jObject.ToString();
 
                 //path= @"E:\导出测试\延庆园-B1.rvt";
@@ -85,34 +90,34 @@ namespace ExportStart
             Log4Net.Info(path);
             if (File.Exists(path) && Enum.TryParse(command, out CommandType commandType))
             {
-                var app = RevitCoreContext.Instance.Application;
-                string result = null;
-                Console.WriteLine("Task StartTime:" + DateTime.Now);
-                try
-                {
-                    var doc = app.OpenDocumentFile(path);
-                    switch (commandType)
-                    {
-                        case CommandType.DataCheck:
-                            result = Check(doc, param);
-                            break;
-                        case CommandType.DataExport:
-                            result = Export(doc, param);
-                            break;
-                    }
-                }
-                catch (Exception e)
-                {
-                    JObject errorJObject = new JObject();
-                    errorJObject.Add("ResultMsg", e.Message);
-                    errorJObject.Add("Result", "Failure");
-                    result = errorJObject.ToString();
-                }
-                SaveResult(param, result);
-                Console.WriteLine("Task EndTime:" + DateTime.Now);
-                RevitCoreContext.Instance.Stop();
-
-                StartRevitSimplify(path);
+                //var app = RevitCoreContext.Instance.Application;
+                //string result = null;
+                //Console.WriteLine("Task StartTime:" + DateTime.Now);
+                //try
+                //{
+                //    var doc = app.OpenDocumentFile(path);
+                //    switch (commandType)
+                //    {
+                //        case CommandType.DataCheck:
+                //            result = Check(doc, param);
+                //            break;
+                //        case CommandType.DataExport:
+                //            result = Export(doc, param);
+                //            break;
+                //    }
+                //}
+                //catch (Exception e)
+                //{
+                //    JObject errorJObject = new JObject();
+                //    errorJObject.Add("ResultMsg", e.Message);
+                //    errorJObject.Add("Result", "Failure");
+                //    result = errorJObject.ToString();
+                //}
+                //SaveResult(param, result);
+                //Console.WriteLine("Task EndTime:" + DateTime.Now);
+                //RevitCoreContext.Instance.Stop();
+
+                StartRevitSimplify(path, param);
             }
 
             //强制退出
@@ -144,25 +149,57 @@ namespace ExportStart
                 Log4Net.Debug(e.StackTrace);
             }
         }
-
-        static void StartRevitSimplify(string filePath)
+        static WebClient CreateDefaultClient()
+        {
+            WebClient client = new WebClient();
+            client.Headers.Add("Content-Type", "application/json; charset=utf-8");
+            return client;
+        }
+        static void StartRevitSimplify(string filePath, string param)
         {
-            var filename = Path.GetFileNameWithoutExtension(filePath);
-            var project = ConfigurationManager.AppSettings["Project"];
-
-            Console.WriteLine(DateTime.Now + " 准备执行轻量化:");
-            string fullPath = ConfigurationManager.AppSettings["RevitSimplifyPath"];
-            Process process = new Process();
-            process.StartInfo.FileName = fullPath;//执行的exe路径
-            process.StartInfo.WorkingDirectory = Path.GetDirectoryName(fullPath);
-            process.StartInfo.UseShellExecute = true;
-            process.StartInfo.CreateNoWindow = false;
-            //process.StartInfo.RedirectStandardInput = true;//打开流输入
-            //process.StartInfo.RedirectStandardOutput = true;//打开流输出
-            //process.StartInfo.RedirectStandardError = true;//打开错误流
-            process.StartInfo.Arguments = $" InputFile={filePath} OutputDir={project}/{filename}";
-            process.Start();//执行
-            process.WaitForExit();
+            try
+            {
+                JObject jObject = JObject.Parse(param);
+                var MBIName = jObject.GetValueEx("MBIName");//"Pj1101051029";//
+                var ModelId = jObject.GetValueEx("ModelId");//"a294b443403911eb9bae4d9eff3fa8d4";//
+
+                var url = ConfigurationManager.AppSettings["FloorServerUrl"];
+                string fid = null;
+                using (var client = CreateDefaultClient())
+                {
+                    client.Headers.Add("ProjectId", MBIName);
+                    var json = "{\"Filters\":\"currentModelId = '" + ModelId + "'\"}";
+                    var result = client.UploadString(url, json);
+                    var jrst = JObject.Parse(result);
+                    var jcontent = jrst["Content"].First;
+                    var floorname = jcontent["FloorName"] + "";
+                    if (string.IsNullOrEmpty(floorname)) return;
+                    var folderid = jcontent["FolderId"] + "";
+                    if (string.IsNullOrEmpty(folderid)) return;
+                    fid = $"{MBIName}{folderid}{floorname}";
+                }
+
+                var outputDir = ConfigurationManager.AppSettings["OutputDir"];
+                Console.WriteLine(DateTime.Now + " 准备执行轻量化:");
+                Console.WriteLine($"filePath:{filePath}");
+                Console.WriteLine($"fid:{MBIName}{ModelId}");
+                string fullPath = ConfigurationManager.AppSettings["RevitSimplifyPath"];
+                Process process = new Process();
+                process.StartInfo.FileName = fullPath;//执行的exe路径
+                process.StartInfo.WorkingDirectory = Path.GetDirectoryName(fullPath);
+                process.StartInfo.UseShellExecute = true;
+                process.StartInfo.CreateNoWindow = false;
+                //process.StartInfo.RedirectStandardInput = true;//打开流输入
+                //process.StartInfo.RedirectStandardOutput = true;//打开流输出
+                //process.StartInfo.RedirectStandardError = true;//打开错误流
+                process.StartInfo.Arguments = $" InputFile={filePath} OutputDir={outputDir}/{MBIName}/{fid}";
+                process.Start();//执行
+                process.WaitForExit();
+            }
+            catch (Exception e)
+            {
+                Log4Net.Debug(e.StackTrace);
+            }
         }
         enum CommandType
         {