Commit ba1e2704 LN

修改离线问题

1 个父辈 684dce68
......@@ -13,18 +13,7 @@ namespace OnlineStore.Common
public class ConfigAppSettings
{
private static int seq = 1;
public static int nextSeq()
{
if (seq.Equals(Int32.MaxValue))
{
LogUtil.info("seq当前值:" + seq + ",重置seq=0");
seq = 0;
}
Interlocked.Increment(ref seq);
return seq;
}
public static string GetValue(string keyStr, string storeStr)
{
string key = keyStr + storeStr;
......
......@@ -19,13 +19,17 @@ namespace OnlineStore.Common
{
public class HttpHelper
{
public static string LastSend = "";
public static string LastRevice = "";
private static int isLog = ConfigAppSettings.GetIntValue(Setting_Init.Server_Log_Open);
private static object lockObj = "";
//private static object lockObj = "";
public static Operation PostOP(string url, Operation operation, int lockTime, out bool isTimeOut)
{
isTimeOut = false;
if (Monitor.TryEnter(lockObj, lockTime))
{
//if (Monitor.TryEnter(lockObj, lockTime))
//{
try
{
string json = JsonHelper.SerializeObject(operation);
......@@ -39,16 +43,16 @@ namespace OnlineStore.Common
{
LogUtil.error("Post 出错【operation.op=" + operation.op + "】:" + ex);
}
finally
{
Monitor.Exit(lockObj);
}
}
else if (lockTime > 10)
{
string json = JsonHelper.SerializeObject(operation);
LogUtil.error(" PostOP " + lockTime + " send " + json + " TryEnter fail ");
}
//finally
//{
// Monitor.Exit(lockObj);
//}
//}
//else if (lockTime > 10)
//{
// string json = JsonHelper.SerializeObject(operation);
// LogUtil.error(" PostOP " + lockTime + " send " + json + " TryEnter fail ");
//}
return null;
}
private static string PostJson(string url, string paramData, Encoding encoding, out bool IsTimeOut)
......@@ -69,12 +73,14 @@ namespace OnlineStore.Common
try
{
LastSend = DateTime.Now.ToLongTimeString() + " Send :" + paramData;
var wc = new MyWebClient(3000);
if (string.IsNullOrEmpty(wc.Headers["Content-Type"]))
wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
wc.Encoding = encoding;
result = wc.UploadString(url, "POST", paramData);
LastRevice = DateTime.Now.ToLongTimeString() + " Revice :" + result;
}
catch (WebException ex)
{
......
......@@ -1122,7 +1122,17 @@ namespace OnlineStore.DeviceLibrary
isInProcess = false;
}
}
private int seq = 1;
public int nextSeq()
{
if (seq.Equals(Int32.MaxValue))
{
LogUtil.info("seq当前值:" + seq + ",重置seq=0");
seq = 0;
}
Interlocked.Increment(ref seq);
return seq;
}
public Operation getLineBoxStatus()
{
//构建发送给服务器的对象
......@@ -1130,7 +1140,7 @@ namespace OnlineStore.DeviceLibrary
lineOperation.msg = "";
lineOperation.alarmList = new List<AlarmInfo>();
lineOperation.cid = CID;
lineOperation.seq = ConfigAppSettings.nextSeq();
lineOperation.seq = nextSeq();
lineOperation.status = 1;
if (WarnMsg != "")
{
......@@ -1195,10 +1205,6 @@ namespace OnlineStore.DeviceLibrary
}
}
//温湿度
//ASTemperateParam param = HumitureServer.GetTemperateParam(Config.Temperate_Serveraddress);
//HumitureParam param = HumitureController.LastData;
if (humBean != null)
{
boxStatus.humidity = humBean.LastData.Humidity.ToString();
......@@ -1212,7 +1218,7 @@ namespace OnlineStore.DeviceLibrary
}
return lineOperation;
}
public string LastSend = "";
public void SendLineStatus()
{
DateTime time = DateTime.Now;
......@@ -1226,6 +1232,7 @@ namespace OnlineStore.DeviceLibrary
}
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
bool isTimeout = false;
LastSend = DateTime.Now.ToLongTimeString() + " Send: " + JsonHelper.SerializeObject(lineOperation);
Operation resultOperation = HttpHelper.PostOP(StoreManager.GetPostApi(server), lineOperation,10, out isTimeout);
//发送状态信息到服务器
......
......@@ -12,6 +12,10 @@ namespace OnlineStore.DeviceLibrary
{
public class LineConnect
{
public string LastSend = "";
public string LastRevice = "";
public static char cmd_spilt = ';';
public static string cmd_heart = "heart";
private static string cmd_outend = "outend";
......@@ -79,12 +83,12 @@ namespace OnlineStore.DeviceLibrary
{
store.Cmd = cmd_heart;
string heartMsg = ToParamStr(store);
LastSend = DateTime.Now.ToLongTimeString() + " Send :" + heartMsg;
client.send(heartMsg);
}
catch (Exception ex)
{
LogUtil.error("["+CID+"]SendHeart 出错:" + ex.ToString());
LogUtil.error("[" + CID + "]SendHeart 出错:" + ex.ToString());
}
}
private DateTime LastOutStoreEndTime = DateTime.Now;
......@@ -100,6 +104,8 @@ namespace OnlineStore.DeviceLibrary
store.Cmd = cmd_outend;
string msg = ToParamStr(store);
LogUtil.info("[" + CID + "]OutStoreEnd:" + msg);
LastSend = DateTime.Now.ToLongTimeString() + " Send :" + msg;
client.send(msg);
}
catch (Exception ex)
......@@ -117,6 +123,8 @@ namespace OnlineStore.DeviceLibrary
try
{
message = message.Replace("\r", "");
LastRevice = DateTime.Now.ToLongTimeString() + " Revice :" + message;
StoreReviceBean reviceInfo = JsonHelper.DeserializeJsonToObject<StoreReviceBean>(message);
//string[] msgArray = message.Split(cmd_spilt);
if (reviceInfo == null)
......
......@@ -137,6 +137,10 @@
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.lblLRevice = new System.Windows.Forms.Label();
this.lblLSend = new System.Windows.Forms.Label();
this.lblRevice = new System.Windows.Forms.Label();
this.lblSend = new System.Windows.Forms.Label();
this.tabControl1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.groupBox1.SuspendLayout();
......@@ -262,6 +266,10 @@
//
// tabPage2
//
this.tabPage2.Controls.Add(this.lblLRevice);
this.tabPage2.Controls.Add(this.lblLSend);
this.tabPage2.Controls.Add(this.lblRevice);
this.tabPage2.Controls.Add(this.lblSend);
this.tabPage2.Controls.Add(this.lblMoveStr);
this.tabPage2.Controls.Add(this.groupBox1);
this.tabPage2.Controls.Add(this.groupBox2);
......@@ -315,7 +323,7 @@
this.groupBox1.Controls.Add(this.label43);
this.groupBox1.Controls.Add(this.label42);
this.groupBox1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox1.Location = new System.Drawing.Point(11, 462);
this.groupBox1.Location = new System.Drawing.Point(505, 324);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(476, 136);
this.groupBox1.TabIndex = 217;
......@@ -495,7 +503,7 @@
this.groupBox2.Controls.Add(this.button6);
this.groupBox2.Controls.Add(this.button3);
this.groupBox2.Controls.Add(this.button5);
this.groupBox2.Location = new System.Drawing.Point(11, 378);
this.groupBox2.Location = new System.Drawing.Point(11, 382);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(476, 78);
this.groupBox2.TabIndex = 276;
......@@ -1665,6 +1673,50 @@
this.tableLayoutPanel2.Size = new System.Drawing.Size(218, 297);
this.tableLayoutPanel2.TabIndex = 103;
//
// lblLRevice
//
this.lblLRevice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblLRevice.AutoSize = true;
this.lblLRevice.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblLRevice.ForeColor = System.Drawing.Color.Green;
this.lblLRevice.Location = new System.Drawing.Point(13, 538);
this.lblLRevice.Name = "lblLRevice";
this.lblLRevice.Size = new System.Drawing.Size(0, 17);
this.lblLRevice.TabIndex = 281;
//
// lblLSend
//
this.lblLSend.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblLSend.AutoSize = true;
this.lblLSend.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblLSend.ForeColor = System.Drawing.Color.Green;
this.lblLSend.Location = new System.Drawing.Point(13, 518);
this.lblLSend.Name = "lblLSend";
this.lblLSend.Size = new System.Drawing.Size(0, 17);
this.lblLSend.TabIndex = 280;
//
// lblRevice
//
this.lblRevice.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblRevice.AutoSize = true;
this.lblRevice.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblRevice.ForeColor = System.Drawing.Color.Green;
this.lblRevice.Location = new System.Drawing.Point(13, 579);
this.lblRevice.Name = "lblRevice";
this.lblRevice.Size = new System.Drawing.Size(0, 17);
this.lblRevice.TabIndex = 279;
//
// lblSend
//
this.lblSend.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblSend.AutoSize = true;
this.lblSend.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblSend.ForeColor = System.Drawing.Color.Green;
this.lblSend.Location = new System.Drawing.Point(13, 559);
this.lblSend.Name = "lblSend";
this.lblSend.Size = new System.Drawing.Size(0, 17);
this.lblSend.TabIndex = 278;
//
// FrmBox
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
......@@ -1818,6 +1870,10 @@
private System.Windows.Forms.PictureBox picPPoint;
private UserFromControl.IOTextControl ioSingle;
private System.Windows.Forms.Label lblSize;
private System.Windows.Forms.Label lblLRevice;
private System.Windows.Forms.Label lblLSend;
private System.Windows.Forms.Label lblRevice;
private System.Windows.Forms.Label lblSend;
}
}
......@@ -179,6 +179,10 @@ namespace OnlineStore.ACSingleStore
{
return;
}
lblLSend.Text =boxBean.lineConnect.LastSend.ToString();
//lblLRevice.Text = boxBean.lineConnect.LastRevice.ToString();
lblSend.Text = boxBean.LastSend.ToString();
//lblRevice.Text = HttpHelper.LastRevice.ToString();
ioSingle.IOValue = (int)boxBean.IOValue(IO_Type.CheckPos);
ioSingle.ShowData();
......
......@@ -55,9 +55,9 @@
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
this.开机自动启动ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator15 = new System.Windows.Forms.ToolStripSeparator();
this.启用蜂鸣器ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator15 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator();
this.开启DEBUG日志ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.设置TToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
......@@ -214,7 +214,7 @@
this.logBox.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.logBox.Location = new System.Drawing.Point(241, 6);
this.logBox.Name = "logBox";
this.logBox.Size = new System.Drawing.Size(1085, 613);
this.logBox.Size = new System.Drawing.Size(1085, 632);
this.logBox.TabIndex = 106;
this.logBox.Text = "";
this.logBox.VisibleChanged += new System.EventHandler(this.logBox_VisibleChanged);
......@@ -343,24 +343,24 @@
this.toolStripSeparator10.Name = "toolStripSeparator10";
this.toolStripSeparator10.Size = new System.Drawing.Size(196, 6);
//
// toolStripMenuItem5
// 启用蜂鸣器ToolStripMenuItem
//
this.toolStripMenuItem5.Name = "toolStripMenuItem5";
this.toolStripMenuItem5.Size = new System.Drawing.Size(199, 26);
this.toolStripMenuItem5.Text = "启用温湿度";
this.toolStripMenuItem5.Click += new System.EventHandler(this.toolStripMenuItem5_Click);
this.启用蜂鸣器ToolStripMenuItem.Name = "启用蜂鸣器ToolStripMenuItem";
this.启用蜂鸣器ToolStripMenuItem.Size = new System.Drawing.Size(199, 26);
this.启用蜂鸣器ToolStripMenuItem.Text = "启用蜂鸣器";
this.启用蜂鸣器ToolStripMenuItem.Click += new System.EventHandler(this.启用蜂鸣器ToolStripMenuItem_Click);
//
// toolStripSeparator15
//
this.toolStripSeparator15.Name = "toolStripSeparator15";
this.toolStripSeparator15.Size = new System.Drawing.Size(196, 6);
//
// 启用蜂鸣器ToolStripMenuItem
// toolStripMenuItem5
//
this.启用蜂鸣器ToolStripMenuItem.Name = "启用蜂鸣器ToolStripMenuItem";
this.启用蜂鸣器ToolStripMenuItem.Size = new System.Drawing.Size(199, 26);
this.启用蜂鸣器ToolStripMenuItem.Text = "启用蜂鸣器";
this.启用蜂鸣器ToolStripMenuItem.Click += new System.EventHandler(this.启用蜂鸣器ToolStripMenuItem_Click);
this.toolStripMenuItem5.Name = "toolStripMenuItem5";
this.toolStripMenuItem5.Size = new System.Drawing.Size(199, 26);
this.toolStripMenuItem5.Text = "启用温湿度";
this.toolStripMenuItem5.Click += new System.EventHandler(this.toolStripMenuItem5_Click);
//
// toolStripSeparator11
//
......
......@@ -401,6 +401,7 @@ namespace OnlineStore.ACSingleStore
{
return;
}
//lblServerMsg.Text = HttpHelper.LastServerMsg;
ReadIOList();
string msg = "";
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!