登录连接信息
This commit is contained in:
commit
5c51e96f67
6 files changed
+176
-59
No files matched your search
+28
-17
@@ -3,25 +3,29 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SunlightAggregationTerminal.View.LogPage"
|
||||
Title="登录">
|
||||
<VerticalStackLayout Padding="30" Spacing="20"
|
||||
<VerticalStackLayout Padding="30" Spacing="10"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="Center"
|
||||
MaximumWidthRequest="600">
|
||||
<Grid RowDefinitions="Auto, *" ColumnDefinitions="*, Auto">
|
||||
<HorizontalStackLayout VerticalOptions="Center" Spacing="15">
|
||||
MaximumWidthRequest="550">
|
||||
<Grid>
|
||||
<VerticalStackLayout Spacing="-20" >
|
||||
<Grid RowDefinitions="Auto, *" ColumnDefinitions="*, Auto" >
|
||||
<HorizontalStackLayout VerticalOptions="Center" Spacing="15">
|
||||
<!-- 信息 -->
|
||||
<VerticalStackLayout Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
VerticalOptions="Center">
|
||||
<VerticalStackLayout Grid.Row="0" Grid.Column="0" VerticalOptions="Center">
|
||||
<HorizontalStackLayout VerticalOptions="Center">
|
||||
<Entry Text="服务器:" FontSize="26" TextColor="Black" />
|
||||
<Entry x:Name="Enterprise"
|
||||
Text="IP"
|
||||
FontSize="26"
|
||||
TextColor="Gray"
|
||||
WidthRequest="200"
|
||||
MaximumWidthRequest="200"/>
|
||||
</HorizontalStackLayout>
|
||||
<Entry Text="服务器:" FontSize="26" TextColor="Black" IsReadOnly="True"/>
|
||||
<Picker x:Name="SERVER"
|
||||
FontSize="24"
|
||||
TextColor="Gray"
|
||||
WidthRequest="200"
|
||||
MaximumWidthRequest="200"
|
||||
SelectedIndexChanged="SERVER_SelectedIndexChanged">
|
||||
<Picker.ItemDisplayBinding>
|
||||
<Binding Path="SERVER"/>
|
||||
</Picker.ItemDisplayBinding>
|
||||
</Picker>
|
||||
</HorizontalStackLayout>
|
||||
</VerticalStackLayout>
|
||||
</HorizontalStackLayout>
|
||||
<Button Grid.Row="0" Grid.Column="1"
|
||||
@@ -34,9 +38,15 @@
|
||||
<FileImageSource File="lucidescanline.png" />
|
||||
</Button.ImageSource>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Entry x:Name="SERVERIP" FontSize="26" TextColor="Gray"
|
||||
WidthRequest="350" MaximumWidthRequest="350"/>
|
||||
</VerticalStackLayout>
|
||||
</Grid>
|
||||
|
||||
<HorizontalStackLayout VerticalOptions="Center">
|
||||
<Entry Text="用户:" FontSize="26" TextColor="Black" />
|
||||
<Entry Text="用户:" FontSize="26" TextColor="Black"
|
||||
IsReadOnly="True"/>
|
||||
<!-- 用户名输入 -->
|
||||
<Entry x:Name="UsernameEntry"
|
||||
Placeholder="请输入用户名"
|
||||
@@ -45,7 +55,8 @@
|
||||
MaximumWidthRequest="250"/>
|
||||
</HorizontalStackLayout>
|
||||
<HorizontalStackLayout VerticalOptions="Center">
|
||||
<Entry Text="密码:" FontSize="26" TextColor="Black"/>
|
||||
<Entry Text="密码:" FontSize="26" TextColor="Black"
|
||||
IsReadOnly="True"/>
|
||||
<!-- 密码输入 -->
|
||||
<Entry x:Name="PasswordEntry"
|
||||
Placeholder="请输入密码"
|
||||
|
||||
+77
-25
@@ -1,21 +1,64 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using SunlightAggregationTerminal.Class;
|
||||
using SunlightAggregationTerminal.Models;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
|
||||
namespace SunlightAggregationTerminal.View;
|
||||
|
||||
public class ItemOption
|
||||
{
|
||||
public required string SERVER { get; set; }
|
||||
public required string SERVERIP { get; set; }
|
||||
}
|
||||
|
||||
public partial class LogPage : ContentPage
|
||||
{
|
||||
public static Action<string>? OnScanProfile;
|
||||
public ObservableCollection<ItemOption> Items { get; }
|
||||
|
||||
public LogPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
WeakReferenceMessenger.Default.Register<string>(this, (r, scannedValue) =>
|
||||
{
|
||||
Enterprise.Text = scannedValue;
|
||||
SERVERIP.Text = scannedValue;
|
||||
});
|
||||
|
||||
//可用服务器列表
|
||||
AppModels.sqliteHelper.Open();
|
||||
var userdata = AppModels.sqliteHelper.ExecuteDataSet("select * from Server", null);
|
||||
AppModels.sqliteHelper.Close();
|
||||
if (userdata != null)
|
||||
{
|
||||
foreach (DataRow dataRow in userdata.Tables[0].Rows)
|
||||
{
|
||||
if (dataRow != null)
|
||||
{
|
||||
Items?.Add(new ItemOption {
|
||||
SERVER = dataRow.Field<string>("UserName") ?? "",
|
||||
SERVERIP = dataRow.Field<string>("UserName") ?? ""
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 可选:设置默认选中项
|
||||
if (Items != null)
|
||||
{
|
||||
SERVER.ItemsSource = Items;
|
||||
SERVER.SelectedItem = Items[0];
|
||||
}
|
||||
}
|
||||
|
||||
private void SERVER_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
var dat = SERVER.SelectedItem as ItemOption;
|
||||
if (dat != null)
|
||||
{
|
||||
SERVERIP.Text = dat.SERVERIP.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnScanButtonClicked(object sender, EventArgs e)
|
||||
@@ -27,34 +70,43 @@ public partial class LogPage : ContentPage
|
||||
|
||||
private async void Log_Clicked(object sender, EventArgs e)//登录
|
||||
{
|
||||
TcpServer.Configuration(Enterprise.Text, UsernameEntry.Text, PasswordEntry.Text,
|
||||
TcpServer.Configuration(SERVERIP.Text, UsernameEntry.Text, PasswordEntry.Text,
|
||||
Models.AppModels.GetAppUniqueId());
|
||||
|
||||
// while(!App.GlobalData.LogNo);
|
||||
/*
|
||||
var temp_name = AppModels.Select("SELECT * FROM Users WHERE User='" + UsernameEntry.Text + "' LIMIT 1;");
|
||||
if (temp_name != null)
|
||||
if (await AppModels.LogIn())
|
||||
{
|
||||
//存在更新账号状态
|
||||
//var name = temp_name.Tables[0].AsEnumerable().FirstOrDefault();
|
||||
var temp_name = AppModels.Select("SELECT * FROM Users WHERE User='" + UsernameEntry.Text + "' LIMIT 1;")!.Tables[0];
|
||||
if (temp_name != null)
|
||||
{
|
||||
//存在更新账号状态
|
||||
string sql = @"UPDATE Users SET ServerID = '" + SERVERIP.Text
|
||||
+ "', UserPassword = '" + PasswordEntry.Text +
|
||||
"', LogNo = true WHERE User='" + UsernameEntry.Text + "';";
|
||||
AppModels.Updata(sql);
|
||||
}
|
||||
else
|
||||
{
|
||||
//插入账号
|
||||
string sql = @"INSERT INTO Users (User,UserId ,UserName ,UserPassword ,
|
||||
Enterprise ,Department ,ServerID ,Groups ,
|
||||
ProxyID ,LogNo ,LocalAreaNetworkMode ,DarkMode ,
|
||||
MessageNotificationMode ,GUID
|
||||
)VALUES('" + UsernameEntry.Text + "','SUNLIGHT','SUNLIGHT','" + PasswordEntry.Text +
|
||||
"','SUNLIGHT','ENGINEER','" + SERVERIP.Text + "','ENGINEER'," +
|
||||
" '',0,0,0,0,'" + Models.AppModels.GetAppUniqueId() + "');";
|
||||
AppModels.INSERT(sql);
|
||||
}
|
||||
|
||||
string sql = @"UPDATE Users SET ServerID = '" + Enterprise.Text
|
||||
+ "', UserPassword = '" + PasswordEntry.Text+
|
||||
"', LogNo = true WHERE User='" + UsernameEntry.Text + "';";
|
||||
AppModels.Updata(sql);
|
||||
var temp_server = AppModels.Select("SELECT * FROM Server WHERE ServerID='" + SERVERIP.Text + "' LIMIT 1;")!.Tables[0];
|
||||
if (temp_server == null)
|
||||
{
|
||||
string sql = @"INSERT INTO Server ( Server, ServerID)VALUES('" + App.GlobalData.Enterprise + "','" +
|
||||
App.GlobalData.ServerID + "');";
|
||||
AppModels.INSERT(sql);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//插入账号
|
||||
string sql = @"INSERT INTO Users (User,UserId ,UserName ,UserPassword ,
|
||||
Enterprise ,Department ,ServerID ,Groups ,
|
||||
ProxyID ,LogNo ,LocalAreaNetworkMode ,DarkMode ,
|
||||
MessageNotificationMode ,GUID
|
||||
)VALUES('"+ UsernameEntry.Text + "','SUNLIGHT','SUNLIGHT','"+ PasswordEntry.Text +
|
||||
"','SUNLIGHT','ENGINEER','"+ Enterprise.Text + "','ENGINEER',"+
|
||||
" '',0,0,0,0,'" + Models.AppModels.GetAppUniqueId() + "');";
|
||||
AppModels.INSERT(sql);
|
||||
}*/
|
||||
await Navigation.PopModalAsync();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user