|
@@ -7,6 +7,7 @@ using SAGA.DotNetUtils.Extend;
|
|
|
using SAGA.DotNetUtils.Logger;
|
|
|
using System.Configuration;
|
|
|
using System.Diagnostics;
|
|
|
+using System.Net;
|
|
|
|
|
|
|
|
|
|
|
@@ -16,7 +17,7 @@ namespace ExportStart
|
|
|
{
|
|
|
static Program()
|
|
|
{
|
|
|
- RevitCoreContext.Instance.Run();
|
|
|
+
|
|
|
}
|
|
|
[STAThread]
|
|
|
static void Main(string[] args)
|
|
@@ -55,7 +56,9 @@ namespace ExportStart
|
|
|
|
|
|
|
|
|
|
|
|
- path = @"E:\LGWDGC-F01-ALL.rvt";
|
|
|
+
|
|
|
+ path = @"E:\Develop\RevitProject\RevitPro\ServiceRevit-wanda\OutputDll\testdata\生命科学园\生命科学园2#地块201号楼B1模型文件v2.rvt";
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -70,6 +73,8 @@ namespace ExportStart
|
|
|
JObject jObject = new JObject();
|
|
|
|
|
|
jObject.Add("ResultFileName", @"D:\1.txt");
|
|
|
+ jObject.Add("MBIName", "Pj1101051029");
|
|
|
+ jObject.Add("ModelId", "a294b443403911eb9bae4d9eff3fa8d4");
|
|
|
param = jObject.ToString();
|
|
|
|
|
|
|
|
@@ -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);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 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;
|
|
|
- process.StartInfo.WorkingDirectory = Path.GetDirectoryName(fullPath);
|
|
|
- process.StartInfo.UseShellExecute = true;
|
|
|
- process.StartInfo.CreateNoWindow = false;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- process.StartInfo.Arguments = $" InputFile={filePath} OutputDir={project}/{filename}";
|
|
|
- process.Start();
|
|
|
- process.WaitForExit();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ JObject jObject = JObject.Parse(param);
|
|
|
+ var MBIName = jObject.GetValueEx("MBIName");
|
|
|
+ var ModelId = jObject.GetValueEx("ModelId");
|
|
|
+
|
|
|
+ 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;
|
|
|
+ process.StartInfo.WorkingDirectory = Path.GetDirectoryName(fullPath);
|
|
|
+ process.StartInfo.UseShellExecute = true;
|
|
|
+ process.StartInfo.CreateNoWindow = false;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ process.StartInfo.Arguments = $" InputFile={filePath} OutputDir={outputDir}/{MBIName}/{fid}";
|
|
|
+ process.Start();
|
|
|
+ process.WaitForExit();
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ Log4Net.Debug(e.StackTrace);
|
|
|
+ }
|
|
|
}
|
|
|
enum CommandType
|
|
|
{
|