Commit 6e29a642 LN

界面调整

1 个父辈 54093547
...@@ -123,12 +123,21 @@ ...@@ -123,12 +123,21 @@
<metadata name="Column_F.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Column_F.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="Column_Suanfa.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_suanfavalue.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_Des.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Column_Des.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="Column_Del.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Column_Del.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
......
...@@ -117,7 +117,7 @@ namespace OnlineStore.AutoCountClient ...@@ -117,7 +117,7 @@ namespace OnlineStore.AutoCountClient
} }
else else
{ {
ShowType(0); ShowType(-1);
} }
imgCurrImg.HorizontalScroll.Value = 173; imgCurrImg.HorizontalScroll.Value = 173;
...@@ -136,7 +136,7 @@ namespace OnlineStore.AutoCountClient ...@@ -136,7 +136,7 @@ namespace OnlineStore.AutoCountClient
return; return;
} }
CurrType = type; CurrType = type;
int index = 1; int index = 0;
btnTest.Text = "请选择算法"; btnTest.Text = "请选择算法";
foreach (Button btn in SelBtnList) foreach (Button btn in SelBtnList)
{ {
...@@ -153,7 +153,7 @@ namespace OnlineStore.AutoCountClient ...@@ -153,7 +153,7 @@ namespace OnlineStore.AutoCountClient
} }
index++; index++;
} }
bool isShowBtn = (type > 0); bool isShowBtn = (type >= 0&&type<5);
btnTest.Enabled = isShowBtn; btnTest.Enabled = isShowBtn;
btnNext.Enabled = isShowBtn; btnNext.Enabled = isShowBtn;
...@@ -169,11 +169,24 @@ namespace OnlineStore.AutoCountClient ...@@ -169,11 +169,24 @@ namespace OnlineStore.AutoCountClient
MessageBox.Show("未加载图片,无法点料"); MessageBox.Show("未加载图片,无法点料");
return; return;
} }
int index = 0;
foreach (Button btn in SelBtnList)
{
if (index.Equals(CurrType))
{
btnTest.Text = btn.Tag + "-点料测试";
break;
}
index++;
}
LogUtil.info( Name + "用户点击 "+btnTest.Text); LogUtil.info( Name + "用户点击 "+btnTest.Text);
try try
{ {
btnTest.Enabled = false; btnTest.Enabled = false;
this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
int th = (int)numTh.Value; int th = (int)numTh.Value;
int wsize = (int)numWSize.Value; int wsize = (int)numWSize.Value;
Asa.API.EyemImage tpDstImg; Asa.API.EyemImage tpDstImg;
...@@ -188,6 +201,7 @@ namespace OnlineStore.AutoCountClient ...@@ -188,6 +201,7 @@ namespace OnlineStore.AutoCountClient
LogUtil.error("点料测试出错:" + ex.ToString()); LogUtil.error("点料测试出错:" + ex.ToString());
} }
btnTest.Enabled = true; btnTest.Enabled = true;
this.Cursor = System.Windows.Forms.Cursors.Default ;
} }
...@@ -215,24 +229,38 @@ namespace OnlineStore.AutoCountClient ...@@ -215,24 +229,38 @@ namespace OnlineStore.AutoCountClient
private void btnSaveParam_Click(object sender, EventArgs e) private void btnSaveParam_Click(object sender, EventArgs e)
{ {
SaveCurrParam(); SaveCurrParam();
int leftC = (ImageList.Count - currIndex - 1);
DialogResult result = MessageBox.Show("当前第[" + (currIndex + 1) + "]张图片,还剩余[" + (ImageList.Count - currIndex - 1) + "]张图片未选择算法,是否结束学习?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk); if (leftC > 0)
{
DialogResult result = MessageBox.Show("当前第[" + (currIndex + 1) + "]张图片,还剩余[" + leftC + "]张图片未选择算法,是否结束学习?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
if (result.Equals(DialogResult.Yes)) if (result.Equals(DialogResult.Yes))
{ {
ParamManager.SaveMapToFile();
IsSave = true;
this.Close();
} }
else else
{ {
return; return;
} }
} }
ParamManager.SaveMapToFile();
IsSave = true;
this.Close();
}
private void btnNext_Click(object sender, EventArgs e) private void btnNext_Click(object sender, EventArgs e)
{ {
btnNext.Enabled = false;
this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
try
{
SaveCurrParam(); SaveCurrParam();
ShowNextImg(); ShowNextImg();
}catch(Exception ex)
{
LogUtil.error("下一张 报错:" + ex.ToString());
}
btnNext.Enabled = true;
this.Cursor = System.Windows.Forms.Cursors.Default;
} }
private void btnCancel_Click(object sender, EventArgs e) private void btnCancel_Click(object sender, EventArgs e)
...@@ -313,23 +341,23 @@ namespace OnlineStore.AutoCountClient ...@@ -313,23 +341,23 @@ namespace OnlineStore.AutoCountClient
private void buttonA_Click(object sender, EventArgs e) private void buttonA_Click(object sender, EventArgs e)
{ {
ShowType(1); ShowType(0);
} }
private void buttonB_Click(object sender, EventArgs e) private void buttonB_Click(object sender, EventArgs e)
{ {
ShowType(2); ShowType(1);
} }
private void buttonC_Click(object sender, EventArgs e) private void buttonC_Click(object sender, EventArgs e)
{ {
ShowType(3); ShowType(2);
} }
private void buttonD_Click(object sender, EventArgs e) private void buttonD_Click(object sender, EventArgs e)
{ {
ShowType(4); ShowType(3);
} }
private void buttonE_Click(object sender, EventArgs e) private void buttonE_Click(object sender, EventArgs e)
{ {
ShowType(5); ShowType(4);
} }
} }
} }
...@@ -58,7 +58,6 @@ ...@@ -58,7 +58,6 @@
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.设置TToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.设置TToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.元器件学习ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.元器件学习ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator16 = new System.Windows.Forms.ToolStripSeparator();
this.二维码学习ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.二维码学习ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
...@@ -88,6 +87,9 @@ ...@@ -88,6 +87,9 @@
this.启用蜂鸣器ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.启用蜂鸣器ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.lblXrayWork = new System.Windows.Forms.Label(); this.lblXrayWork = new System.Windows.Forms.Label();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.toolStripSeparator17 = new System.Windows.Forms.ToolStripSeparator();
this.元器件库ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator16 = new System.Windows.Forms.ToolStripSeparator();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout(); this.tabPage1.SuspendLayout();
this.panWork.SuspendLayout(); this.panWork.SuspendLayout();
...@@ -346,7 +348,7 @@ ...@@ -346,7 +348,7 @@
// //
this.设置TToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.设置TToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.元器件学习ToolStripMenuItem, this.元器件学习ToolStripMenuItem,
this.toolStripSeparator16, this.toolStripSeparator17,
this.二维码学习ToolStripMenuItem, this.二维码学习ToolStripMenuItem,
this.toolStripSeparator7, this.toolStripSeparator7,
this.toolStripMenuItem2, this.toolStripMenuItem2,
...@@ -359,43 +361,38 @@ ...@@ -359,43 +361,38 @@
// 元器件学习ToolStripMenuItem // 元器件学习ToolStripMenuItem
// //
this.元器件学习ToolStripMenuItem.Name = "元器件学习ToolStripMenuItem"; this.元器件学习ToolStripMenuItem.Name = "元器件学习ToolStripMenuItem";
this.元器件学习ToolStripMenuItem.Size = new System.Drawing.Size(180, 26); this.元器件学习ToolStripMenuItem.Size = new System.Drawing.Size(234, 26);
this.元器件学习ToolStripMenuItem.Text = "元器件学习"; this.元器件学习ToolStripMenuItem.Text = "元器件学习";
this.元器件学习ToolStripMenuItem.Click += new System.EventHandler(this.元器件学习ToolStripMenuItem_Click); this.元器件学习ToolStripMenuItem.Click += new System.EventHandler(this.元器件学习ToolStripMenuItem_Click);
// //
// toolStripSeparator16
//
this.toolStripSeparator16.Name = "toolStripSeparator16";
this.toolStripSeparator16.Size = new System.Drawing.Size(177, 6);
//
// 二维码学习ToolStripMenuItem // 二维码学习ToolStripMenuItem
// //
this.二维码学习ToolStripMenuItem.Name = "二维码学习ToolStripMenuItem"; this.二维码学习ToolStripMenuItem.Name = "二维码学习ToolStripMenuItem";
this.二维码学习ToolStripMenuItem.Size = new System.Drawing.Size(180, 26); this.二维码学习ToolStripMenuItem.Size = new System.Drawing.Size(234, 26);
this.二维码学习ToolStripMenuItem.Text = "二维码学习"; this.二维码学习ToolStripMenuItem.Text = "二维码学习";
this.二维码学习ToolStripMenuItem.Click += new System.EventHandler(this.二维码学习ToolStripMenuItem_Click); this.二维码学习ToolStripMenuItem.Click += new System.EventHandler(this.二维码学习ToolStripMenuItem_Click);
// //
// toolStripSeparator7 // toolStripSeparator7
// //
this.toolStripSeparator7.Name = "toolStripSeparator7"; this.toolStripSeparator7.Name = "toolStripSeparator7";
this.toolStripSeparator7.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator7.Size = new System.Drawing.Size(231, 6);
// //
// toolStripMenuItem2 // toolStripMenuItem2
// //
this.toolStripMenuItem2.Name = "toolStripMenuItem2"; this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(180, 26); this.toolStripMenuItem2.Size = new System.Drawing.Size(234, 26);
this.toolStripMenuItem2.Text = "AGV调试"; this.toolStripMenuItem2.Text = "AGV调试";
this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click); this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click);
// //
// toolStripSeparator6 // toolStripSeparator6
// //
this.toolStripSeparator6.Name = "toolStripSeparator6"; this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(177, 6); this.toolStripSeparator6.Size = new System.Drawing.Size(231, 6);
// //
// 标签编辑ToolStripMenuItem // 标签编辑ToolStripMenuItem
// //
this.标签编辑ToolStripMenuItem.Name = "标签编辑ToolStripMenuItem"; this.标签编辑ToolStripMenuItem.Name = "标签编辑ToolStripMenuItem";
this.标签编辑ToolStripMenuItem.Size = new System.Drawing.Size(180, 26); this.标签编辑ToolStripMenuItem.Size = new System.Drawing.Size(234, 26);
this.标签编辑ToolStripMenuItem.Text = "标签编辑"; this.标签编辑ToolStripMenuItem.Text = "标签编辑";
this.标签编辑ToolStripMenuItem.Click += new System.EventHandler(this.标签编辑ToolStripMenuItem_Click); this.标签编辑ToolStripMenuItem.Click += new System.EventHandler(this.标签编辑ToolStripMenuItem_Click);
// //
...@@ -404,6 +401,8 @@ ...@@ -404,6 +401,8 @@
this.帮助ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.帮助ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem3, this.toolStripMenuItem3,
this.toolStripSeparator5, this.toolStripSeparator5,
this.元器件库ToolStripMenuItem,
this.toolStripSeparator16,
this.清空日志ToolStripMenuItem, this.清空日志ToolStripMenuItem,
this.toolStripSeparator10, this.toolStripSeparator10,
this.复制日志ToolStripMenuItem, this.复制日志ToolStripMenuItem,
...@@ -578,6 +577,23 @@ ...@@ -578,6 +577,23 @@
this.lblXrayWork.Text = "警告:点料过程中,请勿开门"; this.lblXrayWork.Text = "警告:点料过程中,请勿开门";
this.lblXrayWork.Visible = false; this.lblXrayWork.Visible = false;
// //
// toolStripSeparator17
//
this.toolStripSeparator17.Name = "toolStripSeparator17";
this.toolStripSeparator17.Size = new System.Drawing.Size(231, 6);
//
// 元器件库ToolStripMenuItem
//
this.元器件库ToolStripMenuItem.Name = "元器件库ToolStripMenuItem";
this.元器件库ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.元器件库ToolStripMenuItem.Text = "元器件库";
this.元器件库ToolStripMenuItem.Click += new System.EventHandler(this.元器件库ToolStripMenuItem_Click);
//
// toolStripSeparator16
//
this.toolStripSeparator16.Name = "toolStripSeparator16";
this.toolStripSeparator16.Size = new System.Drawing.Size(177, 6);
//
// FrmRobotMain // FrmRobotMain
// //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
...@@ -670,8 +686,10 @@ ...@@ -670,8 +686,10 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator15; private System.Windows.Forms.ToolStripSeparator toolStripSeparator15;
private System.Windows.Forms.ToolStripMenuItem 启用蜂鸣器ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 启用蜂鸣器ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 元器件学习ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 元器件学习ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator16;
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator17;
private System.Windows.Forms.ToolStripMenuItem 元器件库ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator16;
} }
} }
...@@ -112,6 +112,9 @@ namespace OnlineStore.AutoCountClient ...@@ -112,6 +112,9 @@ namespace OnlineStore.AutoCountClient
{ {
开机自动启动ToolStripMenuItem.Text = "开机自动启动"; 开机自动启动ToolStripMenuItem.Text = "开机自动启动";
} }
CSVBomManager.LoadAllCom();
LoadStoreData(); LoadStoreData();
LoadListView(); LoadListView();
LogUtil.logBox = this.logBox; LogUtil.logBox = this.logBox;
...@@ -899,5 +902,10 @@ namespace OnlineStore.AutoCountClient ...@@ -899,5 +902,10 @@ namespace OnlineStore.AutoCountClient
frm.ShowDialog(); frm.ShowDialog();
} }
} }
private void 元器件库ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmComponentList frm = new FrmComponentList();
frm.ShowDialog();
}
} }
} }
...@@ -9,6 +9,11 @@ namespace OnlineStore.Common ...@@ -9,6 +9,11 @@ namespace OnlineStore.Common
{ {
public class FormUtil public class FormUtil
{ {
public static string GetValue(TextBox txt)
{
string value = txt.Text;
return value;
}
public static int GetIntValue(TextBox txt) public static int GetIntValue(TextBox txt)
{ {
int value = 0; int value = 0;
......
...@@ -182,7 +182,9 @@ ...@@ -182,7 +182,9 @@
<None Include="XRAY\countParam.csv"> <None Include="XRAY\countParam.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="XRAY\pnDetailedList.csv" /> <None Include="XRAY\pnDetailedList.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
物料编号,描述,产品,封装 物料编号,描述,产品,封装
2B.C0132.051,#SKT MICRO USB3.0B GF H2.83 BK,#SKT,未找到 2B.C0132.051,#SKT MICRO USB3.0B GF H2.83 BK,#SKT111,未找到
2K.D1091.102,HEAD ML1R 2P ST D1.25 JS-1147V,HEAD,未找到 2K.D1091.102,HEAD ML1R 2P ST D1.25 JS-1147V,HEAD,未找到
2K.D2128.102,HEAD ML 1R2P D.8 RT H1.7,HEAD,未找到 2K.D2128.102,HEAD ML 1R2P D.8 RT H1.7,HEAD,未找到
2K.E2021.102,HEAD FML 1R2P D0.8 H1.75,HEAD,未找到 2K.E2021.102,HEAD FML 1R2P D0.8 H1.75,HEAD,未找到
......
using OnlineStore.Common; using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
...@@ -20,6 +21,31 @@ namespace OnlineStore.DeviceLibrary ...@@ -20,6 +21,31 @@ namespace OnlineStore.DeviceLibrary
ConfigFilePath = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.CounParamConfig); ConfigFilePath = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.CounParamConfig);
countParamMap = LoadParamMap( ); countParamMap = LoadParamMap( );
} }
public static string GetSufanStr(int type)
{
if (type.Equals(0))
{
return "算法A";
}
else if (type.Equals(1))
{
return "算法B";
}
else if (type.Equals(2))
{
return "算法C";
}
else if (type.Equals(3))
{
return "算法D";
}
else if (type.Equals(4))
{
return "算法E";
}
return "";
}
public static CountParam GetParamByPN(string pn) public static CountParam GetParamByPN(string pn)
{ {
if (countParamMap.ContainsKey(pn)) if (countParamMap.ContainsKey(pn))
...@@ -152,6 +178,51 @@ namespace OnlineStore.DeviceLibrary ...@@ -152,6 +178,51 @@ namespace OnlineStore.DeviceLibrary
if (param == null) if (param == null)
{ {
//TODO //TODO
ComponetInfo com = CSVBomManager.GetCom(currPN);
if (com == null)
{
LogUtil.info("元器件库未找到 PN=" + currPN + " 的元器件");
return param;
}
List<ComponetInfo> FZList = new List<ComponetInfo>();
Dictionary<int, int> sufaCount = new Dictionary<int, int>();
int maxSufa = -1;
int maxCount = 0;
foreach (ComponetInfo obj in CSVBomManager.allComMap.Values)
{
if (obj.Encapsulations.Trim().Equals(com.Encapsulations.Trim()))
{
CountParam p = GetParamByPN(obj.PartNum);
if (p != null)
{
obj.Sufan = p.Sign;
if (sufaCount.ContainsKey(obj.Sufan))
{
sufaCount[obj.Sufan]++;
}
else
{
sufaCount.Add(obj.Sufan, 1);
}
if (sufaCount[obj.Sufan] > maxCount)
{
maxCount = sufaCount[obj.Sufan];
maxSufa = obj.Sufan;
}
}
FZList.Add(obj);
}
}
if (maxCount >= 1)
{
LogUtil.info("元器件【" + com.ToStr() + "】查找到最优算法:【" + maxSufa + "】");
param = new CountParam(currPN, RobotManager.robot.XrayBean.ThresholdValue, 3, maxSufa);
}
} }
return param; return param;
} }
......
...@@ -22,7 +22,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -22,7 +22,7 @@ namespace OnlineStore.LoadCSVLibrary
public static bool LoadAllCom() public static bool LoadAllCom()
{ {
string fileName = getFilePath(); string fileName = getFilePath();
if (!Directory.Exists(fileName)) if (!File.Exists(fileName))
{ {
return false; return false;
} }
...@@ -30,20 +30,20 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -30,20 +30,20 @@ namespace OnlineStore.LoadCSVLibrary
{ {
string bomName = Path.GetFileNameWithoutExtension(fileName); //-->BenXHCMS string bomName = Path.GetFileNameWithoutExtension(fileName); //-->BenXHCMS
List<ComponetInfo> list = ReadFile(fileName); List<ComponetInfo> list = ReadFile(fileName);
Dictionary<string, ComponetInfo> map = new Dictionary<string, ComponetInfo>(); allComMap = new Dictionary<string, ComponetInfo>();
foreach (ComponetInfo com in list) foreach (ComponetInfo com in list)
{ {
if (com == null || com.PartNum == null || com.Encapsulations == null) if (com == null || com.PartNum == null || com.Encapsulations == null)
{ {
continue; continue;
} }
if (map.ContainsKey(com.PartNum)) if (allComMap.ContainsKey(com.PartNum))
{ {
LogUtil.error("元器件库【" + bomName + "】【" + com.PartNum + "】重复"); LogUtil.error("元器件库【" + bomName + "】【" + com.PartNum + "】重复");
} }
else else
{ {
map.Add(com.PartNum, com); allComMap.Add(com.PartNum, com);
} }
} }
} }
...@@ -144,54 +144,14 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -144,54 +144,14 @@ namespace OnlineStore.LoadCSVLibrary
{ {
if (!allComMap.ContainsKey(com.PartNum)) if (!allComMap.ContainsKey(com.PartNum))
{ {
return false; allComMap.Add(com.PartNum, com);
}
System.Type type = typeof(ComponetInfo);
Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(ComponetInfo));
List<string> cvsTitleList = new List<string>(proTitleMap.Values);
List<string> propertyList = new List<string>(proTitleMap.Keys);
int IdIndex = propertyList.IndexOf("PartNum");
int csvIndex = -1;
string filePath = getFilePath();
int idIndex = propertyList.IndexOf("PartNum");
string[] lines = ReadCSVFile(filePath);
int index = 0;
Dictionary<string, int> titleIndex = new Dictionary<string, int>();
foreach (var line in lines)
{
var array = line.Split(',');
if (index == 0)
{
titleIndex = GetTitleIndex(line, cvsTitleList);
} }
else else
{ {
if (array.Length == titleIndex.Count) allComMap[com.PartNum] = com;
{
if (csvIndex < 0)
{
csvIndex = titleIndex[cvsTitleList[idIndex]];
}
string value = array[csvIndex];
if (value.Equals(com.PartNum))
{
//更新缓存
allComMap.Remove(com.PartNum);
allComMap.Add(com.PartNum, com);
string newValue = ObjToString(com, titleIndex, proTitleMap);
lines[index] = newValue;
return WriteCSVFile(filePath, lines);
}
}
}
index++;
} }
return true;
return SaveToFile();
} }
private static string ObjToString(ComponetInfo position, Dictionary<string, int> titleIndex, Dictionary<string, string> proTitleMap) private static string ObjToString(ComponetInfo position, Dictionary<string, int> titleIndex, Dictionary<string, string> proTitleMap)
...@@ -250,12 +210,15 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -250,12 +210,15 @@ namespace OnlineStore.LoadCSVLibrary
/// <summary> /// <summary>
/// 增加一个元器件库 /// 增加一个元器件库
/// </summary> /// </summary>
public static bool SaveToFile() public static bool SaveToFile(string filePath = "")
{ {
try try
{ {
List<ComponetInfo> comList = new List<ComponetInfo>(); List<ComponetInfo> comList = new List<ComponetInfo>(allComMap.Values);
string filePath = getFilePath(); if (String.IsNullOrEmpty(filePath))
{
filePath = getFilePath();
}
System.Type type = typeof(ComponetInfo); System.Type type = typeof(ComponetInfo);
Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(ComponetInfo)); Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(ComponetInfo));
...@@ -337,5 +300,13 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -337,5 +300,13 @@ namespace OnlineStore.LoadCSVLibrary
/// </summary> /// </summary>
[CSVAttribute("封装")] [CSVAttribute("封装")]
public string Encapsulations { get; set; } public string Encapsulations { get; set; }
public int Sufan = -1;
public string ToStr()
{
return "[" + PartNum + "][" + ProductName + "][" + Encapsulations + "][" + Describe + "]";
}
} }
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!