|
|
@@ -406,6 +406,12 @@ namespace UAS_MES_NEW.Make
|
|
|
LogMessage($"文件不存在: {file}");
|
|
|
}
|
|
|
|
|
|
+ string outFileMsg = CheckFileAccess(file);
|
|
|
+ if (outFileMsg != "OK")
|
|
|
+ {
|
|
|
+ LogMessage(outFileMsg);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
if (Device.SelectedIndex == 0) // 劲拓SPI
|
|
|
{
|
|
|
@@ -700,7 +706,7 @@ namespace UAS_MES_NEW.Make
|
|
|
}
|
|
|
if (dh.getRowCount("productsmtlocation", "PSL_PSID=" + ps_id) > 0)
|
|
|
{
|
|
|
- dh.ExecuteSql("delete from productsmtlocation where PSL_PSID" + ps_id, "delete");
|
|
|
+ dh.ExecuteSql("delete from productsmtlocation where PSL_PSID = '" + ps_id +"'", "delete");
|
|
|
}
|
|
|
sql.Clear();
|
|
|
sql.Append("insert into productsmtlocation(PSL_ID, PSL_PSID, PSL_DETNO, PSL_PRODCODE, PSL_REPCODE, PSL_LOCATION, PSL_BASEQTY, PSL_TABLE)" +
|
|
|
@@ -1130,6 +1136,7 @@ namespace UAS_MES_NEW.Make
|
|
|
|
|
|
return dataList;
|
|
|
}
|
|
|
+
|
|
|
private SpiData MapToSpiData(string fileName, string[] headers, string[] values,string others,int num)
|
|
|
{
|
|
|
return new SpiData
|
|
|
@@ -1230,6 +1237,30 @@ namespace UAS_MES_NEW.Make
|
|
|
return values[index];
|
|
|
}
|
|
|
|
|
|
+ public string CheckFileAccess(string filePath)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ using (FileStream fileStream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.None))
|
|
|
+ {
|
|
|
+ return "OK";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (IOException ex)
|
|
|
+ {
|
|
|
+ return "文件被占用: " + ex.Message;
|
|
|
+ }
|
|
|
+ catch (UnauthorizedAccessException ex)
|
|
|
+ {
|
|
|
+ return "权限不足,无法访问文件: " + ex.Message;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return ex.Message;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private class Log
|
|
|
{
|
|
|
public string work_order { get; set; }
|