diff --git a/newFront/c#前端/SWS.CAD.Base/General.cs b/newFront/c#前端/SWS.CAD.Base/General.cs
index 36bdcaf5..8df9cbb4 100644
--- a/newFront/c#前端/SWS.CAD.Base/General.cs
+++ b/newFront/c#前端/SWS.CAD.Base/General.cs
@@ -14,6 +14,7 @@ using Entity = Teigha.DatabaseServices.Entity;
using Path = System.IO.Path;
using Color = Teigha.Colors.Color;
using System.Security.Cryptography;
+using System.Threading.Tasks;
namespace SWS.CAD.Base
{
public static class General
@@ -137,7 +138,7 @@ namespace SWS.CAD.Base
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
- ObjectId idBtr = doc.Database.Insert(blockName, blockName, blockDb, true);
+ ObjectId idBtr = doc.Database.Insert(blockName, blockName, blockDb, true);
BlockTableRecord curBtr = trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
var block = new BlockReference(Point3d.Origin, idBtr);
block.Position = position;
@@ -1065,12 +1066,13 @@ namespace SWS.CAD.Base
}
#endregion
- #region 获取当前图纸所有实体
+ #region 获取当前图纸XData不为空的所有实体
///
/// 获取当前图纸XData不为空的所有实体
///
+ /// 要删除的位号
///
- public static List GetAllEntity()
+ public static List GetAllEntity(List listTagNumber)
{
doc = Application.DocumentManager.MdiActiveDocument;
ed = doc.Editor;
@@ -1084,18 +1086,20 @@ namespace SWS.CAD.Base
{
// 获取模型空间块表记录
BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
- BlockTableRecord modelSpace = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord;
-
+ BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord;
+ // 收集要删除的块参照
+ ObjectIdCollection idsToErase = new ObjectIdCollection();
// 遍历模型空间中的所有实体
- foreach (ObjectId objId in modelSpace)
+ foreach (ObjectId objId in btr)
{
- Entity entity = tr.GetObject(objId, OpenMode.ForRead) as Entity;
+ Entity entity = tr.GetObject(objId, OpenMode.ForWrite) as Entity;
if (entity != null && entity.XData != null)
{
// 提取句柄(十六进制格式)
var blockRef = entity as BlockReference;
if (blockRef != null)
{
+ bool flag = true;
var dto = new DtoBasePoint()
{
Handle = entity.Handle.ToString(),
@@ -1113,14 +1117,27 @@ namespace SWS.CAD.Base
if (attRef.Tag == "HKSK_TAG")
{
dto.TagNumber = attRef.TextString;
+ if (listTagNumber != null && listTagNumber.Contains(attRef.TextString))
+ {
+ idsToErase.Add(objId);
+ flag = false;
+ }
break;
}
}
-
- handles.Add(dto);
+ if (flag)
+ { handles.Add(dto); }
}
}
}
+ if (idsToErase.Count > 0)
+ {
+ foreach (ObjectId id in idsToErase)
+ {
+ Entity ent = (Entity)tr.GetObject(id, OpenMode.ForWrite);
+ ent.Erase();
+ }
+ }
tr.Commit();
}
@@ -1920,15 +1937,18 @@ namespace SWS.CAD.Base
/// 位号值
/// true:默认块,false:异性块
///
- public static bool UpdateCableNo(string dwgName, List listTagName, string tagNumber, bool IsNotDefaultSymbol, string tag, string system)
+ public static string UpdateCableNo(string dwgName, List listTagName, string tagNumber, bool IsNotDefaultSymbol, string tag, string system)
{
try
{
- OpenDwg(dwgName);
+ //OpenDwg(dwgName);
+ Application.DocumentManager.Open(dwgName);
+ //Thread.Sleep(1000);
doc = Application.DocumentManager.MdiActiveDocument;
ed = doc.Editor;
db = doc.Database;
+ var s=doc.Name;
// 开启事务
using (Transaction tr = db.TransactionManager.StartTransaction())
{
@@ -1986,12 +2006,13 @@ namespace SWS.CAD.Base
tr.Commit();
}
doc.CloseAndSave(dwgName);
- return true;
+ Thread.Sleep(20);
+ return "";
}
catch (Exception ex)
{
SendMessage(ex.Message);
- return false;
+ return ex.Message;
}
}
@@ -2019,7 +2040,7 @@ namespace SWS.CAD.Base
// 创建多行文字对象
MText mText = new MText();
mText.Contents = textInfo.Text;
- mText.Location = textInfo.Position;
+ mText.Location = textInfo.Position;
mText.TextHeight = textInfo.Height;
mText.Width = textInfo.Width; // 设置文本宽度,控制自动换行
if (textInfo.Align == 0)
@@ -2040,7 +2061,7 @@ namespace SWS.CAD.Base
DBText dbText = new DBText();
dbText.TextString = textInfo.Text;
dbText.Position = textInfo.Position;
- dbText.AlignmentPoint= textInfo.Position;
+ dbText.AlignmentPoint = textInfo.Position;
dbText.Height = textInfo.Height;
if (textInfo.Align == 0)
{
@@ -2078,7 +2099,7 @@ namespace SWS.CAD.Base
/// 坐标位置
///
public static ObjectId AddBlockDWG(string filePath, string blockName, Point3d position)
- {
+ {
Document doc = Application.DocumentManager.MdiActiveDocument;
var ed = doc.Editor;
ObjectId oid = ObjectId.Null;
@@ -2118,10 +2139,10 @@ namespace SWS.CAD.Base
// 处理插入结果
btr.AppendEntity(br);
- tr.AddNewlyCreatedDBObject(br, true);
+ tr.AddNewlyCreatedDBObject(br, true);
tr.Commit();
- oid = br.Id;
- }
+ oid = br.Id;
+ }
}
catch (Exception ex)
{
diff --git a/newFront/c#前端/SWS.CAD.Base/bin/Debug/log4net.config b/newFront/c#前端/SWS.CAD.Base/bin/Debug/log4net.config
index dc48092d..2e52c6ab 100644
--- a/newFront/c#前端/SWS.CAD.Base/bin/Debug/log4net.config
+++ b/newFront/c#前端/SWS.CAD.Base/bin/Debug/log4net.config
@@ -8,13 +8,30 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
@@ -29,7 +46,25 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -70,24 +105,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/newFront/c#前端/SWS.CAD/Commands.cs b/newFront/c#前端/SWS.CAD/Commands.cs
index a28f2dcd..76c62baf 100644
--- a/newFront/c#前端/SWS.CAD/Commands.cs
+++ b/newFront/c#前端/SWS.CAD/Commands.cs
@@ -25,6 +25,8 @@ using GlobalObject = SWS.Commons.GlobalObject;
using SWS.Model;
using SWS.Service;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
+using System.Windows;
+using MessageBox = System.Windows.Forms.MessageBox;
[assembly: CommandClass(typeof(Commands))]
@@ -67,6 +69,15 @@ namespace SWS.CAD
panel.Icon = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CSharp.ico");
panel.Visible = true;
+ if (System.Windows.Application.Current == null)
+ {
+ var app = new System.Windows.Application
+ {
+ // 设置为显式关闭,防止窗口关闭时 Application 被自动终结
+ ShutdownMode = ShutdownMode.OnExplicitShutdown
+ };
+ }
+ GlobalObject.ClearLog();
}
catch (System.Exception e)
{
diff --git a/newFront/c#前端/SWS.Commons/GlobalObject.cs b/newFront/c#前端/SWS.Commons/GlobalObject.cs
index 4cae166c..3734edde 100644
--- a/newFront/c#前端/SWS.Commons/GlobalObject.cs
+++ b/newFront/c#前端/SWS.Commons/GlobalObject.cs
@@ -85,7 +85,7 @@ namespace SWS.Commons
public static List designTree = new List();
#endregion
-
+
public enum DBConst
{
///
@@ -316,19 +316,50 @@ namespace SWS.Commons
return dllPath;
}
#endregion
- ///
- ///
- ///
- /// 包括命名空间
- ///
+
+ #region 获取日志文件夹路径
+ ///
+ /// 获取日志文件夹路径
+ ///
+ ///
+ public static string GetLogPath()
+ {
+ string path = Path.Combine(GetDllPath(),"SWSLogs");
+ return path;
+ }
+ #endregion
+
+ #region 清理超时日志文件
+ public static void ClearLog()
+ {
+ try
+ {
+ var path = Path.Combine(GlobalObject.GetDllPath(), "SWSLogs\\");
+ int retainDays = 7;//保留7天的日志
+
+ foreach (var file in Directory.GetFiles(path, "*.log"))
+ {
+ if (File.GetCreationTime(file) < DateTime.Now.AddDays(-retainDays))
+ {
+ File.Delete(file);
+ }
+ }
+ }
+ catch
+ {
+ }
+ }
+ #endregion
+
+ ///
+ ///
+ ///
+ /// 包括命名空间
+ ///
public static System.Windows.Media.ImageSource ImageSourceFromEmbeddedResourceStream(string resName)
{
string imgPath = $"SWS.Commons.Images.{resName}";
System.Reflection.Assembly assy = System.Reflection.Assembly.GetExecutingAssembly();
- //foreach (string resource in assy.GetManifestResourceNames())
- //{
- // Console.WriteLine(resource);//遍历所有的内嵌资源
- //}
System.IO.Stream stream = assy.GetManifestResourceStream(imgPath);
if (stream == null)
return null;
@@ -341,9 +372,8 @@ namespace SWS.Commons
public static string GetPCInfo()
{
- string computerName = Environment.MachineName; // 获取计算机名称
+ string computerName = Environment.MachineName; // 获取计算机名称
string userName = Environment.UserName; // 获取当前用户名称
-
return $"{computerName} 计算机{userName} 用户";
}
diff --git a/newFront/c#前端/SWS.Commons/Helper/LoggerHelper.cs b/newFront/c#前端/SWS.Commons/Helper/LoggerHelper.cs
index ca5bc6d4..534dacce 100644
--- a/newFront/c#前端/SWS.Commons/Helper/LoggerHelper.cs
+++ b/newFront/c#前端/SWS.Commons/Helper/LoggerHelper.cs
@@ -1,12 +1,16 @@
using System;
using System.IO;
using System.Reflection;
+using System.Windows;
+using log4net.Appender;
+using log4net.Config;
+using log4net.Layout;
using Newtonsoft.Json.Linq;
namespace SWS.Commons
{
///
- /// nLog使用帮助类
+ /// Log使用帮助类
///
public class LoggerHelper
{
@@ -19,13 +23,42 @@ namespace SWS.Commons
private static LoggerHelper _obj = null;
private static string logPath = string.Empty;
private LoggerHelper()
- {
-
- logPath = Path.Combine(GlobalObject.GetDllPath(), "Logs\\");
- if (!Directory.Exists(logPath))
- { Directory.CreateDirectory(logPath); }
- var configFile = new FileInfo(Path.Combine(GlobalObject.GetDllPath(), "log4net.config"));
- log4net.Config.XmlConfigurator.ConfigureAndWatch(configFile);
+ {
+ try
+ {
+ logPath = Path.Combine(GlobalObject.GetDllPath(), "Logs\\");
+ if (!Directory.Exists(logPath))
+ { Directory.CreateDirectory(logPath); }
+ var configFile = new FileInfo(Path.Combine(GlobalObject.GetDllPath(), "log4net.config"));
+ log4net.Config.XmlConfigurator.ConfigureAndWatch(configFile);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message+"\n\r"+ex.ToString());
+ }
+
+ }
+ #region 初始
+
+ #endregion
+ public static bool ChangeLogFileName(string name)
+ {
+ var path = Path.Combine(GlobalObject.GetDllPath(), "SWSLogs\\");
+ if (!Directory.Exists(path))
+ { Directory.CreateDirectory(path); }
+ var rootRepository = log4net.LogManager.GetRepository();
+ foreach (var appender in rootRepository.GetAppenders())
+ {
+ if (appender is log4net.Appender.FileAppender fileAppender&&!string.IsNullOrEmpty(fileAppender.File) && appender.Name.ToLower().Contains(name))
+ {
+ // string filename= Path.Combine(GlobalObject.GetDllPath(),$"SWSLogs\\");
+ //fileAppender.Close();
+ fileAppender.File = path;
+ fileAppender.ActivateOptions();
+ return true;
+ }
+ }
+ return false;
}
///
/// 获取当前的日志记录对象。
@@ -55,6 +88,7 @@ namespace SWS.Commons
/// 需要记录的信息。
public void Info(string msg)
{
+ ChangeLogFileName("info");
loginfo.Info(msg);
}
@@ -67,6 +101,7 @@ namespace SWS.Commons
/// 需要记录的信息。
public void Warn(string msg)
{
+ ChangeLogFileName("warn");
logwarn.Warn(msg);
}
@@ -79,6 +114,7 @@ namespace SWS.Commons
/// 需要记录的信息。
public void Error(string msg)
{
+ ChangeLogFileName("error");
logerror.Error("----------------------------Error BEGIN------------------------------");
logerror.Error(msg);
logerror.Error("-----------------------------Error END-------------------------------");
@@ -93,9 +129,10 @@ namespace SWS.Commons
/// 需要记录的系统异常。
public void Fatal(string msg)
{
+ ChangeLogFileName("fatal");
logfatal.Fatal("----------------------------Fatal BEGIN------------------------------");
- logerror.Fatal(msg);
- logerror.Fatal("-----------------------------Fatal END-------------------------------");
+ logfatal.Fatal(msg);
+ logfatal.Fatal("-----------------------------Fatal END-------------------------------");
}
#endregion
diff --git a/newFront/c#前端/SWS.Commons/bin/Debug/log4net.config b/newFront/c#前端/SWS.Commons/bin/Debug/log4net.config
index dc48092d..2e52c6ab 100644
--- a/newFront/c#前端/SWS.Commons/bin/Debug/log4net.config
+++ b/newFront/c#前端/SWS.Commons/bin/Debug/log4net.config
@@ -8,13 +8,30 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
@@ -29,7 +46,25 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -70,24 +105,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/newFront/c#前端/SWS.Commons/log4net.config b/newFront/c#前端/SWS.Commons/log4net.config
index dc48092d..2e52c6ab 100644
--- a/newFront/c#前端/SWS.Commons/log4net.config
+++ b/newFront/c#前端/SWS.Commons/log4net.config
@@ -8,13 +8,30 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
@@ -29,7 +46,25 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -70,24 +105,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/newFront/c#前端/SWS.Electrical/Commands.cs b/newFront/c#前端/SWS.Electrical/Commands.cs
index 79ddf8bb..4a00b482 100644
--- a/newFront/c#前端/SWS.Electrical/Commands.cs
+++ b/newFront/c#前端/SWS.Electrical/Commands.cs
@@ -1,5 +1,11 @@
using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
using System.Windows.Forms;
+using Bricscad.ApplicationServices;
using Bricscad.Ribbon;
using Bricscad.Windows;
using Prism.Events;
@@ -16,6 +22,7 @@ using Telerik.Windows.Controls;
using Unity;
using Application = Bricscad.ApplicationServices.Application;
using DialogParameters = Prism.Services.Dialogs.DialogParameters;
+using MessageBox = System.Windows.Forms.MessageBox;
[assembly: CommandClass(typeof(Commands))]
[assembly: ExtensionApplication(typeof(Commands))]
@@ -23,27 +30,71 @@ namespace SWS.Electrical
{
public partial class Commands : IExtensionApplication
{
-
public void Initialize()
{
try
{
+
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
if (RibbonServices.RibbonPaletteSet == null)
RibbonServices.CreateRibbonPaletteSet();
Start.RegisterTypes();
Start.AutoLogin();
- AddTab();
+ // 延迟初始化UI组件
+ InitializeCustomUI();
+
+ System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
+ timer.Interval = 50; // 50ms延迟
+ timer.Tick += (s, e) =>
+ {
+ timer.Stop();
+ var ribbonControl = ComponentManager.Ribbon;
+ if (ribbonControl != null)
+ {
+ //先切换到常用标签,再切换到电气系统标签
+ ribbonControl.Tabs[0].IsActive = true;
+ Thread.Sleep(5);
+ foreach (var tab in ribbonControl.Tabs)
+ {
+ if (tab.Name == "Electric")
+ {
+ // 激活选项卡
+ tab.IsActive = true;
+ }
+ }
+ }
+ };
+ timer.Start();
+
+ if (System.Windows.Application.Current == null)
+ {
+ var app = new System.Windows.Application
+ {
+ // 设置为显式关闭,防止窗口关闭时 Application 被自动终结
+ ShutdownMode = ShutdownMode.OnExplicitShutdown
+ };
+ }
+ GlobalObject.ClearLog();
}
catch (System.Exception e)
{
Application.ShowAlertDialog(" An exception occurred in Initialize():\n" + e.ToString());
}
}
-
-
+ private void InitializeCustomUI()
+ {
+ try
+ {
+ //在这里初始化你的自定义UI
+ AddTab();
+ }
+ catch (System.Exception ex)
+ {
+ LoggerHelper.Current.Error("UI初始化失败: " + ex.Message);
+ }
+ }
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
@@ -51,26 +102,27 @@ namespace SWS.Electrical
{
// 记录异常信息到日志文件,这里简单打印到控制 ?
System.Exception ex = e.ExceptionObject as System.Exception;
- Console.WriteLine($"发生未处理的异常: {ex.Message}");
- Console.WriteLine($"异常堆栈跟踪: {ex.StackTrace}");
+ LoggerHelper.Current.Error($"发生未处理的异常: {ex.Message}");
+ LoggerHelper.Current.Error($"异常信息: {ex.ToString()}");
+ LoggerHelper.Current.Error($"异常堆栈跟踪: {ex.StackTrace}");
// 关闭所有打开的对话框窗口
// 提示用户发生了错 ?
- MessageBox.Show("发生错误,请检查日志文件以获取更多信息 ?", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ var result= MessageBox.Show("发生错误,是否打开日志文件以获取更多信息?", "错误", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
+ if(result== System.Windows.Forms.DialogResult.OK)
+ {
+ System.Diagnostics.Process.Start("explorer.exe", GlobalObject.GetLogPath());
+ }
}
catch (System.Exception innerEx)
{
// 如果在处理异常时又发生了异常,简单打印信 ?
- Console.WriteLine($"处理异常时发生错 ? {innerEx.Message}");
+ LoggerHelper.Current.Error($"处理异常时发生错: {innerEx.Message}");
}
}
- public void Terminate()
- {
- }
-
void AddTab()
{
RibbonControl rbnCtrl = ComponentManager.Ribbon; //整个上面都是ribbon,比如莫工做的电气系统,就是ribbon中的一个tab
@@ -235,10 +287,10 @@ namespace SWS.Electrical
ribbonRowPanel.Items.Add(btnMenu);
ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
#endregion
-
+
dataSource.Items.Add(ribbonRowPanel);
#endregion
-
+
#region Ribbon 材料管理
dataSource = new RibbonPanelSource();
dataSource.Title = "材料表管理";
@@ -249,7 +301,7 @@ namespace SWS.Electrical
//垂直排列按钮panel
ribbonRowPanel = new RibbonRowPanel();
-
+
#region buttons 材料表自动生成
btnMenu = new RibbonButton();
btnMenu.ToolTip = "材料表自动生成";
@@ -290,6 +342,9 @@ namespace SWS.Electrical
}
+ public void Terminate()
+ {
+ }
}
}
diff --git a/newFront/c#前端/SWS.Electrical/Event/checkInEvent.cs b/newFront/c#前端/SWS.Electrical/Event/checkInEvent.cs
new file mode 100644
index 00000000..cb649d61
--- /dev/null
+++ b/newFront/c#前端/SWS.Electrical/Event/checkInEvent.cs
@@ -0,0 +1,10 @@
+using Prism.Events;
+using SWS.Electrical.ViewModels;
+using SWS.Model;
+
+namespace SWS.Electrical
+{
+ public class sendMessageEvent : PubSubEvent
+ {
+ }
+}
diff --git a/newFront/c#前端/SWS.Electrical/GlobalObj.cs b/newFront/c#前端/SWS.Electrical/GlobalObj.cs
index e5d7d323..45168dad 100644
--- a/newFront/c#前端/SWS.Electrical/GlobalObj.cs
+++ b/newFront/c#前端/SWS.Electrical/GlobalObj.cs
@@ -42,19 +42,7 @@ namespace SWS.Electrical
public static async Task CheckLogin()
{
try
- {
- //var parser = new FileIniDataParser();
- //string[] lines = File.ReadAllLines(GlobalObject.configPath);
- //IniData data = parser.Parser.Parse(File.ReadAllText(GlobalObject.configPath));
- //var data = configIni.ReadFile(GlobalObject.configPath);
- //string token = data["LoginInfo"]["LoginToken"];
- //string loginkey = data["LoginInfo"]["LoginMark"];
- //string curProjId = data["LoginInfo"]["CurProjId"];
- //LocalWorkDir= data["Profile"]["strLocalWorkDir"];
- //string address = data["Profile"]["strIPAddress"];
- //string port = data["Profile"]["nPort"];
- //string dbType = data["Profile"]["nConType"];
- //string domain= data["Profile"]["strDomainName"];
+ {
string token = IniHelper.ReadValueFromIniFile("LoginInfo", "LoginToken");
string loginkey = IniHelper.ReadValueFromIniFile("LoginInfo", "LoginMark");
string curProjId = IniHelper.ReadValueFromIniFile("LoginInfo", "CurProjId");
@@ -69,7 +57,7 @@ namespace SWS.Electrical
GlobalObject.client = new HttpClient()
{
BaseAddress = new Uri($"{strDomain}/api/"),
- Timeout = TimeSpan.FromSeconds(120)
+ Timeout = TimeSpan.FromSeconds(600)
};
}
else if (dbType == "0")
@@ -77,7 +65,7 @@ namespace SWS.Electrical
GlobalObject.client = new HttpClient()
{
BaseAddress = new Uri($"http://{address}:{port}/api/"),
- Timeout = TimeSpan.FromSeconds(120)
+ Timeout = TimeSpan.FromSeconds(600)
};
}
GlobalObject.client.DefaultRequestHeaders.Add("logintoken", token);
@@ -105,7 +93,7 @@ namespace SWS.Electrical
}
}
if (GlobalObject.curProject == null)
- { GlobalObject.curProject = new ec_project() { ProjectId = curProjId }; }
+ { GlobalObject.curProject = new ec_project() { ProjectId = curProjId }; }
return flag;
}
catch (System.Exception ex)
diff --git a/newFront/c#前端/SWS.Electrical/Models/DtoAutoPlotLayout.cs b/newFront/c#前端/SWS.Electrical/Models/DtoAutoPlotLayout.cs
index 383e614c..9b066ef6 100644
--- a/newFront/c#前端/SWS.Electrical/Models/DtoAutoPlotLayout.cs
+++ b/newFront/c#前端/SWS.Electrical/Models/DtoAutoPlotLayout.cs
@@ -31,9 +31,13 @@ namespace SWS.Electrical.Models
///
public string BasePointTagNumber { get; set; } = "";
///
+ /// 房间号
+ ///
+ public string RoomNo { get; set; }
+ ///
/// 比例
///
- public double Scale { get; set; }
+ public double Scale { get; set; }
///
/// true:默认块,false:异性块
///
@@ -68,7 +72,7 @@ namespace SWS.Electrical.Models
{
get { return _TagPixelOnDwg; }
set { _TagPixelOnDwg = value; RaisePropertyChanged(nameof(TagPixelOnDwg)); }
- }
+ }
///
/// 肋位号 和 偏移量
///
diff --git a/newFront/c#前端/SWS.Electrical/SWS.Electrical.csproj b/newFront/c#前端/SWS.Electrical/SWS.Electrical.csproj
index 74cedada..49673316 100644
--- a/newFront/c#前端/SWS.Electrical/SWS.Electrical.csproj
+++ b/newFront/c#前端/SWS.Electrical/SWS.Electrical.csproj
@@ -133,6 +133,7 @@
+
diff --git a/newFront/c#前端/SWS.Electrical/ViewModels/DialogAutoArrangeLayoutViewModel.cs b/newFront/c#前端/SWS.Electrical/ViewModels/DialogAutoArrangeLayoutViewModel.cs
index b91a8efe..2835a6ab 100644
--- a/newFront/c#前端/SWS.Electrical/ViewModels/DialogAutoArrangeLayoutViewModel.cs
+++ b/newFront/c#前端/SWS.Electrical/ViewModels/DialogAutoArrangeLayoutViewModel.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Threading;
@@ -12,7 +13,11 @@ using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using Bricscad.EditorInput;
+using ImTools;
+using IniParser.Model;
+using Microsoft.Win32;
using Newtonsoft.Json;
+using Prism.Events;
using Prism.Services.Dialogs;
using SWS.CAD.Base;
using SWS.Commons;
@@ -29,6 +34,17 @@ using Visibility = System.Windows.Visibility;
namespace SWS.Electrical.ViewModels
{
+ public class MessageModel
+ {
+ ///
+ /// 信息
+ ///
+ public string Message { get; set; }
+ ///
+ /// 是否成功
+ ///
+ public bool IsSuccess { get; set; } = true;
+ }
public class DialogAutoArrangeLayoutViewModel : DialogBase, IDialogAware
{
private ObservableCollection _listDrawings;
@@ -227,6 +243,15 @@ namespace SWS.Electrical.ViewModels
get { return _ErrTagCount; }
set { _ErrTagCount = value; OnPropertyChanged(nameof(ErrTagCount)); }
}
+ private bool _isCheckDelete = false;
+ ///
+ /// 删除现有元件再绘制
+ ///
+ public bool isCheckDelete
+ {
+ get { return _isCheckDelete; }
+ set { _isCheckDelete = value; OnPropertyChanged(nameof(isCheckDelete)); }
+ }
///
/// 命令事件
@@ -252,8 +277,11 @@ namespace SWS.Electrical.ViewModels
private string dwgName = string.Empty;
private List listLibraryTagName = new List();//元件图纸上的位号属性名称,
private List listDeck = new List();//甲板号值列表
- private List listArea = new List();//区域值列表
- private List listSystem = new List();//所属系统值列表
+ private List listSystem = new List();//所属系统值列表
+ List listEnginedata = new List();//要绘制的多个位号的位号信息
+ List listObjecttype = new List();//要绘制的多个位号的属性信息列表
+ List listUpdateEnginedata = new List();//要绘制的多个位号的关联图纸属性列表
+ IEventAggregator eventAggregator;
public DialogAutoArrangeLayoutViewModel()
{
Command_StartDrawing = new DelegateCommand(onStartDrawing);
@@ -270,10 +298,12 @@ namespace SWS.Electrical.ViewModels
_ServiceObjectType = GlobalObject.container.Resolve();
_ServiceProjectSettings = GlobalObject.container.Resolve();
_ServiceDataItem = GlobalObject.container.Resolve();
+ eventAggregator = GlobalObject.container.Resolve();
listDrawings = new ObservableCollection();
listBasePoint = new ObservableCollection();
listErrBasePoint = new ObservableCollection();
- listMsg = new ObservableCollection();
+ listMsg = new ObservableCollection();
+ eventAggregator.GetEvent().Subscribe(onReceviceMsg, ThreadOption.UIThread, true);
var list = new ObservableCollection();
list.Add(new KeyValueModel { Key = "甲板号", Value = "甲板号" });
//list.Add(new KeyValueModel { Key = "区域", Value = "区域" });
@@ -364,11 +394,12 @@ namespace SWS.Electrical.ViewModels
{
AddMsg($"布置图列表加载中...");
var listDwg = await _ServiceDrawing.GetDrawingCatalogue();
- if (listDwg == null)
+ if (listDwg == null || !listDwg.Any())
{
AddMsg($"布置图列表没有数据!");
return;
}
+ GlobalObject.AllDrawings = listDwg.ToList();
foreach (var model in listDwg)
{
if (model.Text == "布置图")
@@ -409,14 +440,14 @@ namespace SWS.Electrical.ViewModels
}
else { listLibraryTagName = settingModel.SettingValue.Split(',').ToList(); }
//区域下拉框对应值列表
- var listDetail = await _ServiceDataItem.GetDetails("Area");
- if (listDetail != null && listDetail.Any())
- {
- foreach (var item in listDetail)
- { listArea.Add(new KeyValueModel() { Key = item.DataItemName, Value = item.DataItemName }); }
- }
+ //var listDetail = await _ServiceDataItem.GetDetails("Area");
+ //if (listDetail != null && listDetail.Any())
+ //{
+ // foreach (var item in listDetail)
+ // { listArea.Add(new KeyValueModel() { Key = item.DataItemName, Value = item.DataItemName }); }
+ //}
//甲板号下拉框对应值列表
- listDetail = await _ServiceDataItem.GetDetails("甲板号");
+ var listDetail = await _ServiceDataItem.GetDetails("甲板号");
if (listDetail != null && listDetail.Any())
{
foreach (var item in listDetail)
@@ -505,7 +536,7 @@ namespace SWS.Electrical.ViewModels
{
string strErr = isBasePointErr ? "基点异常;" : "";
strErr += isTagErr ? "元件异常" : "";
- strErr = strErr.Replace(";","");
+ strErr = strErr.EndsWith(";") ? strErr.Replace(";", "") : strErr;
listErrDto.Add(new DtoAutoPlotLayout()
{
IsSelected = true,
@@ -513,6 +544,7 @@ namespace SWS.Electrical.ViewModels
DrawingFileName = dwg.DrawingFileName,
EngineDataID = basePoint.EngineDataID,
BasePointTagNumber = basePoint.TagNumber,
+ RoomNo = basePoint.RoomNo,
Scale = basePoint.Scale,
FileId = basePoint.FileId,
PixelOnDwg = basePoint.PixelOnDwg,
@@ -538,6 +570,7 @@ namespace SWS.Electrical.ViewModels
DrawingFileName = dwg.DrawingFileName,
EngineDataID = basePoint.EngineDataID,
BasePointTagNumber = basePoint.TagNumber,
+ RoomNo = basePoint.RoomNo,
Scale = basePoint.Scale,
FileId = basePoint.FileId,
PixelOnDwg = basePoint.PixelOnDwg,
@@ -588,41 +621,499 @@ namespace SWS.Electrical.ViewModels
MessageBox.Show("请先勾选基点元件信息!");
return;
}
+ listMsg.Clear();
+ var progress = new Progress(UpdateProgress);
+ await DoWorkAsync(progress, new CancellationTokenSource());
+
+
+ #region back
+
+ //try
+ //{
+ // isDrawing = true;
+ // List listFile = new List();
+ // List listBlockDwgPath = new List(); //图块下载路径列表,同个异形块下载一次,先下载后删除
+ // listMsg.Clear();
+ // listUpdateEnginedata.Clear();
+ // //获取多个位号属性
+ // AddMsg($"开始获取全部位号属性...");
+ // string strTagNumbers = string.Join(",", listDto.Select(a => a.TagNumber).ToList());
+ // listObjecttype = await _ServiceObjectType.GetTagInfosByTags(strTagNumbers);
+ // listEnginedata = await _ServiceObjectType.GetEngineDataListByTags(strTagNumbers);
+ // AddMsg($"获取全部位号类型属性完成,共有{listObjecttype.Count}种类型!");
+ // //循环画图
+ // for (int i = 0; i < listDto.Count; i++)
+ // {
+ // var basePoint = listDto[i];
+ // if (basePoint.AutoDrawing == "已绘制")
+ // {
+ // AddMsg($"当前基点[{basePoint.BasePointTagNumber}]和元件[{basePoint.TagNumber}]已绘制,跳至下一个元件");
+ // continue;
+ // }
+ // if (basePoint.AutoDrawing == "已存在" && !isCheckDelete)
+ // {
+ // AddMsg($"当前基点[{basePoint.BasePointTagNumber}]和元件[{basePoint.TagNumber}]已存在,跳至下一个元件");
+ // continue;
+ // }
+
+ // msg = OpenDwg(basePoint);
+ // if (!string.IsNullOrEmpty(msg))
+ // {
+ // AddMsg($"图纸打开失败:{msg}", false);
+ // continue;
+ // }
+ // var listTag = listDto.Where(a => a.DrawingFileID == basePoint.DrawingFileID).Select(a => a.TagNumber).ToList();
+ // var listEntitys = isCheckDelete ? General.GetAllEntity(listTag) : General.GetAllEntity(new List());//获取图纸所有实体
+ // var entity = listEntitys.FirstOrDefault(a => a.Handle.ToString() == basePoint.PixelOnDwg);
+ // if (entity == null)
+ // {
+ // AddMsg($"当前基点:{basePoint.BasePointTagNumber} 在图上找不到,不添加此元件,跳至下一个元件", false);
+ // continue;
+ // }
+ // var tag = basePoint.Tag;
+ // var tagDto = listEntitys.FirstOrDefault(a => a.TagNumber == basePoint.TagNumber);
+ // if (tagDto != null)
+ // {
+ // AddMsg($"当前元件:{basePoint.TagNumber} 在图上已存在,句柄:{tagDto.Handle},不添加此元件,跳至下一个元件", false);
+ // basePoint.AutoDrawing = "已存在";
+ // basePoint.TagPixelOnDwg = tagDto.Handle;
+ // continue;
+ // }
+ // filePath = Path.Combine(GlobalObject.GetCacheFolder(), $"{tag.TagNumber}.dwg");
+ // string blockName = string.Empty;
+ // if (string.IsNullOrEmpty(tag.FileId))
+ // {
+ // //元件ID为空 用本地默认图块图纸
+ // if (!string.IsNullOrEmpty(tag.TagNumber_Lower))
+ // {
+ // var blockDwgPath = Path.Combine(GlobalObject.GetDllPath(), "Template\\常规矩形两行图块.dwg");
+ // if (!File.Exists(blockDwgPath))
+ // {
+ // AddMsg($"默认图块找不到:{blockDwgPath}", false);
+ // continue;
+ // }
+ // //默认上下图块
+ // blockName = "常规矩形两行图块";
+ // File.Copy(blockDwgPath, filePath, true);
+ // AddMsg($"本地默认常规图块图纸复制成功");
+ // }
+ // else
+ // {
+ // var blockDwgPath = Path.Combine(GlobalObject.GetDllPath(), "Template\\常规矩形单行图块.dwg");
+ // if (!File.Exists(blockDwgPath))
+ // {
+ // AddMsg($"默认图块找不到:{blockDwgPath}", false);
+ // continue;
+ // }
+ // //默认图块,只有中间部分
+ // blockName = "常规矩形单行图块";
+ // File.Copy(blockDwgPath, filePath, true);
+ // AddMsg($"本地默认常规图块图纸复制成功");
+ // }
+ // }
+ // else
+ // {
+ // string blockDwgPath = Path.Combine(GlobalObject.GetCacheFolder(), $"{tag.FileId}.dwg");
+ // if (File.Exists(blockDwgPath))
+ // {
+ // File.Copy(blockDwgPath, filePath, true);
+ // var item = listFile.FirstOrDefault(a => a.LibraryFileID == tag.FileId);
+ // if (item != null)
+ // {
+ // blockName = item.LibraryFileName;
+ // }
+ // else { blockName = tag.TagNumber; }
+ // AddMsg($"元件图纸:{tag.TagNumber},已下载过,复制本地缓存块图纸文件成功");
+ // }
+ // else
+ // {
+ // //下载元件图纸文件
+ // var obj = await _ServiceLibraryFile.GetEntity(tag.FileId);
+ // blockName = obj.LibraryFileName;
+ // AddMsg($"元件图纸:{tag.TagNumber}, 开始下载...");
+ // msg = await _ServiceAnnexes.DownloadFile(blockDwgPath, obj.FolderId);
+ // if (!string.IsNullOrEmpty(msg))
+ // {
+ // AddMsg($"元件图纸下载失败,信息:" + msg, false);
+ // continue;
+ // }
+ // File.Copy(blockDwgPath, filePath, true);
+ // listBlockDwgPath.Add(blockDwgPath);
+ // listFile.Add(obj);
+ // AddMsg($"元件图纸:{tag.TagNumber}, 下载成功");
+ // }
+ // }
+ // listBlockDwgPath.Add(filePath);
+ // //把元件的位号属性改成要绘制的位号值
+ // var flag = General.UpdateCableNo(filePath, listLibraryTagName, tag.TagNumber, tag.IsNotDefaultSymbol, tag.TagNumber_Upper, tag.TagNumber_Lower);
+
+ // //X轴:图上基点的坐标X +(接口数据元件的X + 接口数据元件的XOFF -接口数据基点的X-接口数据基点的Xoff)*比例系数
+ // //Y轴:图上基点的坐标Y +(接口数据元件的Yoff-接口数据基点的Yoff)*比例系数
+ // double scale = basePoint.Scale;//比例系数
+ // double x = entity.X + (tag.X + double.Parse(tag.XOff) - basePoint.X - double.Parse(basePoint.XOff)) * scale;
+ // AddMsg($"块X坐标计算:{entity.X}+({tag.X}+{tag.XOff}-{basePoint.X}-{basePoint.XOff})*{scale}={x}");
+ // double y = entity.Y + (double.Parse(tag.YOff) - double.Parse(basePoint.XOff)) * scale;
+ // AddMsg($"块Y坐标计算:{entity.Y}+({tag.YOff}-{basePoint.XOff})*{scale}={y}");
+ // AddMsg($"块最后坐标:{x},{y},0");
+ // double z = entity.Z;
+ // Point3d tagPoint = new Point3d(x, y, z);
+ // AddMsg($"元件图纸:{tag.TagNumber}, 开始添加进布置图中...");
+ // msg =await AddBlock(basePoint, blockName, filePath, tagPoint);
+ // if (string.IsNullOrEmpty(msg))
+ // {
+ // AddMsg($"布置图:{basePoint.DrawingFileName},成功插入元件:" + tag.TagNumber);
+ // basePoint.AutoDrawing = "已绘制";
+ // //当下一个要画元件的图纸和当前图纸不一样时,保存图纸
+ // if (i + 1 >= listDto.Count)
+ // { General.SetDrawingReadOnly(dwgName, false); }
+ // else
+ // {
+ // var nextTag = listDto[i + 1];
+ // if (basePoint.DrawingFileID != nextTag.DrawingFileID)
+ // { General.SetDrawingReadOnly(dwgName, false); }
+ // }
+ // }
+ // else
+ // {
+ // basePoint.AutoDrawing = "已失败";
+ // AddMsg($"元件:{tag.TagNumber},绘制异常:{msg}", false);
+ // }
+
+ // }
+ // if (listUpdateEnginedata.Any())
+ // {
+ // AddMsg($"开始批量位号关联属性,数量:{listUpdateEnginedata.Count}......");
+ // msg = await _ServiceObjectType.UpdatePixelAndPropBatch(listUpdateEnginedata);
+ // if (string.IsNullOrEmpty(msg))
+ // {
+ // AddMsg("位号关联属性成功,数量:" + listUpdateEnginedata.Count);
+ // }
+ // else
+ // {
+ // AddMsg($"位号关联属性失败,数量:{listUpdateEnginedata.Count},异常:{msg}", false);
+ // }
+ // }
+ // foreach (var file in listBlockDwgPath)
+ // {
+ // File.Delete(file);//删除缓存图块图纸文件
+ // File.Delete(file.Replace(".dwg", ".bak"));
+ // }
+ // AddMsg("操作已完成!");
+ // isDrawing = false;
+ //}
+ //catch (Exception ex)
+ //{
+ // MessageBox.Show("绘图异常:" + ex.Message);
+ // isDrawing = false;
+ //}
+ #endregion
+ }
+ #region DoWork
+ private void UpdateProgress(MessageModel dto)
+ {
+ System.Windows.Application.Current.Dispatcher.Invoke(new System.Action(() =>
+ {
+ AddMsg(dto.Message, dto.IsSuccess);
+ }));
+ }
+
+ private async Task DoWorkAsync(IProgress progress, CancellationTokenSource cts)
+ {
try
{
+ int time = 1;
+ var msg = string.Empty;
+ var filePath = string.Empty;
+ var listDto = listBasePoint.Where(a => a.IsSelected == true).ToList();
isDrawing = true;
+ List listFile = new List();
+ List listBlockDwgPath = new List(); //图块下载路径列表,同个异形块下载一次,先下载后删除
listMsg.Clear();
+ listUpdateEnginedata.Clear();
+ //获取多个位号属性
+ AddMsg($"开始获取全部位号属性...");
+ await Task.Delay(time, cts.Token);
+ string strTagNumbers = string.Join(",", listDto.Select(a => a.TagNumber).ToList());
+ listObjecttype = await _ServiceObjectType.GetTagInfosByTags(strTagNumbers);
+ listEnginedata = await _ServiceObjectType.GetEngineDataListByTags(strTagNumbers);
+ AddMsg($"获取全部位号类型属性完成,共有{listObjecttype.Count}种类型!");
+ await Task.Delay(time, cts.Token);
+ //循环画图
for (int i = 0; i < listDto.Count; i++)
- //foreach (var basePoint in listDto)
{
+ cts.Token.ThrowIfCancellationRequested();
var basePoint = listDto[i];
- if (basePoint.AutoDrawing == "已绘制")
+ if (basePoint.AutoDrawing == "已绘制" && !isCheckDelete)
+ {
+ AddMsg($"当前基点[{basePoint.BasePointTagNumber}]和元件[{basePoint.TagNumber}]已绘制,跳至下一个元件", false);
+ await Task.Delay(time, cts.Token);
+ continue;
+ }
+ if (basePoint.AutoDrawing == "已存在" && !isCheckDelete)
+ {
+ AddMsg($"当前基点[{basePoint.BasePointTagNumber}]和元件[{basePoint.TagNumber}]已存在,跳至下一个元件", false);
+ await Task.Delay(time, cts.Token);
+ continue;
+ }
+
+ msg = OpenDwg(basePoint);
+ if (!string.IsNullOrEmpty(msg))
+ {
+ AddMsg($"图纸打开失败:{msg}", false);
+ await Task.Delay(time, cts.Token);
+ continue;
+ }
+ var listTag = listDto.Where(a => a.DrawingFileID == basePoint.DrawingFileID).Select(a => a.TagNumber).ToList();
+ var listEntitys = isCheckDelete ? General.GetAllEntity(listTag) : General.GetAllEntity(new List());//获取图纸所有实体
+ var entity = listEntitys.FirstOrDefault(a => a.Handle.ToString() == basePoint.PixelOnDwg);
+ if (entity == null)
+ {
+ AddMsg($"当前基点:{basePoint.BasePointTagNumber} 在图上找不到,不添加此元件,跳至下一个元件", false);
+ await Task.Delay(time, cts.Token);
+ continue;
+ }
+ var tag = basePoint.Tag;
+ var tagDto = listEntitys.FirstOrDefault(a => a.TagNumber == basePoint.TagNumber);
+ if (tagDto != null)
+ {
+ AddMsg($"当前元件:{basePoint.TagNumber} 在图上已存在,句柄:{tagDto.Handle},不添加此元件,跳至下一个元件", false);
+ basePoint.AutoDrawing = "已存在";
+ basePoint.TagPixelOnDwg = tagDto.Handle;
+ await Task.Delay(time, cts.Token);
+ continue;
+ }
+ filePath = Path.Combine(GlobalObject.GetCacheFolder(), $"{tag.TagNumber}.dwg");
+ string blockName = string.Empty;
+ if (string.IsNullOrEmpty(tag.FileId))
+ {
+ //元件ID为空 用本地默认图块图纸
+ if (!string.IsNullOrEmpty(tag.TagNumber_Lower))
+ {
+ var blockDwgPath = Path.Combine(GlobalObject.GetDllPath(), "Template\\常规矩形两行图块.dwg");
+ if (!File.Exists(blockDwgPath))
+ {
+ AddMsg($"默认图块找不到:{blockDwgPath}", false);
+ await Task.Delay(time, cts.Token);
+ continue;
+ }
+ //默认上下图块
+ blockName = "常规矩形两行图块";
+ File.Copy(blockDwgPath, filePath, true);
+ }
+ else
+ {
+ var blockDwgPath = Path.Combine(GlobalObject.GetDllPath(), "Template\\常规矩形单行图块.dwg");
+ if (!File.Exists(blockDwgPath))
+ {
+ AddMsg($"默认图块找不到:{blockDwgPath}", false);
+ await Task.Delay(time, cts.Token);
+ continue;
+ }
+ //默认图块,只有中间部分
+ blockName = "常规矩形单行图块";
+ File.Copy(blockDwgPath, filePath, true);
+ }
+ }
+ else
+ {
+ string blockDwgPath = Path.Combine(GlobalObject.GetCacheFolder(), $"{tag.FileId}.dwg");
+ if (File.Exists(blockDwgPath))
+ {
+ File.Copy(blockDwgPath, filePath, true);
+ var item = listFile.FirstOrDefault(a => a.LibraryFileID == tag.FileId);
+ if (item != null)
+ {
+ blockName = item.LibraryFileName;
+ }
+ else { blockName = tag.TagNumber; }
+ }
+ else
+ {
+ //下载元件图纸文件
+ var obj = await _ServiceLibraryFile.GetEntity(tag.FileId);
+ blockName = obj.LibraryFileName;
+ AddMsg($"元件图纸:{tag.TagNumber}, 开始下载...");
+ await Task.Delay(time, cts.Token);
+ msg = await _ServiceAnnexes.DownloadFile(blockDwgPath, obj.FolderId);
+ if (!string.IsNullOrEmpty(msg))
+ {
+ AddMsg($"元件图纸下载失败,信息:{msg}", false);
+ await Task.Delay(time, cts.Token);
+ continue;
+ }
+ File.Copy(blockDwgPath, filePath, true);
+ listBlockDwgPath.Add(blockDwgPath);
+ listFile.Add(obj);
+ AddMsg($"元件图纸:{tag.TagNumber}, 下载成功");
+ await Task.Delay(time, cts.Token);
+ }
+ }
+ listBlockDwgPath.Add(filePath);
+ //把元件的位号属性改成要绘制的位号值
+ var flag = General.UpdateCableNo(filePath, listLibraryTagName, tag.TagNumber, tag.IsNotDefaultSymbol, tag.TagNumber_Upper, tag.TagNumber_Lower);
+ //X轴:图上基点的坐标X +(接口数据元件的X + 接口数据元件的XOFF -接口数据基点的X-接口数据基点的Xoff)*比例系数
+ //Y轴:图上基点的坐标Y +(接口数据元件的Yoff-接口数据基点的Yoff)*比例系数
+ double scale = basePoint.Scale;//比例系数
+ double x = 0;
+ double y = 0;
+ if (tag.X != 0)//肋位号不为0的时候,去肋位号相关数据去算坐标
+ {
+ x = entity.X + (tag.X + double.Parse(tag.XOff) - basePoint.X - double.Parse(basePoint.XOff)) * scale;
+ msg = $"块X坐标计算:{entity.X}+({tag.X}+{tag.XOff}-{basePoint.X}-{basePoint.XOff})*{scale}={x}";
+ AddMsg(msg);
+ y = entity.Y + (double.Parse(tag.YOff) - double.Parse(basePoint.XOff)) * scale;
+ msg = $"块Y坐标计算:{entity.Y}+({tag.YOff}-{basePoint.XOff})*{scale}={y}";
+ AddMsg(msg);
+ await Task.Delay(time, cts.Token);
+ }
+ else
+ {
+ if (!string.IsNullOrEmpty(tag.RoomNo))
+ {
+ int rnd = new Random().Next(1, 5);
+ x = entity.X + rnd;
+ msg = $"块X坐标取房间号基点附近:{entity.X}+{rnd}={x}";
+ AddMsg(msg);
+ y = entity.Y + rnd;
+ msg = $"块Y坐标取房间号基点附近:{entity.Y}+{rnd}={y}";
+ AddMsg(msg);
+ await Task.Delay(time, cts.Token);
+ }
+ else
+ {
+ x = entity.X + (tag.X + double.Parse(tag.XOff) - basePoint.X - double.Parse(basePoint.XOff)) * scale;
+ msg = $"块X坐标计算:{entity.X}+({tag.X}+{tag.XOff}-{basePoint.X}-{basePoint.XOff})*{scale}={x}";
+ AddMsg(msg);
+ y = entity.Y + (double.Parse(tag.YOff) - double.Parse(basePoint.XOff)) * scale;
+ msg = $"块Y坐标计算:{entity.Y}+({tag.YOff}-{basePoint.XOff})*{scale}={y}";
+ AddMsg(msg);
+ await Task.Delay(time, cts.Token);
+ }
+ }
+ double z = entity.Z;
+ Point3d tagPoint = new Point3d(x, y, z);
+ AddMsg($"元件图纸:{tag.TagNumber}, 开始添加进布置图中...");
+ await Task.Delay(time, cts.Token);
+ msg = await AddBlock(basePoint, blockName, filePath, tagPoint);
+ if (string.IsNullOrEmpty(msg))
+ {
+ AddMsg($"布置图:{basePoint.DrawingFileName},成功插入元件:{tag.TagNumber}");
+ basePoint.AutoDrawing = "已绘制";
+ await Task.Delay(time, cts.Token);
+ //当下一个要画元件的图纸和当前图纸不一样时,保存图纸
+ if (i + 1 >= listDto.Count)
+ {
+ AddMsg($"布置图:{basePoint.DrawingFileName},开始保存...");
+ await Task.Delay(time, cts.Token);
+ General.SetDrawingReadOnly(dwgName, false);
+ msg = $"布置图:{basePoint.DrawingFileName},保存完成";
+ await Task.Delay(time, cts.Token);
+ }
+ else
+ {
+ var nextTag = listDto[i + 1];
+ if (basePoint.DrawingFileID != nextTag.DrawingFileID)
+ {
+ AddMsg($"布置图:{basePoint.DrawingFileName},开始保存...");
+ await Task.Delay(time, cts.Token);
+ General.SetDrawingReadOnly(dwgName, false);
+ AddMsg($"布置图:{basePoint.DrawingFileName},保存完成");
+ await Task.Delay(time, cts.Token);
+ }
+ }
+ }
+ else
+ {
+ basePoint.AutoDrawing = "已失败";
+ AddMsg($"元件:{tag.TagNumber},绘制异常:{msg}");
+ await Task.Delay(time, cts.Token);
+ }
+ }
+ if (listUpdateEnginedata.Any())
+ {
+ AddMsg($"开始批量位号关联属性,数量:{listUpdateEnginedata.Count}......");
+ await Task.Delay(time, cts.Token);
+ msg = await _ServiceObjectType.UpdatePixelAndPropBatch(listUpdateEnginedata);
+ if (string.IsNullOrEmpty(msg))
+ {
+ AddMsg("位号关联属性成功,数量:" + listUpdateEnginedata.Count);
+ await Task.Delay(time, cts.Token);
+ }
+ else
+ {
+ AddMsg($"位号关联属性失败,数量:{listUpdateEnginedata.Count},异常:{msg}");
+ await Task.Delay(time, cts.Token);
+ }
+ }
+ foreach (var file in listBlockDwgPath)
+ {
+ File.Delete(file);//删除缓存图块图纸文件
+ File.Delete(file.Replace(".dwg", ".bak"));
+ }
+ AddMsg("操作已完成!");
+ isDrawing = false;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("绘图异常:" + ex.Message);
+ LoggerHelper.Current.Error("绘图异常:" + ex.ToString());
+ isDrawing = false;
+ }
+ }
+
+ #endregion
+ private async void onAutoDrawing()
+ {
+ #region back
+ var msg = string.Empty;
+ var filePath = string.Empty;
+ var listDto = listBasePoint.Where(a => a.IsSelected == true).ToList();
+ if (!listDto.Any())
+ {
+ MessageBox.Show("请先勾选基点元件信息!");
+ return;
+ }
+ try
+ {
+ List listFile = new List();
+ List listBlockDwgPath = new List(); //图块下载路径列表,同个异形块下载一次,先下载后删除
+ isDrawing = true;
+ listUpdateEnginedata.Clear();
+ //获取多个位号属性
+ AddMsg($"开始获取全部位号属性...");
+ string strTagNumbers = string.Join(",", listDto.Select(a => a.TagNumber).ToList());
+ listObjecttype = await _ServiceObjectType.GetTagInfosByTags(strTagNumbers);
+ listEnginedata = await _ServiceObjectType.GetEngineDataListByTags(strTagNumbers);
+ AddMsg($"获取全部位号类型属性完成,共有{listObjecttype.Count}种类型!");
+ //循环画图
+ for (int i = 0; i < listDto.Count; i++)
+ {
+ var basePoint = listDto[i];
+ if (basePoint.AutoDrawing == "已绘制" && !isCheckDelete)
{
AddMsg($"当前基点[{basePoint.BasePointTagNumber}]和元件[{basePoint.TagNumber}]已绘制,跳至下一个元件");
continue;
}
- if (basePoint.AutoDrawing == "已存在")
+ if (basePoint.AutoDrawing == "已存在" && !isCheckDelete)
{
AddMsg($"当前基点[{basePoint.BasePointTagNumber}]和元件[{basePoint.TagNumber}]已存在,跳至下一个元件");
continue;
}
- msg = await OpenDwg(basePoint.DrawingFileID);
+ msg = OpenDwg(basePoint);
if (!string.IsNullOrEmpty(msg))
{
AddMsg($"图纸打开失败:{msg}", false);
continue;
}
-
- AddMsg($"打开图纸:{basePoint.DrawingFileName} ");
- var listEntitys = General.GetAllEntity();//获取图纸所有实体
+ var listTag = listDto.Where(a => a.DrawingFileID == basePoint.DrawingFileID).Select(a => a.TagNumber).ToList();
+ var listEntitys = isCheckDelete ? General.GetAllEntity(listTag) : General.GetAllEntity(new List());//获取图纸所有实体
var entity = listEntitys.FirstOrDefault(a => a.Handle.ToString() == basePoint.PixelOnDwg);
if (entity == null)
{
AddMsg($"当前基点:{basePoint.BasePointTagNumber} 在图上找不到,不添加此元件,跳至下一个元件", false);
continue;
}
-
var tag = basePoint.Tag;
var tagDto = listEntitys.FirstOrDefault(a => a.TagNumber == basePoint.TagNumber);
if (tagDto != null)
@@ -632,12 +1123,6 @@ namespace SWS.Electrical.ViewModels
basePoint.TagPixelOnDwg = tagDto.Handle;
continue;
}
- //var flag = basePoint.deck == tag.deck && basePoint.area == tag.area;
- //if (!flag)
- //{
- // AddMsg($"当前基点[{basePoint.BasePointTagNumber}]和元件[{tag.TagNumber}] 的deck和area不一致,不添加此元件,跳至下一个元件", false);
- // continue;
- //}
filePath = Path.Combine(GlobalObject.GetCacheFolder(), $"{tag.TagNumber}.dwg");
string blockName = string.Empty;
if (string.IsNullOrEmpty(tag.FileId))
@@ -654,6 +1139,7 @@ namespace SWS.Electrical.ViewModels
//默认上下图块
blockName = "常规矩形两行图块";
File.Copy(blockDwgPath, filePath, true);
+ AddMsg($"本地默认常规图块图纸复制成功");
}
else
{
@@ -666,31 +1152,53 @@ namespace SWS.Electrical.ViewModels
//默认图块,只有中间部分
blockName = "常规矩形单行图块";
File.Copy(blockDwgPath, filePath, true);
+ AddMsg($"本地默认常规图块图纸复制成功");
}
}
else
{
- //下载元件图纸文件
- var obj = await _ServiceLibraryFile.GetEntity(tag.FileId);
- blockName = obj.LibraryFileName;
- AddMsg($"元件图纸:{tag.TagNumber}, 开始下载...");
- msg = await _ServiceAnnexes.DownloadFile(filePath, obj.FolderId);
- if (!string.IsNullOrEmpty(msg))
+ string blockDwgPath = Path.Combine(GlobalObject.GetCacheFolder(), $"{tag.FileId}.dwg");
+ if (File.Exists(blockDwgPath))
{
- AddMsg($"元件图纸下载失败,信息:" + msg, false);
- continue;
+ File.Copy(blockDwgPath, filePath, true);
+ var item = listFile.FirstOrDefault(a => a.LibraryFileID == tag.FileId);
+ if (item != null)
+ {
+ blockName = item.LibraryFileName;
+ }
+ else { blockName = tag.TagNumber; }
+ AddMsg($"元件图纸:{tag.TagNumber},已下载过,复制本地缓存块图纸文件成功");
+ }
+ else
+ {
+ //下载元件图纸文件
+ var obj = await _ServiceLibraryFile.GetEntity(tag.FileId);
+ blockName = obj.LibraryFileName;
+ AddMsg($"元件图纸:{tag.TagNumber}, 开始下载...");
+ msg = await _ServiceAnnexes.DownloadFile(blockDwgPath, obj.FolderId);
+ if (!string.IsNullOrEmpty(msg))
+ {
+ AddMsg($"元件图纸下载失败,信息:" + msg, false);
+ continue;
+ }
+ File.Copy(blockDwgPath, filePath, true);
+ listBlockDwgPath.Add(blockDwgPath);
+ listFile.Add(obj);
+ AddMsg($"元件图纸:{tag.TagNumber}, 下载成功");
}
- AddMsg($"元件图纸:{tag.TagNumber}, 下载成功");
}
- //filePath = "D:\\BricsCAD\\Temp\\测试11.dwg";
+ listBlockDwgPath.Add(filePath);
//把元件的位号属性改成要绘制的位号值
var flag = General.UpdateCableNo(filePath, listLibraryTagName, tag.TagNumber, tag.IsNotDefaultSymbol, tag.TagNumber_Upper, tag.TagNumber_Lower);
//X轴:图上基点的坐标X +(接口数据元件的X + 接口数据元件的XOFF -接口数据基点的X-接口数据基点的Xoff)*比例系数
//Y轴:图上基点的坐标Y +(接口数据元件的Yoff-接口数据基点的Yoff)*比例系数
- double scale = 1;//比例系数
+ double scale = basePoint.Scale;//比例系数
double x = entity.X + (tag.X + double.Parse(tag.XOff) - basePoint.X - double.Parse(basePoint.XOff)) * scale;
+ AddMsg($"块X坐标计算:{entity.X}+({tag.X}+{tag.XOff}-{basePoint.X}-{basePoint.XOff})*{scale}={x}");
double y = entity.Y + (double.Parse(tag.YOff) - double.Parse(basePoint.XOff)) * scale;
+ AddMsg($"块Y坐标计算:{entity.Y}+({tag.YOff}-{basePoint.XOff})*{scale}={y}");
+ AddMsg($"块最后坐标:{x},{y},0");
double z = entity.Z;
Point3d tagPoint = new Point3d(x, y, z);
AddMsg($"元件图纸:{tag.TagNumber}, 开始添加进布置图中...");
@@ -709,9 +1217,31 @@ namespace SWS.Electrical.ViewModels
{ General.SetDrawingReadOnly(dwgName, false); }
}
}
- else { AddMsg($"元件:{tag.TagNumber},绘制异常:{msg}"); }
+ else
+ {
+ basePoint.AutoDrawing = "已失败";
+ AddMsg($"元件:{tag.TagNumber},绘制异常:{msg}", false);
+ }
}
+ if (listUpdateEnginedata.Any())
+ {
+ AddMsg($"开始批量位号关联属性,数量:{listUpdateEnginedata.Count}......");
+ msg = await _ServiceObjectType.UpdatePixelAndPropBatch(listUpdateEnginedata);
+ if (string.IsNullOrEmpty(msg))
+ {
+ AddMsg("位号关联属性成功,数量:" + listUpdateEnginedata.Count);
+ }
+ else
+ {
+ AddMsg($"位号关联属性失败,数量:{listUpdateEnginedata.Count},异常:{msg}", false);
+ }
+ }
+ foreach (var file in listBlockDwgPath)
+ {
+ File.Delete(file);//删除缓存图块图纸文件
+ File.Delete(file.Replace(".dwg", ".bak"));
+ }
AddMsg("操作已完成!");
isDrawing = false;
}
@@ -720,36 +1250,26 @@ namespace SWS.Electrical.ViewModels
MessageBox.Show("绘图异常:" + ex.Message);
isDrawing = false;
}
+ #endregion
}
///
/// 打开图纸
///
///
- private async Task OpenDwg(string dwgId)
+ private string OpenDwg(DtoAutoPlotLayout dto)
{
try
{
-
string res = string.Empty;
string fullpath = string.Empty;
- var dwgObj = await _ServiceDrawing.GetDrawingFile(dwgId);
- var cate = await _ServiceDrawingCatalogue.GetEntity(dwgObj.DrawingCatalogueID);
- if (cate.FullPath != cate.DrawingCatalogueID)
- {
- foreach (var id in cate.FullPath.Split(',').ToList())
- {
- cate = await _ServiceDrawingCatalogue.GetEntity(id);
- fullpath += $"{cate.DrawingCatalogueName}\\";
- }
- }
- else { fullpath = $"{cate.DrawingCatalogueName}\\"; }
- fullpath += dwgObj.DrawingFileName;
- fullpath = Path.Combine(GlobalObj.LocalWorkDir, GlobalObject.curProject.ProjectName, fullpath);
+ string folderpath = GlobalObject.GetDwgPath(dto.DrawingFileID);
+ fullpath = Path.Combine(GlobalObj.LocalWorkDir, GlobalObject.curProject.ProjectName, folderpath, $"{dto.DrawingFileName}");
+
if (!File.Exists(fullpath))
{
- return dwgObj.DrawingFileName + ",图纸文件不存在,请先检出到本地!";
+ return dto.DrawingFileName + ",图纸文件不存在,请先检出到本地!";
}
- if (dwgObj.DrawingFileName == General.GetDwgName())
+ if (dto.DrawingFileName == General.GetDwgName())
{
return res;
}
@@ -758,12 +1278,14 @@ namespace SWS.Electrical.ViewModels
{
General.OpenDwg(fullpath);
dwgName = fullpath;
+ AddMsg($"打开图纸:{dto.DrawingFileName} ");
return res;
}
else
{
General.SwitchToDocument(fullpath);
dwgName = fullpath;
+ AddMsg($"已打开图纸:{dto.DrawingFileName} ");
return res;
}
@@ -784,46 +1306,54 @@ namespace SWS.Electrical.ViewModels
string tagNumber = basePoint.Tag.TagNumber;
double scale = basePoint.Scale;
string msg = string.Empty;
- string tagNum = string.Empty;
- var lsitEnginedata = await _ServiceObjectType.GetEngineDataListByTags(tagNumber);
- if (!lsitEnginedata.Any())
+ //string tagNum = string.Empty;
+ //var lsitEnginedata = await _ServiceObjectType.GetEngineDataListByTags(tagNumber);
+ //if (!lsitEnginedata.Any())
+ //{
+ // msg = $"元件位号:{tagNumber},属性未绑定,_ServiceObjectType.GetEngineDataListByTags({tagNumber})接口无数据";
+ // AddMsg(msg, false);
+ // return msg;
+ //}
+ var enginedata = listEnginedata.FirstOrDefault(a => a.TagNumber == tagNumber);
+ if (enginedata == null)
{
- msg = $"元件位号:{tagNumber},属性未绑定,ServiceEnginedata.GetTagPixelsById({enginedataId})接口无数据";
- AddMsg(msg, false);
+ msg = $"元件位号:{tagNumber},找不到位号工程属性,无法关联属性!";
return msg;
}
- string objTypeId = lsitEnginedata[0].ObjectTypeID;
- string objTypeName = lsitEnginedata[0].ObjectTypeName;
+ string objTypeId = enginedata.ObjectTypeID;
+ string objTypeName = enginedata.ObjectTypeName;
var objId = General.AddTagDWG(blockDwg, tagName, tagNumber, objTypeId, scale, tagPoint);
#region 图纸上保存图元属性
if (!objId.IsNull)
{
- AddMsg($"元件已添加至图纸,句柄:{objId.Handle.ToString()}");
- AddMsg("开始关联元件属性至图纸...");
- var dwgLibrary = await _ServiceLibraryFile.GetEntity(blockDwgId);
+ //AddMsg($"元件已添加至图纸,句柄:{objId.Handle.ToString()}");
+ //RefreshUI(999, $"元件已添加至图纸,句柄:{objId.Handle.ToString()}");
+ //var dwgLibrary = await _ServiceLibraryFile.GetEntity(blockDwgId);
List listPro = new List();
var handlid = objId.Handle.ToString();//添加图元返回的句柄
ec_enginedata item = new ec_enginedata();
+ item.EngineDataID = enginedataId;
item.TagNumber = tagNumber;
item.ObjectTypeID = objTypeId;
- item.Layout_Block_File = dwgLibrary;
- //var result = await _ServiceObjectType.GetObjectTypePById(objTypeId);//添加属性
- var res = await _ServiceObjectType.GetTagInfosByTags(tagNumber);
- if (res.Any())
+ //item.Layout_Block_File = dwgLibrary;
+ var tagInfo = listObjecttype.FirstOrDefault(a => a.ObjectTypeID == enginedata.ObjectTypeID);
+ if (tagInfo == null)
{
- foreach (var dto in res[0].tags[0].EngineDataProperty)
+ msg = $"元件位号:{tagNumber},找不到位号属性信息,无法关联属性!";
+ return msg;
+ }
+ foreach (var dto in tagInfo.tags[0].EngineDataProperty)
+ {
+ listPro.Add(new ec_enginedata_property()
{
- listPro.Add(new ec_enginedata_property()
- {
- EngineDataPropertyID = dto.PropertyID,
- PropertyName = dto.PropertyName,
- PropertyNameEN = dto.PropertyNameEN,
- PropertyValue = dto.PropertyValue,
- MeasuringUnit = dto.MeasuringUnit,
- PropertyGID = dto.PropertyGID,
- PropertyGroupName = dto.PropertyGroupName
- });
- }
+ EngineDataPropertyID = dto.PropertyID,
+ PropertyName = dto.PropertyName,
+ PropertyNameEN = dto.PropertyNameEN,
+ PropertyValue = dto.PropertyValue,
+ MeasuringUnit = dto.MeasuringUnit,
+ PropertyGID = dto.PropertyGID,
+ PropertyGroupName = dto.PropertyGroupName
+ });
}
item.EngineDataProperty = listPro;
List listPixel = new List();
@@ -831,7 +1361,7 @@ namespace SWS.Electrical.ViewModels
{
TagNumber = tagNumber,
DrawingFileID = dwgId,
- LibraryFileID = dwgLibrary == null ? "" : dwgLibrary.LibraryFileID,
+ LibraryFileID = blockDwgId,// == null ? "" : dwgLibrary.LibraryFileID
PixelCode = handlid,
ObjectTypeID = objTypeId,
ObjectTypeName = objTypeName,
@@ -839,25 +1369,13 @@ namespace SWS.Electrical.ViewModels
};
listPixel.Add(pixelDto);
item.EngineDataPixel = listPixel;
-
- msg = await _ServiceObjectType.UpdatePixelAndProp(item);
- if (msg != string.Empty)
- {
- msg = "保存元件属性至图纸异常:" + msg;
- AddMsg(msg, false);
- return msg;
- }
- else
- {
- basePoint.TagPixelOnDwg = handlid;
- AddMsg("添加元件属性至图纸成功!");
- return "";
- }
+ basePoint.TagPixelOnDwg = handlid;
+ listUpdateEnginedata.Add(item);
+ return "";
}
else
{
msg = $"元件:{blockDwg} ,添加失败";
- AddMsg(msg, false);
return msg;
}
#endregion
@@ -891,11 +1409,14 @@ namespace SWS.Electrical.ViewModels
foreach (var item in listBasePoint)
{
item.IsSelected = IsSelectAll;
- }
-
+ }
}
+
+ string message = string.Empty;
+ bool isSuccess = false;
+
///
- /// 添加提示信息
+ /// 添加 提示信息
///
/// 信息
/// 是否成功
@@ -903,15 +1424,23 @@ namespace SWS.Electrical.ViewModels
{
try
{
- TextBlock tb = new TextBlock();
- tb.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff") + "==>> " + msg;
- tb.Foreground = isSucc ? Brushes.LightSeaGreen : Brushes.Red;
- listMsg.Add(tb);
+ System.Windows.Application.Current.Dispatcher.Invoke((System.Action)(() =>
+ {
+ TextBlock tb = new TextBlock();
+ tb.Text = DateTime.Now.ToString("yyyy-MM-6dd HH:mm:ss:ffff") + "==>> " + msg;
+ tb.Foreground = isSucc ? Brushes.LightSeaGreen : Brushes.Red;
+ listMsg.Add(tb);
+ }));
+ //Task.Delay(100);
}
catch (Exception ex)
{
MessageBox.Show("添加提示信息异常:" + ex.Message);
}
}
+ private void onReceviceMsg(MessageModel model)
+ {
+ AddMsg(model.Message, model.IsSuccess);
+ }
}
}
diff --git a/newFront/c#前端/SWS.Electrical/ViewModels/DialogGenerateBOMViewModel.cs b/newFront/c#前端/SWS.Electrical/ViewModels/DialogGenerateBOMViewModel.cs
index b5469d1b..2b88fee9 100644
--- a/newFront/c#前端/SWS.Electrical/ViewModels/DialogGenerateBOMViewModel.cs
+++ b/newFront/c#前端/SWS.Electrical/ViewModels/DialogGenerateBOMViewModel.cs
@@ -420,7 +420,7 @@ namespace SWS.Electrical.ViewModels
if (dwg.AutoGenerate == "已存在")
{
AddMsg($"当前图纸[{dwg.DrawingFileName}]的材料表已存在,跳至下一个图纸");
- //continue;
+ continue;
}
if (dwg.AutoGenerate == "无材料信息")
{
@@ -433,7 +433,7 @@ namespace SWS.Electrical.ViewModels
{
AddMsg($"当前图纸[{dwg.DrawingFileName}]的材料表已存在,跳至下一个图纸", false);
dwg.AutoGenerate = "已存在";
- //continue;
+ continue;
}
var listBomGroup = await _ServicePlotBOM.GetBOMGroupInfo(dwg.DrawingFileID);
diff --git a/newFront/c#前端/SWS.Electrical/Views/DialogAutoArrangeLayout.xaml b/newFront/c#前端/SWS.Electrical/Views/DialogAutoArrangeLayout.xaml
index 494936aa..91d91195 100644
--- a/newFront/c#前端/SWS.Electrical/Views/DialogAutoArrangeLayout.xaml
+++ b/newFront/c#前端/SWS.Electrical/Views/DialogAutoArrangeLayout.xaml
@@ -217,7 +217,7 @@
Orientation="Horizontal">
@@ -227,6 +227,14 @@
Command="{Binding Command_StartDrawing}"
Content="开始自动绘图"
FontSize="16" />
+
+
+
+
diff --git a/newFront/c#前端/SWS.Electrical/bin/Debug/log4net.config b/newFront/c#前端/SWS.Electrical/bin/Debug/log4net.config
index dc48092d..2e52c6ab 100644
--- a/newFront/c#前端/SWS.Electrical/bin/Debug/log4net.config
+++ b/newFront/c#前端/SWS.Electrical/bin/Debug/log4net.config
@@ -8,13 +8,30 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
@@ -29,7 +46,25 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -70,24 +105,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/newFront/c#前端/SWS.Electrical/obj/Debug/Views/DialogAutoArrangeLayout.g.cs b/newFront/c#前端/SWS.Electrical/obj/Debug/Views/DialogAutoArrangeLayout.g.cs
index 3fd1d88d..54f6a180 100644
--- a/newFront/c#前端/SWS.Electrical/obj/Debug/Views/DialogAutoArrangeLayout.g.cs
+++ b/newFront/c#前端/SWS.Electrical/obj/Debug/Views/DialogAutoArrangeLayout.g.cs
@@ -1,4 +1,4 @@
-#pragma checksum "..\..\..\Views\DialogAutoArrangeLayout.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "D381518E6A709FE4FD61B7B59C0FE6A02830580BBED56CC9959DA9E027AC6A01"
+#pragma checksum "..\..\..\Views\DialogAutoArrangeLayout.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "8E0302C7B31AF0BFE57DDCDA7BD9F7E1B53C3458B14B24E3C31D70FADF66C1B2"
//------------------------------------------------------------------------------
//
// 此代码由工具生成。
@@ -85,7 +85,7 @@ namespace SWS.Electrical.Views {
#line hidden
- #line 237 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
+ #line 245 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.DataGrid dgTag;
@@ -93,7 +93,7 @@ namespace SWS.Electrical.Views {
#line hidden
- #line 340 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
+ #line 351 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.DataGrid dgErrTag;
@@ -136,7 +136,7 @@ namespace SWS.Electrical.Views {
case 2:
this.dgTag = ((System.Windows.Controls.DataGrid)(target));
- #line 243 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
+ #line 251 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
this.dgTag.LoadingRow += new System.EventHandler(this.dgTag_LoadingRow);
#line default
@@ -145,7 +145,7 @@ namespace SWS.Electrical.Views {
case 3:
this.dgErrTag = ((System.Windows.Controls.DataGrid)(target));
- #line 346 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
+ #line 357 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
this.dgErrTag.LoadingRow += new System.EventHandler(this.dgTag_LoadingRow);
#line default
diff --git a/newFront/c#前端/SWS.Electrical/obj/Debug/Views/DialogAutoArrangeLayout.g.i.cs b/newFront/c#前端/SWS.Electrical/obj/Debug/Views/DialogAutoArrangeLayout.g.i.cs
index 3fd1d88d..54f6a180 100644
--- a/newFront/c#前端/SWS.Electrical/obj/Debug/Views/DialogAutoArrangeLayout.g.i.cs
+++ b/newFront/c#前端/SWS.Electrical/obj/Debug/Views/DialogAutoArrangeLayout.g.i.cs
@@ -1,4 +1,4 @@
-#pragma checksum "..\..\..\Views\DialogAutoArrangeLayout.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "D381518E6A709FE4FD61B7B59C0FE6A02830580BBED56CC9959DA9E027AC6A01"
+#pragma checksum "..\..\..\Views\DialogAutoArrangeLayout.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "8E0302C7B31AF0BFE57DDCDA7BD9F7E1B53C3458B14B24E3C31D70FADF66C1B2"
//------------------------------------------------------------------------------
//
// 此代码由工具生成。
@@ -85,7 +85,7 @@ namespace SWS.Electrical.Views {
#line hidden
- #line 237 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
+ #line 245 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.DataGrid dgTag;
@@ -93,7 +93,7 @@ namespace SWS.Electrical.Views {
#line hidden
- #line 340 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
+ #line 351 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.DataGrid dgErrTag;
@@ -136,7 +136,7 @@ namespace SWS.Electrical.Views {
case 2:
this.dgTag = ((System.Windows.Controls.DataGrid)(target));
- #line 243 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
+ #line 251 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
this.dgTag.LoadingRow += new System.EventHandler(this.dgTag_LoadingRow);
#line default
@@ -145,7 +145,7 @@ namespace SWS.Electrical.Views {
case 3:
this.dgErrTag = ((System.Windows.Controls.DataGrid)(target));
- #line 346 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
+ #line 357 "..\..\..\Views\DialogAutoArrangeLayout.xaml"
this.dgErrTag.LoadingRow += new System.EventHandler(this.dgTag_LoadingRow);
#line default
diff --git a/newFront/c#前端/SWS.Model/LayoutTagInfoBrief.cs b/newFront/c#前端/SWS.Model/LayoutTagInfoBrief.cs
index c6d50e4d..84cd6060 100644
--- a/newFront/c#前端/SWS.Model/LayoutTagInfoBrief.cs
+++ b/newFront/c#前端/SWS.Model/LayoutTagInfoBrief.cs
@@ -38,6 +38,10 @@ namespace SWS.Model
///
public string PixelOnDwg { get; set; }
///
+ /// 房间号
+ ///
+ public string RoomNo { get; set; }
+ ///
/// 比例
///
public double Scale { get; set; }
diff --git a/newFront/c#前端/SWS.Service/HttpService.cs b/newFront/c#前端/SWS.Service/HttpService.cs
index 7e44fb9f..b46770f9 100644
--- a/newFront/c#前端/SWS.Service/HttpService.cs
+++ b/newFront/c#前端/SWS.Service/HttpService.cs
@@ -23,7 +23,7 @@ namespace SWS.Service
GlobalObject.client = new HttpClient()
{
BaseAddress = new Uri($"http://{address}:{port}/api/"),
- Timeout = TimeSpan.FromSeconds(120)
+ Timeout = TimeSpan.FromSeconds(180)
};
//}
//else
@@ -57,9 +57,9 @@ namespace SWS.Service
{
var uri = new Uri(GlobalObject.client.BaseAddress + requestUri);
var funName = uri.Segments.Last();
- LoggerHelper.Current.WriteJson(funName, strJson);
+ //LoggerHelper.Current.WriteJson(funName, strJson);
}
- catch { }
+ catch (Exception ex){ }
}
public async Task> GetAsync(string requestUri)
@@ -79,7 +79,7 @@ namespace SWS.Service
if (response.StatusCode != HttpStatusCode.OK)
{
string errorMsg = $"服务器地址 [{requestUri}] 获取数据失败, 返回HTTP代码:" + response.StatusCode;
- LoggerHelper.Current.Error(errorMsg);
+ //LoggerHelper.Current.Error(errorMsg);
throw new HttpRequestException(errorMsg);
}
result = await response.Content.ReadAsStringAsync();
@@ -89,14 +89,14 @@ namespace SWS.Service
catch (JsonException)
{
string errorMsg = $"服务器地址 [{requestUri}] 解析为{typeof(T).Name}失败,原始返回数据为: " + result;
- LoggerHelper.Current.Error(errorMsg);
+ //LoggerHelper.Current.Error(errorMsg);
resultObj = new learunHttpRes() { code = -100, info = errorMsg };
return resultObj;
}
catch (Exception ex)
{
string errorMsg = $"接口:{requestUri}失败,异常:{ex.Message} ";
- LoggerHelper.Current.Error(errorMsg);
+ //LoggerHelper.Current.Error(errorMsg);
resultObj = new learunHttpRes() { code = -100, info=errorMsg };
return resultObj;
}
@@ -111,12 +111,12 @@ namespace SWS.Service
//业务错误,不是http本质错误
default:
string errorMsg = $"服务器地址 [{requestUri}] Get失败, 返回自定义代码:" + resultObj.code;
- LoggerHelper.Current.Error(errorMsg);
+ //LoggerHelper.Current.Error(errorMsg);
throw new HttpRequestException(errorMsg);
}
}
- LoggerHelper.Current.Info($"Get成功:{requestUri}");
+ ////LoggerHelper.Current.Info($"Get成功:{requestUri}");
return resultObj;
@@ -133,7 +133,7 @@ namespace SWS.Service
if (response.StatusCode != HttpStatusCode.OK)
{
string errorMsg = $"服务器地址 [{requestUri}] 获取数据失败, 返回HTTP代码:" + response.StatusCode;
- LoggerHelper.Current.Error(errorMsg);
+ //LoggerHelper.Current.Error(errorMsg);
throw new HttpRequestException(errorMsg);
}
result = await response.Content.ReadAsStringAsync();
@@ -143,17 +143,17 @@ namespace SWS.Service
catch (JsonException)
{
string errorMsg = $"服务器地址 [{requestUri}] 解析为{typeof(T).Name}失败,原始返回数据为: " + result;
- LoggerHelper.Current.Error(errorMsg);
+ //LoggerHelper.Current.Error(errorMsg);
throw new JsonException(errorMsg);
}
catch (Exception ex)
{
string errorMsg = $"接口:{requestUri}失败,异常:{ex.Message} ";
- LoggerHelper.Current.Error(errorMsg);
+ //LoggerHelper.Current.Error(errorMsg);
throw new JsonException(errorMsg);
}
- LoggerHelper.Current.Info($"Get成功:{requestUri}");
+ //LoggerHelper.Current.Info($"Get成功:{requestUri}");
return resultObj;
@@ -184,7 +184,7 @@ namespace SWS.Service
if (response.StatusCode != HttpStatusCode.OK)
{
string errorMsg = $"服务器地址 [{requestUri}] Post数据失败, 返回HTTP代码:" + response.StatusCode;
- LoggerHelper.Current.Error(errorMsg);
+ //LoggerHelper.Current.Error(errorMsg);
throw new HttpRequestException(errorMsg);
}
result = await response.Content.ReadAsStringAsync();
@@ -194,14 +194,14 @@ namespace SWS.Service
catch (JsonException)
{
string errorMsg = $"服务器地址 [{requestUri}] 解析为{typeof(T).Name}失败,原始返回数据为: " + result;
- LoggerHelper.Current.Error(errorMsg);
+ //LoggerHelper.Current.Error(errorMsg);
resultObj = new learunHttpRes() { code = -100, info = errorMsg };
return resultObj;
}
catch (Exception ex)
{
string errorMsg = $"接口:{requestUri}失败,参数数据为:{strContent},异常:{ex.Message} ";
- LoggerHelper.Current.Error(errorMsg);
+ //LoggerHelper.Current.Error(errorMsg);
resultObj = new learunHttpRes() { code = -100, info = errorMsg };
return resultObj;
}
@@ -216,12 +216,12 @@ namespace SWS.Service
//业务错误,不是http本质错误
default:
string errorMsg = $"服务器地址 [{requestUri}] Post失败, 返回自定义代码:" + resultObj.code;
- LoggerHelper.Current.Error(errorMsg);
+ //LoggerHelper.Current.Error(errorMsg);
throw new HttpRequestException(errorMsg);
}
}
- LoggerHelper.Current.Info($"Post成功:{requestUri}");
+ //LoggerHelper.Current.Info($"Post成功:{requestUri}");
return resultObj;
@@ -245,7 +245,7 @@ namespace SWS.Service
if (response.StatusCode != HttpStatusCode.OK)
{
string errorMsg = $"服务器地址 [{requestUri}] Post数据失败, 返回HTTP代码:" + response.StatusCode;
- LoggerHelper.Current.Error(errorMsg);
+ //LoggerHelper.Current.Error(errorMsg);
throw new HttpRequestException(errorMsg);
}
var result = await response.Content.ReadAsStringAsync();
@@ -257,10 +257,10 @@ namespace SWS.Service
catch (JsonException)
{
string errorMsg = $"服务器地址 [{requestUri}] 解析为 string 失败,原始返回数据为: " + result;
- LoggerHelper.Current.Error(errorMsg);
+ //LoggerHelper.Current.Error(errorMsg);
throw new JsonException(errorMsg);
}
- LoggerHelper.Current.Info($"Post上传文件成功:{requestUri}");
+ //LoggerHelper.Current.Info($"Post上传文件成功:{requestUri}");
return resultObj;
}
diff --git a/newFront/c#前端/SWS.Service/bin/Debug/log4net.config b/newFront/c#前端/SWS.Service/bin/Debug/log4net.config
index dc48092d..2e52c6ab 100644
--- a/newFront/c#前端/SWS.Service/bin/Debug/log4net.config
+++ b/newFront/c#前端/SWS.Service/bin/Debug/log4net.config
@@ -8,13 +8,30 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
@@ -29,7 +46,25 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -70,24 +105,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/newFront/c#前端/SWS.WPF/bin/Debug/log4net.config b/newFront/c#前端/SWS.WPF/bin/Debug/log4net.config
index dc48092d..2e52c6ab 100644
--- a/newFront/c#前端/SWS.WPF/bin/Debug/log4net.config
+++ b/newFront/c#前端/SWS.WPF/bin/Debug/log4net.config
@@ -8,13 +8,30 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
@@ -29,7 +46,25 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -70,24 +105,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file