Files
CJLR-Analysis/Analysis/CjlrForm/FAddConfig.cs
T
zhengxuan.zhang 08e623410f 260520 优化历史已解析入库但没有分发成功的问题
新到文件是否仍然正常出现 匹配成功 -> 待解析区 -> 解析成功 -> 正式区 -> 双侧完成 -> 客户报告生成。
历史遗留文件是否出现 已补充分发到正式区 这类新日志,并从源目录消失。
已经真正分发完成的文件,是否仍然保持 已处理且目标区域已存在,跳过,没有重复搬运。
2026-05-20 16:06:37 +08:00

203 lines
5.6 KiB
C#

using BaseFunction;
using NSAnalysis.DAL;
using NSAnalysis.Model;
using System;
using System.Drawing;
using System.Windows.Forms;
using Telerik.WinControls.UI;
namespace NSAnalysis
{
public partial class FAddConfig : Telerik.WinControls.UI.ShapedForm
{
#region
private CjlrDAL tmdal = new CjlrDAL();
private FConfigSetup gFTS;
#endregion
#region
private void btn_MouseHover(object sender, EventArgs e)
{
RadButton btn = sender as RadButton;
btn.BackColor = Color.FromArgb(0, 151, 186);
}
private void btn_MouseLeave(object sender, EventArgs e)
{
RadButton btn = sender as RadButton;
btn.BackColor = Color.FromArgb(19, 46, 53);
}
#endregion
public FAddConfig(FConfigSetup fts)
{
InitializeComponent();
gFTS = fts;
}
private void FAddTolerance_Load(object sender, EventArgs e)
{
rddl_ReadType.SelectedIndex = 0;
rddl_Position.SelectedIndex = 0;
rddl_Status.SelectedIndex = 0;
}
private void rbtnOK_Click(object sender, EventArgs e)
{
#region
string strCarName = rtbCarName.Text.Trim();
string strCarType = rtbCarType.Text.Trim();
string strReadType = rddl_ReadType.Text.Trim();
string strPosition = rddl_Position.Text.Trim();
string strStatus = rddl_Status.Text.Trim();
if (string.IsNullOrEmpty(rtbCarName.Text.Trim()))
{
MessageBox.Show("车型名称不能为空,请重新输入! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (string.IsNullOrEmpty(rtbCarType.Text.Trim()))
{
MessageBox.Show("车型代码不能为空,请重新输入! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (string.IsNullOrEmpty(rtb_sourceFilePath.Text.Trim()))
{
MessageBox.Show("源文件路径不能为空,请重新输入! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (string.IsNullOrEmpty(rtb_targetFilePath.Text.Trim()))
{
MessageBox.Show("目标文件路径不能为空,请重新输入! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// 对于分发配置,strReadType 进行转换,文件内容对应1,文件名称对应2
if (string.IsNullOrEmpty(strReadType) || (strReadType != "文件内容" && strReadType != "文件名称"))
{
MessageBox.Show("请选择正确的读取类型! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (strReadType.Equals("文件名称"))
{
strReadType = "2"; // 文件名称
}
else if (strReadType.Equals("文件内容"))
{
strReadType = "1"; // 文件内容
}
if (tmdal.CheckTaskExit(strCarName, strCarType, strReadType))
{
MessageBox.Show("该车身类型下,已经存在该测量点位名称和尺寸名称,请修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
#endregion
//数据转换
if (strPosition.Equals("左侧"))
{
strPosition = "L";
}
else if (strPosition.Equals("右侧"))
{
strPosition = "R";
}
if (strStatus.Equals("启动"))
{
strStatus = "start"; // 启动
}
else if (strStatus.Equals("停止"))
{
strStatus = "stop"; // 停止
}
//添加分发配置
CjlrTaskReleaseModel cJLR_TASK_RELEASE = new CjlrTaskReleaseModel();
cJLR_TASK_RELEASE.ModelsName = strCarName;
cJLR_TASK_RELEASE.ModelsCode = strCarType;
cJLR_TASK_RELEASE.Position = strPosition;
cJLR_TASK_RELEASE.SourceFile = rtb_sourceFilePath.Text.Trim();
cJLR_TASK_RELEASE.TargetFile = rtb_targetFilePath.Text.Trim();
cJLR_TASK_RELEASE.ReadType = int.Parse(strReadType);
cJLR_TASK_RELEASE.IsDelete = 1; //默认未删除
cJLR_TASK_RELEASE.Status = strStatus;
try
{
tmdal.InsertTask(cJLR_TASK_RELEASE);
}
catch (Exception ex)
{
MessageBox.Show("添加分发配置失败,原因:" + ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
MyBase.TraceWriteLine("添加分发配置失败,原因:" + ex.ToString());
return;
}
MessageBox.Show("添加分发配置成功! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
gFTS.rtbnSearch_Click(null, null);
}
private void rbtnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btn_sourceFile_Click(object sender, EventArgs e) //原路径
{
// 创建 FolderBrowserDialog 实例
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog
{
Description = "选择源文件夹"
};
// 显示文件夹浏览对话框
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
// 设置选中的文件夹路径到文本框
rtb_sourceFilePath.Text = folderBrowserDialog.SelectedPath;
}
else
{
// 显示未选择文件夹的提示信息
MessageBox.Show("未选择源文件夹", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void btn_targetFile_Click(object sender, EventArgs e) //目标路径
{
// 创建 FolderBrowserDialog 实例
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog
{
Description = "选择目标文件夹"
};
// 显示文件夹浏览对话框
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
// 设置选中的文件夹路径到文本框
rtb_targetFilePath.Text = folderBrowserDialog.SelectedPath;
}
else
{
// 显示未选择文件夹的提示信息
MessageBox.Show("未选择目标文件夹", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}