Commit f233d67d authored by 姜春辉's avatar 姜春辉

修改宿舍信息数据结构,呈现方式

parent 13cc06cf
...@@ -5,7 +5,15 @@ using System.Text; ...@@ -5,7 +5,15 @@ using System.Text;
namespace DashBoard.ServiceModel namespace DashBoard.ServiceModel
{ {
//宿舍状态测试地址:http://192.168.1.2:8019/Visualization/SuSheState.ashx?Bui=a
public class School_SuSheBuild
{
public int BuiId { get; set; }
public string BuiName { get; set; }
public List<School_SuSheState> Floors { get; set; }
}
//传参说明:?Bui=a a男生宿舍楼b女生宿舍楼y游泳馆 //传参说明:?Bui=a a男生宿舍楼b女生宿舍楼y游泳馆
public class School_SuSheState public class School_SuSheState
{ {
......
This diff is collapsed.
...@@ -7,30 +7,21 @@ using System.Collections.ObjectModel; ...@@ -7,30 +7,21 @@ using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Controls;
namespace SchoolSituation namespace SchoolSituation
{ {
public partial class DormInfoViewModel : PageViewModel public partial class DormInfoViewModel : PageViewModel
{ {
private ObservableCollection<ViewSuSheState> _Dorma; private ObservableCollection<ViewSuSheBuild> _DormList;
public ObservableCollection<ViewSuSheState> Dorma
{ public ObservableCollection<ViewSuSheBuild> DormList
get { return _Dorma; }
set { _Dorma = value; RaisePropertyChanged("Dorma"); }
}
private ObservableCollection<ViewSuSheState> _Dormb;
public ObservableCollection<ViewSuSheState> Dormb
{
get { return _Dormb; }
set { _Dormb = value; RaisePropertyChanged("Dormb"); }
}
private ObservableCollection<ViewSuSheState> _Dormy;
public ObservableCollection<ViewSuSheState> Dormy
{ {
get { return _Dormy; } get { return _DormList ?? (_DormList = new ObservableCollection<ViewSuSheBuild>()); }
set { _Dormy = value; RaisePropertyChanged("Dormy"); } set { _DormList = value; RaisePropertyChanged("DormList"); }
} }
public override void Enter() public override void Enter()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
...@@ -48,49 +39,23 @@ namespace SchoolSituation ...@@ -48,49 +39,23 @@ namespace SchoolSituation
if (isfirst) if (isfirst)
{ {
isfirst = false; isfirst = false;
var localresulta = Tools.ReadCache($"SuShetStatea.json"); var localresult = Tools.ReadCache($"SuSheBuild.json");
var locala = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheState>>(localresulta); var local = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheBuild>>(localresult);
var localresultb = Tools.ReadCache($"SuShetStateb.json"); if (local != null)
var localb = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheState>>(localresultb);
var localresulty = Tools.ReadCache($"SuShetStatey.json");
var localy = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheState>>(localresulty);
if (locala != null || locala != null || locala != null)
{ {
Dorma = new ObservableCollection<ViewSuSheState>(locala.Select(r => (ViewSuSheState)r).ToList()); DormList = new ObservableCollection<ViewSuSheBuild>(local.Select(r => (ViewSuSheBuild)r).ToList());
Dormb = new ObservableCollection<ViewSuSheState>(localb.Select(r => (ViewSuSheState)r).ToList());
Dormy = new ObservableCollection<ViewSuSheState>(localy.Select(r => (ViewSuSheState)r).ToList());
} }
} }
//读取本地数据加载界面 //读取本地数据加载界面
if (string.IsNullOrEmpty(Source)) return false; if (string.IsNullOrEmpty(Source)) return false;
var updateResult = false; var updateResult = false;
var getUrla = new Uri(Source + "?Bui=a"); var resulta = Tools.Get(new Uri(Source), out string backDataa);
var getUrlb = new Uri(Source + "?Bui=b");
var getUrly = new Uri(Source + "?Bui=y");
var resulta = Tools.Get(getUrla, out string backDataa);
if (resulta) if (resulta)
{ {
var writeCacheResulta = Tools.WriteCache($"SuShetStatea.json", backDataa); var writeCacheResulta = Tools.WriteCache($"SuSheBuild.json", backDataa);
var entiya = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheState>>(backDataa); var entiya = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheBuild>>(backDataa);
Dorma = new ObservableCollection<ViewSuSheState>(entiya.Select(r => (ViewSuSheState)r).ToList()); DormList = new ObservableCollection<ViewSuSheBuild>(entiya.Select(r => (ViewSuSheBuild)r).ToList());
updateResult = true;
}
var resultb = Tools.Get(getUrlb, out string backDatab);
if (resultb)
{
var writeCacheResultb = Tools.WriteCache($"SuShetStateb.json", backDatab);
var entiyb = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheState>>(backDatab);
Dormb = new ObservableCollection<ViewSuSheState>(entiyb.Select(r => (ViewSuSheState)r).ToList());
updateResult = true;
}
var resulty = Tools.Get(getUrly, out string backDatay);
if (resulty)
{
var writeCacheResulty = Tools.WriteCache($"SuShetStatey.json", backDatay);
var entiyy = JsonConvert.DeserializeObject<List<DashBoard.ServiceModel.School_SuSheState>>(backDatay);
Dormy = new ObservableCollection<ViewSuSheState>(entiyy.Select(r => (ViewSuSheState)r).ToList());
updateResult = true; updateResult = true;
} }
return updateResult; return updateResult;
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -7,6 +8,43 @@ using GalaSoft.MvvmLight; ...@@ -7,6 +8,43 @@ using GalaSoft.MvvmLight;
namespace SchoolSituation namespace SchoolSituation
{ {
public class ViewSuSheBuild : ObservableObject
{
private int _Id;
public int Id
{
get { return _Id; }
set { _Id = value; RaisePropertyChanged("Id"); }
}
private string _Name;
public string Name
{
get { return _Name; }
set { _Name = value; RaisePropertyChanged("Name"); }
}
private ObservableCollection<ViewSuSheState> _Floors;
public ObservableCollection<ViewSuSheState> Floors
{
get { return _Floors; }
set { _Floors = value; RaisePropertyChanged("Floors"); }
}
public static explicit operator ViewSuSheBuild(DashBoard.ServiceModel.School_SuSheBuild data)
{
var entity = new ViewSuSheBuild();
entity.Id = data.BuiId;
entity.Name = data.BuiName;
entity.Floors = new ObservableCollection<ViewSuSheState>(data.Floors.Select(r => (ViewSuSheState)r).ToList());
return entity;
}
}
public class ViewSuSheState : ObservableObject public class ViewSuSheState : ObservableObject
{ {
......
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