This commit is contained in:
Administrator committed 2026-05-23 01:12:40 +08:00
commit 2334555c7b
13 files changed
+206 -41

No files matched your search

+28 -13
View File
@@ -4,6 +4,7 @@ using SunlightAggregationTerminal.Models;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using static System.Net.Mime.MediaTypeNames;
namespace SunlightAggregationTerminal.View;
@@ -42,7 +43,8 @@ public partial class LogPage : ContentPage
var dat = new ItemOption
{
SERVER = dataRow.Field<string>("Server") ?? "",
SERVERIP = dataRow.Field<string>("ServerID") ?? ""
SERVERIP = dataRow.Field<string>("ServerID") ?? "" +","+
dataRow.Field<string>("ServerHTTP") ?? ""
};
Items.Add(dat);
}
@@ -76,41 +78,54 @@ public partial class LogPage : ContentPage
{
LoadingIndicator.IsVisible = true;
App.GlobalData.ServerID = SERVERIP.Text;
string[] result = SERVERIP.Text.Split(',', 2, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
App.GlobalData.ServerID = result[0]?? "";
//判断是否有http连接信息
if (result.Length == 2)
{
App.GlobalData.ServerHTTP = result[1] ?? "";
}
else
{
App.GlobalData.LocalAreaNetworkMode = true;
}
App.GlobalData.User = UsernameEntry.Text;
App.GlobalData.UserPassword = PasswordEntry.Text;
if (await AppModels.LogIn())
{
App.GlobalData.ServerID = SERVERIP.Text;
int temp_name = AppModels.Select("SELECT * FROM Users WHERE User='" + UsernameEntry.Text + "' LIMIT 1;")!.Tables[0].Rows.Count;
if (temp_name >0)
{
//存在更新账号状态
string sql = "UPDATE Users SET ServerID = '" + SERVERIP.Text
+ "', UserPassword = '" + PasswordEntry.Text +
"', LogNo = 1 WHERE User='" + UsernameEntry.Text + "';";
string sql = "UPDATE Users SET ServerID = '" + App.GlobalData.ServerID
+ "', ServerHTTP = '" + App.GlobalData.ServerHTTP
+ "', UserPassword = '" + PasswordEntry.Text
+"', LogNo = 1 WHERE User='" + UsernameEntry.Text + "';";
AppModels.Updata(sql);
}
else
{
//插入账号
string sql = @"INSERT INTO Users (User,UserId ,UserName ,UserPassword ,
Enterprise ,Department ,ServerID ,Groups ,
Enterprise ,Department ,ServerID ,ServerHTTP ,Groups ,
ProxyID ,LogNo ,LocalAreaNetworkMode ,DarkMode ,
MessageNotificationMode ,GUID
)VALUES('" + UsernameEntry.Text + "','SUNLIGHT','SUNLIGHT','" + PasswordEntry.Text +
"','SUNLIGHT','ENGINEER','" + SERVERIP.Text + "','ENGINEER'," +
)VALUES('" + UsernameEntry.Text + "','"+ App.GlobalData.UserId +
"','" + App.GlobalData.UserName + "','" + PasswordEntry.Text +
"','"+ App.GlobalData.Enterprise + "','"+ App.GlobalData.Department +
"','" + App.GlobalData.ServerID + "','" +App.GlobalData.ServerHTTP+
"','"+ App.GlobalData.Groups + "'," +
" '',1,0,0,0,'" + Models.AppModels.GetAppUniqueId() + "');";
AppModels.INSERT(sql);
}
int temp_server = AppModels.Select("SELECT * FROM Server WHERE ServerID='" + SERVERIP.Text + "' LIMIT 1;")!.Tables[0].Rows.Count;
int temp_server = AppModels.Select("SELECT * FROM Server WHERE ServerID='' LIMIT 1;")!.Tables[0].Rows.Count;
if (temp_server == 0)
{
string sql = @"INSERT INTO Server ( Server, ServerID)VALUES('" + App.GlobalData.Enterprise + "','" +
App.GlobalData.ServerID + "');";
string sql = @"INSERT INTO Server ( Server, ServerID,ServerHTTP)VALUES('" + App.GlobalData.Enterprise + "','" +
App.GlobalData.ServerID+ App.GlobalData.ServerHTTP + "');";
AppModels.INSERT(sql);
}