Explorar el Código

添加轮询入职记录

章政 hace 7 años
padre
commit
c902092a41

+ 1 - 1
UAS_DeviceMonitor/Main.Designer.cs

@@ -3,7 +3,7 @@ using UAS_DeviceMonitor.CustomerControl.AutoDataGridControl;
 using UAS_DeviceMonitor.CustomerControl;
 using UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum;
 
-namespace UAS_DeviceMonitor
+namespace UAS_DeviceMonitor 
 {
     partial class Main
     {

+ 33 - 3
UAS_DeviceMonitor/Main.cs

@@ -22,6 +22,7 @@ namespace UAS_DeviceMonitor
         StringBuilder sql = new StringBuilder();
         DataHelper dh;
         ModeBusTCPServer mbt = new ModeBusTCPServer();
+        List<string> SQL = new List<string>();
 
         #region 初始化代码
         public Main()
@@ -236,6 +237,11 @@ namespace UAS_DeviceMonitor
                 pl.Dh = new DataHelper();
                 if (pl.Enable)
                 {
+                    //插入轮询日志
+                    sql.Clear();
+                    sql.Append("insert into DEVICEPOLLINGLOG(dpg_id,dpg_decode,dpg_starttime,dpg_interval)values");
+                    sql.Append("(DEVICEPOLLINGLOG_seq.nextval,'" + pl.DeviceCode + "',sysdate,'" + pl.Interval + "')");
+                    dh.ExecuteSql(sql.ToString(), "insert");
                     pt.AddTask(RunTask, pl);
                     //添加到状态为运行的行
                     PollSettingPaintRowIndex.Add(i);
@@ -299,23 +305,47 @@ namespace UAS_DeviceMonitor
                 string SendCoding = "";
                 string ReceiveCoding = "";
                 string Command = "";
+                int SendCommandByteSize = 0;
                 if (dt1.Rows.Count > 0)
                 {
                     SendCoding = dt1.Rows[0]["dc_sendcoding"].ToString();
                     ReceiveCoding = dt1.Rows[0]["dc_receivecoding"].ToString();
                     Command = dt1.Rows[0]["dc_value"].ToString();
+                    SendCommandByteSize = Encoding.Default.GetBytes(Command.ToCharArray()).Length;
                 }
                 mbt.Send(IP, SendCoding, ReceiveCoding, Command);
                 //处理2秒之内返回的指令
-                Thread.Sleep(2000);
+                Thread.Sleep(1000);
                 if (mbt.Returnvalue.ContainsKey(IP))
                 {
+                    int ReceiveCommandByteSize = Encoding.Default.GetBytes(mbt.Returnvalue[IP].ToCharArray()).Length;
                     mbt.Returnvalue.Remove(IP);
-                    dh.UpdateByCondition("DEVICEPOLLINGCONFIG", "dpc_status='Running'", "dpc_decode='" + Decode + "' and dpc_dccode='" + Dccode + "'");
+                    SQL.Clear();
+                    //更新轮询状态
+                    sql.Clear();
+                    sql.Append("update DEVICEPOLLINGCONFIG set dpc_status='Running' where dpc_decode='" + Decode + "' and dpc_dccode='" + Dccode + "'");
+                    SQL.Add(sql.ToString());
+                    //更新轮询日志状态
+                    sql.Clear();
+                    sql.Append("update DEVICEPOLLINGLOG set dpg_status='Running',dpg_senddatasize=nvl(dpg_senddatasize,0)+" + SendCommandByteSize);
+                    sql.Append(",dpg_receivedatasize=nvl(dpg_receivedatasize,0)+" + ReceiveCommandByteSize);
+                    sql.Append(" where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + Decode + "')");
+                    SQL.Add(sql.ToString());
+                    dh.ExecuteSQLTran(SQL.ToArray());
                 }
                 else
                 {
-                    dh.UpdateByCondition("DEVICEPOLLINGCONFIG", "dpc_status='Stop'", "dpc_decode='" + Decode + "' and dpc_dccode='" + Dccode + "'");
+                    SQL.Clear();
+                    //更新轮询状态
+                    sql.Clear();
+                    sql.Append("update DEVICEPOLLINGCONFIG set dpc_status='Stop' where dpc_decode='" + Decode + "' and dpc_dccode='" + Dccode + "'");
+                    SQL.Add(sql.ToString());
+                    //更新轮询日志状态
+                    sql.Clear();
+                    sql.Append("update DEVICEPOLLINGLOG set dpg_status='Running',dpg_senddatasize=nvl(dpg_senddatasize,0)+" + SendCommandByteSize);
+                    sql.Append(" where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + Decode + "')");
+                    SQL.Add(sql.ToString());
+                    dh.ExecuteSQLTran(SQL.ToArray());
                 }
             }
         }

+ 1 - 0
UAS_DeviceMonitor/UAS_DeviceMonitor.csproj

@@ -49,6 +49,7 @@
     <Reference Include="DevExpress.XtraPrinting.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
     <Reference Include="DevExpress.XtraSpellChecker.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
     <Reference Include="DevExpress.XtraVerticalGrid.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
+    <Reference Include="DevExpress.XtraWizard.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
     <Reference Include="Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=MSIL" />
     <Reference Include="System" />
     <Reference Include="System.Configuration" />