105040 Update 不再使用json转换;增加DEBUG标记判断,方便调试
This commit is contained in:
parent
5b11cae2cd
commit
4b2f449a97
|
@ -8,6 +8,7 @@ using EPLAN.Harness.Core.Props;
|
|||
using EPLAN.Harness.ProjectCore;
|
||||
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
|
||||
using Sinvo.EplanHpD.Plugin.Service;
|
||||
using Sinvo.EplanHpD.Plugin.Service.Model;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -15,6 +16,7 @@ using System.ComponentModel;
|
|||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Remoting.Contexts;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -70,8 +72,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
if (_selectLineId == null) return "";
|
||||
var part = _currentFlexDesigner.GetOccurrenceByID(_selectLineId);
|
||||
if (part != null)
|
||||
|
@ -115,7 +115,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
set
|
||||
{
|
||||
|
@ -185,22 +184,18 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
{
|
||||
SelectMotorModel = part.Parents?.First()?.Name ?? "";
|
||||
Debug.WriteLine($"Select part parent -> {part.Parents?.First()?.Name} / {part.Parents?.First()?.ID}");
|
||||
|
||||
}
|
||||
}
|
||||
else if (item != null)
|
||||
{
|
||||
CheckSelLine(slient: true);
|
||||
_selectLineId = item.ID;
|
||||
OnPropertyChanged(nameof(SelectLineName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsCable(BaseOccurrence occ)
|
||||
{
|
||||
return occ is OccCableForked;
|
||||
}
|
||||
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
|
@ -211,14 +206,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
{
|
||||
if (_motorIds != null && _motorIds.Any())
|
||||
{
|
||||
|
||||
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
var service = new MotorLectotypeService();
|
||||
var data = service.GetMotorLectotypeData(_motorIds[CurrentMotorIndex]);
|
||||
if (!string.IsNullOrEmpty(data))
|
||||
if (data != null)
|
||||
{
|
||||
cableLectotypeViewModel = Newtonsoft.Json.JsonConvert.DeserializeObject<CableLectotypeViewModel>(data);
|
||||
cableLectotypeViewModel = data;
|
||||
if (cableLectotypeViewModel?.SelectedLines?.Any() ?? false)
|
||||
{
|
||||
SelectedLines = cableLectotypeViewModel.SelectedLines;
|
||||
|
@ -285,7 +280,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
private bool CheckSelLine()
|
||||
private bool CheckSelLine(bool slient = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -300,7 +295,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
: part is OccCablesInsulatorGraph ?
|
||||
part
|
||||
: part.Parents?.FirstOrDefault() as OccCableForked;
|
||||
|
||||
if (linePart != null)
|
||||
{
|
||||
var libName = linePart?.LibraryName;
|
||||
|
@ -327,37 +321,53 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
}
|
||||
if (string.IsNullOrEmpty(imprint))
|
||||
{
|
||||
FlexMessageBox.Warning($"当前选中的线 {libName} 印记未填写");
|
||||
#if DEBUG
|
||||
return true;
|
||||
#else
|
||||
if(!slient)
|
||||
FlexMessageBox.Warning($"当前选中的线 {libName} 印记未填写");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
if ($"{SelectedLine.AxisNo}-{SelectedLine.CurrentLine}" == imprint)
|
||||
{
|
||||
subLine.IsChecked = true;
|
||||
//cableLectotypeViewModel.SaveToDb();
|
||||
SetSubLineAndSave(subLine.CableModel);
|
||||
SetSubLineAndSave(subLine.CableLectotypeId);
|
||||
return SubLines.All(it => it.IsChecked);
|
||||
}
|
||||
else
|
||||
{
|
||||
FlexMessageBox.Warning($"当前选中的线 {libName} 印记与推荐中的线印记不一致");
|
||||
{
|
||||
#if DEBUG
|
||||
return true;
|
||||
#else
|
||||
if(!slient)
|
||||
FlexMessageBox.Warning($"当前选中的线 {libName} 印记与推荐中的线印记不一致");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FlexMessageBox.Warning($"当前选中的线不是推荐中的线型号");
|
||||
#if DEBUG
|
||||
return true;
|
||||
#else
|
||||
if(!slient)
|
||||
FlexMessageBox.Warning($"当前选中的线不是推荐中的线型号");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
FlexMessageBox.Warning("抓取线信息异常");
|
||||
if(!slient)
|
||||
FlexMessageBox.Warning("抓取线信息异常");
|
||||
return false;
|
||||
}
|
||||
FlexMessageBox.Warning("请选择正确的线");
|
||||
if (!slient)
|
||||
FlexMessageBox.Warning("请选择正确的线");
|
||||
return false;
|
||||
}
|
||||
|
||||
internal void ToPrevMotor()
|
||||
{
|
||||
if (CurrentMotorIndex > 0)
|
||||
|
@ -380,33 +390,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
{
|
||||
SubLines = SelectedLine.SubLines.Distinct(it => it.CableModel).ToList();
|
||||
}
|
||||
|
||||
internal void SetSubLineAndSave(string cableModel)
|
||||
internal void SetSubLineAndSave(string cableLectotypeId)
|
||||
{
|
||||
foreach (var it in cableLectotypeViewModel.SelectedLines)
|
||||
{
|
||||
if (it.AxisNo == SelectedLine.AxisNo && it.CurrentLine == SelectedLine.CurrentLine)
|
||||
{
|
||||
foreach (var line in it.SubLines)
|
||||
{
|
||||
if (cableModel == line.CableModel)
|
||||
{
|
||||
line.IsChecked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SaveToDb(cableLectotypeViewModel);
|
||||
}
|
||||
|
||||
public bool SaveToDb(CableLectotypeViewModel cableLectotypeViewModel)
|
||||
{
|
||||
var id = cableLectotypeViewModel.Motor.OccPartId;
|
||||
var json = Newtonsoft.Json.JsonConvert.SerializeObject(cableLectotypeViewModel);
|
||||
var service = new MotorLectotypeService();
|
||||
return service.SaveMotorLectotypeData(id, json);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue