Эх сурвалжийг харах

添加日期异常处理,如未添加联网配置则显示离线

章政 7 жил өмнө
parent
commit
bedc60bdcb

+ 10 - 3
PLCDataReader/DataOperate/DataHelper.cs

@@ -12,7 +12,7 @@ namespace UAS_PLCDataReader.DataOperate
         //系统默认的的连接字符串
         private string ConnectionStrings = Properties.Settings.Default.Properties["MES"].DefaultValue.ToString();
         //用户选择的数据库的连接字符串
-        public static string DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=UAS_MES_PROD;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.253.6)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        public static string DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=UAS_DEV;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.253.6)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
         public static OracleConnection connection = null;
         OracleCommand command = null;
         /// <summary>
@@ -815,9 +815,16 @@ namespace UAS_PLCDataReader.DataOperate
                     DateTime[] time = new DateTime[names[i].Length];
                     for (int j = 0; j < names[i].Length; j++)
                     {
-                        time[j] = Convert.ToDateTime(names[i][j]);
+                        try
+                        {
+                            time[j] = Convert.ToDateTime(names[i][j]);
+                            command.Parameters.Add(new OracleParameter(names[0][i - 1].ToString(), OracleDbType.Date, time, ParameterDirection.Input));
+                        }
+                        catch (Exception)
+                        {
+                            command.Parameters.Add(new OracleParameter(names[0][i - 1].ToString(), OracleDbType.Varchar2, names[i], ParameterDirection.Input));
+                        }
                     }
-                    command.Parameters.Add(new OracleParameter(names[0][i - 1].ToString(), OracleDbType.Date, time, ParameterDirection.Input));
                 }
                 else
                 {

+ 1 - 0
PLCDataReader/Main.cs

@@ -597,6 +597,7 @@ namespace UAS_PLCDataReader
                     client[DpcID].Returnvalue.Remove(IP);
                 }
             }
+            else LogicHandler.UpdateDeviceStatus(pl.Dh, pl.DeviceCode, pl.DeviceName, DeviceStatus.Disconnect);
         }
 
         /// <summary>