Commit 290dc647 authored by 姜春辉's avatar 姜春辉

登记结果页完成

parent c399aa0d
...@@ -10,6 +10,7 @@ namespace GS.Terminal.VisitorSelfService.Logic.Core ...@@ -10,6 +10,7 @@ namespace GS.Terminal.VisitorSelfService.Logic.Core
public class HistoryAppointmentPageHandler : Corebase<ViewModels.Pages.HistoryAppointmentPage.ViewModel> public class HistoryAppointmentPageHandler : Corebase<ViewModels.Pages.HistoryAppointmentPage.ViewModel>
{ {
private IViewModel _BackView; private IViewModel _BackView;
private string _idnum;
public override void Init() public override void Init()
{ {
...@@ -17,8 +18,11 @@ namespace GS.Terminal.VisitorSelfService.Logic.Core ...@@ -17,8 +18,11 @@ namespace GS.Terminal.VisitorSelfService.Logic.Core
public void ShowView(string idnum, IViewModel backview = null) public void ShowView(string idnum, IViewModel backview = null)
{ {
_idnum = idnum;
_BackView = backview; _BackView = backview;
ShowView(); ShowView();
} }
} }
} }
using System; using GS.Unitive.Framework.Utils.Serializing;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace GS.Terminal.VisitorSelfService.Logic.Core namespace GS.Terminal.VisitorSelfService.Logic.Core
{ {
public class SubmitVisitInfoResultHandler : Corebase<ViewModels.Pages.SubmitVisitInfoResult.ViewModel> public class SubmitVisitInfoResultHandler : Corebase<ViewModels.Pages.SubmitVisitInfoResult.ViewModel>
{ {
private const int AUTODELAY = 5;
private Task _task;
private CancellationTokenSource _CTS;
public override void Init() public override void Init()
{ {
VM.OnGoHomeClicked += VM_OnGoHomeClicked;
VM.OnNavigateInto += VM_OnNavigateInto;
VM.OnNavigateOut += VM_OnNavigateOut;
}
private void VM_OnNavigateOut(LogicShell.Interface.IViewModel obj)
{
StopDowncount();
}
private void VM_OnNavigateInto(LogicShell.Interface.IViewModel obj)
{
StartDowncount();
}
private void VM_OnGoHomeClicked()
{
gohome();
}
private void gohome()
{
ThirdAddon.LogicShell.ShowView(vmLocator.MenuPage);
}
private void StartDowncount()
{
_CTS = new CancellationTokenSource();
_task = Task.Factory.StartNew(async () =>
{
VM.Downcount = AUTODELAY;
while (!_CTS.IsCancellationRequested && VM.Downcount > 0)
{
await Task.Delay(1000);
VM.Downcount--;
}
if (VM.Downcount == 0)
gohome();
}, _CTS.Token);
}
private void StopDowncount()
{
_CTS.Cancel();
while (_task.Status == TaskStatus.Running)
Task.Delay(100).Wait();
_task = null;
} }
} }
} }
...@@ -38,12 +38,20 @@ namespace GS.Terminal.VisitorSelfService.Logic.Remote ...@@ -38,12 +38,20 @@ namespace GS.Terminal.VisitorSelfService.Logic.Remote
{ {
Program._Context.Logger.Error($"请求服务[{service}]异常,StatusCode:{result.StatusCode}", null); Program._Context.Logger.Error($"请求服务[{service}]异常,StatusCode:{result.StatusCode}", null);
} }
return default(T);
}
catch (Exception ex)
{
Program._Context.Logger.Error($"Get请求{service}服务异常.", ex);
if (ex.InnerException != null)
Program._Context.Logger.Error($"Get请求{service}服务异常.InnerException", ex.InnerException);
} }
finally finally
{ {
_httpclientPool.Return(_clientPoolObject); _httpclientPool.Return(_clientPoolObject);
} }
return default(T);
} }
public static async Task<T> PostAsync<T>(string service, object requestBody) public static async Task<T> PostAsync<T>(string service, object requestBody)
...@@ -65,12 +73,19 @@ namespace GS.Terminal.VisitorSelfService.Logic.Remote ...@@ -65,12 +73,19 @@ namespace GS.Terminal.VisitorSelfService.Logic.Remote
{ {
Program._Context.Logger.Error($"请求服务[{service}]异常,StatusCode:{result.StatusCode}", null); Program._Context.Logger.Error($"请求服务[{service}]异常,StatusCode:{result.StatusCode}", null);
} }
return default(T);
}
catch (Exception ex)
{
Program._Context.Logger.Error($"Post请求{service}服务异常.", ex);
if (ex.InnerException != null)
Program._Context.Logger.Error($"Post请求{service}服务异常.InnerException", ex.InnerException);
} }
finally finally
{ {
_httpclientPool.Return(_clientPoolObject); _httpclientPool.Return(_clientPoolObject);
} }
return default(T);
} }
public static T Post<T>(string service, object requestBody) public static T Post<T>(string service, object requestBody)
...@@ -87,12 +102,19 @@ namespace GS.Terminal.VisitorSelfService.Logic.Remote ...@@ -87,12 +102,19 @@ namespace GS.Terminal.VisitorSelfService.Logic.Remote
var responseBody = result.Content.ReadAsStringAsync().Result; var responseBody = result.Content.ReadAsStringAsync().Result;
return JsonConvert.DeserializeObject<T>(responseBody); return JsonConvert.DeserializeObject<T>(responseBody);
} }
return default(T);
}
catch (Exception ex)
{
Program._Context.Logger.Error($"Post请求{service}服务异常.", ex);
if (ex.InnerException != null)
Program._Context.Logger.Error($"Post请求{service}服务异常.InnerException", ex.InnerException);
} }
finally finally
{ {
_httpclientPool.Return(_clientPoolObject); _httpclientPool.Return(_clientPoolObject);
} }
return default(T);
} }
} }
} }
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GS.Terminal.LogicShell.Interface; using GS.Terminal.LogicShell.Interface;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -8,13 +9,37 @@ using System.Threading.Tasks; ...@@ -8,13 +9,37 @@ using System.Threading.Tasks;
namespace ViewModels.Pages.SubmitVisitInfoResult namespace ViewModels.Pages.SubmitVisitInfoResult
{ {
public class ViewModel : ViewModelBase, IViewModel public class ViewModel : ViewModelBase, IViewModel, IViewModelBehavior
{ {
public string ViewID => "cc808936-9d19-4e9c-86b7-3620cedd72fe"; public string ViewID => "cc808936-9d19-4e9c-86b7-3620cedd72fe";
private int _Downcount;
public int Downcount
{
get { return _Downcount; }
set { _Downcount = value; RaisePropertyChanged("Downcount"); }
}
public event Action OnGoHomeClicked;
public RelayCommand GoHomeCommand => new RelayCommand(() =>
{
OnGoHomeClicked?.Invoke();
});
public void Reset() public void Reset()
{ {
} }
public event Action<IViewModel> OnNavigateInto;
public void NavigateInto(IViewModel from)
{
OnNavigateInto?.Invoke(from);
}
public event Action<IViewModel> OnNavigateOut;
public void NavigateOut(IViewModel to)
{
OnNavigateOut?.Invoke(to);
}
} }
} }
...@@ -22,8 +22,10 @@ ...@@ -22,8 +22,10 @@
HorizontalAlignment="Center" VerticalAlignment="Center"/> HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Text="登记成功!" Foreground="#62ba67" FontSize="72" Margin="0,50,0,0"/> <TextBlock Text="登记成功!" Foreground="#62ba67" FontSize="72" Margin="0,50,0,0"/>
<TextBlock Text="欢迎来访,您已获得通行权限可以在来访区域通行了!" FontSize="36" Margin="0,70,0,0"/> <TextBlock Text="欢迎来访,您已获得通行权限可以在来访区域通行了!" FontSize="36" Margin="0,70,0,0"/>
<TextBlock Text="5秒后自动跳转至首页" Margin="0,216,0,0" FontSize="24"/> <TextBlock Text="{Binding Downcount,StringFormat={}{0}秒后自动跳转至首页}" Margin="0,216,0,0" FontSize="24"/>
<Button Width="460" Height="80" Margin="0,70,0,0" Template="{StaticResource CommonButton}" Content="返回首页" FontSize="36"/> <Button Width="460" Height="80" Margin="0,70,0,0"
Command="{Binding GoHomeCommand}"
Template="{StaticResource CommonButton}" Content="返回首页" FontSize="36"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Page> </Page>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment