|
@@ -7,6 +7,7 @@ using SAGA.DotNetUtils.Extend;
|
|
using SAGA.DotNetUtils.Logger;
|
|
using SAGA.DotNetUtils.Logger;
|
|
using System.Configuration;
|
|
using System.Configuration;
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
|
|
+using System.Net;
|
|
|
|
|
|
//using RevitToJBim.Common;
|
|
//using RevitToJBim.Common;
|
|
|
|
|
|
@@ -16,7 +17,7 @@ namespace ExportStart
|
|
{
|
|
{
|
|
static Program()
|
|
static Program()
|
|
{
|
|
{
|
|
- RevitCoreContext.Instance.Run();
|
|
|
|
|
|
+ //RevitCoreContext.Instance.Run();
|
|
}
|
|
}
|
|
[STAThread]
|
|
[STAThread]
|
|
static void Main(string[] args)
|
|
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\LG-WDGC-B02-ALL.rvt";
|
|
//path = @"testdata\龙岗万达2020.12.10\LGWDGC-F01-ALL.rvt";
|
|
//path = @"testdata\龙岗万达2020.12.10\LGWDGC-F01-ALL.rvt";
|
|
//path = @"testdata\龙岗万达2020.12.10\LG-WDGC-F03-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\LG-WDGC-F06-ALL.rvt";
|
|
//path = @"testdata\龙岗万达2020.12.10\LGWDGC-Q-B01-ALL.rvt";
|
|
//path = @"testdata\龙岗万达2020.12.10\LGWDGC-Q-B01-ALL.rvt";
|
|
//path = @"testdata\龙岗万达2020.12.10\LGWDGC-Q-F02-ALL.rvt";
|
|
//path = @"testdata\龙岗万达2020.12.10\LGWDGC-Q-F02-ALL.rvt";
|
|
@@ -70,6 +73,8 @@ namespace ExportStart
|
|
JObject jObject = new JObject();
|
|
JObject jObject = new JObject();
|
|
//jObject.Add("ResultFileName", @"C:\Users\SAGACLOUD\AppData\Local\RevitService\Result_e26be2fd-2097-462b-bdd0-a2a86b616928.txt");
|
|
//jObject.Add("ResultFileName", @"C:\Users\SAGACLOUD\AppData\Local\RevitService\Result_e26be2fd-2097-462b-bdd0-a2a86b616928.txt");
|
|
jObject.Add("ResultFileName", @"D:\1.txt");
|
|
jObject.Add("ResultFileName", @"D:\1.txt");
|
|
|
|
+ jObject.Add("MBIName", "Pj1101051029");
|
|
|
|
+ jObject.Add("ModelId", "a294b443403911eb9bae4d9eff3fa8d4");
|
|
param = jObject.ToString();
|
|
param = jObject.ToString();
|
|
|
|
|
|
//path= @"E:\导出测试\延庆园-B1.rvt";
|
|
//path= @"E:\导出测试\延庆园-B1.rvt";
|
|
@@ -85,34 +90,34 @@ namespace ExportStart
|
|
Log4Net.Info(path);
|
|
Log4Net.Info(path);
|
|
if (File.Exists(path) && Enum.TryParse(command, out CommandType commandType))
|
|
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);
|
|
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
|
|
enum CommandType
|
|
{
|
|
{
|