You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.IO;
using System.Windows;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.DataModel;
using Eplan.EplApi.HEServices;
using KPlan.Util;
using Progress = Eplan.EplApi.Base.Progress;
namespace KPlan.Actions {
class KCheckProjectAction : Eplan.EplApi.ApplicationFramework.IEplAction {
public bool Execute(ActionCallingContext ctx) {
TCUtil.DO_NOTHING();
if (!TCUtil.CheckLogin()) {
return true;
}
SelectionSet selectionSet = new SelectionSet();
Project currentProject = selectionSet.GetCurrentProject(false);
if (currentProject == null) {
MessageBox.Show("没有选择项目");
return true;
}
string projectCode = EplanUtil.GetPropValue(currentProject.Properties.PROJ_DRAWINGNUMBER);
if (KUtil.IsEmpty(projectCode)) {
MessageBox.Show("项目编号不可为空");
return true;
}
string projPath = currentProject.ProjectDirectoryPath;
DirectoryInfo di = new DirectoryInfo(projPath);
projPath = di.Parent.FullName;
KUtil.Log("加载项目信息[" + currentProject.ProjectName + "]" + projPath);
if (!projPath.EndsWith("\\")) {
projPath += "\\";
}
string exportFile = projPath + currentProject.ProjectName + ".xml";
Progress progress = new Progress("SimpleProgress");
try {
ExportPartList(progress,currentProject,exportFile);
if (progress.Canceled()) {
progress.EndPart(true);
return true;
}
progress.EndPart(true);
if (!File.Exists(exportFile)) {
MessageBox.Show("导出Partlist异常未找到导出文件");
return true;
}
}
catch (System.Exception ex) {
progress.EndPart(true);
KUtil.LogErr(ex);
MessageBox.Show("执行出错:" + ex.Message);
}
new Forms.KCheckProject(currentProject,projPath,exportFile,projectCode).ShowDialog();
string save = KUtil.GetConfigValue(KConfigure.CHECK_SECTION, KConfigure.CHECK_SAVEXML);
if (!"TRUE".Equals(save?.ToUpper())) {
File.Delete(exportFile);
}
return true;
}
private void ExportPartList(Progress progress,Project currentProject, string exportFile) {
progress.SetTitle("导出检查数据...");
progress.SetAllowCancel(true);
progress.BeginPart(100.0, "");
EplanUtil.ExportPartList(currentProject, exportFile, PartsService.Format.XML);
}
public bool OnRegister(ref string Name, ref int Ordinal) {
Name = "KCheckProjectAction";
Ordinal = 20;
return true;
}
public void GetActionProperties(ref ActionProperties actionProperties) {
//actionProperties.Description = "Action test with parameters.";
}
}
}