From 1877d455d7a8fbb0d05d75ed5a341b8e3579acbd Mon Sep 17 00:00:00 2001
From: wxr <wxr@hdlchina.com.cn>
Date: 星期四, 02 四月 2026 16:23:47 +0800
Subject: [PATCH] 新服务器
---
SmartHome/UI/SimpleControl/Phone/System/SearchServerOnePortListPage.cs | 164 ++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 128 insertions(+), 36 deletions(-)
diff --git a/SmartHome/UI/SimpleControl/Phone/System/SearchServerOnePortListPage.cs b/SmartHome/UI/SimpleControl/Phone/System/SearchServerOnePortListPage.cs
index c8e42fc..409866f 100644
--- a/SmartHome/UI/SimpleControl/Phone/System/SearchServerOnePortListPage.cs
+++ b/SmartHome/UI/SimpleControl/Phone/System/SearchServerOnePortListPage.cs
@@ -1,5 +1,6 @@
锘�
using System;
+using System.Collections.Generic;
using Shared;
using Shared.SimpleControl;
@@ -8,14 +9,14 @@
public class SearchServerOnePortListPage : FrameLayout
{
#region 鏂囨湰
- string text_Title = "杩滅▼杩炴帴";
+ string text_Title = "杩滅▼";
string text_userName = "缁勫悕";
string text_projectName = "宸ョ▼鍚�";
string text_password = "瀵嗙爜";
string text_entry_userName_tip = "璇疯緭鍏ョ粍鍚嶃��";
string text_entry_projectName_tip = "璇疯緭鍏ュ伐绋嬪悕銆�";
string text_entry_password_tip = "璇疯緭鍏ュ瘑鐮併��";
- string text_link = "杩炴帴涓�绔彛";
+ string text_link = "杩炴帴";
string text_back = "鍚庨��";
string text_reading = "璇诲彇涓�";
/// <summary>
@@ -40,11 +41,12 @@
string text_readFailure = "璇诲彇澶辫触";
string txt_breakLink = "鏂紑杩炴帴";
- string txt_connectionSucceeded = "杩炴帴鎴愬姛";
+ string txt_connectionSucceeded = "鎼滅储瀹屾垚";
string txt_linkSeverFailed = "杩炴帴鏈嶅姟鍣ㄥけ璐�";
string txt_DataError = "鏁版嵁寮傚父";
string txt_QueryFailed = "鏌ヨ澶辫触";
+ string txt_NoData = "鏃犳暟鎹�";
string txt_Search = "鎼滅储";
#endregion
@@ -66,7 +68,7 @@
public SearchServerOnePortListPage ()
{
if (Language.CurrentLanguage != "Chinese") {
- text_Title = "Remote connection";
+ text_Title = "Remote";
text_userName = "Group name";
text_projectName = "project name";
text_password = "Password";
@@ -76,17 +78,18 @@
text_Upgraded = "Upgraded";
text_Upgrading = "Upgrading";
text_UpgradeFailed = "Upgrade failed";
- text_UnknownVersion = "Unknown version";
+ text_UnknownVersion = "Other version";
text_readFailure = "Read failure";
text_back = "Back";
text_link = "Link";
text_reading = "Reading";
txt_breakLink = "Break link";
- txt_connectionSucceeded = "Connection succeeded";
+ txt_connectionSucceeded = "Search complete";
txt_linkSeverFailed = "Failed to connect to the server";
txt_DataError = "Data exception";
txt_QueryFailed = "Query failed";
txt_Search = "search";
+ txt_NoData = "No data";
}
}
@@ -179,7 +182,7 @@
userNameView.AddChidren (tvUserName);
var btnLine = new Button () {
- Height = Application.GetRealHeight (1),
+ Height = Application.GetRealHeight (2),
BackgroundColor = SkinStyle.Current.LineColor,
};
infoView.AddChidren (btnLine);
@@ -227,23 +230,25 @@
CommonPage.IsRemote = true;
var sendBytes = new byte [29];
- var b1 = System.Text.Encoding.UTF8.GetBytes (userName);
+ var b1 = CommonPage.MyEncodingGB2312.GetBytes (userName);
byte [] ggn = new byte [20];
Array.Copy (b1, 0, ggn, 0, 20 < b1.Length ? 20 : b1.Length);
Array.Copy (ggn, 0, sendBytes, 9, 20);
-
+ string newIp = "35.156.34.111";
+
new System.Threading.Thread (() => {
CommonPage.IsRemote = true;
Application.RunOnMainThread (() => {
MainPage.Loading.Start ();
});
try {
+ //璇诲彇鏃ф湇鍔″櫒涓婄殑宸ョ▼鍒楄〃
var sss = Control.ControlBytesSendHasReturn (Command.GetRemoteOnePortListInfo, 0xFB, 0xFB, sendBytes);
+ var oldGatewayList = new List<GatewayBase> ();
if (sss != null) {
try {
if (sss [1] == 248) {
-
Application.RunOnMainThread (() => {
MainPage.Loading.Start ();
rightButton1.Text = txt_connectionSucceeded;
@@ -251,6 +256,7 @@
});
var count = sss [2] * 256 + sss [3];
+
for (int i = 1; i <= count; i++) {
byte [] arayImp = new byte [23];
if (b1.Length <= 20)
@@ -262,18 +268,20 @@
var oneProtData = Control.ControlBytesSendHasReturn (Command.GetRemoteOnePortInfo, 0xFB, 0xFB, arayImp);
if (oneProtData != null) {
try {
- var groupName = System.Text.Encoding.UTF8.GetString (oneProtData, 1, 20).Trim ('\0');//=============
- var projectName = System.Text.Encoding.UTF8.GetString (oneProtData, 23, 20).Trim ('\0');//=============
- var userName = System.Text.Encoding.UTF8.GetString (oneProtData, 43, 8).Trim ('\0');//=============
- Application.RunOnMainThread (() => {
+ var groupName = CommonPage.MyEncodingGB2312.GetString (oneProtData, 1, 20).Trim ('\0');
+ var projectName22 = CommonPage.MyEncodingGB2312.GetString (oneProtData, 23, 20).Trim ('\0');
+ var userName22 = CommonPage.MyEncodingGB2312.GetString (oneProtData, 43, 8).Trim ('\0');
+ var isOnline = oneProtData [57] == 1;
- RowLayout wirelessView = new RowLayout () {
- Height = Application.GetRealHeight (93),
- BackgroundColor = SkinStyle.Current.ViewColor,
- };
- listView.AddChidren (wirelessView);
- showGatewayRow (userName,projectName, wirelessView);
- });
+ GatewayBase gatewayBase = new GatewayBase () {
+ Remote_GroupName = groupName,
+ Remote_ProjectName = projectName22,
+ Remote_UserName = userName22,
+ isOnline = isOnline,
+ };
+ oldGatewayList.Add (gatewayBase);
+
+
}catch (Exception ex) {
}
@@ -281,7 +289,83 @@
}
}
- } else {
+
+
+
+
+ //璇诲彇鏂版湇鍔″櫒涓婄殑宸ョ▼鍒楄〃
+ var sss2 = Control.ControlBytesSendHasReturn (Command.GetRemoteOnePortListInfo, 0xFB, 0xFB, sendBytes, newIp);
+ var newGatewayList = new List<GatewayBase> ();
+ try {
+ if (sss [1] == 248) {
+ var countNew = sss [2] * 256 + sss [3];
+
+ for (int i = 1; i <= countNew; i++) {
+ byte [] arayImp = new byte [23];
+ if (b1.Length <= 20)
+ Array.Copy (b1, 0, arayImp, 1, b1.Length);
+ else
+ Array.Copy (b1, 0, arayImp, 1, 20);
+ arayImp [21] = (byte)(i / 256);
+ arayImp [22] = (byte)(i % 256);
+ var oneProtData = Control.ControlBytesSendHasReturn (Command.GetRemoteOnePortInfo, 0xFB, 0xFB, arayImp, newIp);
+ if (oneProtData != null) {
+ try {
+ var groupName = CommonPage.MyEncodingGB2312.GetString (oneProtData, 1, 20).Trim ('\0');
+ var projectName22 = CommonPage.MyEncodingGB2312.GetString (oneProtData, 23, 20).Trim ('\0');
+ var userName22 = CommonPage.MyEncodingGB2312.GetString (oneProtData, 43, 8).Trim ('\0');
+
+ var oldGateway = oldGatewayList.Find ((obj) => obj.Remote_GroupName == groupName &&
+ obj.Remote_ProjectName == projectName22 && obj.Remote_UserName == userName22);
+ if (oldGateway != null) {
+ oldGateway.isMoveToNewServer = true;
+ }
+ } catch (Exception ex) {
+
+ }
+ } else {
+
+ }
+ }
+ } else if (sss [1] == 245) {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = txt_NoData;
+ rightButton1.TextColor = 0x99FF0000;
+ });
+ } else {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = txt_QueryFailed;
+ rightButton1.TextColor = 0x99FF0000;
+ });
+ }
+ } catch (Exception ex) {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = txt_DataError;
+ rightButton1.TextColor = 0x99FF0000;
+ });
+ } finally {
+
+ }
+
+
+ Application.RunOnMainThread (() => {
+ foreach (var one in oldGatewayList) {
+ RowLayout wirelessView = new RowLayout () {
+ Height = Application.GetRealHeight (93),
+ BackgroundColor = SkinStyle.Current.ViewColor,
+ };
+ listView.AddChidren (wirelessView);
+ showGatewayRow (one,wirelessView);
+ }
+ });
+
+ } else if(sss[1] == 245) {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = txt_NoData;
+ rightButton1.TextColor = 0x99FF0000;
+ });
+ }
+ else {
Application.RunOnMainThread (() => {
rightButton1.Text = txt_QueryFailed;
rightButton1.TextColor = 0x99FF0000;
@@ -328,23 +412,24 @@
/// <summary>
/// 鏄剧ず
/// </summary>
- void showGatewayRow (string userName,string projectName, RowLayout wirelessView)
+ void showGatewayRow (GatewayBase gatewayBase, RowLayout wirelessView)
{
Button pointButton1 = new Button () {
- Width = Application.GetRealHeight (13),
- Height = Application.GetRealHeight (13),
+ Width = Application.GetRealHeight (20),
+ Height = Application.GetRealHeight (20),
X = Application.GetRealWidth (60),
- UnSelectedImagePath = "Item/Point.png",
- SelectedImagePath = "Item/PointSelected.png",
+ Radius = (uint)Application.GetRealHeight (7),
Gravity = Gravity.CenterVertical,
+ BackgroundColor = gatewayBase.isOnline ? 0xFF00FF00: 0xFF000000
};
wirelessView.AddChidren (pointButton1);
+
Button nameButton1 = new Button () {
Width = Application.GetRealWidth (342),
Height = LayoutParams.MatchParent,
- Text = projectName,
+ Text = gatewayBase.Remote_ProjectName,
TextAlignment = TextAlignment.CenterLeft,
X = pointButton1.Right + Application.GetRealWidth (20),
TextColor = SkinStyle.Current.TextColor1,
@@ -353,22 +438,29 @@
Button rightButton1 = new Button () {
X = Application.GetRealWidth (480),
- Width = Application.GetRealWidth (100),
+ Width = Application.GetRealWidth (150),
Height = Application.GetRealHeight (40),
Gravity = Gravity.CenterVertical,
TextAlignment = TextAlignment.CenterLeft,
TextColor = SkinStyle.Current.TextColor1,
IsMoreLines = true,
TextSize = 12,
+ Text = text_link,
};
- wirelessView.AddChidren (rightButton1);
- EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
- LinkOnePort (userName,projectName);
- };
- nameButton1.MouseUpEventHandler = eventHandler;
- rightButton1.MouseUpEventHandler = eventHandler;
- wirelessView.MouseUpEventHandler = eventHandler;
+ if (gatewayBase.isMoveToNewServer && !gatewayBase.isOnline) {
+ wirelessView.AddChidren (rightButton1);
+ rightButton1.Text = text_Upgraded;
+ } else {
+ if (gatewayBase.isOnline)
+ wirelessView.AddChidren (rightButton1);
+ EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
+ LinkOnePort (gatewayBase.Remote_UserName, gatewayBase.Remote_ProjectName);
+ };
+ nameButton1.MouseUpEventHandler = eventHandler;
+ rightButton1.MouseUpEventHandler = eventHandler;
+ wirelessView.MouseUpEventHandler = eventHandler;
+ }
}
void LinkOnePort (string userName, string projectName) {
--
Gitblit v1.8.0