Compare commits
2 Commits
9ea7efaeb7
...
d88f2c2654
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d88f2c2654 | ||
![]() |
ce1a577588 |
@ -78,6 +78,8 @@ namespace Learun.Application.Web.AppApi
|
|||||||
#region 预处理每个位号,然后进行分组
|
#region 预处理每个位号,然后进行分组
|
||||||
foreach (ec_enginedataEntity tag in allTag)
|
foreach (ec_enginedataEntity tag in allTag)
|
||||||
{
|
{
|
||||||
|
if(tag.TagNumber.Length==38&&tag.TagNumber.Contains("{"))
|
||||||
|
{ continue; }
|
||||||
var matchedTypes = new List<string>();
|
var matchedTypes = new List<string>();
|
||||||
var idx = 0;
|
var idx = 0;
|
||||||
var GroupName = TrimTagNubmer(tag.TagNumber, out idx);// 如 A-B1,A-B2,取出来的group就是A-B,idx为0
|
var GroupName = TrimTagNubmer(tag.TagNumber, out idx);// 如 A-B1,A-B2,取出来的group就是A-B,idx为0
|
||||||
@ -103,7 +105,6 @@ namespace Learun.Application.Web.AppApi
|
|||||||
//如照明下的。比如10个照明的灯,4个中文名称是“顶灯”,6个中文名称是“壁灯”
|
//如照明下的。比如10个照明的灯,4个中文名称是“顶灯”,6个中文名称是“壁灯”
|
||||||
BOMTagInfo.Name = allProp.FirstOrDefault(x => x.EngineDataID == tag.EngineDataID && x.PropertyName == GlobalObject.propName_NameCN)?.PropertyValue ?? "";
|
BOMTagInfo.Name = allProp.FirstOrDefault(x => x.EngineDataID == tag.EngineDataID && x.PropertyName == GlobalObject.propName_NameCN)?.PropertyValue ?? "";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TagsInBOM.Add(BOMTagInfo);
|
TagsInBOM.Add(BOMTagInfo);
|
||||||
|
@ -15,6 +15,7 @@ using Path = System.IO.Path;
|
|||||||
using Color = Teigha.Colors.Color;
|
using Color = Teigha.Colors.Color;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using SWS.Model;
|
||||||
namespace SWS.CAD.Base
|
namespace SWS.CAD.Base
|
||||||
{
|
{
|
||||||
public static class General
|
public static class General
|
||||||
@ -2019,7 +2020,7 @@ namespace SWS.CAD.Base
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 插入文本内容
|
#region 插入文本内容
|
||||||
public static string InsertTextInfo(List<DtoCadTextInfo> listTextInfo)
|
public static string InsertTextInfo(List<DtoTextInfo> listTextInfo)
|
||||||
{
|
{
|
||||||
string res = string.Empty;
|
string res = string.Empty;
|
||||||
try
|
try
|
||||||
@ -2155,6 +2156,245 @@ namespace SWS.CAD.Base
|
|||||||
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 材料表插入图标块
|
||||||
|
/// <summary>
|
||||||
|
/// 读取元件块,插入图纸
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">图元文件路径</param>
|
||||||
|
/// <param name="symbolName">块名</param>
|
||||||
|
/// <param name="scale">比例大小</param>
|
||||||
|
/// <param name="position">坐标位置</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static ObjectId AddBomSymbolDWG(string filePath, string symbolName, double scale, Point3d position)
|
||||||
|
{
|
||||||
|
if (scale == 0)
|
||||||
|
{ scale = 1; }
|
||||||
|
Document doc = Application.DocumentManager.MdiActiveDocument;
|
||||||
|
var ed = doc.Editor;
|
||||||
|
ObjectId oid = ObjectId.Null;
|
||||||
|
if (!File.Exists(filePath))
|
||||||
|
{
|
||||||
|
ed.WriteMessage("\n 错误:图元文件不存在!\n");
|
||||||
|
return oid;
|
||||||
|
}
|
||||||
|
// 获取当前数据库
|
||||||
|
Database destDb = HostApplicationServices.WorkingDatabase;
|
||||||
|
using (Transaction tr = destDb.TransactionManager.StartTransaction())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 创建临时数据库读取外部DWG
|
||||||
|
using (Database sourceDb = new Database(false, true))
|
||||||
|
{
|
||||||
|
sourceDb.ReadDwgFile(filePath, FileOpenMode.OpenForReadAndAllShare, false, null);
|
||||||
|
|
||||||
|
// 生成唯一块名(避免重名)
|
||||||
|
string blockName = GetUniqueBlockName(destDb, symbolName);
|
||||||
|
// 将外部DWG转换为块定义
|
||||||
|
ObjectId blockId = destDb.Insert(blockName, sourceDb, true);
|
||||||
|
// 创建块参照
|
||||||
|
BlockReference br = new BlockReference(
|
||||||
|
Point3d.Origin, // 插入点(可修改)
|
||||||
|
blockId// bt[blockName]
|
||||||
|
);
|
||||||
|
br.Position = position;
|
||||||
|
// 设置比例和旋转
|
||||||
|
br.ScaleFactors = new Scale3d(scale); //比例因子
|
||||||
|
br.Rotation = 0.0; // 旋转角度(弧度)
|
||||||
|
// 获取实时鼠标位置
|
||||||
|
// 添加到当前模型空间
|
||||||
|
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(
|
||||||
|
SymbolUtilityServices.GetBlockModelSpaceId(destDb),
|
||||||
|
OpenMode.ForWrite
|
||||||
|
);
|
||||||
|
|
||||||
|
// 处理插入结果
|
||||||
|
btr.AppendEntity(br);
|
||||||
|
tr.AddNewlyCreatedDBObject(br, true);
|
||||||
|
//创建位号属性
|
||||||
|
//var attDef = AddAttributeDefinition(btr, "HKSK_TAG", tag);
|
||||||
|
//AttributeReference attRef = new AttributeReference();
|
||||||
|
//attRef.SetAttributeFromBlock(attDef, br.BlockTransform);
|
||||||
|
//br.AttributeCollection.AppendAttribute(attRef);
|
||||||
|
//tr.AddNewlyCreatedDBObject(attRef, true);
|
||||||
|
tr.Commit();
|
||||||
|
oid = br.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
tr.Abort();
|
||||||
|
ed.WriteMessage($"\n错误: {ex.Message}\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return oid;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取当前图纸的所有有标注信息的句柄
|
||||||
|
/// <summary>
|
||||||
|
/// 获取当前图纸的所有有标注信息的句柄 ,XData第一个属性为(1001, "HKSK_LABEL")
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<DtoTagAnnotation> GetAllAnnotation()
|
||||||
|
{
|
||||||
|
doc = Application.DocumentManager.MdiActiveDocument;
|
||||||
|
ed = doc.Editor;
|
||||||
|
db = doc.Database;
|
||||||
|
|
||||||
|
List<DtoTagAnnotation> listInfo = new List<DtoTagAnnotation>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 开启事务
|
||||||
|
using (Transaction tr = db.TransactionManager.StartTransaction())
|
||||||
|
{
|
||||||
|
// 获取模型空间块表记录
|
||||||
|
BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
|
||||||
|
BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord;
|
||||||
|
|
||||||
|
// 遍历模型空间中的所有实体
|
||||||
|
foreach (ObjectId objId in btr)
|
||||||
|
{
|
||||||
|
if (objId.ObjectClass.Name == "AcDbBlockReference")
|
||||||
|
{
|
||||||
|
BlockReference blockRef = (BlockReference)tr.GetObject(objId, OpenMode.ForRead);
|
||||||
|
if (blockRef.XData != null)
|
||||||
|
{
|
||||||
|
ResultBuffer rb = blockRef.XData;
|
||||||
|
if (HasTargetXData(rb, "HKSK_LABEL"))
|
||||||
|
{
|
||||||
|
TypedValue[] xdata = rb.AsArray();
|
||||||
|
for (int i = 1; i < xdata.Length; i++)
|
||||||
|
{
|
||||||
|
if (i + 1 >= xdata.Length)
|
||||||
|
{ break; }
|
||||||
|
TypedValue data1 = xdata[i];
|
||||||
|
TypedValue data2 = xdata[i + 1];
|
||||||
|
if (data1.TypeCode == 1000 && data2.TypeCode == 1005)
|
||||||
|
{
|
||||||
|
listInfo.Add(new DtoTagAnnotation()
|
||||||
|
{
|
||||||
|
TagHandId = objId.Handle.ToString(),
|
||||||
|
Name = data1.Value.ToString(),
|
||||||
|
LabelHandId = data2.Value.ToString(),
|
||||||
|
});
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else { break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tr.Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
ed.WriteMessage($"\n错误: {ex.Message}");
|
||||||
|
}
|
||||||
|
return listInfo;
|
||||||
|
}
|
||||||
|
private static bool HasTargetXData(ResultBuffer rb, string targetAppName)
|
||||||
|
{
|
||||||
|
if (rb == null) return false;
|
||||||
|
|
||||||
|
TypedValue[] data = rb.AsArray();
|
||||||
|
if (data.Length == 0) return false;
|
||||||
|
|
||||||
|
// 检查第一个TypedValue是否为(1001, "HKSK_LABEL")
|
||||||
|
TypedValue firstValue = data[0];
|
||||||
|
return firstValue.TypeCode == 1001 &&
|
||||||
|
firstValue.Value.ToString() == targetAppName;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取当前图纸的所有Mtext
|
||||||
|
/// <summary>
|
||||||
|
/// 获取当前图纸的所有Mtext
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<DtoMText> GetAllMText()
|
||||||
|
{
|
||||||
|
doc = Application.DocumentManager.MdiActiveDocument;
|
||||||
|
ed = doc.Editor;
|
||||||
|
db = doc.Database;
|
||||||
|
|
||||||
|
List<DtoMText> listMText = new List<DtoMText>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 开启事务
|
||||||
|
using (Transaction tr = db.TransactionManager.StartTransaction())
|
||||||
|
{
|
||||||
|
// 获取模型空间块表记录
|
||||||
|
BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
|
||||||
|
BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord;
|
||||||
|
|
||||||
|
// 遍历模型空间中的所有实体
|
||||||
|
foreach (ObjectId objId in btr)
|
||||||
|
{
|
||||||
|
Entity entity = tr.GetObject(objId, OpenMode.ForRead) as Entity;
|
||||||
|
if (entity is MText mtext)
|
||||||
|
{
|
||||||
|
listMText.Add(new DtoMText() { Text = mtext.Text, HandId = mtext.Handle.ToString() });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tr.Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
ed.WriteMessage($"\n错误: {ex.Message}");
|
||||||
|
}
|
||||||
|
return listMText;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 刷新文本信息
|
||||||
|
/// <summary>
|
||||||
|
/// 刷新文本信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string RefreshMTextInfo(List<KeyValueModel> keyValues)
|
||||||
|
{
|
||||||
|
doc = Application.DocumentManager.MdiActiveDocument;
|
||||||
|
ed = doc.Editor;
|
||||||
|
db = doc.Database;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (Transaction tr = db.TransactionManager.StartTransaction())
|
||||||
|
{
|
||||||
|
foreach (var item in keyValues)
|
||||||
|
{
|
||||||
|
Handle handleObj= new Handle(Convert.ToInt64(item.Key, 16));
|
||||||
|
|
||||||
|
// 通过句柄获取ObjectId
|
||||||
|
ObjectId objectId = db.GetObjectId(false, handleObj, 0);
|
||||||
|
|
||||||
|
// 获取对象并检查是否为MText
|
||||||
|
DBObject dbObj = tr.GetObject(objectId, OpenMode.ForWrite);
|
||||||
|
if (dbObj is MText mtext)
|
||||||
|
{
|
||||||
|
mtext.Contents = item.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tr.Commit();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
21
newFront/c#前端/SWS.CAD.Base/Model/DtoMText.cs
Normal file
21
newFront/c#前端/SWS.CAD.Base/Model/DtoMText.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Teigha.Geometry;
|
||||||
|
|
||||||
|
namespace SWS.CAD.Base
|
||||||
|
{
|
||||||
|
public class DtoMText
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文本内容,多行文本用\n 进行换行
|
||||||
|
/// </summary>
|
||||||
|
public string Text { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 句柄Id
|
||||||
|
/// </summary>
|
||||||
|
public string HandId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
25
newFront/c#前端/SWS.CAD.Base/Model/DtoSymbolInfo.cs
Normal file
25
newFront/c#前端/SWS.CAD.Base/Model/DtoSymbolInfo.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Teigha.Geometry;
|
||||||
|
|
||||||
|
namespace SWS.Electrical
|
||||||
|
{
|
||||||
|
public class DtoSymbolInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 坐标
|
||||||
|
/// </summary>
|
||||||
|
public Point3d Position { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 图标上面部分显示内容
|
||||||
|
/// </summary>
|
||||||
|
public string Upper_Text { set; get; }
|
||||||
|
/// <summary>
|
||||||
|
/// 图标下面部分显示内容
|
||||||
|
/// </summary>
|
||||||
|
public string Lower_Text { set; get; }
|
||||||
|
/// <summary>
|
||||||
|
/// 比例
|
||||||
|
/// </summary>
|
||||||
|
public double Scale { set; get; }
|
||||||
|
}
|
||||||
|
}
|
25
newFront/c#前端/SWS.CAD.Base/Model/DtoTagAnnotation.cs
Normal file
25
newFront/c#前端/SWS.CAD.Base/Model/DtoTagAnnotation.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Teigha.Geometry;
|
||||||
|
|
||||||
|
namespace SWS.CAD.Base
|
||||||
|
{
|
||||||
|
public class DtoTagAnnotation
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 元件句柄Id
|
||||||
|
/// </summary>
|
||||||
|
public string TagHandId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 属性名
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 文本标注句柄Id
|
||||||
|
/// </summary>
|
||||||
|
public string LabelHandId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ using Teigha.Geometry;
|
|||||||
|
|
||||||
namespace SWS.CAD.Base
|
namespace SWS.CAD.Base
|
||||||
{
|
{
|
||||||
public class DtoCadTextInfo
|
public class DtoTextInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 坐标
|
/// 坐标
|
@ -52,7 +52,10 @@
|
|||||||
<Compile Include="BlockDragJig.cs" />
|
<Compile Include="BlockDragJig.cs" />
|
||||||
<Compile Include="General.cs" />
|
<Compile Include="General.cs" />
|
||||||
<Compile Include="Model\DtoBasePoint.cs" />
|
<Compile Include="Model\DtoBasePoint.cs" />
|
||||||
<Compile Include="Model\DtoCadTextInfo.cs" />
|
<Compile Include="Model\DtoTagAnnotation.cs" />
|
||||||
|
<Compile Include="Model\DtoSymbolInfo.cs" />
|
||||||
|
<Compile Include="Model\DtoMText.cs" />
|
||||||
|
<Compile Include="Model\DtoTextInfo.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -60,6 +63,10 @@
|
|||||||
<Project>{9ac724f6-883d-4357-9422-602748f25b69}</Project>
|
<Project>{9ac724f6-883d-4357-9422-602748f25b69}</Project>
|
||||||
<Name>SWS.Commons</Name>
|
<Name>SWS.Commons</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\SWS.Model\SWS.Model.csproj">
|
||||||
|
<Project>{1995385B-D1B0-4C55-835E-D3E769972A6A}</Project>
|
||||||
|
<Name>SWS.Model</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="app.config" />
|
<None Include="app.config" />
|
||||||
|
@ -231,27 +231,7 @@ namespace SWS.CAD
|
|||||||
public static List<Model.TreeModel> designTree = new List<Model.TreeModel>();
|
public static List<Model.TreeModel> designTree = new List<Model.TreeModel>();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public enum dialogPar
|
|
||||||
{
|
|
||||||
id,
|
|
||||||
textYes,
|
|
||||||
textNo,
|
|
||||||
title,
|
|
||||||
OK,
|
|
||||||
unitTypeId,
|
|
||||||
info,
|
|
||||||
unit,
|
|
||||||
para1,
|
|
||||||
para2
|
|
||||||
}
|
|
||||||
//public static IUnityContainer container;
|
|
||||||
//public static IContainerExtension _prismContainer;
|
|
||||||
//public static HttpClient client;
|
|
||||||
//public static loginRes userInfo;
|
|
||||||
//public static List<User> Users;
|
|
||||||
|
|
||||||
public static bool isConfigIniCreateBySys = true;
|
public static bool isConfigIniCreateBySys = true;
|
||||||
//public static string drawingFileId;
|
|
||||||
public static ec_project curProject;
|
public static ec_project curProject;
|
||||||
public static DateTime preClickTime = DateTime.Now;
|
public static DateTime preClickTime = DateTime.Now;
|
||||||
public static Style TransparentComboBoxStyle;
|
public static Style TransparentComboBoxStyle;
|
||||||
@ -322,28 +302,6 @@ namespace SWS.CAD
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//#region 根据ID获取用户名称
|
|
||||||
///// <summary>
|
|
||||||
///// 根据ID获取用户名称
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="id"></param>
|
|
||||||
///// <returns></returns>
|
|
||||||
//public static string GetUserNameById(string id)
|
|
||||||
//{
|
|
||||||
// if (string.IsNullOrEmpty(id))
|
|
||||||
// { return ""; }
|
|
||||||
// var user = Users.FirstOrDefault(a => a.F_UserId == id || a.F_Account == id);
|
|
||||||
// if (user != null)
|
|
||||||
// { return user.F_RealName; }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// return "";
|
|
||||||
// //user = GlobalObject.Users.FirstOrDefault(a => a.F_Account == id);
|
|
||||||
// //return user != null ? user.F_RealName : "";
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//#endregion
|
|
||||||
|
|
||||||
#region 查找子控件
|
#region 查找子控件
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -377,74 +335,5 @@ namespace SWS.CAD
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 判断是否是电缆
|
|
||||||
/// <summary>
|
|
||||||
/// 判断是否是电缆
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static bool IsCable(ec_objecttype obj)
|
|
||||||
{
|
|
||||||
if (obj == null) { return false; }
|
|
||||||
var flag = obj.ObjectTypeName.EndsWith("电缆");
|
|
||||||
return flag;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 取字符串最后的一个或多个数字
|
|
||||||
/// <summary>
|
|
||||||
/// 取字符串最后的一个或多个数字
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input">输入字符串</param>
|
|
||||||
/// <param name="preInput">数字前的字符串</param>
|
|
||||||
/// <param name="num">最后的数字</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static bool GetLastNumber(string input, ref string preInput, ref int num)
|
|
||||||
{
|
|
||||||
string pattern = @"(\d+)$"; // 正则表达式,匹配字符串末尾的一个或多个数字
|
|
||||||
Match match = Regex.Match(input, pattern);
|
|
||||||
if (match.Success)
|
|
||||||
{
|
|
||||||
preInput = input.Substring(0, input.Length - match.Value.Length);
|
|
||||||
num = int.Parse(match.Value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="resName">包括命名空间</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static System.Windows.Media.ImageSource ImageSourceFromEmbeddedResourceStream(string resName)
|
|
||||||
{
|
|
||||||
System.Reflection.Assembly assy = System.Reflection.Assembly.GetExecutingAssembly();
|
|
||||||
//foreach (string resource in assy.GetManifestResourceNames())
|
|
||||||
//{
|
|
||||||
// Console.WriteLine(resource);//遍历所有的内嵌资源
|
|
||||||
//}
|
|
||||||
System.IO.Stream stream = assy.GetManifestResourceStream(resName);
|
|
||||||
if (stream == null)
|
|
||||||
return null;
|
|
||||||
System.Windows.Media.Imaging.BitmapImage img = new System.Windows.Media.Imaging.BitmapImage();
|
|
||||||
img.BeginInit();
|
|
||||||
img.StreamSource = stream;
|
|
||||||
img.EndInit();
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetPCInfo()
|
|
||||||
{
|
|
||||||
string computerName = Environment.MachineName; // 获取计算机名称
|
|
||||||
string userName = Environment.UserName; // 获取当前用户名称
|
|
||||||
|
|
||||||
return $"{computerName} 计算机{userName} 用户";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -432,6 +432,8 @@ namespace SWS.CAD.ViewModels
|
|||||||
{
|
{
|
||||||
foreach (Model.TreeModel node in trees)
|
foreach (Model.TreeModel node in trees)
|
||||||
{
|
{
|
||||||
|
if (node.NodeType == "0"||node.ChildNodes!=null&&node.ChildNodes.Any())
|
||||||
|
{ CheckInOutStatus(node.ChildNodes); }
|
||||||
foreach (var item in node.ChildNodes)
|
foreach (var item in node.ChildNodes)
|
||||||
{
|
{
|
||||||
ec_drawing_file dwgObj = JsonConvert.DeserializeObject<ec_drawing_file>(item.NodeExtData.ToString());
|
ec_drawing_file dwgObj = JsonConvert.DeserializeObject<ec_drawing_file>(item.NodeExtData.ToString());
|
||||||
@ -491,6 +493,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
originDrawings = JsonConvert.DeserializeObject<ObservableCollection<Model.TreeModel>>(data.ToString());
|
originDrawings = JsonConvert.DeserializeObject<ObservableCollection<Model.TreeModel>>(data.ToString());
|
||||||
Drawings = new ObservableCollection<Model.TreeModel>(originDrawings);
|
Drawings = new ObservableCollection<Model.TreeModel>(originDrawings);
|
||||||
Drawings = CheckInOutStatus(Drawings);
|
Drawings = CheckInOutStatus(Drawings);
|
||||||
|
GlobalObject.AllDrawings= Drawings.ToList();
|
||||||
curProjName = "当前项目:" + GlobalObject.curProject.ProjectName;
|
curProjName = "当前项目:" + GlobalObject.curProject.ProjectName;
|
||||||
LoginOK = true;
|
LoginOK = true;
|
||||||
//放置元件列表树
|
//放置元件列表树
|
||||||
@ -756,7 +759,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
/// <param name="model">图纸</param>
|
/// <param name="model">图纸</param>
|
||||||
private async void onOpenDwg(Model.TreeModel model)
|
private async void onOpenDwg(Model.TreeModel model)
|
||||||
{
|
{
|
||||||
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(), model.Text);
|
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(model.ID), model.Text);
|
||||||
var msg = string.Empty;
|
var msg = string.Empty;
|
||||||
var dwgObj = JsonConvert.DeserializeObject<ec_drawing_file>(model.NodeExtData.ToString());
|
var dwgObj = JsonConvert.DeserializeObject<ec_drawing_file>(model.NodeExtData.ToString());
|
||||||
if (dwgObj.IsPublish == 1)
|
if (dwgObj.IsPublish == 1)
|
||||||
@ -797,7 +800,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private async void OpenDwgByMyself(Model.TreeModel model)
|
private async void OpenDwgByMyself(Model.TreeModel model)
|
||||||
{
|
{
|
||||||
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(), model.Text);
|
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(model.ID), model.Text);
|
||||||
var dwgObj = JsonConvert.DeserializeObject<ec_drawing_file>(model.NodeExtData.ToString());
|
var dwgObj = JsonConvert.DeserializeObject<ec_drawing_file>(model.NodeExtData.ToString());
|
||||||
string msg = string.Empty;
|
string msg = string.Empty;
|
||||||
if (!string.IsNullOrEmpty(dwgObj.PCInfo) && !GlobalObject.GetPCInfo().Equals(dwgObj.PCInfo))//对比PCInfo
|
if (!string.IsNullOrEmpty(dwgObj.PCInfo) && !GlobalObject.GetPCInfo().Equals(dwgObj.PCInfo))//对比PCInfo
|
||||||
@ -848,7 +851,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
private async void DownDwgByOpenReadOnly(Model.TreeModel model)
|
private async void DownDwgByOpenReadOnly(Model.TreeModel model)
|
||||||
{
|
{
|
||||||
#region 下载文件,只读打开
|
#region 下载文件,只读打开
|
||||||
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(), model.Text);
|
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(model.ID), model.Text);
|
||||||
var msg = string.Empty;
|
var msg = string.Empty;
|
||||||
var dwgObj = JsonConvert.DeserializeObject<ec_drawing_file>(model.NodeExtData.ToString());
|
var dwgObj = JsonConvert.DeserializeObject<ec_drawing_file>(model.NodeExtData.ToString());
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
@ -860,7 +863,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
}
|
}
|
||||||
//已有本地图纸文件移至备份文件夹
|
//已有本地图纸文件移至备份文件夹
|
||||||
string now = DateTime.Now.ToString("yyyyMMddHHmmss");//加上当前时间,防止重名
|
string now = DateTime.Now.ToString("yyyyMMddHHmmss");//加上当前时间,防止重名
|
||||||
string backFile = Path.Combine(GlobalObject.GetBackupDwgFileFolder(), now + model.Text);
|
string backFile = Path.Combine(GlobalObject.GetBackupDwgFileFolder(model.ID), now + model.Text);
|
||||||
File.Move(filePath, backFile);
|
File.Move(filePath, backFile);
|
||||||
MessageBox.Show($"本地图纸文件已移至:{backFile} !");
|
MessageBox.Show($"本地图纸文件已移至:{backFile} !");
|
||||||
}
|
}
|
||||||
@ -933,7 +936,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
System.Diagnostics.Process.Start(GlobalObject.GetDwgFileFolder());
|
System.Diagnostics.Process.Start(GlobalObject.GetDwgFileFolder(model.ID));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -955,7 +958,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string msg = string.Empty;
|
string msg = string.Empty;
|
||||||
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(), model.Text);
|
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(model.ID), model.Text);
|
||||||
#region 校验
|
#region 校验
|
||||||
|
|
||||||
if (!File.Exists(filePath))
|
if (!File.Exists(filePath))
|
||||||
@ -1086,7 +1089,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
ec_drawing_file dwgObj = model.dwgObj;
|
ec_drawing_file dwgObj = model.dwgObj;
|
||||||
List<string> handles = model.handles;
|
List<string> handles = model.handles;
|
||||||
ec_drawing_syn syn = model.syn;
|
ec_drawing_syn syn = model.syn;
|
||||||
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(), dwgObj.DrawingFileName);
|
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(model.dwgObj.DrawingFileID), dwgObj.DrawingFileName);
|
||||||
//预检入校验
|
//预检入校验
|
||||||
var msg = await _dwgService.PreCheckInDrawingFile(dwgObj, handles);
|
var msg = await _dwgService.PreCheckInDrawingFile(dwgObj, handles);
|
||||||
if (!string.IsNullOrEmpty(msg))
|
if (!string.IsNullOrEmpty(msg))
|
||||||
@ -1155,7 +1158,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task<bool> CheckOut(Model.TreeModel model)
|
private async Task<bool> CheckOut(Model.TreeModel model)
|
||||||
{
|
{
|
||||||
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(), model.Text);
|
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(model.ID), model.Text);
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
if (FileHelper.IsFileLocked(filePath))
|
if (FileHelper.IsFileLocked(filePath))
|
||||||
@ -1163,12 +1166,12 @@ namespace SWS.CAD.ViewModels
|
|||||||
MessageBox.Show($"本地图纸文件:{model.Text} 已存在并被打开,请关闭文件再检出");
|
MessageBox.Show($"本地图纸文件:{model.Text} 已存在并被打开,请关闭文件再检出");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
string backFolder = GlobalObject.GetBackupDwgFileFolder();
|
string backFolder = GlobalObject.GetBackupDwgFileFolder(model.ID);
|
||||||
if (MessageBoxResult.OK == MessageBox.Show($"本地图纸文件:{model.Text} 已存在,继续检出会把本地图纸移至:[{backFolder}]", "是否继续检出", MessageBoxButton.OKCancel, MessageBoxImage.Question))
|
if (MessageBoxResult.OK == MessageBox.Show($"本地图纸文件:{model.Text} 已存在,继续检出会把本地图纸移至:[{backFolder}]", "是否继续检出", MessageBoxButton.OKCancel, MessageBoxImage.Question))
|
||||||
{
|
{
|
||||||
//本地图纸文件移至备份文件夹
|
//本地图纸文件移至备份文件夹
|
||||||
string now = DateTime.Now.ToString("yyyyMMddHHmmss");//加上当前时间,防止重名
|
string now = DateTime.Now.ToString("yyyyMMddHHmmss");//加上当前时间,防止重名
|
||||||
string backFile = Path.Combine(GlobalObject.GetBackupDwgFileFolder(), now + model.Text);
|
string backFile = Path.Combine(GlobalObject.GetBackupDwgFileFolder(model.ID), now + model.Text);
|
||||||
File.Move(filePath, backFile);
|
File.Move(filePath, backFile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1191,7 +1194,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//打开图纸文件
|
//打开图纸文件
|
||||||
filePath = Path.Combine(GlobalObject.GetDwgFileFolder(), model.Text);
|
filePath = Path.Combine(GlobalObject.GetDwgFileFolder(model.ID), model.Text);
|
||||||
msg = General.OpenDwg(filePath);
|
msg = General.OpenDwg(filePath);
|
||||||
|
|
||||||
//更新图纸节点图标和字体颜色
|
//更新图纸节点图标和字体颜色
|
||||||
@ -1225,7 +1228,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
var msg = await _dwgService.FreeDrawingFile(model.ID);
|
var msg = await _dwgService.FreeDrawingFile(model.ID);
|
||||||
if (!string.IsNullOrEmpty(msg))
|
if (!string.IsNullOrEmpty(msg))
|
||||||
{ MessageBox.Show("释放失败,信息:" + msg); return; }
|
{ MessageBox.Show("释放失败,信息:" + msg); return; }
|
||||||
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(), model.Text);
|
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(model.ID), model.Text);
|
||||||
if (!FileHelper.IsFileLocked(filePath))
|
if (!FileHelper.IsFileLocked(filePath))
|
||||||
{ File.Delete(filePath); }//删除本地图纸文件
|
{ File.Delete(filePath); }//删除本地图纸文件
|
||||||
MessageBox.Show("释放成功!");
|
MessageBox.Show("释放成功!");
|
||||||
@ -1531,7 +1534,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
{
|
{
|
||||||
//下载文件
|
//下载文件
|
||||||
var dwgfileDto = await _annexesService.GetAnnexesFile(item.FolderId);
|
var dwgfileDto = await _annexesService.GetAnnexesFile(item.FolderId);
|
||||||
var filePath = Path.Combine(GlobalObject.GetDwgFileFolder(), item.LibraryFileName + ".dwg");
|
var filePath = Path.Combine(GlobalObject.GetDwgFileFolder(id), item.LibraryFileName + ".dwg");
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
{ File.Delete(filePath); }
|
{ File.Delete(filePath); }
|
||||||
msg = await _annexesService.DownloadFile(filePath, dwgfileDto.F_Id);
|
msg = await _annexesService.DownloadFile(filePath, dwgfileDto.F_Id);
|
||||||
@ -1543,7 +1546,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
var img = General.GetDwgThumbnail(filePath);
|
var img = General.GetDwgThumbnail(filePath);
|
||||||
if (img != null)
|
if (img != null)
|
||||||
{
|
{
|
||||||
var imgPath = Path.Combine(GlobalObject.GetDwgFileFolder(), item.LibraryFileName + ".png");
|
var imgPath = Path.Combine(GlobalObject.GetDwgFileFolder(id), item.LibraryFileName + ".png");
|
||||||
if (File.Exists(imgPath))
|
if (File.Exists(imgPath))
|
||||||
{ File.Delete(imgPath); }
|
{ File.Delete(imgPath); }
|
||||||
img.Save(imgPath);
|
img.Save(imgPath);
|
||||||
@ -1675,7 +1678,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
{
|
{
|
||||||
if (model == null) return;
|
if (model == null) return;
|
||||||
if (model.NodeType != "91") return;
|
if (model.NodeType != "91") return;
|
||||||
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(), model.Text);
|
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(model.ID), model.Text);
|
||||||
var pixel = JsonConvert.DeserializeObject<ec_enginedata_pixel>(model.NodeExtData.ToString());
|
var pixel = JsonConvert.DeserializeObject<ec_enginedata_pixel>(model.NodeExtData.ToString());
|
||||||
var dwgObj = await _dwgService.GetDrawingFile(pixel.DrawingFileID);
|
var dwgObj = await _dwgService.GetDrawingFile(pixel.DrawingFileID);
|
||||||
//获取属性
|
//获取属性
|
||||||
@ -1797,7 +1800,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
GlobalObject.ListDwgOpened.Add(new DrawingOpened()
|
GlobalObject.ListDwgOpened.Add(new DrawingOpened()
|
||||||
{
|
{
|
||||||
Id = dwgObj.DrawingFileID,
|
Id = dwgObj.DrawingFileID,
|
||||||
Path = Path.Combine(GlobalObject.GetDwgFileFolder(), dwgObj.DrawingFileName),
|
Path = Path.Combine(GlobalObject.GetDwgFileFolder(dwgObj.DrawingFileID), dwgObj.DrawingFileName),
|
||||||
IsReadOnly = isReadOnly
|
IsReadOnly = isReadOnly
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1815,7 +1818,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
GlobalObject.ListDwgOpened.Add(new DrawingOpened()
|
GlobalObject.ListDwgOpened.Add(new DrawingOpened()
|
||||||
{
|
{
|
||||||
Id = dwgObj.ID,
|
Id = dwgObj.ID,
|
||||||
Path = Path.Combine(GlobalObject.GetDwgFileFolder(), dwgObj.Text),
|
Path = Path.Combine(GlobalObject.GetDwgFileFolder(dwgObj.ID), dwgObj.Text),
|
||||||
IsReadOnly = isReadOnly
|
IsReadOnly = isReadOnly
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2138,7 +2141,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
private async void onReadOnlyOpenDwg(Model.TreeModel model)
|
private async void onReadOnlyOpenDwg(Model.TreeModel model)
|
||||||
{
|
{
|
||||||
#region 下载文件,只读打开
|
#region 下载文件,只读打开
|
||||||
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(), model.Text);
|
string filePath = Path.Combine(GlobalObject.GetDwgFileFolder(model.ID), model.Text);
|
||||||
var msg = string.Empty;
|
var msg = string.Empty;
|
||||||
var dwgPublishObj = JsonConvert.DeserializeObject<ec_drawing_publish>(model.NodeExtData.ToString());
|
var dwgPublishObj = JsonConvert.DeserializeObject<ec_drawing_publish>(model.NodeExtData.ToString());
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
@ -2214,7 +2217,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
{
|
{
|
||||||
string tagNum = string.Empty;
|
string tagNum = string.Empty;
|
||||||
var tagNumber = RES.Parameters.GetValue<string>(GlobalObject.dialogPar.info.ToString());
|
var tagNumber = RES.Parameters.GetValue<string>(GlobalObject.dialogPar.info.ToString());
|
||||||
var dgwFilePath = Path.Combine(GlobalObject.GetDwgFileFolder(), dwgLibrary.LibraryFileName + ".dwg");
|
var dgwFilePath = Path.Combine(GlobalObject.GetDwgFileFolder(dwgFile.Id), dwgLibrary.LibraryFileName + ".dwg");
|
||||||
var objId = General.InsertExternalDWG(dgwFilePath, tagNumber, ref tagNum);
|
var objId = General.InsertExternalDWG(dgwFilePath, tagNumber, ref tagNum);
|
||||||
#region 图纸上保存图元属性
|
#region 图纸上保存图元属性
|
||||||
if (!objId.IsNull)
|
if (!objId.IsNull)
|
||||||
|
@ -353,7 +353,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
//根据模板实体的FolderId,获取上传文件的实体
|
//根据模板实体的FolderId,获取上传文件的实体
|
||||||
var dwgfileDto = await _annexesService.GetAnnexesFile(templatefileDto.FolderId);
|
var dwgfileDto = await _annexesService.GetAnnexesFile(templatefileDto.FolderId);
|
||||||
// 指定新 DWG 文件的保存路径
|
// 指定新 DWG 文件的保存路径
|
||||||
string folderPath = GlobalObject.GetDwgFileFolder();
|
string folderPath = GlobalObject.GetDwgFileFolder(dwgObj.DrawingCatalogueID);
|
||||||
string filePath = Path.Combine(folderPath, dwgObj.DrawingFileName);
|
string filePath = Path.Combine(folderPath, dwgObj.DrawingFileName);
|
||||||
var msg = await _annexesService.DownloadFile(filePath, dwgfileDto.F_Id);
|
var msg = await _annexesService.DownloadFile(filePath, dwgfileDto.F_Id);
|
||||||
if (!string.IsNullOrEmpty(msg))
|
if (!string.IsNullOrEmpty(msg))
|
||||||
@ -414,7 +414,7 @@ namespace SWS.CAD.ViewModels
|
|||||||
//旧图纸文件名和新图纸文件名不一致,则修改本地图纸文件名
|
//旧图纸文件名和新图纸文件名不一致,则修改本地图纸文件名
|
||||||
if (oldDwgFileName != dwgObj.DrawingFileName)
|
if (oldDwgFileName != dwgObj.DrawingFileName)
|
||||||
{
|
{
|
||||||
string folderPath = GlobalObject.GetDwgFileFolder();
|
string folderPath = GlobalObject.GetDwgFileFolder(dwgObj.DrawingFileID);
|
||||||
var oldFilePath = Path.Combine(folderPath, oldDwgFileName);
|
var oldFilePath = Path.Combine(folderPath, oldDwgFileName);
|
||||||
if (FileHelper.IsFileLocked(oldFilePath))
|
if (FileHelper.IsFileLocked(oldFilePath))
|
||||||
{
|
{
|
||||||
|
@ -36,10 +36,7 @@ namespace SWS.CAD.ViewModels.myViewModelBase
|
|||||||
//Application.ShowModalDialog(Application.MainWindow,);// 用来显示WinForms对话框
|
//Application.ShowModalDialog(Application.MainWindow,);// 用来显示WinForms对话框
|
||||||
Application.ShowModalWindow(Application.MainWindow.Handle, loginView);//用来显示WPF的对话框,任务栏里可以看到2个Windows
|
Application.ShowModalWindow(Application.MainWindow.Handle, loginView);//用来显示WPF的对话框,任务栏里可以看到2个Windows
|
||||||
|
|
||||||
//if (GlobalObject.userInfo == null)
|
|
||||||
//{
|
|
||||||
// CloseWindowAction?.Invoke();//依旧没登录上的话,放这里没用,因为这个时候,主体还没加载呢
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GlobalObject.curProject == null)
|
if (GlobalObject.curProject == null)
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
x:Class="SWS.CAD.Views.LeftPanel"
|
x:Class="SWS.CAD.Views.LeftPanel"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:Behaviors="clr-namespace:SWS.Commons.Helper.Behaviours;assembly=SWS.Commons"
|
||||||
xmlns:converter="clr-namespace:SWS.CAD.Converter"
|
xmlns:converter="clr-namespace:SWS.CAD.Converter"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
xmlns:local="clr-namespace:SWS.CAD.Views"
|
xmlns:local="clr-namespace:SWS.CAD.Views"
|
||||||
xmlns:local2="clr-namespace:SWS.Model;assembly=SWS.Model"
|
xmlns:local2="clr-namespace:SWS.Model;assembly=SWS.Model"
|
||||||
xmlns:Behaviors="clr-namespace:SWS.Commons.Helper.Behaviours;assembly=SWS.Commons"
|
|
||||||
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
|
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
|
||||||
Width="250"
|
Width="250"
|
||||||
Loaded="UserControl_Loaded">
|
Loaded="UserControl_Loaded">
|
||||||
@ -188,12 +188,12 @@
|
|||||||
x:Name="radTreeView"
|
x:Name="radTreeView"
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
Background="Transparent"
|
|
||||||
Margin="-5,0,0,0"
|
Margin="-5,0,0,0"
|
||||||
|
Behaviors:TreeViewSelectedItemBehavior.SelectedItem="{Binding selectedNode, Mode=TwoWay}"
|
||||||
|
Background="Transparent"
|
||||||
FontSize="11"
|
FontSize="11"
|
||||||
ItemsSource="{Binding Drawings}"
|
ItemsSource="{Binding Drawings}"
|
||||||
PreviewMouseRightButtonDown="RadTreeView_PreviewMouseRightButtonDown"
|
PreviewMouseRightButtonDown="RadTreeView_PreviewMouseRightButtonDown">
|
||||||
Behaviors:TreeViewSelectedItemBehavior.SelectedItem="{Binding selectedNode, Mode=TwoWay}">
|
|
||||||
<TreeView.ItemTemplate>
|
<TreeView.ItemTemplate>
|
||||||
<HierarchicalDataTemplate DataType="{x:Type local2:TreeModel}" ItemsSource="{Binding ChildNodes}">
|
<HierarchicalDataTemplate DataType="{x:Type local2:TreeModel}" ItemsSource="{Binding ChildNodes}">
|
||||||
<StackPanel
|
<StackPanel
|
||||||
@ -227,11 +227,11 @@
|
|||||||
<TreeView
|
<TreeView
|
||||||
x:Name="treeDwgHistory"
|
x:Name="treeDwgHistory"
|
||||||
Margin="-5,0,0,0"
|
Margin="-5,0,0,0"
|
||||||
|
Behaviors:TreeViewSelectedItemBehavior.SelectedItem="{Binding selectedHistoryDwg, Mode=TwoWay}"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
FontSize="11"
|
FontSize="11"
|
||||||
ItemsSource="{Binding historyDrawings}"
|
ItemsSource="{Binding historyDrawings}"
|
||||||
PreviewMouseRightButtonDown="treeDwgHistory_PreviewMouseRightButtonDown"
|
PreviewMouseRightButtonDown="treeDwgHistory_PreviewMouseRightButtonDown">
|
||||||
Behaviors:TreeViewSelectedItemBehavior.SelectedItem="{Binding selectedHistoryDwg, Mode=TwoWay}">
|
|
||||||
<TreeView.ItemContainerStyle>
|
<TreeView.ItemContainerStyle>
|
||||||
<Style TargetType="telerik:RadTreeViewItem">
|
<Style TargetType="telerik:RadTreeViewItem">
|
||||||
<Setter Property="IsExpanded" Value="{Binding isexpand, Mode=TwoWay, Converter={StaticResource expandConverter}}" />
|
<Setter Property="IsExpanded" Value="{Binding isexpand, Mode=TwoWay, Converter={StaticResource expandConverter}}" />
|
||||||
@ -341,10 +341,10 @@
|
|||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
Margin="-5,0,0,0"
|
Margin="-5,0,0,0"
|
||||||
|
Behaviors:TreeViewSelectedItemBehavior.SelectedItem="{Binding selectType, Mode=TwoWay}"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
FontSize="11"
|
FontSize="11"
|
||||||
ItemsSource="{Binding objectTypeTree}"
|
ItemsSource="{Binding objectTypeTree}">
|
||||||
Behaviors:TreeViewSelectedItemBehavior.SelectedItem="{Binding selectType, Mode=TwoWay}">
|
|
||||||
<TreeView.ItemTemplate>
|
<TreeView.ItemTemplate>
|
||||||
<HierarchicalDataTemplate DataType="{x:Type local2:TreeModel}" ItemsSource="{Binding ChildNodes}">
|
<HierarchicalDataTemplate DataType="{x:Type local2:TreeModel}" ItemsSource="{Binding ChildNodes}">
|
||||||
<StackPanel Height="16" Orientation="Horizontal">
|
<StackPanel Height="16" Orientation="Horizontal">
|
||||||
@ -388,8 +388,8 @@
|
|||||||
<telerik:EventToCommandBehavior.EventBindings>
|
<telerik:EventToCommandBehavior.EventBindings>
|
||||||
<telerik:EventBinding
|
<telerik:EventBinding
|
||||||
Command="{Binding Command_TagDoubleClick}"
|
Command="{Binding Command_TagDoubleClick}"
|
||||||
EventName="MouseDoubleClick"
|
|
||||||
CommandParameter="{Binding ElementName=tagListBox, Path=SelectedItem}"
|
CommandParameter="{Binding ElementName=tagListBox, Path=SelectedItem}"
|
||||||
|
EventName="MouseDoubleClick"
|
||||||
PassEventArgsToCommand="True" />
|
PassEventArgsToCommand="True" />
|
||||||
</telerik:EventToCommandBehavior.EventBindings>
|
</telerik:EventToCommandBehavior.EventBindings>
|
||||||
<telerik:RadListBox.GroupStyle>
|
<telerik:RadListBox.GroupStyle>
|
||||||
@ -441,10 +441,10 @@
|
|||||||
<TreeView
|
<TreeView
|
||||||
x:Name="designTreeView"
|
x:Name="designTreeView"
|
||||||
Margin="-5,0,0,0"
|
Margin="-5,0,0,0"
|
||||||
|
Behaviors:TreeViewSelectedItemBehavior.SelectedItem="{Binding selectDesign, Mode=TwoWay}"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
FontSize="11"
|
FontSize="11"
|
||||||
ItemsSource="{Binding designTree}"
|
ItemsSource="{Binding designTree}">
|
||||||
Behaviors:TreeViewSelectedItemBehavior.SelectedItem="{Binding selectDesign, Mode=TwoWay}">
|
|
||||||
<!--<i:Interaction.Triggers>
|
<!--<i:Interaction.Triggers>
|
||||||
<i:EventTrigger EventName="SelectionChanged">
|
<i:EventTrigger EventName="SelectionChanged">
|
||||||
<i:InvokeCommandAction
|
<i:InvokeCommandAction
|
||||||
@ -462,13 +462,13 @@
|
|||||||
<telerik:EventToCommandBehavior.EventBindings>
|
<telerik:EventToCommandBehavior.EventBindings>
|
||||||
<telerik:EventBinding
|
<telerik:EventBinding
|
||||||
Command="{Binding Common_SelectedDesign}"
|
Command="{Binding Common_SelectedDesign}"
|
||||||
EventName="SelectedItemChanged"
|
|
||||||
CommandParameter="{Binding ElementName=designTreeView, Path=SelectedItem}"
|
CommandParameter="{Binding ElementName=designTreeView, Path=SelectedItem}"
|
||||||
|
EventName="SelectedItemChanged"
|
||||||
PassEventArgsToCommand="True" />
|
PassEventArgsToCommand="True" />
|
||||||
<telerik:EventBinding
|
<telerik:EventBinding
|
||||||
Command="{Binding Common_DoubleClickDesign}"
|
Command="{Binding Common_DoubleClickDesign}"
|
||||||
EventName="MouseDoubleClick"
|
|
||||||
CommandParameter="{Binding ElementName=designTreeView, Path=SelectedItem}"
|
CommandParameter="{Binding ElementName=designTreeView, Path=SelectedItem}"
|
||||||
|
EventName="MouseDoubleClick"
|
||||||
PassEventArgsToCommand="True" />
|
PassEventArgsToCommand="True" />
|
||||||
</telerik:EventToCommandBehavior.EventBindings>
|
</telerik:EventToCommandBehavior.EventBindings>
|
||||||
<TreeView.ItemContainerStyle>
|
<TreeView.ItemContainerStyle>
|
||||||
|
@ -179,9 +179,9 @@ namespace SWS.Commons
|
|||||||
/// 图纸文件所在文件夹
|
/// 图纸文件所在文件夹
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string GetDwgFileFolder()
|
public static string GetDwgFileFolder(string dwgID)
|
||||||
{
|
{
|
||||||
string path = Path.Combine(GetLocalFileDirectory(), curProject.ProjectIndex.ToString());
|
string path = Path.Combine(GetLocalFileDirectory(), curProject.ProjectName, GetDwgPath(dwgID));
|
||||||
if (!Directory.Exists(path))
|
if (!Directory.Exists(path))
|
||||||
Directory.CreateDirectory(path);
|
Directory.CreateDirectory(path);
|
||||||
return path;
|
return path;
|
||||||
@ -193,9 +193,9 @@ namespace SWS.Commons
|
|||||||
/// 图纸文件备份文件夹
|
/// 图纸文件备份文件夹
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string GetBackupDwgFileFolder()
|
public static string GetBackupDwgFileFolder(string dwgID)
|
||||||
{
|
{
|
||||||
string path = Path.Combine(GetDwgFileFolder(), "Backup");
|
string path = Path.Combine(GetDwgFileFolder(dwgID), "Backup");
|
||||||
if (!Directory.Exists(path))
|
if (!Directory.Exists(path))
|
||||||
Directory.CreateDirectory(path);
|
Directory.CreateDirectory(path);
|
||||||
return path;
|
return path;
|
||||||
@ -289,6 +289,8 @@ namespace SWS.Commons
|
|||||||
if (!AllDrawings.Any())
|
if (!AllDrawings.Any())
|
||||||
{ return fullpath; }
|
{ return fullpath; }
|
||||||
fullpath = GetParentPath(dwgID);
|
fullpath = GetParentPath(dwgID);
|
||||||
|
if (string.IsNullOrEmpty(fullpath))
|
||||||
|
{ return "Temp\\"; }
|
||||||
return fullpath;
|
return fullpath;
|
||||||
}
|
}
|
||||||
private static string GetParentPath(string dwgID)
|
private static string GetParentPath(string dwgID)
|
||||||
|
@ -58,6 +58,46 @@ namespace SWS.Commons
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 获取树节点
|
||||||
|
/// <summary>
|
||||||
|
/// 获取树节点
|
||||||
|
/// </summary>
|
||||||
|
public static Model.TreeModel GetTreeModelByText(List<Model.TreeModel> nodes, string text)
|
||||||
|
{
|
||||||
|
Model.TreeModel node = null;
|
||||||
|
foreach (var dto in nodes)
|
||||||
|
{
|
||||||
|
//获取节点下的图纸
|
||||||
|
node = TreeHelper.GetTreeModelByText(dto, text);
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
public static Model.TreeModel GetTreeModelByText(TreeModel node, string text)
|
||||||
|
{
|
||||||
|
// 如果根节点为空,则返回null
|
||||||
|
if (node == null) return null;
|
||||||
|
// 如果找到当前节点,返回当前节点
|
||||||
|
if (node.Text == text) return node;
|
||||||
|
//没有子节点就返回null
|
||||||
|
if (node.ChildNodes == null) return null;
|
||||||
|
// 否则,递归地在子节点中查找
|
||||||
|
foreach (var child in node.ChildNodes)
|
||||||
|
{
|
||||||
|
var result = GetTreeModelByText(child, text);
|
||||||
|
if (result != null)
|
||||||
|
{
|
||||||
|
return result; // 找到后立即返回
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果在当前树中没有找到,返回null
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 获取树节点所有图纸名
|
#region 获取树节点所有图纸名
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@ -11,6 +12,7 @@ using Bricscad.Windows;
|
|||||||
using Prism.Events;
|
using Prism.Events;
|
||||||
using Prism.Ioc;
|
using Prism.Ioc;
|
||||||
using Prism.Services.Dialogs;
|
using Prism.Services.Dialogs;
|
||||||
|
using SWS.CAD.Base;
|
||||||
using SWS.Commons;
|
using SWS.Commons;
|
||||||
using SWS.Electrical;
|
using SWS.Electrical;
|
||||||
using SWS.Electrical.Views;
|
using SWS.Electrical.Views;
|
||||||
@ -150,7 +152,7 @@ namespace SWS.Electrical
|
|||||||
RibbonButton btnMenu = new RibbonButton();
|
RibbonButton btnMenu = new RibbonButton();
|
||||||
btnMenu.ToolTip = "测试绘图";
|
btnMenu.ToolTip = "测试绘图";
|
||||||
btnMenu.Text = "测试绘图";
|
btnMenu.Text = "测试绘图";
|
||||||
btnMenu.ButtonStyle = RibbonButtonStyle.SmallWithText;
|
btnMenu.ButtonStyle = RibbonButtonStyle.LargeWithText;
|
||||||
btnMenu.CommandHandler = new DelegateCommand(async x =>
|
btnMenu.CommandHandler = new DelegateCommand(async x =>
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -207,7 +209,7 @@ namespace SWS.Electrical
|
|||||||
btnMenu = new RibbonButton();
|
btnMenu = new RibbonButton();
|
||||||
btnMenu.ToolTip = "信号管理";
|
btnMenu.ToolTip = "信号管理";
|
||||||
btnMenu.Text = "信号管理";
|
btnMenu.Text = "信号管理";
|
||||||
btnMenu.ButtonStyle = RibbonButtonStyle.SmallWithText;
|
btnMenu.ButtonStyle = RibbonButtonStyle.LargeWithText;
|
||||||
btnMenu.CommandHandler = new DelegateCommand(async x =>
|
btnMenu.CommandHandler = new DelegateCommand(async x =>
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -256,7 +258,7 @@ namespace SWS.Electrical
|
|||||||
btnMenu = new RibbonButton();
|
btnMenu = new RibbonButton();
|
||||||
btnMenu.ToolTip = "布置图自动绘制";
|
btnMenu.ToolTip = "布置图自动绘制";
|
||||||
btnMenu.Text = "布置图自动绘制";
|
btnMenu.Text = "布置图自动绘制";
|
||||||
btnMenu.ButtonStyle = RibbonButtonStyle.SmallWithText;
|
btnMenu.ButtonStyle = RibbonButtonStyle.LargeWithText;
|
||||||
btnMenu.CommandHandler = new DelegateCommand(async x =>
|
btnMenu.CommandHandler = new DelegateCommand(async x =>
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -306,7 +308,7 @@ namespace SWS.Electrical
|
|||||||
btnMenu = new RibbonButton();
|
btnMenu = new RibbonButton();
|
||||||
btnMenu.ToolTip = "材料表自动生成";
|
btnMenu.ToolTip = "材料表自动生成";
|
||||||
btnMenu.Text = "材料表自动生成";
|
btnMenu.Text = "材料表自动生成";
|
||||||
btnMenu.ButtonStyle = RibbonButtonStyle.SmallWithText;
|
btnMenu.ButtonStyle = RibbonButtonStyle.LargeWithText;
|
||||||
btnMenu.CommandHandler = new DelegateCommand(async x =>
|
btnMenu.CommandHandler = new DelegateCommand(async x =>
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -340,6 +342,65 @@ namespace SWS.Electrical
|
|||||||
dataSource.Items.Add(ribbonRowPanel);
|
dataSource.Items.Add(ribbonRowPanel);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Ribbon 图形刷新
|
||||||
|
RibbonPanelSource dwgRefreshSource = new RibbonPanelSource();
|
||||||
|
dwgRefreshSource.Title = "图形刷新";
|
||||||
|
dwgRefreshSource.Id = "图形刷新";
|
||||||
|
RibbonPanel dwgRefreshPanel = new RibbonPanel();
|
||||||
|
dwgRefreshPanel.Source = dwgRefreshSource;
|
||||||
|
tab1.Panels.Add(dwgRefreshPanel);
|
||||||
|
//大按钮
|
||||||
|
#region buttons 刷新标注
|
||||||
|
RibbonButton btnRefreshText = new RibbonButton();
|
||||||
|
btnRefreshText.ToolTip = "刷新标注";
|
||||||
|
btnRefreshText.Text = "刷新标注";
|
||||||
|
btnRefreshText.ButtonStyle = RibbonButtonStyle.LargeWithText;
|
||||||
|
btnRefreshText.CommandHandler = new DelegateCommand(async x =>
|
||||||
|
{
|
||||||
|
//打开窗体
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var flag = await GlobalObj.CheckLogin();
|
||||||
|
if (!flag)
|
||||||
|
{
|
||||||
|
MessageBox.Show("登录已过期,请重新登录!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var curName = General.GetDwgName();
|
||||||
|
var index = curName.LastIndexOf("\\");
|
||||||
|
if (index == -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先在左侧图纸树中打开图纸!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var dwgName = curName.Substring(index+1);//获取当前图纸名称
|
||||||
|
var _ServiceDrawing = GlobalObject.container.Resolve<DrawingServce>();
|
||||||
|
var list = await _ServiceDrawing.GetDrawingCatalogue();
|
||||||
|
GlobalObject.AllDrawings = list.ToList();
|
||||||
|
var node = TreeHelper.GetTreeModelByText(GlobalObject.AllDrawings, dwgName);//从图纸树中获取当前节点
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("当前图纸不是系统图纸,请先在左侧图纸树中打开图纸!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var para = new DialogParameters();
|
||||||
|
para.Add(GlobalObject.dialogPar.para1.ToString(), node);
|
||||||
|
var _dialogService = GlobalObject._prismContainer.Resolve<IDialogService>();
|
||||||
|
_dialogService.ShowDialog(nameof(DialogRefreshAnnotation), para, (RES) =>
|
||||||
|
{
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
btnRefreshText.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshText.png");
|
||||||
|
btnRefreshText.Id = "刷新标注";
|
||||||
|
dwgRefreshSource.Items.Add(btnRefreshText);
|
||||||
|
#endregion
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Terminate()
|
public void Terminate()
|
||||||
|
69
newFront/c#前端/SWS.Electrical/Models/DtoAnnotation.cs
Normal file
69
newFront/c#前端/SWS.Electrical/Models/DtoAnnotation.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SWS.Model;
|
||||||
|
using Telerik.Windows.Controls;
|
||||||
|
|
||||||
|
namespace SWS.Electrical.Models
|
||||||
|
{
|
||||||
|
public class DtoAnnotation : DtoDrawing
|
||||||
|
{
|
||||||
|
private string _Status;
|
||||||
|
/// <summary>
|
||||||
|
/// 已刷新 未刷新
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string Status
|
||||||
|
{
|
||||||
|
get { return _Status; }
|
||||||
|
set { _Status = value; RaisePropertyChanged(nameof(Status)); }
|
||||||
|
}
|
||||||
|
private string _ObjectTypeName;
|
||||||
|
/// <summary>
|
||||||
|
/// 元件类型
|
||||||
|
/// </summary>
|
||||||
|
public string ObjectTypeName
|
||||||
|
{
|
||||||
|
get { return _ObjectTypeName; }
|
||||||
|
set { _ObjectTypeName = value; RaisePropertyChanged(nameof(ObjectTypeName)); }
|
||||||
|
}
|
||||||
|
private string _TagNumber;
|
||||||
|
/// <summary>
|
||||||
|
/// 元件位号
|
||||||
|
/// </summary>
|
||||||
|
public string TagNumber
|
||||||
|
{
|
||||||
|
get { return _TagNumber; }
|
||||||
|
set { _TagNumber = value; RaisePropertyChanged(nameof(TagNumber)); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 元件句柄
|
||||||
|
/// </summary>
|
||||||
|
public string TagHandid { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 属性名
|
||||||
|
/// </summary>
|
||||||
|
public string AttributeName { get; set; }
|
||||||
|
|
||||||
|
private string _AttributeValue;
|
||||||
|
/// <summary>
|
||||||
|
/// 属性值
|
||||||
|
/// </summary>
|
||||||
|
public string AttributeValue
|
||||||
|
{
|
||||||
|
get { return _AttributeValue; }
|
||||||
|
set { _AttributeValue = value; RaisePropertyChanged(nameof(AttributeValue)); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 标注句柄
|
||||||
|
/// </summary>
|
||||||
|
public string AnnotationHandid { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 标注值
|
||||||
|
/// </summary>
|
||||||
|
public string AnnotationValue { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -135,14 +135,19 @@
|
|||||||
<Compile Include="Control\ListBoxScrollToBottomBehavior.cs" />
|
<Compile Include="Control\ListBoxScrollToBottomBehavior.cs" />
|
||||||
<Compile Include="Event\checkInEvent.cs" />
|
<Compile Include="Event\checkInEvent.cs" />
|
||||||
<Compile Include="GlobalObj.cs" />
|
<Compile Include="GlobalObj.cs" />
|
||||||
|
<Compile Include="Models\DtoAnnotation.cs" />
|
||||||
<Compile Include="Models\DtoBomDrawings.cs" />
|
<Compile Include="Models\DtoBomDrawings.cs" />
|
||||||
<Compile Include="Models\DtoAutoPlotLayout.cs" />
|
<Compile Include="Models\DtoAutoPlotLayout.cs" />
|
||||||
<Compile Include="Models\DtoDrawing.cs" />
|
<Compile Include="Models\DtoDrawing.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Start.cs" />
|
<Compile Include="Start.cs" />
|
||||||
|
<Compile Include="ViewModels\DialogRefreshAnnotationViewModel.cs" />
|
||||||
<Compile Include="ViewModels\DialogGenerateBOMViewModel.cs" />
|
<Compile Include="ViewModels\DialogGenerateBOMViewModel.cs" />
|
||||||
<Compile Include="ViewModels\DialogAutoArrangeLayoutViewModel.cs" />
|
<Compile Include="ViewModels\DialogAutoArrangeLayoutViewModel.cs" />
|
||||||
<Compile Include="ViewModels\DialogTest2ViewModel.cs" />
|
<Compile Include="ViewModels\DialogTest2ViewModel.cs" />
|
||||||
|
<Compile Include="Views\DialogRefreshAnnotation.xaml.cs">
|
||||||
|
<DependentUpon>DialogRefreshAnnotation.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\DialogGenerateBOM.xaml.cs">
|
<Compile Include="Views\DialogGenerateBOM.xaml.cs">
|
||||||
<DependentUpon>DialogGenerateBOM.xaml</DependentUpon>
|
<DependentUpon>DialogGenerateBOM.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -209,6 +214,10 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\DialogRefreshAnnotation.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\DialogGenerateBOM.xaml">
|
<Page Include="Views\DialogGenerateBOM.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
@ -68,6 +68,7 @@ namespace SWS.Electrical
|
|||||||
GlobalObject._prismContainer.RegisterDialog<DialogAssociatedSignal, DialogAssociatedSignalViewModel>();
|
GlobalObject._prismContainer.RegisterDialog<DialogAssociatedSignal, DialogAssociatedSignalViewModel>();
|
||||||
GlobalObject._prismContainer.RegisterDialog<DialogAutoArrangeLayout, DialogAutoArrangeLayoutViewModel>();
|
GlobalObject._prismContainer.RegisterDialog<DialogAutoArrangeLayout, DialogAutoArrangeLayoutViewModel>();
|
||||||
GlobalObject._prismContainer.RegisterDialog<DialogGenerateBOM, DialogGenerateBOMViewModel>();
|
GlobalObject._prismContainer.RegisterDialog<DialogGenerateBOM, DialogGenerateBOMViewModel>();
|
||||||
|
GlobalObject._prismContainer.RegisterDialog<DialogRefreshAnnotation, DialogRefreshAnnotationViewModel>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ namespace SWS.Electrical
|
|||||||
GlobalObject.client = new HttpClient()
|
GlobalObject.client = new HttpClient()
|
||||||
{
|
{
|
||||||
BaseAddress = new Uri($"{strDomain}/api/"),
|
BaseAddress = new Uri($"{strDomain}/api/"),
|
||||||
Timeout = TimeSpan.FromSeconds(120)
|
Timeout = TimeSpan.FromSeconds(200)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (dbType == "0")
|
else if (dbType == "0")
|
||||||
@ -99,7 +100,7 @@ namespace SWS.Electrical
|
|||||||
GlobalObject.client = new HttpClient()
|
GlobalObject.client = new HttpClient()
|
||||||
{
|
{
|
||||||
BaseAddress = new Uri($"http://{address}:{port}/api/"),
|
BaseAddress = new Uri($"http://{address}:{port}/api/"),
|
||||||
Timeout = TimeSpan.FromSeconds(120)
|
Timeout = TimeSpan.FromSeconds(200)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
GlobalObject.client.DefaultRequestHeaders.Add("logintoken", token);
|
GlobalObject.client.DefaultRequestHeaders.Add("logintoken", token);
|
||||||
@ -110,12 +111,10 @@ namespace SWS.Electrical
|
|||||||
{
|
{
|
||||||
//第一次要在后台初始化一些数据
|
//第一次要在后台初始化一些数据
|
||||||
var projectService = GlobalObject.container.Resolve<ProjectService>();
|
var projectService = GlobalObject.container.Resolve<ProjectService>();
|
||||||
var listProjects = (await projectService.GetProjects(1, 1000)).Rows;
|
GlobalObject.curProject = await projectService.GetEntity(curProjId);
|
||||||
var p = listProjects.FirstOrDefault(a => a.ProjectId == curProjId);
|
//var obj = await projectService.InitProjInfo(curProjId, "");
|
||||||
GlobalObject.curProject = p;
|
//var treeData = obj.First(x => (string)x["Name"] == "图纸树(按目录)")["data"];
|
||||||
var obj = await projectService.InitProjInfo(curProjId, "");
|
//GlobalObj.treeDrawings = JsonConvert.DeserializeObject<List<TreeModel>>(treeData.ToString());
|
||||||
var treeData = obj.First(x => (string)x["Name"] == "图纸树(按目录)")["data"];
|
|
||||||
GlobalObj.treeDrawings = JsonConvert.DeserializeObject<List<TreeModel>>(treeData.ToString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
Binary file not shown.
@ -2,7 +2,7 @@
|
|||||||
"Width": 230,
|
"Width": 230,
|
||||||
"Height": 320,
|
"Height": 320,
|
||||||
"RowPageCount": 5,
|
"RowPageCount": 5,
|
||||||
"RowCount": 6,
|
"RowCount": 10,
|
||||||
"RowHeight": 20,
|
"RowHeight": 20,
|
||||||
"Column1X": 37,
|
"Column1X": 37,
|
||||||
"Column1Y": 245,
|
"Column1Y": 245,
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
|
|
||||||
--------------- 19-09-2025 10:11:59 --------------- v21.2.04.0 ---------------
|
|
||||||
Exception:
|
|
||||||
ACCESS_VIOLATION (C0000005) in module ntdll.dll at 0033:00007FF9E5D49821
|
|
||||||
Registers:
|
|
||||||
RAX=lX RBX=lX RCX=lX RDX=lX RSI=lX RDI=lX RBP=lX RSP=lX RIP=lX EFL=00000000 CS=17E0000 DS=100000 SS=91BA ES=2EFEB970 FS=2EF80E90 GS=2EFEB970
|
|
||||||
|
|
||||||
Call stack (current) (main):
|
|
||||||
RtlDeleteBoundaryDescriptor()+0x0000000000000221, (0x00000000017E0000 0x000000002EFEB97F 0x000000002EFEB970 0x000000002EFEB980), ntdll.dll, 0x00007FF9E5D49821
|
|
||||||
RtlGetCurrentServiceSessionId()+0x0000000000001294, (0x000000002EFEB970 0x00000000017E0000 0x000000002F2EE640 0x0000000000000000), ntdll.dll, 0x00007FF9E5D4C374
|
|
||||||
RtlFreeHeap()+0x0000000000000051, (0x000000002F30CC20 0x0000000000000001 0x000000000171F838 0x000000002F2EE640), ntdll.dll, 0x00007FF9E5D4B041
|
|
||||||
free_base()+0x000000000000001B, (0x000000002F2D48E0 0x00007FF900000000 0x000000000171F838 0x000000002F2EE640), ucrtbase.dll, 0x00007FF9E2EB364B
|
|
||||||
OdString::freeData()+0x0000000000000027, (0x000000002F2F12E0 0x00007FF9E5D4B041 0x000000002F2F12D0 0x00000000017E0000), TD_Root_21.4_15.dll, 0x00000001800460F7
|
|
||||||
ut::ConfigNode::operator=()+0x00000000000000B5, (0x000000002F30C9E0 0x000000002F2D4260 0x000000002F2F13A0 0x000000002F2F12E0), bcutils.dll, 0x0000000180013615
|
|
||||||
ut::Config::resetProfile()+0x0000000000000810, (0x000000002F2D4340 0x000000002F2EE640 0x000000002F2F13A0 0x00007FF9E5D4B041), bcutils.dll, 0x0000000180026010
|
|
||||||
ut::ConfigNode::ConfigNode()+0x0000000000001142, (0x000000002F2D4340 0x000000002F2EE640 0x000000002F2F1C60 0x000000000B3C6010), bcutils.dll, 0x000000018002D4C2
|
|
||||||
ut::ConfigNode::ConfigNode()+0x000000000000111F, (0x000000002F2D4340 0x000000002F2EE640 0x000000002F2F0D60 0x00007FF9E5D4B041), bcutils.dll, 0x000000018002D49F
|
|
||||||
ut::ConfigNode::ConfigNode()+0x000000000000111F, (0x000000002F2D4340 0x000000002F2EE640 0x000000002F2F0660 0x000000002E351440), bcutils.dll, 0x000000018002D49F
|
|
||||||
ut::ConfigNode::ConfigNode()+0x000000000000111F, (0x000000002F2EE4A0 0x000000002F2EE640 0x000000002F2EFD60 0x000000002E351380), bcutils.dll, 0x000000018002D49F
|
|
||||||
ut::ConfigNode::ConfigNode()+0x000000000000111F, (0x000000002F2EE4A0 0x000000002F0E7080 0x000000002F2EEAA0 0x000000000A34EE50), bcutils.dll, 0x000000018002D49F
|
|
||||||
ut::ConfigNode::ConfigNode()+0x0000000000000F95, (0x0000000000000000 0x000000002F2EE640 0x000000002F2EE620 0x00007FF9E5D4B041), bcutils.dll, 0x000000018002D315
|
|
||||||
ut::ConfigNode::ConfigNode()+0x0000000000000149, (0x000000002F2EE620 0x00007FF9E2EB364B 0x000000002F2EE640 0x000000002F2F3620), bcutils.dll, 0x000000018002C4C9
|
|
||||||
ut::Config::resetProfile()+0x0000000000000810, (0x000000002F0E6960 0x000000002F0E7080 0x000000002F2F3460 0x0000000000000101), bcutils.dll, 0x0000000180026010
|
|
||||||
ut::ConfigNode::ConfigNode()+0x0000000000001142, (0x000000002F0E6960 0x000000002F0E7080 0x000000002F2EECE0 0x0000000013EE9240), bcutils.dll, 0x000000018002D4C2
|
|
||||||
ut::ConfigNode::ConfigNode()+0x000000000000111F, (0x000000002F0E6960 0x000000002F0E7080 0x000000002F2EE3E0 0x00007FF9E5D4C3A0), bcutils.dll, 0x000000018002D49F
|
|
||||||
ut::ConfigNode::ConfigNode()+0x000000000000111F, (0x000000002F0E6960 0x000000002F0E7080 0x000000002F2E9220 0x00007FF9E5D4C3A0), bcutils.dll, 0x000000018002D49F
|
|
||||||
ut::ConfigNode::ConfigNode()+0x000000000000111F, (0x000000002F0E6960 0x000000002F0E6280 0x000000002F0E6DA0 0x0000000000000000), bcutils.dll, 0x000000018002D49F
|
|
||||||
ut::ConfigNode::ConfigNode()+0x0000000000000F95, (0x0000000000000060 0x000000002F0E7080 0x000000002F0E7060 0x00002B6C96C01301), bcutils.dll, 0x000000018002D315
|
|
||||||
ut::ConfigNode::ConfigNode()+0x0000000000000149, (0x000000002F0E7060 0x00007FF9E5D4C3A0 0x000000002F0E7080 0x00007FF900000072), bcutils.dll, 0x000000018002C4C9
|
|
||||||
ut::Config::resetProfile()+0x0000000000000810, (0x0000000031D8EAFF 0x000000002F0E6280 0x000000002F2F3860 0x0000000031BBADA0), bcutils.dll, 0x0000000180026010
|
|
||||||
ut::ConfigNode::ConfigNode()+0x0000000000001142, (0x0000000031B197A0 0x0000000031BAA1F8 0x000000002F0E6460 0x000000000A34EE50), bcutils.dll, 0x000000018002D4C2
|
|
||||||
ut::ConfigNode::ConfigNode()+0x0000000000000F95, (0x0000000031BAA1F8 0x000000002F0E6280 0x000000002F0E6260 0x00007FF9E5D4B041), bcutils.dll, 0x000000018002D315
|
|
||||||
ut::ConfigNode::ConfigNode()+0x0000000000000149, (0x000000002F0E6260 0x000000000A01CE32 0x000000002F0E6280 0x0000000000000000), bcutils.dll, 0x000000018002C4C9
|
|
||||||
ut::Config::resetProfile()+0x0000000000000810, (0x0000000031BA8070 0x0000000000000000 0x0000000031BA9DD8 0x0000000000000000), bcutils.dll, 0x0000000180026010
|
|
||||||
ut::ProfileManagerBase::~ProfileManagerBase()+0x000000000000009D, (0x000000000A6ACDF0 0x0000000031BA9DB8 0x000000000171FC08 0x0000000031BA8070), bcutils.dll, 0x000000018002ED5D
|
|
||||||
_sys_nerr()+0x00000000000002B3, (0x0000000000000000 0x000000000171FC08 0x000000000171FEE0 0x0000000000000001), ucrtbase.dll, 0x00007FF9E2EF3A93
|
|
||||||
o_free()+0x00000000000000DE, (0x0000000000000000 0x000000000A34E4BD 0x0000000000000000 0x000000000171FBF8), ucrtbase.dll, 0x00007FF9E2EC042E
|
|
||||||
execute_onexit_table()+0x000000000000003D, (0x000000000A6A58C8 0x0000000000000002 0x0000C76400000002 0x000000000171FBF0), ucrtbase.dll, 0x00007FF9E2EBDDDD
|
|
||||||
OdRibbonReactorMgrImpl::fireGUIPanelCreated()+0x000000000006FC2E, (0x0000000000000001 0x0000000000000000 0x0000000000000001 0x0000000000000000), cadapp.dll, 0x00000001803EECDE
|
|
||||||
OdRibbonReactorMgrImpl::fireGUIPanelCreated()+0x000000000006FD54, (0x0000000009F60000 0x0000000000000000 0x0000000000000001 0x000000007FFE0385), cadapp.dll, 0x00000001803EEE04
|
|
||||||
RtlActivateActivationContextUnsafeFast()+0x000000000000012F, (0x00000000017EE080 0x0000000009F60000 0x0000000000000000 0x0000000000232000), ntdll.dll, 0x00007FF9E5D38BCF
|
|
||||||
LdrShutdownProcess()+0x0000000000000176, (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), ntdll.dll, 0x00007FF9E5D615D6
|
|
||||||
RtlExitUserProcess()+0x00000000000000AD, (0x0000000000070001 0x0000000000000000 0xFFFFFFFFFFFFFFFE 0xFFFFFFFFFFFFFFFF), ntdll.dll, 0x00007FF9E5D611CD
|
|
||||||
ExitProcess()+0x000000000000000B, (0x0000000000000000 0x0000000000000000 0x000000000171FEB0 0x0000000000000000), KERNEL32.DLL, 0x00007FF9E4767FCB
|
|
||||||
exit()+0x00000000000000B8, (0x0000000000000000 0x0000000000000000 0x0000000000000001 0x000000000171FEB0), ucrtbase.dll, 0x00007FF9E2EBBED8
|
|
||||||
exit()+0x0000000000000279, (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000001), ucrtbase.dll, 0x00007FF9E2EBC099
|
|
||||||
dc::QWinWidget::focusNextPrevChild()+0x0000000000007F90, (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), kunhengcad.exe, 0x000000014009EAF0
|
|
||||||
BaseThreadInitThunk()+0x000000000000001D, (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), KERNEL32.DLL, 0x00007FF9E476259D
|
|
||||||
RtlUserThreadStart()+0x0000000000000028, (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), ntdll.dll, 0x00007FF9E5D6AF78
|
|
Binary file not shown.
@ -306,7 +306,6 @@ namespace SWS.Electrical.ViewModels
|
|||||||
eventAggregator.GetEvent<sendMessageEvent>().Subscribe(onReceviceMsg, ThreadOption.UIThread, true);
|
eventAggregator.GetEvent<sendMessageEvent>().Subscribe(onReceviceMsg, ThreadOption.UIThread, true);
|
||||||
var list = new ObservableCollection<KeyValueModel>();
|
var list = new ObservableCollection<KeyValueModel>();
|
||||||
list.Add(new KeyValueModel { Key = "甲板号", Value = "甲板号" });
|
list.Add(new KeyValueModel { Key = "甲板号", Value = "甲板号" });
|
||||||
//list.Add(new KeyValueModel { Key = "区域", Value = "区域" });
|
|
||||||
list.Add(new KeyValueModel { Key = "所属系统", Value = "所属系统" });
|
list.Add(new KeyValueModel { Key = "所属系统", Value = "所属系统" });
|
||||||
listRange = new ObservableCollection<KeyValueModel>(list);
|
listRange = new ObservableCollection<KeyValueModel>(list);
|
||||||
listOperator = new ObservableCollection<KeyValueModel>()
|
listOperator = new ObservableCollection<KeyValueModel>()
|
||||||
@ -359,35 +358,6 @@ namespace SWS.Electrical.ViewModels
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//if (GlobalObj.treeDrawings.Any())
|
|
||||||
//{
|
|
||||||
// foreach (var model in GlobalObj.treeDrawings)
|
|
||||||
// {
|
|
||||||
// if (model.Text == "布置图")
|
|
||||||
// {
|
|
||||||
// foreach (var item in model.ChildNodes)
|
|
||||||
// {
|
|
||||||
// if (item.NodeType == "1")
|
|
||||||
// {
|
|
||||||
// listDrawings.Add(new DtoDrawing() { DrawingFileID = item.ID, DrawingFileName = item.Text });
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// if (item.Text == "封面、目录、设计说明" || item.Text == "材料表")
|
|
||||||
// { continue; }
|
|
||||||
// var list = GetChildNodes(item);
|
|
||||||
// if (list.Any())
|
|
||||||
// {
|
|
||||||
// foreach (var dto in list)
|
|
||||||
// {
|
|
||||||
// listDrawings.Add(new DtoDrawing() { DrawingFileID = dto.ID, DrawingFileName = dto.Text });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
IsBusy = true;
|
IsBusy = true;
|
||||||
BusyContent = "数据加载中...";
|
BusyContent = "数据加载中...";
|
||||||
if (!listDrawings.Any())
|
if (!listDrawings.Any())
|
||||||
@ -436,16 +406,10 @@ namespace SWS.Electrical.ViewModels
|
|||||||
var settingModel = await _ServiceProjectSettings.GetEntity("布置图图例显示位号名称");
|
var settingModel = await _ServiceProjectSettings.GetEntity("布置图图例显示位号名称");
|
||||||
if (settingModel == null)
|
if (settingModel == null)
|
||||||
{
|
{
|
||||||
listLibraryTagName.Add("位号");//默认
|
listLibraryTagName.Add("TAG");//默认
|
||||||
}
|
}
|
||||||
else { listLibraryTagName = settingModel.SettingValue.Split(',').ToList(); }
|
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("甲板号");
|
var listDetail = await _ServiceDataItem.GetDetails("甲板号");
|
||||||
if (listDetail != null && listDetail.Any())
|
if (listDetail != null && listDetail.Any())
|
||||||
@ -478,8 +442,6 @@ namespace SWS.Electrical.ViewModels
|
|||||||
inputValue = "";
|
inputValue = "";
|
||||||
if (model.Value == "甲板号")
|
if (model.Value == "甲板号")
|
||||||
{ listValue = new ObservableCollection<KeyValueModel>(listDeck); }
|
{ listValue = new ObservableCollection<KeyValueModel>(listDeck); }
|
||||||
//else if (model.Value == "区域")
|
|
||||||
//{ listValue = new ObservableCollection<KeyValueModel>(listArea); }
|
|
||||||
else if (model.Value == "所属系统")
|
else if (model.Value == "所属系统")
|
||||||
{ listValue = new ObservableCollection<KeyValueModel>(listSystem); }
|
{ listValue = new ObservableCollection<KeyValueModel>(listSystem); }
|
||||||
}
|
}
|
||||||
@ -625,188 +587,6 @@ namespace SWS.Electrical.ViewModels
|
|||||||
var progress = new Progress<MessageModel>(UpdateProgress);
|
var progress = new Progress<MessageModel>(UpdateProgress);
|
||||||
await DoWorkAsync(progress, new CancellationTokenSource());
|
await DoWorkAsync(progress, new CancellationTokenSource());
|
||||||
|
|
||||||
|
|
||||||
#region back
|
|
||||||
|
|
||||||
//try
|
|
||||||
//{
|
|
||||||
// isDrawing = true;
|
|
||||||
// List<ec_library_file> listFile = new List<ec_library_file>();
|
|
||||||
// List<string> listBlockDwgPath = new List<string>(); //图块下载路径列表,同个异形块下载一次,先下载后删除
|
|
||||||
// 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<string>());//获取图纸所有实体
|
|
||||||
// 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
|
#region DoWork
|
||||||
private void UpdateProgress(MessageModel dto)
|
private void UpdateProgress(MessageModel dto)
|
||||||
@ -1306,14 +1086,6 @@ namespace SWS.Electrical.ViewModels
|
|||||||
string tagNumber = basePoint.Tag.TagNumber;
|
string tagNumber = basePoint.Tag.TagNumber;
|
||||||
double scale = basePoint.Scale;
|
double scale = basePoint.Scale;
|
||||||
string msg = string.Empty;
|
string msg = string.Empty;
|
||||||
//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);
|
var enginedata = listEnginedata.FirstOrDefault(a => a.TagNumber == tagNumber);
|
||||||
if (enginedata == null)
|
if (enginedata == null)
|
||||||
{
|
{
|
||||||
@ -1326,16 +1098,12 @@ namespace SWS.Electrical.ViewModels
|
|||||||
#region 图纸上保存图元属性
|
#region 图纸上保存图元属性
|
||||||
if (!objId.IsNull)
|
if (!objId.IsNull)
|
||||||
{
|
{
|
||||||
//AddMsg($"元件已添加至图纸,句柄:{objId.Handle.ToString()}");
|
|
||||||
//RefreshUI(999, $"元件已添加至图纸,句柄:{objId.Handle.ToString()}");
|
|
||||||
//var dwgLibrary = await _ServiceLibraryFile.GetEntity(blockDwgId);
|
|
||||||
List<ec_enginedata_property> listPro = new List<ec_enginedata_property>();
|
List<ec_enginedata_property> listPro = new List<ec_enginedata_property>();
|
||||||
var handlid = objId.Handle.ToString();//添加图元返回的句柄
|
var handlid = objId.Handle.ToString();//添加图元返回的句柄
|
||||||
ec_enginedata item = new ec_enginedata();
|
ec_enginedata item = new ec_enginedata();
|
||||||
item.EngineDataID = enginedataId;
|
item.EngineDataID = enginedataId;
|
||||||
item.TagNumber = tagNumber;
|
item.TagNumber = tagNumber;
|
||||||
item.ObjectTypeID = objTypeId;
|
item.ObjectTypeID = objTypeId;
|
||||||
//item.Layout_Block_File = dwgLibrary;
|
|
||||||
var tagInfo = listObjecttype.FirstOrDefault(a => a.ObjectTypeID == enginedata.ObjectTypeID);
|
var tagInfo = listObjecttype.FirstOrDefault(a => a.ObjectTypeID == enginedata.ObjectTypeID);
|
||||||
if (tagInfo == null)
|
if (tagInfo == null)
|
||||||
{
|
{
|
||||||
@ -1427,7 +1195,7 @@ namespace SWS.Electrical.ViewModels
|
|||||||
System.Windows.Application.Current.Dispatcher.Invoke((System.Action)(() =>
|
System.Windows.Application.Current.Dispatcher.Invoke((System.Action)(() =>
|
||||||
{
|
{
|
||||||
TextBlock tb = new TextBlock();
|
TextBlock tb = new TextBlock();
|
||||||
tb.Text = DateTime.Now.ToString("yyyy-MM-6dd HH:mm:ss:ffff") + "==>> " + msg;
|
tb.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff") + "==>> " + msg;
|
||||||
tb.Foreground = isSucc ? Brushes.LightSeaGreen : Brushes.Red;
|
tb.Foreground = isSucc ? Brushes.LightSeaGreen : Brushes.Red;
|
||||||
listMsg.Add(tb);
|
listMsg.Add(tb);
|
||||||
}));
|
}));
|
||||||
|
@ -28,6 +28,8 @@ using Teigha.Geometry;
|
|||||||
using Teigha.GraphicsSystem;
|
using Teigha.GraphicsSystem;
|
||||||
using Telerik.Windows.Controls;
|
using Telerik.Windows.Controls;
|
||||||
using Unity;
|
using Unity;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
|
||||||
|
//using static ImTools.Union<TUnion, T1, T2>;
|
||||||
using Visibility = System.Windows.Visibility;
|
using Visibility = System.Windows.Visibility;
|
||||||
|
|
||||||
namespace SWS.Electrical.ViewModels
|
namespace SWS.Electrical.ViewModels
|
||||||
@ -99,6 +101,7 @@ namespace SWS.Electrical.ViewModels
|
|||||||
PlotBOMService _ServicePlotBOM;
|
PlotBOMService _ServicePlotBOM;
|
||||||
private bool isGenerate = false;//是否正在生成材料表
|
private bool isGenerate = false;//是否正在生成材料表
|
||||||
private string dwgName = string.Empty;
|
private string dwgName = string.Empty;
|
||||||
|
int time = 10;
|
||||||
public DialogGenerateBOMViewModel()
|
public DialogGenerateBOMViewModel()
|
||||||
{
|
{
|
||||||
Command_StartGenerate = new DelegateCommand(onStartGenerate);
|
Command_StartGenerate = new DelegateCommand(onStartGenerate);
|
||||||
@ -410,6 +413,89 @@ namespace SWS.Electrical.ViewModels
|
|||||||
listBomDrawings = new ObservableCollection<DtoBomDrawings>(listBom);
|
listBomDrawings = new ObservableCollection<DtoBomDrawings>(listBom);
|
||||||
isGenerate = true;
|
isGenerate = true;
|
||||||
listMsg.Clear();
|
listMsg.Clear();
|
||||||
|
var progress = new Progress<MessageModel>(UpdateProgress);
|
||||||
|
await DoWorkAsync(progress, new CancellationTokenSource());
|
||||||
|
|
||||||
|
//foreach (var dwg in listBomDrawings)
|
||||||
|
//{
|
||||||
|
// if (dwg.AutoGenerate == "已生成")
|
||||||
|
// {
|
||||||
|
// AddMsg($"当前图纸[{dwg.DrawingFileName}]的材料表已绘制,跳至下一个图纸");
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// if (dwg.AutoGenerate == "已存在")
|
||||||
|
// {
|
||||||
|
// AddMsg($"当前图纸[{dwg.DrawingFileName}]的材料表已存在,跳至下一个图纸");
|
||||||
|
// //continue;
|
||||||
|
// }
|
||||||
|
// if (dwg.AutoGenerate == "无材料信息")
|
||||||
|
// {
|
||||||
|
// AddMsg($"当前图纸[{dwg.DrawingFileName}]无材料信息,跳至下一个图纸");
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// string folderpath = GlobalObject.GetDwgPath(dwg.DrawingFileID);
|
||||||
|
// string filepath = Path.Combine(GlobalObj.LocalWorkDir, GlobalObject.curProject.ProjectName, folderpath, $"材料表\\{dwg.DrawingFileName}");
|
||||||
|
// if (File.Exists(filepath))
|
||||||
|
// {
|
||||||
|
// AddMsg($"当前图纸[{dwg.DrawingFileName}]的材料表已存在,跳至下一个图纸", false);
|
||||||
|
// dwg.AutoGenerate = "已存在";
|
||||||
|
// //continue;
|
||||||
|
// }
|
||||||
|
// var listBomGroup = await _ServicePlotBOM.GetBOMGroupInfo(dwg.DrawingFileID);
|
||||||
|
|
||||||
|
// dwg.AutoGenerate = "正在生成...";
|
||||||
|
// AddMsg($"开始生成图纸[{dwg.DrawingFileName}]的材料表...");
|
||||||
|
// if (listBomGroup == null || !listBomGroup.Any())
|
||||||
|
// {
|
||||||
|
// AddMsg($"当前图纸无材料分组信息,跳至下一个图纸");
|
||||||
|
// dwg.AutoGenerate = "无材料信息";
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// msg = GenerateBOM(dwg, filepath, listBomGroup);
|
||||||
|
// if (!string.IsNullOrEmpty(msg))
|
||||||
|
// {
|
||||||
|
// AddMsg($"材料表生成失败,信息:" + msg, false);
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //下载图标图纸文件
|
||||||
|
// //filePath = Path.Combine(GlobalObject.GetCacheFolder(), $"{tag.TagNumber}.dwg");
|
||||||
|
// //AddMsg($"元件图纸:{tag.TagNumber}, 开始下载...");
|
||||||
|
// //msg = await _ServiceAnnexes.DownloadFile(filePath, obj.FolderId);
|
||||||
|
// //if (!string.IsNullOrEmpty(msg))
|
||||||
|
// //{
|
||||||
|
// // AddMsg($"元件图纸下载失败,信息:" + msg, false);
|
||||||
|
// // continue;
|
||||||
|
// //}
|
||||||
|
// //AddMsg($"元件图纸:{tag.TagNumber}, 下载成功");
|
||||||
|
// //filePath = "D:\\BricsCAD\\Temp\\测试11.dwg";
|
||||||
|
|
||||||
|
|
||||||
|
// dwg.AutoGenerate = "已生成";
|
||||||
|
// AddMsg($"材料表生成成功!");
|
||||||
|
//}
|
||||||
|
//AddMsg("操作已完成!");
|
||||||
|
//isGenerate = false;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("异常:" + ex.Message);
|
||||||
|
isGenerate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#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<MessageModel> progress, CancellationTokenSource cts)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var msg = string.Empty;
|
||||||
foreach (var dwg in listBomDrawings)
|
foreach (var dwg in listBomDrawings)
|
||||||
{
|
{
|
||||||
if (dwg.AutoGenerate == "已生成")
|
if (dwg.AutoGenerate == "已生成")
|
||||||
@ -419,8 +505,8 @@ namespace SWS.Electrical.ViewModels
|
|||||||
}
|
}
|
||||||
if (dwg.AutoGenerate == "已存在")
|
if (dwg.AutoGenerate == "已存在")
|
||||||
{
|
{
|
||||||
AddMsg($"当前图纸[{dwg.DrawingFileName}]的材料表已存在,跳至下一个图纸");
|
//AddMsg($"当前图纸[{dwg.DrawingFileName}]的材料表已存在,跳至下一个图纸");
|
||||||
continue;
|
//continue;
|
||||||
}
|
}
|
||||||
if (dwg.AutoGenerate == "无材料信息")
|
if (dwg.AutoGenerate == "无材料信息")
|
||||||
{
|
{
|
||||||
@ -431,9 +517,9 @@ namespace SWS.Electrical.ViewModels
|
|||||||
string filepath = Path.Combine(GlobalObj.LocalWorkDir, GlobalObject.curProject.ProjectName, folderpath, $"材料表\\{dwg.DrawingFileName}");
|
string filepath = Path.Combine(GlobalObj.LocalWorkDir, GlobalObject.curProject.ProjectName, folderpath, $"材料表\\{dwg.DrawingFileName}");
|
||||||
if (File.Exists(filepath))
|
if (File.Exists(filepath))
|
||||||
{
|
{
|
||||||
AddMsg($"当前图纸[{dwg.DrawingFileName}]的材料表已存在,跳至下一个图纸", false);
|
//AddMsg($"当前图纸[{dwg.DrawingFileName}]的材料表已存在,跳至下一个图纸", false);
|
||||||
dwg.AutoGenerate = "已存在";
|
//dwg.AutoGenerate = "已存在";
|
||||||
continue;
|
//continue;
|
||||||
}
|
}
|
||||||
var listBomGroup = await _ServicePlotBOM.GetBOMGroupInfo(dwg.DrawingFileID);
|
var listBomGroup = await _ServicePlotBOM.GetBOMGroupInfo(dwg.DrawingFileID);
|
||||||
|
|
||||||
@ -445,7 +531,7 @@ namespace SWS.Electrical.ViewModels
|
|||||||
dwg.AutoGenerate = "无材料信息";
|
dwg.AutoGenerate = "无材料信息";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
msg = GenerateBOM(dwg, filepath, listBomGroup);
|
msg = await GenerateBOM(dwg, filepath, listBomGroup, cts);
|
||||||
if (!string.IsNullOrEmpty(msg))
|
if (!string.IsNullOrEmpty(msg))
|
||||||
{
|
{
|
||||||
AddMsg($"材料表生成失败,信息:" + msg, false);
|
AddMsg($"材料表生成失败,信息:" + msg, false);
|
||||||
@ -477,13 +563,14 @@ namespace SWS.Electrical.ViewModels
|
|||||||
isGenerate = false;
|
isGenerate = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成BOM表图纸
|
/// 生成BOM表图纸
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filepath">材料表文件路径</param>
|
/// <param name="filepath">材料表文件路径</param>
|
||||||
/// <param name="listBomGroup">位号分组信息</param>
|
/// <param name="listBomGroup">位号分组信息</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private string GenerateBOM(DtoBomDrawings dtoBOM, string filepath, List<BOMGroupInfo> listBomGroup)
|
private async Task<string> GenerateBOM(DtoBomDrawings dtoBOM, string filepath, List<BOMGroupInfo> listBomGroup, CancellationTokenSource cts)
|
||||||
{
|
{
|
||||||
string msg = string.Empty;
|
string msg = string.Empty;
|
||||||
//1.创建材料表图纸文件
|
//1.创建材料表图纸文件
|
||||||
@ -491,91 +578,139 @@ namespace SWS.Electrical.ViewModels
|
|||||||
string bomName = Path.Combine(folderpath, "BomTemp.dwg");
|
string bomName = Path.Combine(folderpath, "BomTemp.dwg");
|
||||||
string dwgName = dtoBOM.DrawingFileName.Substring(0, dtoBOM.DrawingFileName.Length - 4);
|
string dwgName = dtoBOM.DrawingFileName.Substring(0, dtoBOM.DrawingFileName.Length - 4);
|
||||||
var flag = General.CreateDwg(folderpath, dwgName);
|
var flag = General.CreateDwg(folderpath, dwgName);
|
||||||
|
|
||||||
if (!flag)
|
if (!flag)
|
||||||
{
|
{
|
||||||
msg = $"材料表图纸创建失败,路径:{filepath}";
|
msg = $"材料表图纸创建失败,路径:{filepath}";
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
//2.读取BOM表配置文件
|
//2.读取BOM表配置文件
|
||||||
string strJson = File.ReadAllText("Template\\BomConfig.json");
|
string strJson = File.ReadAllText(Path.Combine(GlobalObject.GetDllPath(), "Template\\BomConfig.json"));
|
||||||
BomConfig bomComfig = JsonConvert.DeserializeObject<BomConfig>(strJson);
|
BomConfig bomComfig = JsonConvert.DeserializeObject<BomConfig>(strJson);
|
||||||
//3.判断位号分组信息需要分成几张材料表,分页生成材料表
|
//3.判断位号分组信息需要分成几张材料表,分页生成材料表
|
||||||
List<DtoCadTextInfo> listTextInfo = new List<DtoCadTextInfo>();
|
List<DtoTextInfo> listTextInfo = new List<DtoTextInfo>();
|
||||||
|
List<DtoSymbolInfo> listSymbolInfo = new List<DtoSymbolInfo>();
|
||||||
decimal mod = (decimal)listBomGroup.Count / (decimal)bomComfig.RowCount;
|
decimal mod = (decimal)listBomGroup.Count / (decimal)bomComfig.RowCount;
|
||||||
var page = Math.Ceiling(mod);//总的A4表格页数 小数点向上取整数
|
var page = Math.Ceiling(mod);//总的A4表格页数 小数点向上取整数
|
||||||
|
#region 1
|
||||||
|
|
||||||
|
//for (int i = 0; i < page; i++)
|
||||||
|
//{
|
||||||
|
// listTextInfo = new List<DtoTextInfo>();
|
||||||
|
// listSymbolInfo = new List<DtoSymbolInfo>();
|
||||||
|
// int count = (i + 1) == page ? (listBomGroup.Count % bomComfig.RowCount) : bomComfig.RowCount;
|
||||||
|
// for (int j = 0; j < count; j++)
|
||||||
|
// {
|
||||||
|
// var index = i * bomComfig.RowCount + j;
|
||||||
|
// var bomInfo = listBomGroup[index];
|
||||||
|
// #region 序号
|
||||||
|
// var dto = new DtoTextInfo();
|
||||||
|
// dto.Text = (j + 1).ToString();
|
||||||
|
// dto.Position = new Point3d(bomComfig.Column1X, bomComfig.Column1Y - (j * bomComfig.RowHeight), 0);
|
||||||
|
// dto.IsMText = false;
|
||||||
|
// dto.Height = 4;
|
||||||
|
// dto.Width = 20;
|
||||||
|
// dto.Align = 1;
|
||||||
|
// listTextInfo.Add(dto);
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region 图标
|
||||||
|
// var symbol = new DtoSymbolInfo();
|
||||||
|
// symbol.Upper_Text = bomInfo.upper_text;
|
||||||
|
// symbol.Lower_Text = bomInfo.lower_text;
|
||||||
|
// symbol.Position = new Point3d(bomComfig.Column2X, bomComfig.Column2Y - (j * bomComfig.RowHeight), 0);
|
||||||
|
// symbol.Scale = 0.02;
|
||||||
|
// listSymbolInfo.Add(symbol);
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region 数量
|
||||||
|
// dto = new DtoTextInfo();
|
||||||
|
// dto.Text = (bomInfo.Count).ToString();
|
||||||
|
// dto.Position = new Point3d(bomComfig.Column3X, bomComfig.Column3Y - (j * bomComfig.RowHeight), 0);
|
||||||
|
// dto.IsMText = false;
|
||||||
|
// dto.Height = 4;
|
||||||
|
// dto.Width = 20;
|
||||||
|
// dto.Align = 1;
|
||||||
|
// listTextInfo.Add(dto);
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region 型号
|
||||||
|
// dto = new DtoTextInfo();
|
||||||
|
// dto.Text = (bomInfo.Model).ToString();
|
||||||
|
// dto.Position = new Point3d(bomComfig.Column4X, bomComfig.Column4Y - (j * bomComfig.RowHeight), 0);
|
||||||
|
// dto.IsMText = false;
|
||||||
|
// dto.Height = 4;
|
||||||
|
// dto.Width = 20;
|
||||||
|
// dto.Align = 1;
|
||||||
|
// listTextInfo.Add(dto);
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region 规格
|
||||||
|
// dto = new DtoTextInfo();
|
||||||
|
// dto.Text = (bomInfo.Spec).ToString();
|
||||||
|
// dto.Position = new Point3d(bomComfig.Column5X, bomComfig.Column5Y - (j * bomComfig.RowHeight), 0);
|
||||||
|
// dto.IsMText = false;
|
||||||
|
// dto.Height = 4;
|
||||||
|
// dto.Width = 20;
|
||||||
|
// dto.Align = 1;
|
||||||
|
// listTextInfo.Add(dto);
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region 备注
|
||||||
|
// dto = new DtoTextInfo();
|
||||||
|
// dto.Text = (bomInfo.Remark).ToString();
|
||||||
|
// dto.Position = new Point3d(bomComfig.Column6X, bomComfig.Column6Y - (j * bomComfig.RowHeight), 0);
|
||||||
|
// dto.IsMText = false;
|
||||||
|
// dto.Height = 4;
|
||||||
|
// dto.Width = 20;
|
||||||
|
// dto.Align = 1;
|
||||||
|
// listTextInfo.Add(dto);
|
||||||
|
// #endregion
|
||||||
|
// }
|
||||||
|
// #region 把材料信息插入材料表图纸里
|
||||||
|
// var filename = bomName.Replace("BomTemp", "BomTemp" + (i + 1));
|
||||||
|
// File.Copy("Template\\材料表.dwg", filename, true);
|
||||||
|
// General.OpenDwg(filename);
|
||||||
|
// General.InsertTextInfo(listTextInfo);
|
||||||
|
// Thread.Sleep(1000);
|
||||||
|
// InsertSymbol(listSymbolInfo);
|
||||||
|
// listSymbolInfo.Clear();
|
||||||
|
// General.SaveAndCloseDwg(filename);
|
||||||
|
// Thread.Sleep(1000);
|
||||||
|
// //计算该页材料表是第几行第几列的
|
||||||
|
// //double x, y = 0;//坐标x,y
|
||||||
|
// //decimal row = (decimal)i / (decimal)bomComfig.RowPageCount;//row表示行数,在第几行
|
||||||
|
// //row = Math.Floor(row);
|
||||||
|
// //var column = i % bomComfig.RowPageCount;//column表示列数,在第几列
|
||||||
|
// //x = column == 0 ? 0 : (double)column * bomComfig.Width;
|
||||||
|
// //y = row == 0 ? 0 : 0 - (double)row * bomComfig.Height;
|
||||||
|
// //var position = new Point3d(x, y, 0);
|
||||||
|
// //General.AddBlockDWG(filename, $"材料表{i + 1}", position);
|
||||||
|
// //Thread.Sleep(1000);
|
||||||
|
// #endregion
|
||||||
|
//}
|
||||||
|
//General.OpenDwg(filepath);
|
||||||
|
//Thread.Sleep(1000);
|
||||||
|
//for (int i = 0; i < page; i++)
|
||||||
|
//{
|
||||||
|
// var filename = bomName.Replace("BomTemp", "BomTemp" + (i + 1));
|
||||||
|
// //计算该页材料表是第几行第几列的
|
||||||
|
// double x, y = 0;//坐标x,y
|
||||||
|
// decimal row = (decimal)i / (decimal)bomComfig.RowPageCount;//row表示行数,在第几行
|
||||||
|
// row = Math.Floor(row);
|
||||||
|
// var column = i % bomComfig.RowPageCount;//column表示列数,在第几列
|
||||||
|
// x = column == 0 ? 0 : (double)column * bomComfig.Width;
|
||||||
|
// y = row == 0 ? 0 : 0 - (double)row * bomComfig.Height;
|
||||||
|
// var position = new Point3d(x, y, 0);
|
||||||
|
// General.AddBlockDWG(filename, $"材料表{i + 1}", position);
|
||||||
|
// Thread.Sleep(1000);
|
||||||
|
//}
|
||||||
|
//General.SaveAndCloseDwg(filepath);
|
||||||
|
#endregion
|
||||||
|
#region 2
|
||||||
|
General.OpenDwg(filepath);
|
||||||
for (int i = 0; i < page; i++)
|
for (int i = 0; i < page; i++)
|
||||||
{
|
{
|
||||||
listTextInfo = new List<DtoCadTextInfo>();
|
|
||||||
int count = (i + 1) == page ? (listBomGroup.Count % bomComfig.RowCount) : bomComfig.RowCount;
|
|
||||||
for (int j = 0; j < count; j++)
|
|
||||||
{
|
|
||||||
var index = i * bomComfig.RowCount + j;
|
|
||||||
var bomInfo = listBomGroup[index];
|
|
||||||
#region 序号
|
|
||||||
var dto = new DtoCadTextInfo();
|
|
||||||
dto.Text = (j + 1).ToString();
|
|
||||||
dto.Position = new Point3d(bomComfig.Column1X, bomComfig.Column1Y - (j * bomComfig.RowHeight), 0);
|
|
||||||
dto.IsMText = false;
|
|
||||||
dto.Height = 4;
|
|
||||||
dto.Width = 20;
|
|
||||||
dto.Align = 1;
|
|
||||||
listTextInfo.Add(dto);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 图标
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 数量
|
|
||||||
dto = new DtoCadTextInfo();
|
|
||||||
dto.Text = (bomInfo.Count).ToString();
|
|
||||||
dto.Position = new Point3d(bomComfig.Column3X, bomComfig.Column3Y - (j * bomComfig.RowHeight), 0);
|
|
||||||
dto.IsMText = false;
|
|
||||||
dto.Height = 4;
|
|
||||||
dto.Width = 20;
|
|
||||||
dto.Align = 1;
|
|
||||||
listTextInfo.Add(dto);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 型号
|
|
||||||
dto = new DtoCadTextInfo();
|
|
||||||
dto.Text = (bomInfo.Model).ToString();
|
|
||||||
dto.Position = new Point3d(bomComfig.Column4X, bomComfig.Column4Y - (j * bomComfig.RowHeight), 0);
|
|
||||||
dto.IsMText = false;
|
|
||||||
dto.Height = 4;
|
|
||||||
dto.Width = 20;
|
|
||||||
dto.Align = 1;
|
|
||||||
listTextInfo.Add(dto);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 规格
|
|
||||||
dto = new DtoCadTextInfo();
|
|
||||||
dto.Text = (bomInfo.Spec).ToString();
|
|
||||||
dto.Position = new Point3d(bomComfig.Column5X, bomComfig.Column5Y - (j * bomComfig.RowHeight), 0);
|
|
||||||
dto.IsMText = false;
|
|
||||||
dto.Height = 4;
|
|
||||||
dto.Width = 20;
|
|
||||||
dto.Align = 1;
|
|
||||||
listTextInfo.Add(dto);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 备注
|
|
||||||
dto = new DtoCadTextInfo();
|
|
||||||
dto.Text = (bomInfo.Remark).ToString();
|
|
||||||
dto.Position = new Point3d(bomComfig.Column6X, bomComfig.Column6Y - (j * bomComfig.RowHeight), 0);
|
|
||||||
dto.IsMText = false;
|
|
||||||
dto.Height = 4;
|
|
||||||
dto.Width = 20;
|
|
||||||
dto.Align = 1;
|
|
||||||
listTextInfo.Add(dto);
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
#region 把材料信息插入材料表图纸里
|
|
||||||
File.Copy("Template\\材料表.dwg", bomName, true);
|
|
||||||
General.OpenDwg(bomName);
|
|
||||||
General.InsertTextInfo(listTextInfo);
|
|
||||||
General.SaveAndCloseDwg(bomName);
|
|
||||||
General.OpenDwg(filepath);
|
|
||||||
//计算该页材料表是第几行第几列的
|
//计算该页材料表是第几行第几列的
|
||||||
double x, y = 0;//坐标x,y
|
double x, y = 0;//坐标x,y
|
||||||
decimal row = (decimal)i / (decimal)bomComfig.RowPageCount;//row表示行数,在第几行
|
decimal row = (decimal)i / (decimal)bomComfig.RowPageCount;//row表示行数,在第几行
|
||||||
@ -584,14 +719,131 @@ namespace SWS.Electrical.ViewModels
|
|||||||
x = column == 0 ? 0 : (double)column * bomComfig.Width;
|
x = column == 0 ? 0 : (double)column * bomComfig.Width;
|
||||||
y = row == 0 ? 0 : 0 - (double)row * bomComfig.Height;
|
y = row == 0 ? 0 : 0 - (double)row * bomComfig.Height;
|
||||||
var position = new Point3d(x, y, 0);
|
var position = new Point3d(x, y, 0);
|
||||||
|
File.Copy(Path.Combine(GlobalObject.GetDllPath(), "Template\\材料表.dwg"), bomName, true);
|
||||||
General.AddBlockDWG(bomName, $"材料表{i + 1}", position);
|
General.AddBlockDWG(bomName, $"材料表{i + 1}", position);
|
||||||
General.SaveAndCloseDwg(filepath);
|
listTextInfo = new List<DtoTextInfo>();
|
||||||
|
listSymbolInfo = new List<DtoSymbolInfo>();
|
||||||
|
int count = (i + 1) == page ? (listBomGroup.Count % bomComfig.RowCount) : bomComfig.RowCount;
|
||||||
|
for (int j = 0; j < count; j++)
|
||||||
|
{
|
||||||
|
var index = i * bomComfig.RowCount + j;
|
||||||
|
var bomInfo = listBomGroup[index];
|
||||||
|
#region 序号
|
||||||
|
var dto = new DtoTextInfo();
|
||||||
|
dto.Text = (j + 1).ToString();
|
||||||
|
dto.Position = new Point3d(bomComfig.Column1X + x, bomComfig.Column1Y - (j * bomComfig.RowHeight) + y, 0);
|
||||||
|
dto.IsMText = false;
|
||||||
|
dto.Height = 4;
|
||||||
|
dto.Width = 20;
|
||||||
|
dto.Align = 1;
|
||||||
|
listTextInfo.Add(dto);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 图标
|
||||||
|
var symbol = new DtoSymbolInfo();
|
||||||
|
symbol.Upper_Text = bomInfo.upper_text;
|
||||||
|
symbol.Lower_Text = bomInfo.lower_text;
|
||||||
|
symbol.Position = new Point3d(bomComfig.Column2X + x, bomComfig.Column2Y - (j * bomComfig.RowHeight) + y, 0);
|
||||||
|
symbol.Scale = string.IsNullOrWhiteSpace(bomInfo.lower_text) ? 1 : 0.02;
|
||||||
|
listSymbolInfo.Add(symbol);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 数量
|
||||||
|
dto = new DtoTextInfo();
|
||||||
|
dto.Text = (bomInfo.Count).ToString();
|
||||||
|
dto.Position = new Point3d(bomComfig.Column3X + x, bomComfig.Column3Y - (j * bomComfig.RowHeight) + y, 0);
|
||||||
|
dto.IsMText = false;
|
||||||
|
dto.Height = 4;
|
||||||
|
dto.Width = 20;
|
||||||
|
dto.Align = 1;
|
||||||
|
listTextInfo.Add(dto);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 型号
|
||||||
|
dto = new DtoTextInfo();
|
||||||
|
dto.Text = (bomInfo.Model).ToString();
|
||||||
|
dto.Position = new Point3d(bomComfig.Column4X + x, bomComfig.Column4Y - (j * bomComfig.RowHeight) + y, 0);
|
||||||
|
dto.IsMText = false;
|
||||||
|
dto.Height = 4;
|
||||||
|
dto.Width = 20;
|
||||||
|
dto.Align = 1;
|
||||||
|
listTextInfo.Add(dto);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 规格
|
||||||
|
dto = new DtoTextInfo();
|
||||||
|
dto.Text = (bomInfo.Spec).ToString();
|
||||||
|
dto.Position = new Point3d(bomComfig.Column5X + x, bomComfig.Column5Y - (j * bomComfig.RowHeight) + y, 0);
|
||||||
|
dto.IsMText = false;
|
||||||
|
dto.Height = 4;
|
||||||
|
dto.Width = 20;
|
||||||
|
dto.Align = 1;
|
||||||
|
listTextInfo.Add(dto);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 备注
|
||||||
|
dto = new DtoTextInfo();
|
||||||
|
dto.Text = (bomInfo.Remark).ToString();
|
||||||
|
dto.Position = new Point3d(bomComfig.Column6X + x, bomComfig.Column6Y - (j * bomComfig.RowHeight) + y, 0);
|
||||||
|
dto.IsMText = false;
|
||||||
|
dto.Height = 4;
|
||||||
|
dto.Width = 20;
|
||||||
|
dto.Align = 1;
|
||||||
|
listTextInfo.Add(dto);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
#region 把材料信息插入材料表图纸里
|
||||||
|
General.InsertTextInfo(listTextInfo); //插入文本信息
|
||||||
|
await InsertSymbol(listSymbolInfo, cts);//插入图标信息
|
||||||
|
listSymbolInfo.Clear();
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
General.SaveAndCloseDwg(filepath);
|
||||||
File.Delete(bomName);
|
File.Delete(bomName);
|
||||||
General.OpenDwg(filepath);
|
General.OpenDwg(filepath);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 插入图标
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<bool> InsertSymbol(List<DtoSymbolInfo> listSymbolInfo, CancellationTokenSource cts)
|
||||||
|
{
|
||||||
|
#region 插入图标
|
||||||
|
var filePath = Path.Combine(GlobalObject.GetCacheFolder(), $"symbol.dwg");
|
||||||
|
|
||||||
|
//默认上下图块
|
||||||
|
var blockName = "图标图块";
|
||||||
|
string msg = string.Empty;
|
||||||
|
foreach (var symbol in listSymbolInfo)
|
||||||
|
{
|
||||||
|
var symbolPath = Path.Combine(GlobalObject.GetDllPath(), "Template\\常规矩形两行图块.dwg");
|
||||||
|
if (string.IsNullOrWhiteSpace(symbol.Lower_Text))
|
||||||
|
{ symbolPath = Path.Combine(GlobalObject.GetDllPath(), "Template\\常规矩形单行图块.dwg"); }
|
||||||
|
if (!File.Exists(symbolPath))
|
||||||
|
{
|
||||||
|
AddMsg($"默认图标图块找不到:{symbolPath}", false);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
File.Copy(symbolPath, filePath, true);
|
||||||
|
AddMsg($"开始插入图标,上:{symbol.Upper_Text},下:{symbol.Lower_Text}...");
|
||||||
|
msg = General.UpdateCableNo(filePath, new List<string>(), "", true, symbol.Upper_Text, symbol.Lower_Text);
|
||||||
|
if (!string.IsNullOrEmpty(msg))
|
||||||
|
{
|
||||||
|
AddMsg($"图标修改上下信息失败,上:{symbol.Upper_Text},下:{symbol.Lower_Text},信息:{msg}", false);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var objId = General.AddBomSymbolDWG(filePath, blockName, symbol.Scale, symbol.Position);
|
||||||
|
if (!objId.IsNull)
|
||||||
|
{ AddMsg($"图标插入成功!"); }
|
||||||
|
else { AddMsg($"图标插入失败", false); }
|
||||||
|
await Task.Delay(time, cts.Token);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#region 添加提示信息
|
#region 添加提示信息
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -0,0 +1,394 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.UI.WebControls;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Interop;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Media3D;
|
||||||
|
using Bricscad.EditorInput;
|
||||||
|
using ImTools;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Prism.Services.Dialogs;
|
||||||
|
using SWS.CAD.Base;
|
||||||
|
using SWS.Commons;
|
||||||
|
using SWS.Electrical.Models;
|
||||||
|
using SWS.Model;
|
||||||
|
using SWS.Service;
|
||||||
|
using SWS.Share;
|
||||||
|
using SWS.WPF.ViewModels;
|
||||||
|
using Teigha.DatabaseServices;
|
||||||
|
using Teigha.Geometry;
|
||||||
|
using Teigha.GraphicsSystem;
|
||||||
|
using Telerik.Windows.Controls;
|
||||||
|
using Unity;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
|
||||||
|
//using static ImTools.Union<TUnion, T1, T2>;
|
||||||
|
using Visibility = System.Windows.Visibility;
|
||||||
|
|
||||||
|
namespace SWS.Electrical.ViewModels
|
||||||
|
{
|
||||||
|
|
||||||
|
public class DialogRefreshAnnotationViewModel : DialogBase, IDialogAware
|
||||||
|
{
|
||||||
|
|
||||||
|
private ObservableCollection<DtoAnnotation> _listAnnotation = new ObservableCollection<DtoAnnotation>();
|
||||||
|
/// <summary>
|
||||||
|
/// 正常标注列表
|
||||||
|
/// </summary>
|
||||||
|
public ObservableCollection<DtoAnnotation> listAnnotation
|
||||||
|
{
|
||||||
|
get { return this._listAnnotation; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value != this._listAnnotation)
|
||||||
|
{
|
||||||
|
this._listAnnotation = value;
|
||||||
|
RaisePropertyChanged(nameof(listAnnotation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private ObservableCollection<DtoAnnotation> _listErrAnnotation = new ObservableCollection<DtoAnnotation>();
|
||||||
|
/// <summary>
|
||||||
|
/// 异常标注列表
|
||||||
|
/// </summary>
|
||||||
|
public ObservableCollection<DtoAnnotation> listErrAnnotation
|
||||||
|
{
|
||||||
|
get { return this._listErrAnnotation; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value != this._listErrAnnotation)
|
||||||
|
{
|
||||||
|
this._listErrAnnotation = value;
|
||||||
|
RaisePropertyChanged(nameof(listErrAnnotation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ObservableCollection<TextBlock> _listMsg = new ObservableCollection<TextBlock>();
|
||||||
|
/// <summary>
|
||||||
|
/// 信息列表
|
||||||
|
/// </summary>
|
||||||
|
public ObservableCollection<TextBlock> listMsg
|
||||||
|
{
|
||||||
|
get { return this._listMsg; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value != this._listMsg)
|
||||||
|
{
|
||||||
|
this._listMsg = value;
|
||||||
|
RaisePropertyChanged(nameof(listMsg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private string _NormalTagCount = "正常标注";
|
||||||
|
/// <summary>
|
||||||
|
/// 正常标注
|
||||||
|
/// </summary>
|
||||||
|
public string NormalTagCount
|
||||||
|
{
|
||||||
|
get { return _NormalTagCount; }
|
||||||
|
set { _NormalTagCount = value; OnPropertyChanged(nameof(NormalTagCount)); }
|
||||||
|
}
|
||||||
|
private string _ErrTagCount = "异常标注";
|
||||||
|
/// <summary>
|
||||||
|
/// 异常标注
|
||||||
|
/// </summary>
|
||||||
|
public string ErrTagCount
|
||||||
|
{
|
||||||
|
get { return _ErrTagCount; }
|
||||||
|
set { _ErrTagCount = value; OnPropertyChanged(nameof(ErrTagCount)); }
|
||||||
|
}
|
||||||
|
private bool _IsEnableGetAttribute = true;
|
||||||
|
/// <summary>
|
||||||
|
/// 获取元件属性值 是否可用
|
||||||
|
/// </summary>
|
||||||
|
public bool IsEnableGetAttribute
|
||||||
|
{
|
||||||
|
get { return _IsEnableGetAttribute; }
|
||||||
|
set { _IsEnableGetAttribute = value; OnPropertyChanged(nameof(IsEnableGetAttribute)); }
|
||||||
|
}
|
||||||
|
private bool _IsEnableRefreshAnnotation = true;
|
||||||
|
/// <summary>
|
||||||
|
/// 刷新标注 是否可用
|
||||||
|
/// </summary>
|
||||||
|
public bool IsEnableRefreshAnnotation
|
||||||
|
{
|
||||||
|
get { return _IsEnableRefreshAnnotation; }
|
||||||
|
set { _IsEnableRefreshAnnotation = value; OnPropertyChanged(nameof(IsEnableRefreshAnnotation)); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 命令事件 获取元件属性值
|
||||||
|
/// </summary>
|
||||||
|
public ICommand Command_GetAttribute { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 命令事件 刷新标注
|
||||||
|
/// </summary>
|
||||||
|
public ICommand Command_RefreshAnnotation { get; set; }
|
||||||
|
|
||||||
|
DrawingServce _ServiceDrawing;
|
||||||
|
DrawingCatalogueService _ServiceDrawingCatalogue;
|
||||||
|
ObjectTypeService _ServiceObjectType;
|
||||||
|
private TreeModel dwgNode;
|
||||||
|
int time = 10;
|
||||||
|
public DialogRefreshAnnotationViewModel()
|
||||||
|
{
|
||||||
|
Command_GetAttribute = new DelegateCommand(onGetAttribute);
|
||||||
|
Command_RefreshAnnotation = new DelegateCommand(onRefreshAnnotation);
|
||||||
|
title = "刷新标注";
|
||||||
|
_ServiceDrawing = GlobalObject.container.Resolve<DrawingServce>();
|
||||||
|
_ServiceObjectType = GlobalObject.container.Resolve<ObjectTypeService>();
|
||||||
|
_ServiceDrawingCatalogue = GlobalObject.container.Resolve<DrawingCatalogueService>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Title => "";
|
||||||
|
|
||||||
|
public event Action<IDialogResult> RequestClose;
|
||||||
|
|
||||||
|
public bool CanCloseDialog()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDialogClosed()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public void OnDialogOpened(IDialogParameters parameters)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
dwgNode = parameters.GetValue<TreeModel>(GlobalObject.dialogPar.para1.ToString());
|
||||||
|
title += " - " + dwgNode.Text;
|
||||||
|
IsBusy = true;
|
||||||
|
BusyContent = "数据加载中...";
|
||||||
|
AddMsg($"数据加载中...");
|
||||||
|
var listMtext = General.GetAllMText();
|
||||||
|
var listTag = General.GetAllAnnotation();
|
||||||
|
List<DtoAnnotation> listSuccess = new List<DtoAnnotation>();
|
||||||
|
List<DtoAnnotation> listFailed = new List<DtoAnnotation>();
|
||||||
|
foreach (var item in listTag)
|
||||||
|
{
|
||||||
|
DtoAnnotation dto = new DtoAnnotation();
|
||||||
|
dto.TagHandid = item.TagHandId;
|
||||||
|
dto.AttributeName = item.Name;
|
||||||
|
dto.AnnotationHandid = item.LabelHandId;
|
||||||
|
dto.Status = "未刷新";
|
||||||
|
var mtext = listMtext.FirstOrDefault(a => a.HandId == dto.AnnotationHandid);
|
||||||
|
if (mtext != null)
|
||||||
|
{
|
||||||
|
dto.AnnotationValue = mtext.Text;
|
||||||
|
listSuccess.Add(dto);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dto.Status = "未匹配";
|
||||||
|
listFailed.Add(dto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
listAnnotation = new ObservableCollection<DtoAnnotation>(listSuccess);
|
||||||
|
listErrAnnotation = new ObservableCollection<DtoAnnotation>(listFailed);
|
||||||
|
NormalTagCount = $"正常标注({listSuccess.Count}个)";
|
||||||
|
ErrTagCount = $"异常标注({listFailed.Count}个)";
|
||||||
|
AddMsg($"数据加载完成");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("DialogOpened异常:" + ex.Message);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IsBusy = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取元件属性值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="o"></param>
|
||||||
|
public async void onGetAttribute(object o)
|
||||||
|
{
|
||||||
|
//if (isRefresh)
|
||||||
|
//{
|
||||||
|
// MessageBox.Show("正在刷新标注,请勿操作...");
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
//if (isGetAttribute)
|
||||||
|
//{
|
||||||
|
// MessageBox.Show("正在获取属性值,请勿操作...");
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IsEnableGetAttribute = IsEnableRefreshAnnotation = false;
|
||||||
|
listMsg.Clear();
|
||||||
|
AddMsg("开始查询元件属性值信息...");
|
||||||
|
List<string> listTagHandid = new List<string>();
|
||||||
|
listTagHandid = listAnnotation.Select(a => a.TagHandid).Distinct().ToList();
|
||||||
|
foreach (string handid in listTagHandid)
|
||||||
|
{
|
||||||
|
AddMsg($"查询元件句柄[{handid}]属性值......");
|
||||||
|
var res = await _ServiceObjectType.GetTagInfosByPixels(dwgNode.ID, handid);
|
||||||
|
if (res == null || !res.Any())
|
||||||
|
{
|
||||||
|
AddMsg($"元件句柄[{handid}]获取属性值失败!", false);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (res.Count == 1)
|
||||||
|
{
|
||||||
|
var objectTypeName = res[0].ObjectTypeName;
|
||||||
|
var tagNumber = res[0].tags[0].TagNumber;
|
||||||
|
var props = res[0].tags[0].EngineDataProperty;
|
||||||
|
var listAnno = listAnnotation.Where(a => a.TagHandid == handid).ToList();
|
||||||
|
foreach (var anno in listAnno)
|
||||||
|
{
|
||||||
|
var pro = props.FirstOrDefault(a => a.PropertyName == anno.AttributeName);
|
||||||
|
if (pro != null)
|
||||||
|
{
|
||||||
|
anno.ObjectTypeName = objectTypeName;
|
||||||
|
anno.TagNumber = tagNumber;
|
||||||
|
anno.AttributeValue = pro.PropertyValue.ToString();
|
||||||
|
AddMsg($"获取属性值成功,类型:{objectTypeName},位号:{tagNumber},属性名:{anno.AttributeName},属性值:{anno.AttributeValue}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddMsg($"元件句柄({handid})获取属性值异常!", false);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AddMsg("元件属性值信息查询完成!");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
AddMsg("基点元件信息查询异常:" + ex.Message);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IsEnableGetAttribute = IsEnableRefreshAnnotation = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 刷新标注
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="o"></param>
|
||||||
|
public async void onRefreshAnnotation(object o)
|
||||||
|
{
|
||||||
|
//if (isRefresh)
|
||||||
|
//{
|
||||||
|
// MessageBox.Show("正在刷新标注,请勿操作...");
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
|
var msg = string.Empty;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
IsEnableGetAttribute = IsEnableRefreshAnnotation = false;
|
||||||
|
listMsg.Clear();
|
||||||
|
if (!listAnnotation.Any())
|
||||||
|
{
|
||||||
|
AddMsg($"没有正常匹配的标注数据,无需刷新!", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var progress = new Progress<MessageModel>(UpdateProgress);
|
||||||
|
await DoWorkAsync(progress, new CancellationTokenSource());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("异常:" + ex.Message);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IsEnableGetAttribute = IsEnableRefreshAnnotation = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#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<MessageModel> progress, CancellationTokenSource cts)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<KeyValueModel> listValue = new List<KeyValueModel>();
|
||||||
|
var msg = string.Empty;
|
||||||
|
foreach (var anno in listAnnotation)
|
||||||
|
{
|
||||||
|
if (anno.Status == "已刷新")
|
||||||
|
{
|
||||||
|
AddMsg($"当前标注[{anno.AnnotationHandid}]的已刷新,跳至下一个");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (anno.AttributeValue == anno.AnnotationValue)
|
||||||
|
{
|
||||||
|
AddMsg($"当前标注[{anno.AnnotationHandid}]的属性值和标注值一致,无需刷新,跳至下一个");
|
||||||
|
anno.Status = "无需刷新";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
listValue.Add(new KeyValueModel() { Key = anno.AnnotationHandid, Value = anno.AttributeValue });
|
||||||
|
AddMsg($"当前标注句柄:{anno.AnnotationHandid},属性值:{anno.AttributeValue},已加入刷新列表");
|
||||||
|
anno.Status = "等待刷新";
|
||||||
|
await Task.Delay(100);
|
||||||
|
}
|
||||||
|
if (!listValue.Any())
|
||||||
|
{ AddMsg($"所有标注值与属性值一致,无需刷新!", false); return; }
|
||||||
|
msg = General.RefreshMTextInfo(listValue);
|
||||||
|
if (string.IsNullOrWhiteSpace(msg))
|
||||||
|
{
|
||||||
|
foreach (var anno in listValue)
|
||||||
|
{
|
||||||
|
var dto = listAnnotation.FirstOrDefault(a => a.AnnotationHandid == anno.Key);
|
||||||
|
if (dto != null)
|
||||||
|
{
|
||||||
|
dto.Status = "已刷新";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AddMsg("操作已完成!");
|
||||||
|
}
|
||||||
|
else { AddMsg($"刷新标注列表异常:{msg}",false); }
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("异常:" + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region 添加提示信息
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加提示信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="msg">信息</param>
|
||||||
|
/// <param name="isSucc">是否成功</param>
|
||||||
|
private void AddMsg(string msg, bool isSucc = true)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("添加提示信息异常:" + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
290
newFront/c#前端/SWS.Electrical/Views/DialogRefreshAnnotation.xaml
Normal file
290
newFront/c#前端/SWS.Electrical/Views/DialogRefreshAnnotation.xaml
Normal file
@ -0,0 +1,290 @@
|
|||||||
|
<UserControl
|
||||||
|
x:Class="SWS.Electrical.Views.DialogRefreshAnnotation"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:Custom="http://www.galasoft.ch/mvvmlight"
|
||||||
|
xmlns:CustomControl="clr-namespace:SWS.CustomControl;assembly=SWS.CustomControl"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
|
xmlns:local="clr-namespace:SWS.Electrical"
|
||||||
|
xmlns:local2="clr-namespace:SWS.Model;assembly=SWS.Model"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:prism="http://prismlibrary.com/"
|
||||||
|
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
|
||||||
|
Width="900"
|
||||||
|
Height="700"
|
||||||
|
Background="#2D3135"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
<prism:Dialog.WindowStyle>
|
||||||
|
<Style TargetType="Window">
|
||||||
|
<Setter Property="Width" Value="{Binding Source={x:Static SystemParameters.WorkArea}, Path=Width}" />
|
||||||
|
<Setter Property="Height" Value="{Binding Source={x:Static SystemParameters.WorkArea}, Path=Height}" />
|
||||||
|
|
||||||
|
<Setter Property="WindowState" Value="Normal" />
|
||||||
|
<Setter Property="WindowStyle" Value="None" />
|
||||||
|
<Setter Property="ResizeMode" Value="NoResize" />
|
||||||
|
</Style>
|
||||||
|
</prism:Dialog.WindowStyle>
|
||||||
|
<UserControl.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<Style TargetType="DataGrid">
|
||||||
|
<Setter Property="RowHeaderWidth" Value="0" />
|
||||||
|
<Setter Property="AutoGenerateColumns" Value="False" />
|
||||||
|
<Setter Property="CanUserAddRows" Value="False" />
|
||||||
|
<Setter Property="CanUserResizeColumns" Value="False" />
|
||||||
|
<Setter Property="CanUserResizeRows" Value="False" />
|
||||||
|
<Setter Property="HorizontalGridLinesBrush" Value="LightGray" />
|
||||||
|
<Setter Property="VerticalGridLinesBrush" Value="LightGray" />
|
||||||
|
<Setter Property="IsReadOnly" Value="False" />
|
||||||
|
<Setter Property="BorderThickness" Value="1,0" />
|
||||||
|
<Setter Property="BorderBrush" Value="LightGray" />
|
||||||
|
<Setter Property="RowHeight" Value="30" />
|
||||||
|
<Setter Property="VerticalScrollBarVisibility" Value="Auto" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- DataGrid表头样式 -->
|
||||||
|
<Style TargetType="DataGridColumnHeader">
|
||||||
|
<Setter Property="FontSize" Value="13" />
|
||||||
|
<Setter Property="Background" Value="White" />
|
||||||
|
<Setter Property="BorderThickness" Value="1,1,1,1" />
|
||||||
|
<Setter Property="BorderBrush" Value="LightGray" />
|
||||||
|
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- DataGrid复选框样式 -->
|
||||||
|
<Style x:Key="VerticalCheckBox" TargetType="CheckBox">
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center" />
|
||||||
|
<Setter Property="FontSize" Value="16" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type CheckBox}">
|
||||||
|
<StackPanel Name="sp" HorizontalAlignment="Center">
|
||||||
|
<ContentPresenter Margin="2" HorizontalAlignment="Center" />
|
||||||
|
<Border
|
||||||
|
x:Name="bd"
|
||||||
|
Width="20"
|
||||||
|
Height="20"
|
||||||
|
BorderBrush="Gray"
|
||||||
|
BorderThickness="1.5">
|
||||||
|
<Border.Background>
|
||||||
|
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
|
||||||
|
<GradientStop Offset="0.05" Color="LightGray" />
|
||||||
|
<GradientStop Offset="1" Color="White" />
|
||||||
|
</LinearGradientBrush>
|
||||||
|
</Border.Background>
|
||||||
|
<Path
|
||||||
|
Name="checkPath"
|
||||||
|
Width="18"
|
||||||
|
Height="16"
|
||||||
|
Stroke="Black"
|
||||||
|
StrokeThickness="2" />
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsChecked" Value="True">
|
||||||
|
<Setter TargetName="checkPath" Property="Data" Value="M 1.5,5 L 7,13 17,0" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="bd" Property="Background" Value="LightGray" />
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- DataGrid单元格选中样式 #6495ED -->
|
||||||
|
<Style TargetType="DataGridCell">
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="Foreground" Value="#6495ED" />
|
||||||
|
<Setter Property="BorderThickness" Value="0" />
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
|
</UserControl.Resources>
|
||||||
|
<telerik:RadBusyIndicator BusyContent="{Binding BusyContent}" IsBusy="{Binding IsBusy}">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="auto" />
|
||||||
|
<RowDefinition Height="70" />
|
||||||
|
<RowDefinition Height="300" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<CustomControl:customWindowTitleBar x:Name="titleBar" Grid.Row="0" />
|
||||||
|
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="1"
|
||||||
|
Height="30"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<Button
|
||||||
|
Width="150"
|
||||||
|
Margin="60,0,0,0"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Command="{Binding Command_GetAttribute}"
|
||||||
|
Content="获取元件属性值"
|
||||||
|
FontSize="16"
|
||||||
|
IsEnabled="{Binding IsEnableGetAttribute}" />
|
||||||
|
<Button
|
||||||
|
Width="140"
|
||||||
|
Margin="40,0,0,0"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Command="{Binding Command_RefreshAnnotation}"
|
||||||
|
Content="刷新标注"
|
||||||
|
FontSize="16"
|
||||||
|
IsEnabled="{Binding IsEnableRefreshAnnotation}" />
|
||||||
|
</StackPanel>
|
||||||
|
<TabControl Grid.Row="2" Height="auto">
|
||||||
|
<TabItem Header="{Binding NormalTagCount}">
|
||||||
|
<DataGrid
|
||||||
|
x:Name="dgTag"
|
||||||
|
Height="auto"
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
CanUserAddRows="False"
|
||||||
|
CanUserResizeColumns="True"
|
||||||
|
HeadersVisibility="Column"
|
||||||
|
ItemsSource="{Binding listAnnotation, Mode=TwoWay}"
|
||||||
|
RowHeight="22"
|
||||||
|
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||||
|
SelectionMode="Single">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="auto"
|
||||||
|
Binding="{Binding ObjectTypeName}"
|
||||||
|
Header="元件类型"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="auto"
|
||||||
|
Binding="{Binding TagNumber}"
|
||||||
|
Header="元件位号"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="80"
|
||||||
|
Binding="{Binding TagHandid}"
|
||||||
|
Header="元件句柄"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="150"
|
||||||
|
Binding="{Binding AttributeName}"
|
||||||
|
Header="属性名"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="*"
|
||||||
|
Binding="{Binding AttributeValue}"
|
||||||
|
Header="属性值"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="80"
|
||||||
|
Binding="{Binding AnnotationHandid}"
|
||||||
|
Header="标注句柄"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="*"
|
||||||
|
Binding="{Binding AnnotationValue}"
|
||||||
|
Header="图纸标注值"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="100"
|
||||||
|
Binding="{Binding Status}"
|
||||||
|
Header="状态"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
</DataGrid.Columns>
|
||||||
|
<DataGrid.RowStyle>
|
||||||
|
<Style TargetType="DataGridRow">
|
||||||
|
<Setter Property="Background" Value="White" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding Status}" Value="已刷新">
|
||||||
|
<Setter Property="Background" Value="LightGreen" />
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger Binding="{Binding Status}" Value="无需刷新">
|
||||||
|
<Setter Property="Background" Value="LightGreen" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.RowStyle>
|
||||||
|
</DataGrid>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="{Binding ErrTagCount}">
|
||||||
|
<DataGrid
|
||||||
|
Height="auto"
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
CanUserAddRows="False"
|
||||||
|
CanUserResizeColumns="True"
|
||||||
|
HeadersVisibility="Column"
|
||||||
|
ItemsSource="{Binding listErrAnnotation, Mode=TwoWay}"
|
||||||
|
RowHeight="22"
|
||||||
|
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||||
|
SelectionMode="Single">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="auto"
|
||||||
|
Binding="{Binding ObjectTypeName}"
|
||||||
|
Header="元件类型"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="auto"
|
||||||
|
Binding="{Binding TagNumber}"
|
||||||
|
Header="元件位号"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="80"
|
||||||
|
Binding="{Binding TagHandid}"
|
||||||
|
Header="元件句柄"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="150"
|
||||||
|
Binding="{Binding AttributeName}"
|
||||||
|
Header="属性名"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="*"
|
||||||
|
Binding="{Binding AttributeValue}"
|
||||||
|
Header="属性值"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="80"
|
||||||
|
Binding="{Binding AnnotationHandid}"
|
||||||
|
Header="标注句柄"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="*"
|
||||||
|
Binding="{Binding AnnotationValue}"
|
||||||
|
Header="图纸标注值"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="100"
|
||||||
|
Binding="{Binding Status}"
|
||||||
|
Header="状态"
|
||||||
|
IsReadOnly="True" />
|
||||||
|
</DataGrid.Columns>
|
||||||
|
<DataGrid.RowStyle>
|
||||||
|
<Style TargetType="DataGridRow">
|
||||||
|
<Setter Property="Background" Value="White" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding Status}" Value="已刷新">
|
||||||
|
<Setter Property="Background" Value="LightGreen" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.RowStyle>
|
||||||
|
</DataGrid>
|
||||||
|
</TabItem>
|
||||||
|
</TabControl>
|
||||||
|
<ListBox
|
||||||
|
Grid.Row="3"
|
||||||
|
Background="Black"
|
||||||
|
ItemsSource="{Binding listMsg}"
|
||||||
|
ScrollViewer.VerticalScrollBarVisibility="Visible">
|
||||||
|
<i:Interaction.Behaviors>
|
||||||
|
<local:ListBoxScrollToBottomBehavior />
|
||||||
|
</i:Interaction.Behaviors>
|
||||||
|
</ListBox>
|
||||||
|
</Grid>
|
||||||
|
</telerik:RadBusyIndicator>
|
||||||
|
</UserControl>
|
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using SWS.Electrical.ViewModels;
|
||||||
|
using SWS.Model;
|
||||||
|
|
||||||
|
namespace SWS.Electrical.Views
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 刷新标注
|
||||||
|
/// </summary>
|
||||||
|
public partial class DialogRefreshAnnotation : UserControl
|
||||||
|
{
|
||||||
|
public DialogRefreshAnnotation()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -57,7 +57,7 @@ namespace SWS.Service
|
|||||||
{
|
{
|
||||||
var uri = new Uri(GlobalObject.client.BaseAddress + requestUri);
|
var uri = new Uri(GlobalObject.client.BaseAddress + requestUri);
|
||||||
var funName = uri.Segments.Last();
|
var funName = uri.Segments.Last();
|
||||||
//LoggerHelper.Current.WriteJson(funName, strJson);
|
LoggerHelper.Current.WriteJson(funName, strJson);
|
||||||
}
|
}
|
||||||
catch (Exception ex){ }
|
catch (Exception ex){ }
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ namespace SWS.Service
|
|||||||
if (response.StatusCode != HttpStatusCode.OK)
|
if (response.StatusCode != HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
string errorMsg = $"服务器地址 [{requestUri}] 获取数据失败, 返回HTTP代码:" + response.StatusCode;
|
string errorMsg = $"服务器地址 [{requestUri}] 获取数据失败, 返回HTTP代码:" + response.StatusCode;
|
||||||
//LoggerHelper.Current.Error(errorMsg);
|
LoggerHelper.Current.Error(errorMsg);
|
||||||
throw new HttpRequestException(errorMsg);
|
throw new HttpRequestException(errorMsg);
|
||||||
}
|
}
|
||||||
result = await response.Content.ReadAsStringAsync();
|
result = await response.Content.ReadAsStringAsync();
|
||||||
@ -89,14 +89,14 @@ namespace SWS.Service
|
|||||||
catch (JsonException)
|
catch (JsonException)
|
||||||
{
|
{
|
||||||
string errorMsg = $"服务器地址 [{requestUri}] 解析为{typeof(T).Name}失败,原始返回数据为: " + result;
|
string errorMsg = $"服务器地址 [{requestUri}] 解析为{typeof(T).Name}失败,原始返回数据为: " + result;
|
||||||
//LoggerHelper.Current.Error(errorMsg);
|
LoggerHelper.Current.Error(errorMsg);
|
||||||
resultObj = new learunHttpRes<T>() { code = -100, info = errorMsg };
|
resultObj = new learunHttpRes<T>() { code = -100, info = errorMsg };
|
||||||
return resultObj;
|
return resultObj;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
string errorMsg = $"接口:{requestUri}失败,异常:{ex.Message} ";
|
string errorMsg = $"接口:{requestUri}失败,异常:{ex.Message} ";
|
||||||
//LoggerHelper.Current.Error(errorMsg);
|
LoggerHelper.Current.Error(errorMsg);
|
||||||
resultObj = new learunHttpRes<T>() { code = -100, info=errorMsg };
|
resultObj = new learunHttpRes<T>() { code = -100, info=errorMsg };
|
||||||
return resultObj;
|
return resultObj;
|
||||||
}
|
}
|
||||||
@ -111,12 +111,12 @@ namespace SWS.Service
|
|||||||
//业务错误,不是http本质错误
|
//业务错误,不是http本质错误
|
||||||
default:
|
default:
|
||||||
string errorMsg = $"服务器地址 [{requestUri}] Get失败, 返回自定义代码:" + resultObj.code;
|
string errorMsg = $"服务器地址 [{requestUri}] Get失败, 返回自定义代码:" + resultObj.code;
|
||||||
//LoggerHelper.Current.Error(errorMsg);
|
LoggerHelper.Current.Error(errorMsg);
|
||||||
throw new HttpRequestException(errorMsg);
|
throw new HttpRequestException(errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
////LoggerHelper.Current.Info($"Get成功:{requestUri}");
|
LoggerHelper.Current.Info($"Get成功:{requestUri}");
|
||||||
return resultObj;
|
return resultObj;
|
||||||
|
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ namespace SWS.Service
|
|||||||
if (response.StatusCode != HttpStatusCode.OK)
|
if (response.StatusCode != HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
string errorMsg = $"服务器地址 [{requestUri}] 获取数据失败, 返回HTTP代码:" + response.StatusCode;
|
string errorMsg = $"服务器地址 [{requestUri}] 获取数据失败, 返回HTTP代码:" + response.StatusCode;
|
||||||
//LoggerHelper.Current.Error(errorMsg);
|
LoggerHelper.Current.Error(errorMsg);
|
||||||
throw new HttpRequestException(errorMsg);
|
throw new HttpRequestException(errorMsg);
|
||||||
}
|
}
|
||||||
result = await response.Content.ReadAsStringAsync();
|
result = await response.Content.ReadAsStringAsync();
|
||||||
@ -143,17 +143,17 @@ namespace SWS.Service
|
|||||||
catch (JsonException)
|
catch (JsonException)
|
||||||
{
|
{
|
||||||
string errorMsg = $"服务器地址 [{requestUri}] 解析为{typeof(T).Name}失败,原始返回数据为: " + result;
|
string errorMsg = $"服务器地址 [{requestUri}] 解析为{typeof(T).Name}失败,原始返回数据为: " + result;
|
||||||
//LoggerHelper.Current.Error(errorMsg);
|
LoggerHelper.Current.Error(errorMsg);
|
||||||
throw new JsonException(errorMsg);
|
throw new JsonException(errorMsg);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
string errorMsg = $"接口:{requestUri}失败,异常:{ex.Message} ";
|
string errorMsg = $"接口:{requestUri}失败,异常:{ex.Message} ";
|
||||||
//LoggerHelper.Current.Error(errorMsg);
|
LoggerHelper.Current.Error(errorMsg);
|
||||||
throw new JsonException(errorMsg);
|
throw new JsonException(errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
//LoggerHelper.Current.Info($"Get成功:{requestUri}");
|
LoggerHelper.Current.Info($"Get成功:{requestUri}");
|
||||||
return resultObj;
|
return resultObj;
|
||||||
|
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ namespace SWS.Service
|
|||||||
if (response.StatusCode != HttpStatusCode.OK)
|
if (response.StatusCode != HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
string errorMsg = $"服务器地址 [{requestUri}] Post数据失败, 返回HTTP代码:" + response.StatusCode;
|
string errorMsg = $"服务器地址 [{requestUri}] Post数据失败, 返回HTTP代码:" + response.StatusCode;
|
||||||
//LoggerHelper.Current.Error(errorMsg);
|
LoggerHelper.Current.Error(errorMsg);
|
||||||
throw new HttpRequestException(errorMsg);
|
throw new HttpRequestException(errorMsg);
|
||||||
}
|
}
|
||||||
result = await response.Content.ReadAsStringAsync();
|
result = await response.Content.ReadAsStringAsync();
|
||||||
@ -194,14 +194,14 @@ namespace SWS.Service
|
|||||||
catch (JsonException)
|
catch (JsonException)
|
||||||
{
|
{
|
||||||
string errorMsg = $"服务器地址 [{requestUri}] 解析为{typeof(T).Name}失败,原始返回数据为: " + result;
|
string errorMsg = $"服务器地址 [{requestUri}] 解析为{typeof(T).Name}失败,原始返回数据为: " + result;
|
||||||
//LoggerHelper.Current.Error(errorMsg);
|
LoggerHelper.Current.Error(errorMsg);
|
||||||
resultObj = new learunHttpRes<T>() { code = -100, info = errorMsg };
|
resultObj = new learunHttpRes<T>() { code = -100, info = errorMsg };
|
||||||
return resultObj;
|
return resultObj;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
string errorMsg = $"接口:{requestUri}失败,参数数据为:{strContent},异常:{ex.Message} ";
|
string errorMsg = $"接口:{requestUri}失败,参数数据为:{strContent},异常:{ex.Message} ";
|
||||||
//LoggerHelper.Current.Error(errorMsg);
|
LoggerHelper.Current.Error(errorMsg);
|
||||||
resultObj = new learunHttpRes<T>() { code = -100, info = errorMsg };
|
resultObj = new learunHttpRes<T>() { code = -100, info = errorMsg };
|
||||||
return resultObj;
|
return resultObj;
|
||||||
}
|
}
|
||||||
@ -216,12 +216,12 @@ namespace SWS.Service
|
|||||||
//业务错误,不是http本质错误
|
//业务错误,不是http本质错误
|
||||||
default:
|
default:
|
||||||
string errorMsg = $"服务器地址 [{requestUri}] Post失败, 返回自定义代码:" + resultObj.code;
|
string errorMsg = $"服务器地址 [{requestUri}] Post失败, 返回自定义代码:" + resultObj.code;
|
||||||
//LoggerHelper.Current.Error(errorMsg);
|
LoggerHelper.Current.Error(errorMsg);
|
||||||
throw new HttpRequestException(errorMsg);
|
throw new HttpRequestException(errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//LoggerHelper.Current.Info($"Post成功:{requestUri}");
|
LoggerHelper.Current.Info($"Post成功:{requestUri}");
|
||||||
return resultObj;
|
return resultObj;
|
||||||
|
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ namespace SWS.Service
|
|||||||
if (response.StatusCode != HttpStatusCode.OK)
|
if (response.StatusCode != HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
string errorMsg = $"服务器地址 [{requestUri}] Post数据失败, 返回HTTP代码:" + response.StatusCode;
|
string errorMsg = $"服务器地址 [{requestUri}] Post数据失败, 返回HTTP代码:" + response.StatusCode;
|
||||||
//LoggerHelper.Current.Error(errorMsg);
|
LoggerHelper.Current.Error(errorMsg);
|
||||||
throw new HttpRequestException(errorMsg);
|
throw new HttpRequestException(errorMsg);
|
||||||
}
|
}
|
||||||
var result = await response.Content.ReadAsStringAsync();
|
var result = await response.Content.ReadAsStringAsync();
|
||||||
@ -257,10 +257,10 @@ namespace SWS.Service
|
|||||||
catch (JsonException)
|
catch (JsonException)
|
||||||
{
|
{
|
||||||
string errorMsg = $"服务器地址 [{requestUri}] 解析为 string 失败,原始返回数据为: " + result;
|
string errorMsg = $"服务器地址 [{requestUri}] 解析为 string 失败,原始返回数据为: " + result;
|
||||||
//LoggerHelper.Current.Error(errorMsg);
|
LoggerHelper.Current.Error(errorMsg);
|
||||||
throw new JsonException(errorMsg);
|
throw new JsonException(errorMsg);
|
||||||
}
|
}
|
||||||
//LoggerHelper.Current.Info($"Post上传文件成功:{requestUri}");
|
LoggerHelper.Current.Info($"Post上传文件成功:{requestUri}");
|
||||||
return resultObj;
|
return resultObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,10 @@ namespace SWS.Share
|
|||||||
/// system
|
/// system
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string TagNumber_Lower { get; set; } = "";
|
public string TagNumber_Lower { get; set; } = "";
|
||||||
|
/// <summary>
|
||||||
|
/// 房间号
|
||||||
|
/// </summary>
|
||||||
|
public string RoomNo { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 图元文件Id
|
/// 图元文件Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user