#006 调试解析文件,录入数据库,生成客户所需报告样式的功能;(对比奇瑞间隙面差自动化项目)
This commit is contained in:
+122
-1
@@ -1,6 +1,8 @@
|
||||
using NLog;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
@@ -3141,4 +3143,123 @@ namespace BaseFunction
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public static class JsonHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 对象转成JSON 格式字符串
|
||||
/// </summary>
|
||||
/// <param name="obj">对象</param>
|
||||
/// <returns>JSON格式的字符串</returns>
|
||||
public static string ObjectToJson(object obj)
|
||||
{
|
||||
return JsonConvert.SerializeObject(obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析JSON字符串生成对象实体
|
||||
/// </summary>
|
||||
/// <typeparam name="T">对象类型</typeparam>
|
||||
/// <param name="json">json字符串</param>
|
||||
/// <returns>对象实体</returns>
|
||||
public static T DeserializeJsonToObject<T>(string json) where T : class
|
||||
{
|
||||
Newtonsoft.Json.JsonSerializer serializer = new Newtonsoft.Json.JsonSerializer();
|
||||
StringReader sr = new StringReader(json);
|
||||
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(T));
|
||||
T t = o as T;
|
||||
return t;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析JSON数组生成对象实体集合
|
||||
/// </summary>
|
||||
/// <typeparam name="T">对象类型</typeparam>
|
||||
/// <param name="json">json数组字符串(eg.[{"ID":"112","Name":"石子儿"}])</param>
|
||||
/// <returns>对象实体集合</returns>
|
||||
public static List<T> DeserializeJsonToList<T>(string json) where T : class
|
||||
{
|
||||
Newtonsoft.Json.JsonSerializer serializer = new JsonSerializer();
|
||||
StringReader sr = new StringReader(json);
|
||||
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
|
||||
List<T> list = o as List<T>;
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据表转键值对集合 把DataTable转成 List集合, 存每一行 集合中放的是键值对字典,存每一列
|
||||
/// </summary>
|
||||
/// <param name="dt">数据表</param>
|
||||
/// <returns>哈希表数组</returns>
|
||||
public static List<Dictionary<string, object>> DataTableToList(DataTable dt)
|
||||
{
|
||||
List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
|
||||
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
Dictionary<string, object> dic = new Dictionary<string, object>();
|
||||
foreach (DataColumn dc in dt.Columns)
|
||||
{
|
||||
dic.Add(dc.ColumnName, dr[dc.ColumnName]);
|
||||
}
|
||||
list.Add(dic);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据集转键值对数组字典
|
||||
/// </summary>
|
||||
/// <returns>键值对数组字典</returns>
|
||||
public static Dictionary<string, List<Dictionary<string, object>>> DataSetToDic(DataSet ds)
|
||||
{
|
||||
Dictionary<string, List<Dictionary<string, object>>> result = new Dictionary<string, List<Dictionary<string, object>>>();
|
||||
|
||||
foreach (DataTable dt in ds.Tables)
|
||||
result.Add(dt.TableName, DataTableToList(dt));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据表转JSON
|
||||
/// </summary>
|
||||
/// <param name="dt">数据表</param>
|
||||
/// <returns>JSON字符串</returns>
|
||||
public static string DataTableToJson(DataTable dt)
|
||||
{
|
||||
return ObjectToJson(DataTableToList(dt));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// JSON文本转对象,泛型方法 常用
|
||||
/// </summary>
|
||||
/// <typeparam name="T">类型</typeparam>
|
||||
/// <param name="jsonText">JSON文本</param>
|
||||
/// <returns>指定类型的对象</returns>
|
||||
public static T JsonToObject<T>(string jsonText)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(jsonText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将JSON文本转换为数据表数据
|
||||
/// </summary>
|
||||
/// <param name="jsonText">JSON文本</param>
|
||||
/// <returns>数据表字典</returns>
|
||||
public static Dictionary<string, List<Dictionary<string, object>>> TablesDataFromJson(string jsonText)
|
||||
{
|
||||
return JsonToObject<Dictionary<string, List<Dictionary<string, object>>>>(jsonText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将JSON文本转换成数据行
|
||||
/// </summary>
|
||||
/// <param name="jsonText">JSON文本</param>
|
||||
/// <returns>数据行的字典</returns>
|
||||
public static Dictionary<string, object> DataRowFromJson(string jsonText)
|
||||
{
|
||||
return JsonToObject<Dictionary<string, object>>(jsonText);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ using NSAnalysis.DAL;
|
||||
using NSAnalysis.Model;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
|
||||
namespace NSAnalysis.BaseUnit
|
||||
@@ -32,7 +31,6 @@ namespace NSAnalysis.BaseUnit
|
||||
string sourceDir = task["sourceFile"].ToString();
|
||||
string targetDir = task["targetFile"].ToString();
|
||||
|
||||
|
||||
// 打印信息
|
||||
MyBase.TraceWriteLine($"Processing Task - Source: {sourceDir}, Target: {targetDir}, ModelCode: {modelCode} Position: {position}");
|
||||
if (Directory.Exists(sourceDir))
|
||||
@@ -43,7 +41,6 @@ namespace NSAnalysis.BaseUnit
|
||||
{
|
||||
MyBase.TraceWriteLine($"源文件地址不存在或错误: {sourceDir}");
|
||||
|
||||
|
||||
//记录到数据库
|
||||
try
|
||||
{
|
||||
@@ -70,9 +67,6 @@ namespace NSAnalysis.BaseUnit
|
||||
{
|
||||
MyBase.TraceWriteLine($"源文件地址不存在或错误: {sourceDir}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,7 +92,6 @@ namespace NSAnalysis.BaseUnit
|
||||
string matchStr = $"{modelCode}_{position}";
|
||||
MyBase.TraceWriteLine($"Matching files with: {matchStr}");
|
||||
|
||||
|
||||
// 判断目标目录是否存在,如果不存在记录到日志
|
||||
|
||||
// 确保目标目录存在
|
||||
@@ -202,9 +195,6 @@ namespace NSAnalysis.BaseUnit
|
||||
//string testPath = @"D:\CJLR\DATA\Input\LLL\K0902906.csv";
|
||||
//bool result = MatchCsvValue(testPath, "X540_L", 3, 1);
|
||||
//MyBase.TraceWriteLine($"匹配结果: {result}");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 编写一个打印 DataTable 对象的方法,输入是对象
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NSAnalysis.DAL
|
||||
{
|
||||
@@ -163,7 +162,6 @@ namespace NSAnalysis.DAL
|
||||
return dt;
|
||||
}
|
||||
|
||||
|
||||
public bool CheckTaskExit(string strModelsName, string strModelsCode, string strReadType)
|
||||
{
|
||||
DataTable dt = new DataTable();
|
||||
|
||||
@@ -133,8 +133,8 @@ namespace NSAnalysis
|
||||
bLanguage = FileIni.ReadBool(ConfigDfn.strConfigFile, strSection, "Language", 0);
|
||||
bRememberMe = FileIni.ReadBool(ConfigDfn.strConfigFile, strSection, "RememberMe", 0);
|
||||
strNextSenseCSVEH3Path = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "NextsenseCSVEH3Path");
|
||||
strNextSenseCSVEHYPath = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "NextsenseCSVEHYPath");
|
||||
strNextSenseSelfMeasurePath = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "NextseneSelfMeasurePath");
|
||||
|
||||
|
||||
strPwd = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "Password");
|
||||
iCreateReportFlag = FileIni.ReadInt(ConfigDfn.strConfigFile, strSection, "CreateReportFlag");
|
||||
strUploadPath = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "tavascanUploadPath");
|
||||
|
||||
+146
-674
@@ -1,7 +1,7 @@
|
||||
using BaseFunction;
|
||||
using DAL;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using NSAnalysis.DAL;
|
||||
using NSAnalysis.Model;
|
||||
using NSAnalysis.Properties;
|
||||
|
||||
using System;
|
||||
@@ -26,10 +26,9 @@ namespace NSAnalysis
|
||||
private string[] xValues = new string[3];
|
||||
private DataTable dtCSVContent = new DataTable();
|
||||
private DataTable dtRangeData = new DataTable();
|
||||
private TMeasureMSSQLDAL tmdal = new TMeasureMSSQLDAL();
|
||||
private CjlrDAL tmdal = new CjlrDAL();
|
||||
private string strSaveReprotPath = "";
|
||||
private bool bReadCSVFlag = false;
|
||||
private List<CheryIOTData> ListPostIOTData = new List<CheryIOTData>();
|
||||
|
||||
private int iCurrentMeasureItemsFailedCount = 0;
|
||||
#region PLC相关变量
|
||||
@@ -92,17 +91,11 @@ namespace NSAnalysis
|
||||
|
||||
#endregion 初始化全局变量
|
||||
|
||||
if (ConfigDfn.iAnalysisCSVFlag == 1)
|
||||
{
|
||||
|
||||
MyBase.TraceWriteLine(" 进入解析CSV文件模式,开始解析扫码CSV文件!");
|
||||
tmReadNextsenseCSV.Interval = 500;
|
||||
tmReadNextsenseCSV.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
MyBase.TraceWriteLine(" 进入不解析CSV文件模式!");
|
||||
tmReadNextsenseCSV.Stop();
|
||||
}
|
||||
|
||||
|
||||
if (Directory.Exists(ConfigDfn.strNextSenseCSVEH3Path))
|
||||
{
|
||||
@@ -113,37 +106,9 @@ namespace NSAnalysis
|
||||
string strTip = "错误:软件首次启动,读取NextSense生成EH3 CSV报告的路径:" + ConfigDfn.strNextSenseCSVEH3Path + " 不存在!请检查并进行修改!点击是按钮,软件将自动创建该路径!";
|
||||
MyBase.TraceWriteLine(strTip);
|
||||
Directory.CreateDirectory(ConfigDfn.strNextSenseCSVEH3Path);
|
||||
//DialogResult dResult = MessageBox.Show(strTip, "错误", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
|
||||
//if (dResult == DialogResult.Yes)
|
||||
//{
|
||||
// Directory.CreateDirectory(ConfigDfn.strNextSenseCSVEH3Path);
|
||||
// MyBase.TraceWriteLine(strTip + " ; 点击了是按钮,软件自动创建读取目录:" + ConfigDfn.strNextSenseCSVEH3Path);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// MyBase.TraceWriteLine(strTip + " ;点击了否按钮,不创建目录!");
|
||||
//}
|
||||
}
|
||||
if (Directory.Exists(ConfigDfn.strNextSenseCSVEHYPath))
|
||||
{
|
||||
MyBase.TraceWriteLine("软件首次启动, Nextsense EHY CSV读取路径存在;不清空,读取NextSense生成 CSV报告路径下的所有文件,路径为:" + ConfigDfn.strNextSenseCSVEHYPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
string strTip = "错误:软件首次启动,读取NextSense生成EHY CSV报告的路径:" + ConfigDfn.strNextSenseCSVEHYPath + " 不存在!请检查并进行修改!点击是按钮,软件将自动创建该路径!";
|
||||
MyBase.TraceWriteLine(strTip);
|
||||
Directory.CreateDirectory(ConfigDfn.strNextSenseCSVEHYPath);
|
||||
//DialogResult dResult = MessageBox.Show(strTip, "错误", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
|
||||
//if (dResult == DialogResult.Yes)
|
||||
//{
|
||||
// Directory.CreateDirectory(ConfigDfn.strNextSenseCSVEHYPath);
|
||||
// MyBase.TraceWriteLine(strTip + " ; 点击了是按钮,软件自动创建读取目录:" + ConfigDfn.strNextSenseCSVEHYPath);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// MyBase.TraceWriteLine(strTip + " ;点击了否按钮,不创建目录!");
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
lpcSoftwareSetup.labPicture.Click += new EventHandler(lpcSoftwareSetup_Click);
|
||||
lpcSoftwareSetup.labText.Click += new EventHandler(lpcSoftwareSetup_Click);
|
||||
|
||||
@@ -156,8 +121,7 @@ namespace NSAnalysis
|
||||
lpcShowLog.labPicture.Click += new EventHandler(lpcShowLog_Click);
|
||||
lpcShowLog.labText.Click += new EventHandler(lpcShowLog_Click);
|
||||
|
||||
//tmdal.updateMaintenceInfoEmpty();
|
||||
//iLastMesureCount = tmdal.SelectTMeasureResultCount();
|
||||
iLastMesureCount = tmdal.SelectTMeasureResultCount();
|
||||
|
||||
#region 清空信息
|
||||
|
||||
@@ -263,8 +227,6 @@ namespace NSAnalysis
|
||||
#endregion 分页相关
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (DialogResult.Yes == MessageBox.Show("警告:您确定要退出该软件系统吗?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
|
||||
@@ -299,7 +261,7 @@ namespace NSAnalysis
|
||||
private void tmReadNextsenseCSV_Tick(object sender, EventArgs e)
|
||||
{
|
||||
tmReadNextsenseCSV.Stop();
|
||||
AnalysisNextSenseSelfMeasureCSV();
|
||||
|
||||
AnalysisNextSenseEH3CSV();
|
||||
|
||||
tmReadNextsenseCSV.Start();
|
||||
@@ -307,38 +269,6 @@ namespace NSAnalysis
|
||||
|
||||
#region⭐⭐⭐⭐⭐ 解析Nextsense CSV文件功能 核心算法 ⭐⭐⭐⭐⭐
|
||||
|
||||
private double CalculateStrictLowerTolerance(double dLower, double dUpper)
|
||||
{
|
||||
double dStrictLower = 0;
|
||||
double dNormalValue = (dLower + dUpper) / 2;
|
||||
dStrictLower = dNormalValue + (dLower - dNormalValue) * ConfigDfn.dTolerancePer;
|
||||
return dStrictLower;
|
||||
}
|
||||
|
||||
private double CalculateStrictUpperTolerance(double dLower, double dUpper)
|
||||
{
|
||||
double dStrictUpper = 0;
|
||||
double dNormalValue = (dLower + dUpper) / 2;
|
||||
dStrictUpper = dNormalValue + (dUpper - dNormalValue) * ConfigDfn.dTolerancePer;
|
||||
return dStrictUpper;
|
||||
}
|
||||
|
||||
private double CalculateExceptionLowerTolerance(double dLower, double dUpper)
|
||||
{
|
||||
double dStrictLower = 0;
|
||||
double dNormalValue = (dLower + dUpper) / 2;
|
||||
dStrictLower = dNormalValue + (dLower - dNormalValue) * ConfigDfn.dExceptionTolerancePer;
|
||||
return dStrictLower;
|
||||
}
|
||||
|
||||
private double CalculateExceptionUpperTolerance(double dLower, double dUpper)
|
||||
{
|
||||
double dStrictUpper = 0;
|
||||
double dNormalValue = (dLower + dUpper) / 2;
|
||||
dStrictUpper = dNormalValue + (dUpper - dNormalValue) * ConfigDfn.dExceptionTolerancePer;
|
||||
return dStrictUpper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析EH3 CSV文件函数;后续如果Nextsense的csv报告模板变了,修改该函数的行号即可LineNum wsp
|
||||
/// </summary>
|
||||
@@ -360,7 +290,7 @@ namespace NSAnalysis
|
||||
foreach (FileInfo fi in fileInfos)
|
||||
{
|
||||
listCSVTitleInfo.Clear();
|
||||
ListPostIOTData.Clear();
|
||||
|
||||
dtCSVContent.Clear();
|
||||
dgvMeasureContent.Rows.Clear();
|
||||
string strCSVName = fi.FullName;
|
||||
@@ -432,25 +362,11 @@ namespace NSAnalysis
|
||||
ConfigDfn.strMeasureTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
double dNormalValue = 0.0d;
|
||||
|
||||
dt = tmdal.SelectOneToleranceByCondition("EH3", aryLineContent[0], aryLineContent[1]);
|
||||
if (dt.Rows.Count == 1)
|
||||
{
|
||||
dLowerValue = double.Parse(dt.Rows[0]["TolLower"].ToString());
|
||||
dUpperValue = double.Parse(dt.Rows[0]["TolUpper"].ToString());
|
||||
dNormalValue = (dLowerValue + dUpperValue) / 2;
|
||||
dStrictTLower = CalculateStrictLowerTolerance(dLowerValue, dUpperValue);
|
||||
dStrictTUpper = CalculateStrictUpperTolerance(dLowerValue, dUpperValue);
|
||||
dExcepitonTLower = CalculateExceptionLowerTolerance(dLowerValue, dUpperValue);
|
||||
dExceptionTUpper = CalculateExceptionUpperTolerance(dLowerValue, dUpperValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
dStrictTLower = 0;
|
||||
dStrictTUpper = 0;
|
||||
dLowerValue = 0;
|
||||
dUpperValue = 0;
|
||||
MyBase.TraceWriteLine("EH3 " + aryLineContent[0] + " " + aryLineContent[1] + " 查询数据获取公差带失败!数据库中数量不唯一,请检查公差带配置!");
|
||||
}
|
||||
|
||||
if (aryLineContent[2].ToLower().Contains("inv"))
|
||||
{
|
||||
@@ -500,28 +416,13 @@ namespace NSAnalysis
|
||||
|
||||
dgvMeasureContent.Rows.Add(aryLineContent[0], aryLineContent[1], dNormalValue.ToString("F1"), dLowerValue.ToString("F1"), dUpperValue.ToString("F1"), aryLineContent[2], ConfigDfn.strMeasureTime, aryLineContent[4]);
|
||||
|
||||
CheryIOTData cIOTData = new CheryIOTData();
|
||||
cIOTData.vin = strCarID;
|
||||
cIOTData.gfNo = aryLineContent[1];
|
||||
cIOTData.pointNumber = aryLineContent[0];
|
||||
cIOTData.actualValue = aryLineContent[2];
|
||||
cIOTData.controlLine = dLowerValue.ToString("F1") + @"/" + dUpperValue.ToString("F1");
|
||||
if (strMeasureResult.Contains("good") || strMeasureResult.Contains("best") || strMeasureResult.Contains("ng1"))
|
||||
{
|
||||
cIOTData.measurementResult = "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
cIOTData.measurementResult = "NG";
|
||||
}
|
||||
ListPostIOTData.Add(cIOTData);
|
||||
dtRowCount++;
|
||||
dgvMeasureContent.Rows[dtRowCount - 1].HeaderCell.Value = dtRowCount.ToString();
|
||||
}
|
||||
}//End While
|
||||
sr.Close();
|
||||
fs.Close();
|
||||
tmdal.InsertTMeasureDatabyDataTable(dtCSVContent);
|
||||
//tmdal.InsertTMeasureDatabyDataTable(dtCSVContent);
|
||||
MyBase.TraceWriteLine("解析EH3数据完成,并将所有测量数据插入到数据库完毕。");
|
||||
MyBase.TraceWriteLine("解析NextSense EH3 CSV 报告完毕!检测项数=" + dtRowCount.ToString());
|
||||
if (dtRowCount <= ConfigDfn.iMeasureItemsCount)
|
||||
@@ -548,7 +449,7 @@ namespace NSAnalysis
|
||||
#region 界面显示功能
|
||||
|
||||
labCarType.Text = "EH3";
|
||||
//TMeasureResultModel tmrm = new TMeasureResultModel();
|
||||
TMeasureResultModel tmrm = new TMeasureResultModel();
|
||||
labNGCount.Text = OutCount.ToString();
|
||||
labOKCount.Text = OKCount.ToString();
|
||||
labRejectCount.Text = RejectedCount.ToString();
|
||||
@@ -592,16 +493,16 @@ namespace NSAnalysis
|
||||
|
||||
string strTargetRate = Math.Round(ConfigDfn.dFPY2 * 100.00d, 2).ToString("F2") + "%";
|
||||
|
||||
//tmrm.CarID = strCarID;
|
||||
//tmrm.CarType = "EH3";
|
||||
//tmrm.SumMeasureItems = dtRowCount;
|
||||
//tmrm.GoodMeasureItems = (int)OKCount;
|
||||
//tmrm.NoGoodMeasureItems = (int)OutCount;
|
||||
//tmrm.RejectMeasureItems = (int)RejectedCount;
|
||||
//tmrm.FPY = FPYPercent.ToString("F4");
|
||||
//tmrm.Remark = "";
|
||||
//tmrm.MeasureDate = ConfigDfn.strMeasureTime;
|
||||
//tmdal.InsertTMeasureResult(tmrm);
|
||||
tmrm.CarID = strCarID;
|
||||
tmrm.CarType = "EH3";
|
||||
tmrm.SumMeasureItems = dtRowCount;
|
||||
tmrm.GoodMeasureItems = (int)OKCount;
|
||||
tmrm.NoGoodMeasureItems = (int)OutCount;
|
||||
tmrm.RejectMeasureItems = (int)RejectedCount;
|
||||
tmrm.FPY = FPYPercent.ToString("F4");
|
||||
tmrm.Remark = "";
|
||||
tmrm.MeasureDate = ConfigDfn.strMeasureTime;
|
||||
tmdal.InsertTMeasureResult(tmrm);
|
||||
MyBase.TraceWriteLine("将EH3总结果插入数据库完毕。");
|
||||
MyBase.TraceWriteLine("全部插入解析完毕,删除文件:" + fi.Name);
|
||||
fi.Delete();
|
||||
@@ -633,98 +534,83 @@ namespace NSAnalysis
|
||||
|
||||
//#endregion 界面显示功能
|
||||
|
||||
////生成客户的 CSV文件
|
||||
//if (ConfigDfn.iCreateReportFlag == 1)
|
||||
//{
|
||||
// #region 解析完报告后,重新生成客户模板报告
|
||||
//生成客户的 CSV文件
|
||||
|
||||
// string filePath = strSaveReprotPath +
|
||||
// DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + strCarID + ".csv";
|
||||
// //wsp 后期还要再改 string strWithoutLCarVin = strCarID.Substring(1);
|
||||
// StringBuilder sb = new StringBuilder(); //添加表头 sb.Append("Measurement
|
||||
// Info Name"); sb.Append(","); sb.Append("Measurement Info");
|
||||
// sb.AppendLine(); sb.Append("Date_Time"); sb.Append(",");
|
||||
// sb.Append(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
||||
// sb.AppendLine(); for (int i = 0; i < listCSVTitleInfo.Count; i++) {
|
||||
// if (listCSVTitleInfo[i].Contains("prodnum")) { listCSVTitleInfo[i] =
|
||||
// listCSVTitleInfo[i].Replace("prodnum", "Part_ident"); } if
|
||||
// (listCSVTitleInfo[i].Contains(strWithoutLCarVin)) {
|
||||
// listCSVTitleInfo[i] = listCSVTitleInfo[i].Replace(strWithoutLCarVin,
|
||||
// strCarID); } sb.Append(listCSVTitleInfo[i]); sb.AppendLine(); }
|
||||
// sb.AppendLine(); sb.AppendLine(); sb.AppendLine(); sb.AppendLine();
|
||||
// sb.AppendLine(); //添加测量数据 sb.Append("Characteristic");
|
||||
// sb.Append(","); sb.Append("Extension"); sb.Append(",");
|
||||
// sb.Append("Measured_Value"); sb.AppendLine(); foreach (DataRow row in
|
||||
// dtCSVContent.Rows) { sb.Append(row.ItemArray[2]); sb.Append(",");
|
||||
// sb.Append(row.ItemArray[3]); sb.Append(",");
|
||||
// sb.Append(row.ItemArray[7]); sb.AppendLine(); } if
|
||||
// (dtAllRangeDate.Rows.Count > 0) { foreach (DataRow row in
|
||||
// dtAllRangeDate.Rows) { sb.Append(row.ItemArray[2]); sb.Append(",");
|
||||
// sb.Append("G"); sb.Append(","); sb.Append(row.ItemArray[3]);
|
||||
// sb.AppendLine(); } } sb.Append("POP"); sb.Append(",");
|
||||
// sb.Append("P"); sb.Append(","); sb.Append(Math.Round(FPYPercent *
|
||||
// 100.00d, 2).ToString("F2")); sb.AppendLine(); // 将数据写入CSV文件
|
||||
// File.WriteAllText(filePath, sb.ToString());
|
||||
// MyBase.TraceWriteLine("客户csv报告生成完毕,路径为:" + filePath);
|
||||
#region 解析完报告后,重新生成客户模板报告
|
||||
|
||||
// #endregion 解析完报告后,重新生成客户模板报告
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// MyBase.TraceWriteLine("EH3数据生成报告功能未启用!");
|
||||
//}
|
||||
string filePath = strSaveReprotPath + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + strCarID + ".csv"; //wsp 后期还要再改
|
||||
string strWithoutLCarVin = strCarID.Substring(1);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
//添加表头
|
||||
sb.Append("Measurement Info Name");
|
||||
sb.Append(",");
|
||||
sb.Append("Measurement Info");
|
||||
sb.AppendLine();
|
||||
sb.Append("Date_Time");
|
||||
sb.Append(",");
|
||||
sb.Append(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
||||
sb.AppendLine();
|
||||
for (int i = 0; i < listCSVTitleInfo.Count; i++)
|
||||
{
|
||||
if (listCSVTitleInfo[i].Contains("prodnum"))
|
||||
{
|
||||
listCSVTitleInfo[i] = listCSVTitleInfo[i].Replace("prodnum", "Part_ident");
|
||||
}
|
||||
if (listCSVTitleInfo[i].Contains(strWithoutLCarVin))
|
||||
{
|
||||
listCSVTitleInfo[i] = listCSVTitleInfo[i].Replace(strWithoutLCarVin, strCarID);
|
||||
}
|
||||
sb.Append(listCSVTitleInfo[i]);
|
||||
sb.AppendLine();
|
||||
}
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
//添加测量数据
|
||||
sb.Append("Characteristic");
|
||||
sb.Append(",");
|
||||
sb.Append("Extension");
|
||||
sb.Append(",");
|
||||
sb.Append("Measured_Value");
|
||||
sb.AppendLine();
|
||||
foreach (DataRow row in dtCSVContent.Rows)
|
||||
{
|
||||
sb.Append(row.ItemArray[2]);
|
||||
sb.Append(",");
|
||||
sb.Append(row.ItemArray[3]);
|
||||
sb.Append(",");
|
||||
sb.Append(row.ItemArray[7]);
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
sb.Append("POP");
|
||||
sb.Append(",");
|
||||
sb.Append("P");
|
||||
sb.Append(",");
|
||||
sb.Append(Math.Round(FPYPercent * 100.00d, 2).ToString("F2"));
|
||||
sb.AppendLine();
|
||||
// 将数据写入CSV文件
|
||||
File.WriteAllText(filePath, sb.ToString());
|
||||
MyBase.TraceWriteLine("客户csv报告生成完毕,路径为:" + filePath);
|
||||
|
||||
#endregion 解析完报告后,重新生成客户模板报告
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//else
|
||||
//{
|
||||
// MyBase.TraceWriteLine("错误:AnalysisNextSenseEH3CSV函数中,检测EH3 CSV 路径不存在:" + ConfigDfn.strNextSenseCSVPath);
|
||||
//}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MyBase.TraceWriteLine("AnalysisNextSenseCSV 函数分析异常:" + ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public string PostJsonToIOT(string url, string jsonData, int? timeout = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
|
||||
|
||||
if (null != timeout && 0 != timeout)
|
||||
{
|
||||
req.Timeout = timeout.Value;
|
||||
}
|
||||
Encoding encoding = Encoding.UTF8;
|
||||
byte[] bs = Encoding.UTF8.GetBytes(jsonData);
|
||||
string responseData;
|
||||
req.Method = "POST";
|
||||
req.ContentType = "application/json";
|
||||
req.ContentLength = bs.Length;
|
||||
using (Stream reqStream = req.GetRequestStream())
|
||||
{
|
||||
reqStream.Write(bs, 0, bs.Length);
|
||||
reqStream.Close();
|
||||
}
|
||||
using (HttpWebResponse response = (HttpWebResponse)req.GetResponse())
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
|
||||
{
|
||||
responseData = reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
return responseData;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "Error: " + ex.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// 通过给定的文件流,判断文件的编码类型
|
||||
/// <param name="fs">文件流</param>
|
||||
/// <returns>文件的编码类型</returns>
|
||||
@@ -806,188 +692,9 @@ namespace NSAnalysis
|
||||
return er;
|
||||
}
|
||||
|
||||
private void AnalysisNextSenseSelfMeasureCSV()
|
||||
{
|
||||
try
|
||||
{
|
||||
lbCSVFiles.Items.Clear();
|
||||
FileInfo[] fileInfos = null;
|
||||
if (Directory.Exists(ConfigDfn.strNextSenseSelfMeasurePath))
|
||||
{
|
||||
DirectoryInfo di = new DirectoryInfo(ConfigDfn.strNextSenseSelfMeasurePath);
|
||||
fileInfos = di.GetFiles("*.CSV");
|
||||
if (fileInfos.Count() >= 1)
|
||||
{
|
||||
MyBase.TraceWriteLine("存在EHY CSV文件,开始解析:");
|
||||
List<string> listCSVTitleInfo = new List<string>();
|
||||
string strCarID = "SelfMeasure" + DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
foreach (FileInfo fi in fileInfos)
|
||||
{
|
||||
listCSVTitleInfo.Clear();
|
||||
ListPostIOTData.Clear();
|
||||
dtCSVContent.Clear();
|
||||
dgvMeasureContent.Rows.Clear();
|
||||
string strCSVName = fi.FullName;
|
||||
File.Copy(fi.FullName, ConfigDfn.strFileFolder + "\\NextSenseCSVBackup\\" + fi.Name, true);
|
||||
MyBase.TraceWriteLine("Copy " + fi.FullName + " TO " + ConfigDfn.strFileFolder + "\\NextSenseCSVBackup\\" + fi.Name + " Done. 备份完成");
|
||||
lbCSVFiles.Items.Add(fi.Name);
|
||||
|
||||
#region 解析NextSense自检CSV报告
|
||||
|
||||
MyBase.TraceWriteLine("开始解析NextSense EHY CSV 报告:" + strCSVName);
|
||||
Encoding encoding = GetType(strCSVName);
|
||||
FileStream fs = new FileStream(strCSVName, FileMode.Open, FileAccess.Read);
|
||||
StreamReader sr = new StreamReader(fs, encoding);
|
||||
//记录每次读取的一行记录
|
||||
string strLine = "";
|
||||
//记录每行记录中的各字段内容
|
||||
string[] aryLineContent = null;
|
||||
|
||||
//逐行读取CSV中的数据
|
||||
int LineNum = 0;
|
||||
//表格行数
|
||||
int dtRowCount = 0;
|
||||
|
||||
while ((strLine = sr.ReadLine()) != null)
|
||||
{
|
||||
LineNum++;
|
||||
if (LineNum >= 1 & LineNum <= 17)
|
||||
{
|
||||
listCSVTitleInfo.Add(strLine);
|
||||
}
|
||||
if (LineNum >= 19)
|
||||
{
|
||||
aryLineContent = strLine.Split(',');
|
||||
ConfigDfn.strMeasureTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
if (aryLineContent[2].ToLower().Contains("inv"))
|
||||
{
|
||||
aryLineContent[10] = "NG";
|
||||
}
|
||||
string strMeasPointName = "";
|
||||
if (aryLineContent[0].ToUpper().Contains("L"))
|
||||
{
|
||||
strMeasPointName = "L-ZJ1";
|
||||
}
|
||||
else
|
||||
{
|
||||
strMeasPointName = "R-ZJ1";
|
||||
}
|
||||
//测量数据存储到table里
|
||||
dtCSVContent.Rows.Add(strCarID, "SelfMeasure", strMeasPointName, aryLineContent[1], aryLineContent[4], aryLineContent[8], aryLineContent[9], aryLineContent[2], aryLineContent[10], DateTime.Now, "");
|
||||
|
||||
dgvMeasureContent.Rows.Add(strMeasPointName, aryLineContent[1], aryLineContent[4], aryLineContent[8], aryLineContent[9], aryLineContent[2], ConfigDfn.strMeasureTime, aryLineContent[10]);
|
||||
|
||||
dtRowCount++;
|
||||
dgvMeasureContent.Rows[dtRowCount - 1].HeaderCell.Value = dtRowCount.ToString();
|
||||
}
|
||||
}//End While
|
||||
sr.Close();
|
||||
fs.Close();
|
||||
|
||||
MyBase.TraceWriteLine("解析NextSense 自检报告完毕!检查数量=" + dtRowCount.ToString());
|
||||
labCarType.Text = "自检报告";
|
||||
|
||||
fi.Delete();
|
||||
#endregion 解析NextSense自检CSV报告
|
||||
|
||||
if (ConfigDfn.iCreateReportFlag == 1)
|
||||
{
|
||||
#region 解析完报告后,重新生成客户模板报告
|
||||
|
||||
MyBase.TraceWriteLine("开始生成客户所需要的CSV格式文件:");
|
||||
string filePath = strSaveReprotPath + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + strCarID + ".csv"; //wsp 后期还要再改
|
||||
StringBuilder sb = new StringBuilder();
|
||||
//添加表头
|
||||
sb.Append("Measurement Info Name");
|
||||
sb.Append(",");
|
||||
sb.Append("Measurement Info");
|
||||
sb.AppendLine();
|
||||
sb.Append("Date_Time");
|
||||
sb.Append(",");
|
||||
sb.Append(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
||||
sb.AppendLine();
|
||||
for (int i = 2; i < listCSVTitleInfo.Count - 1; i++)
|
||||
{
|
||||
if (listCSVTitleInfo[i].Contains("prodnum"))
|
||||
{
|
||||
listCSVTitleInfo[i] = listCSVTitleInfo[i].Replace("prodnum,", "Part_ident," + DateTime.Now.ToString("yyyyMMdd"));
|
||||
}
|
||||
|
||||
sb.Append(listCSVTitleInfo[i]);
|
||||
sb.AppendLine();
|
||||
}
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
//添加测量数据
|
||||
sb.Append("Characteristic");
|
||||
sb.Append(",");
|
||||
sb.Append("Extension");
|
||||
sb.Append(",");
|
||||
sb.Append("Measured_Value");
|
||||
sb.AppendLine();
|
||||
foreach (DataRow row in dtCSVContent.Rows)
|
||||
{
|
||||
sb.Append(row.ItemArray[2]);
|
||||
sb.Append(",");
|
||||
sb.Append(row.ItemArray[3]);
|
||||
sb.Append(",");
|
||||
sb.Append(row.ItemArray[7]);
|
||||
sb.AppendLine();
|
||||
}
|
||||
sb.AppendLine();
|
||||
// 将数据写入CSV文件
|
||||
File.WriteAllText(filePath, sb.ToString());
|
||||
MyBase.TraceWriteLine("客户自检报告生成完毕,路径为:" + filePath);
|
||||
|
||||
#endregion 解析完报告后,重新生成客户模板报告
|
||||
}
|
||||
else
|
||||
{
|
||||
MyBase.TraceWriteLine("iCreateReportFlag=0 : 数据生成报告功能未启用!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MyBase.TraceWriteLine("AnalysisNextSenseSelfMeasureCSV 函数分析异常:" + ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 界面显示功能
|
||||
|
||||
#region Home Page
|
||||
|
||||
/// <summary>
|
||||
/// 设置DataGridView各行变色
|
||||
/// </summary>
|
||||
/// <param name="dgv">DataGridView</param>
|
||||
public void SetdgvRowBgColor(DataGridView dgv)
|
||||
{
|
||||
if (dgv.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataGridViewRow item in dgv.Rows)
|
||||
{
|
||||
if (item.Index % 2 == 0)
|
||||
{
|
||||
item.DefaultCellStyle.BackColor = Color.FromArgb(19, 46, 53);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.DefaultCellStyle.BackColor = Color.FromArgb(27, 60, 68);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO:
|
||||
|
||||
#endregion Home Page
|
||||
#endregion 界面显示功能
|
||||
|
||||
#region Search Data
|
||||
|
||||
@@ -1273,135 +980,6 @@ namespace NSAnalysis
|
||||
e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
|
||||
}
|
||||
|
||||
#endregion Search Data
|
||||
|
||||
#region 软件设置
|
||||
|
||||
private void lpcSoftwareSetup_Click(object sender, EventArgs e)
|
||||
{
|
||||
string strInputPwd = MyBase.InputBox("密码", "请输入密码 : ", "", "确定", "取消");
|
||||
if (strInputPwd.Contains("-999.999"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (strInputPwd == ConfigDfn.strPwd)
|
||||
{
|
||||
FSoftwareSetup fss = new FSoftwareSetup();
|
||||
fss.ShowDialog(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("密码错误! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
private void lpcToleranceSetup_Click(object sender, EventArgs e)
|
||||
{
|
||||
string strInputPwd = MyBase.InputBox("密码", "请输入密码 : ", "", "确定", "取消");
|
||||
if (strInputPwd.Contains("-999.999"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (strInputPwd == ConfigDfn.strPwd)
|
||||
{
|
||||
FToleranceSetup fts = new FToleranceSetup();
|
||||
fts.ShowDialog(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("密码错误! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
private void lpcAboutSoftware_Click(object sender, EventArgs e)
|
||||
{
|
||||
AboutSoftwareInfo asi = new AboutSoftwareInfo();
|
||||
asi.ShowDialog();
|
||||
}
|
||||
|
||||
private void lpcShowLog_Click(object sender, EventArgs e)
|
||||
{
|
||||
System.Diagnostics.Process.Start("notepad.exe", LogDebugDfn.strDebugFile);
|
||||
}
|
||||
|
||||
#endregion 软件设置
|
||||
|
||||
#region RadButton鼠标事件
|
||||
|
||||
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 RadButton鼠标事件
|
||||
|
||||
private void lpcUploadIOTTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
string strPostData = "{\"serno\":\"" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "\",\"requestData\":[{\"vin\":\"test001\",\"model\":\"EHY\",\"equipmentNo\":\"" + ConfigDfn.strEquipNo + "\",\"equipmentName\":\"" + ConfigDfn.strEquipName + "\",\"calibrationResult\":\"OK\",\"detectionTime\":\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\",\"GapList\":[{\"vin\":\"test001\",\"gfNo\":\"F\",\"pointNumber\":\"L-01\",\"actualValue\":\"-0.30\",\"controlLine\":\"-1.00/1.00\",\"measurementResult\":\"OK\"}]}]}";
|
||||
MyBase.TraceWriteLine("Test Post Data: " + strPostData);
|
||||
string strPostResult = PostJsonToIOT(ConfigDfn.strIOTAddress, strPostData, 10000);
|
||||
MessageBox.Show("测试上传数据完成,获取到的返回值为: " + strPostResult, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
MyBase.TraceWriteLine("测试上传数据完成,获取到的返回值为: " + strPostResult);
|
||||
}
|
||||
|
||||
private void lpcTestGetCarTye_Click(object sender, EventArgs e)
|
||||
{
|
||||
string strPostData = "{\"serno\":\"312314141\",\"vin\":\"LNNAJDDU9RDA00213\"}";
|
||||
MyBase.TraceWriteLine("Test Post Data: " + strPostData);
|
||||
string strPostResult = PostJsonToIOT(ConfigDfn.strIOTCarTypeAddress, strPostData, 10000);
|
||||
MessageBox.Show("测试从IOT获取车型信息完成,获取到的返回值为: " + strPostResult, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
MyBase.TraceWriteLine("测试从IOT获取车型信息完成,获取到的原返回值为: " + strPostResult);
|
||||
string strNewResult = strPostResult.Substring(1, strPostResult.Length - 2).Replace("]", "");
|
||||
MessageBox.Show("测试从IOT获取车型信息完成,处理后 获取到的返回值为: " + strNewResult, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
MyBase.TraceWriteLine("测试从IOT获取车型信息完成,处理后 获取到的返回值为: " + strNewResult);
|
||||
CheryCarTypeInfo ccti = new CheryCarTypeInfo();
|
||||
ccti = JsonConvert.DeserializeObject<CheryCarTypeInfo>(strNewResult);
|
||||
MessageBox.Show("测试从IOT获取车型信息完成,获取到的返回值为: " + strNewResult + "; 解析出的车型:" + ccti.data.model + " ;解析出的物料号为" + ccti.data.material + " ;解析出颜色编号:" + ccti.data.material.Substring(7, 2), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
private string GetCarTypeByIOTAPI(string strVIN, out string strMaterialNo)
|
||||
{
|
||||
string strPostData = "{\"serno\":\"" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "\",\"vin\":\"" + strVIN + "\"}";
|
||||
MyBase.TraceWriteLine(" Post VIN Data: " + strPostData);
|
||||
string strPostResult = PostJsonToIOT(ConfigDfn.strIOTCarTypeAddress, strPostData, 5000);
|
||||
MyBase.TraceWriteLine("GetCarTypeByIOTAPI IOT Return CarType Infomation : " + strPostResult);
|
||||
string strNewResult = strPostResult.Substring(1, strPostResult.Length - 2).Replace("]", "");
|
||||
MyBase.TraceWriteLine("GetCarTypeByIOTAPI IOT Return New CarType Infomation : " + strNewResult);
|
||||
CheryCarTypeInfo ccti = new CheryCarTypeInfo();
|
||||
ccti = JsonConvert.DeserializeObject<CheryCarTypeInfo>(strNewResult);
|
||||
if (ccti.message.Contains("成功"))
|
||||
{
|
||||
if (ccti.data.material != null && ccti.data.material.Length > 9)
|
||||
{
|
||||
strMaterialNo = ccti.data.material.Substring(7, 2);
|
||||
MyBase.TraceWriteLine(" IOT Return CarType Infomation : " + strNewResult + "; 解析出的车型:" + ccti.data.model + "解析出车颜色编号:" + strMaterialNo);
|
||||
}
|
||||
else
|
||||
{
|
||||
strMaterialNo = "TE";
|
||||
MyBase.TraceWriteLine(" IOT Return CarType Infomation : " + strNewResult + "; 解析出的车型:" + ccti.data.model + ";未解析出车颜色编号");
|
||||
}
|
||||
return ccti.data.model;
|
||||
}
|
||||
else
|
||||
{
|
||||
MyBase.TraceWriteLine(" IOT Return CarType Infomation ERROR : " + strPostResult);
|
||||
strMaterialNo = "ER";
|
||||
return "ERR";
|
||||
}
|
||||
}
|
||||
|
||||
private void lpcShowCarData_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void tmrMonitorDBToCreateReport_Tick(object sender, EventArgs e)
|
||||
{
|
||||
tmrMonitorDBToCreateReport.Stop();
|
||||
@@ -1674,197 +1252,91 @@ namespace NSAnalysis
|
||||
tmrMonitorDBToCreateReport.Start();
|
||||
}
|
||||
|
||||
private void lpcRange_Load(object sender, EventArgs e)
|
||||
#endregion Search Data
|
||||
|
||||
#region 软件设置
|
||||
|
||||
private void lpcSoftwareSetup_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void lpcShowCarData_Load(object sender, EventArgs e)
|
||||
string strInputPwd = MyBase.InputBox("密码", "请输入密码 : ", "", "确定", "取消");
|
||||
if (strInputPwd.Contains("-999.999"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public class CheryIOTData
|
||||
else if (strInputPwd == ConfigDfn.strPwd)
|
||||
{
|
||||
/// <summary>
|
||||
/// VIN号
|
||||
/// </summary>
|
||||
public string vin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// FG
|
||||
/// </summary>
|
||||
public string gfNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 测点编号
|
||||
/// </summary>
|
||||
public string pointNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实测值
|
||||
/// </summary>
|
||||
public string actualValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 控制线
|
||||
/// </summary>
|
||||
public string controlLine { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 测量结果
|
||||
/// </summary>
|
||||
public string measurementResult { get; set; }
|
||||
FSoftwareSetup fss = new FSoftwareSetup();
|
||||
fss.ShowDialog(this);
|
||||
}
|
||||
|
||||
public class CarInfoData
|
||||
else
|
||||
{
|
||||
public string material { get; set; }
|
||||
public string model { get; set; }
|
||||
MessageBox.Show("密码错误! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
public class CheryCarTypeInfo
|
||||
private void lpcToleranceSetup_Click(object sender, EventArgs e)
|
||||
{
|
||||
/// <summary>
|
||||
/// data
|
||||
/// </summary>
|
||||
public CarInfoData data { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// message
|
||||
/// </summary>
|
||||
public string message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// serno
|
||||
/// </summary>
|
||||
public string serno { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// success
|
||||
/// </summary>
|
||||
public string success { get; set; }
|
||||
string strInputPwd = MyBase.InputBox("密码", "请输入密码 : ", "", "确定", "取消");
|
||||
if (strInputPwd.Contains("-999.999"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (strInputPwd == ConfigDfn.strPwd)
|
||||
{
|
||||
FToleranceSetup fts = new FToleranceSetup();
|
||||
fts.ShowDialog(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("密码错误! ", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
public static class JsonHelper
|
||||
private void lpcAboutSoftware_Click(object sender, EventArgs e)
|
||||
{
|
||||
/// <summary>
|
||||
/// 对象转成JSON 格式字符串
|
||||
/// </summary>
|
||||
/// <param name="obj">对象</param>
|
||||
/// <returns>JSON格式的字符串</returns>
|
||||
public static string ObjectToJson(object obj)
|
||||
AboutSoftwareInfo asi = new AboutSoftwareInfo();
|
||||
asi.ShowDialog();
|
||||
}
|
||||
|
||||
private void lpcShowLog_Click(object sender, EventArgs e)
|
||||
{
|
||||
return JsonConvert.SerializeObject(obj);
|
||||
System.Diagnostics.Process.Start("notepad.exe", LogDebugDfn.strDebugFile);
|
||||
}
|
||||
|
||||
#endregion 软件设置
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析JSON字符串生成对象实体
|
||||
/// 设置DataGridView各行变色
|
||||
/// </summary>
|
||||
/// <typeparam name="T">对象类型</typeparam>
|
||||
/// <param name="json">json字符串</param>
|
||||
/// <returns>对象实体</returns>
|
||||
public static T DeserializeJsonToObject<T>(string json) where T : class
|
||||
/// <param name="dgv">DataGridView</param>
|
||||
public void SetdgvRowBgColor(DataGridView dgv)
|
||||
{
|
||||
Newtonsoft.Json.JsonSerializer serializer = new Newtonsoft.Json.JsonSerializer();
|
||||
StringReader sr = new StringReader(json);
|
||||
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(T));
|
||||
T t = o as T;
|
||||
return t;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析JSON数组生成对象实体集合
|
||||
/// </summary>
|
||||
/// <typeparam name="T">对象类型</typeparam>
|
||||
/// <param name="json">json数组字符串(eg.[{"ID":"112","Name":"石子儿"}])</param>
|
||||
/// <returns>对象实体集合</returns>
|
||||
public static List<T> DeserializeJsonToList<T>(string json) where T : class
|
||||
if (dgv.Rows.Count > 0)
|
||||
{
|
||||
Newtonsoft.Json.JsonSerializer serializer = new JsonSerializer();
|
||||
StringReader sr = new StringReader(json);
|
||||
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
|
||||
List<T> list = o as List<T>;
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据表转键值对集合 把DataTable转成 List集合, 存每一行 集合中放的是键值对字典,存每一列
|
||||
/// </summary>
|
||||
/// <param name="dt">数据表</param>
|
||||
/// <returns>哈希表数组</returns>
|
||||
public static List<Dictionary<string, object>> DataTableToList(DataTable dt)
|
||||
foreach (DataGridViewRow item in dgv.Rows)
|
||||
{
|
||||
List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
|
||||
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
if (item.Index % 2 == 0)
|
||||
{
|
||||
Dictionary<string, object> dic = new Dictionary<string, object>();
|
||||
foreach (DataColumn dc in dt.Columns)
|
||||
item.DefaultCellStyle.BackColor = Color.FromArgb(19, 46, 53);
|
||||
}
|
||||
else
|
||||
{
|
||||
dic.Add(dc.ColumnName, dr[dc.ColumnName]);
|
||||
}
|
||||
list.Add(dic);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据集转键值对数组字典
|
||||
/// </summary>
|
||||
/// <returns>键值对数组字典</returns>
|
||||
public static Dictionary<string, List<Dictionary<string, object>>> DataSetToDic(DataSet ds)
|
||||
{
|
||||
Dictionary<string, List<Dictionary<string, object>>> result = new Dictionary<string, List<Dictionary<string, object>>>();
|
||||
|
||||
foreach (DataTable dt in ds.Tables)
|
||||
result.Add(dt.TableName, DataTableToList(dt));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据表转JSON
|
||||
/// </summary>
|
||||
/// <param name="dt">数据表</param>
|
||||
/// <returns>JSON字符串</returns>
|
||||
public static string DataTableToJson(DataTable dt)
|
||||
{
|
||||
return ObjectToJson(DataTableToList(dt));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// JSON文本转对象,泛型方法 常用
|
||||
/// </summary>
|
||||
/// <typeparam name="T">类型</typeparam>
|
||||
/// <param name="jsonText">JSON文本</param>
|
||||
/// <returns>指定类型的对象</returns>
|
||||
public static T JsonToObject<T>(string jsonText)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(jsonText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将JSON文本转换为数据表数据
|
||||
/// </summary>
|
||||
/// <param name="jsonText">JSON文本</param>
|
||||
/// <returns>数据表字典</returns>
|
||||
public static Dictionary<string, List<Dictionary<string, object>>> TablesDataFromJson(string jsonText)
|
||||
{
|
||||
return JsonToObject<Dictionary<string, List<Dictionary<string, object>>>>(jsonText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将JSON文本转换成数据行
|
||||
/// </summary>
|
||||
/// <param name="jsonText">JSON文本</param>
|
||||
/// <returns>数据行的字典</returns>
|
||||
public static Dictionary<string, object> DataRowFromJson(string jsonText)
|
||||
{
|
||||
return JsonToObject<Dictionary<string, object>>(jsonText);
|
||||
item.DefaultCellStyle.BackColor = Color.FromArgb(27, 60, 68);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,9 +77,6 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>bin\x64\Debug\Covert.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DAL">
|
||||
<HintPath>..\DAL\bin\Debug\DAL.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
|
||||
+3
-3
@@ -83,9 +83,9 @@ namespace NSAnalysis
|
||||
|
||||
#endregion 创建Log文件
|
||||
|
||||
//Application.Run(new FormMain());
|
||||
FileSorter fileSorter = new FileSorter();
|
||||
fileSorter.test();
|
||||
Application.Run(new FormMain());
|
||||
//FileSorter fileSorter = new FileSorter();
|
||||
//fileSorter.test();
|
||||
|
||||
//if (gAuthorizationMode == 1)
|
||||
// {
|
||||
|
||||
Binary file not shown.
+7678
-12
File diff suppressed because it is too large
Load Diff
@@ -7,8 +7,8 @@ Language =1
|
||||
;0 = 英语
|
||||
RememberMe=1
|
||||
NextsenseCSVEH3Path=D:\cherytestEH3
|
||||
NextsenseCSVEHYPath=D:\cherytestEHY
|
||||
NextseneSelfMeasurePath=D:\test
|
||||
|
||||
|
||||
ReportCSVPath=D:\QMLTest
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user