|
|
@ -3,17 +3,63 @@ using SunlightAggregationTerminal.Class; |
|
|
using SunlightAggregationTerminal.Models; |
|
|
using SunlightAggregationTerminal.Models; |
|
|
using SunlightAggregationTerminal.View; |
|
|
using SunlightAggregationTerminal.View; |
|
|
using System.Collections.ObjectModel; |
|
|
using System.Collections.ObjectModel; |
|
|
|
|
|
using TouchSocket.Core; |
|
|
|
|
|
|
|
|
namespace SunlightAggregationTerminal; |
|
|
namespace SunlightAggregationTerminal; |
|
|
|
|
|
|
|
|
public partial class ProfilePage : ContentPage |
|
|
public partial class ProfilePage : ContentPage |
|
|
{ |
|
|
{ |
|
|
|
|
|
private static bool SET = false; |
|
|
public ProfilePage() |
|
|
public ProfilePage() |
|
|
{ |
|
|
{ |
|
|
InitializeComponent(); |
|
|
InitializeComponent(); |
|
|
this.BindingContext = App.GlobalData; |
|
|
this.BindingContext = App.GlobalData; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void _data(string v,string k) |
|
|
|
|
|
{ |
|
|
|
|
|
if (k == "Password") |
|
|
|
|
|
{ |
|
|
|
|
|
App.GlobalData.UserPassword = v; |
|
|
|
|
|
string sql = @"UPDATE Users SET UserPassword = '" + App.GlobalData.UserPassword |
|
|
|
|
|
+ "' WHERE User='" + App.GlobalData.User + "';"; |
|
|
|
|
|
AppModels.Updata(sql); |
|
|
|
|
|
SET = false; |
|
|
|
|
|
} |
|
|
|
|
|
if (k == "Name") |
|
|
|
|
|
{ |
|
|
|
|
|
App.GlobalData.UserName = v; |
|
|
|
|
|
string sql = @"UPDATE Users SET UserName = '" + App.GlobalData.UserName |
|
|
|
|
|
+ "' WHERE User='" + App.GlobalData.User + "';"; |
|
|
|
|
|
AppModels.Updata(sql); |
|
|
|
|
|
SET = false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
public async void _Command(string dat) |
|
|
|
|
|
{ |
|
|
|
|
|
DataReceived.Transmit(dat); |
|
|
|
|
|
SET = true; |
|
|
|
|
|
// 创建一个 秒的延时任务
|
|
|
|
|
|
Task delayTask = Task.Delay(10000); |
|
|
|
|
|
// 创建一个监测任务,不断检查变量
|
|
|
|
|
|
Task monitorTask = Task.Run(async () => |
|
|
|
|
|
{ |
|
|
|
|
|
while (SET) |
|
|
|
|
|
{ |
|
|
|
|
|
// 每隔 100 毫秒检查一次,避免 CPU 占用过高
|
|
|
|
|
|
await Task.Delay(1000); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
// 使用 Task.WhenAny 等待任意一个任务完成
|
|
|
|
|
|
Task task = await Task.WhenAny(delayTask, monitorTask); |
|
|
|
|
|
|
|
|
|
|
|
if (task==delayTask) |
|
|
|
|
|
{ //超时
|
|
|
|
|
|
await DisplayAlertAsync("", "修改失败", "是"); |
|
|
|
|
|
} |
|
|
|
|
|
SET = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private async void Out_Clicked(object sender, EventArgs e) |
|
|
private async void Out_Clicked(object sender, EventArgs e) |
|
|
{ |
|
|
{ |
|
|
//退出
|
|
|
//退出
|
|
|
@ -38,10 +84,19 @@ public partial class ProfilePage : ContentPage |
|
|
// 处理结果
|
|
|
// 处理结果
|
|
|
if (!string.IsNullOrWhiteSpace(result)) |
|
|
if (!string.IsNullOrWhiteSpace(result)) |
|
|
{ |
|
|
{ |
|
|
App.GlobalData.UserName=result; |
|
|
Dictionary<string, object> data_ = new Dictionary<string, object>(); |
|
|
string sql = @"UPDATE Users SET UserName = '" + App.GlobalData.UserName |
|
|
data_.Add("Command", "SETUSER"); |
|
|
+ "' WHERE User='" + App.GlobalData.User + "';"; |
|
|
data_.Add("USER", App.GlobalData.User); |
|
|
AppModels.Updata(sql); |
|
|
data_.Add("KEY", "Name"); |
|
|
|
|
|
data_.Add("VALUE", result); |
|
|
|
|
|
_Command(data_.ToJsonString()); |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
|
|
|
|
App.GlobalData.UserName=result; |
|
|
|
|
|
string sql = @"UPDATE Users SET UserName = '" + App.GlobalData.UserName |
|
|
|
|
|
+ "' WHERE User='" + App.GlobalData.User + "';"; |
|
|
|
|
|
AppModels.Updata(sql);*/ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
private async void UserPassword_Tapped(object sender, TappedEventArgs e) |
|
|
private async void UserPassword_Tapped(object sender, TappedEventArgs e) |
|
|
@ -51,10 +106,18 @@ public partial class ProfilePage : ContentPage |
|
|
// 处理结果
|
|
|
// 处理结果
|
|
|
if (!string.IsNullOrWhiteSpace(result)) |
|
|
if (!string.IsNullOrWhiteSpace(result)) |
|
|
{ |
|
|
{ |
|
|
App.GlobalData.UserPassword = result; |
|
|
Dictionary<string, object> data_ = new Dictionary<string, object>(); |
|
|
string sql = @"UPDATE Users SET UserPassword = '" + App.GlobalData.UserPassword |
|
|
data_.Add("Command", "SETUSER"); |
|
|
+ "' WHERE User='" + App.GlobalData.User + "';"; |
|
|
data_.Add("USER", App.GlobalData.User); |
|
|
AppModels.Updata(sql); |
|
|
data_.Add("KEY", "Password"); |
|
|
|
|
|
data_.Add("VALUE", result); |
|
|
|
|
|
_Command(data_.ToJsonString()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* App.GlobalData.UserPassword = result; |
|
|
|
|
|
string sql = @"UPDATE Users SET UserPassword = '" + App.GlobalData.UserPassword |
|
|
|
|
|
+ "' WHERE User='" + App.GlobalData.User + "';"; |
|
|
|
|
|
AppModels.Updata(sql);*/ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
private async void ServerID_Tapped(object sender, TappedEventArgs e) |
|
|
private async void ServerID_Tapped(object sender, TappedEventArgs e) |
|
|
|