xiongzhu 5 yıl önce
ebeveyn
işleme
c08f89a292

BIN
.vs/DeviceCenter/v16/.suo


+ 7 - 0
DeviceCenter.csproj

@@ -99,12 +99,19 @@
       <Generator>MSBuild:Compile</Generator>
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
     </ApplicationDefinition>
+    <Compile Include="model\Area.cs" />
+    <Compile Include="model\Building.cs" />
     <Compile Include="model\CarCamDevice.cs" />
     <Compile Include="model\CarCamDevice.cs" />
     <Compile Include="Converter.cs" />
     <Compile Include="Converter.cs" />
     <Compile Include="model\Config.cs" />
     <Compile Include="model\Config.cs" />
+    <Compile Include="model\Floor.cs" />
+    <Compile Include="model\GetAreasResponse.cs" />
+    <Compile Include="model\GetBuildingResponse.cs" />
+    <Compile Include="model\GetFloorResponse.cs" />
     <Compile Include="utils\AcsUtil.cs" />
     <Compile Include="utils\AcsUtil.cs" />
     <Compile Include="utils\AppUtil.cs" />
     <Compile Include="utils\AppUtil.cs" />
     <Compile Include="utils\ConfigUtil.cs" />
     <Compile Include="utils\ConfigUtil.cs" />
+    <Compile Include="utils\EnumerationExtension.cs" />
     <Compile Include="utils\http.cs" />
     <Compile Include="utils\http.cs" />
     <Compile Include="utils\NotificationUtil.cs" />
     <Compile Include="utils\NotificationUtil.cs" />
     <Compile Include="utils\PortUtil.cs" />
     <Compile Include="utils\PortUtil.cs" />

BIN
bin/x86/Debug/DeviceCenter.exe


BIN
bin/x86/Debug/DeviceCenter.pdb


+ 15 - 0
model/Area.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DeviceCenter.model
+{
+    class Area
+    {
+        public long id { get; set; }
+        public string name { get; set; }
+        public string remark { get; set; }
+    }
+}

+ 16 - 0
model/Building.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DeviceCenter.model
+{
+    class Building
+    {
+        public long id { get; set; }
+        public string name { get; set; }
+        public string remark { get; set; }
+        public long areaId { get; set; }
+    }
+}

+ 2 - 0
model/Device.cs

@@ -17,7 +17,9 @@ namespace DeviceCenter
 
 
         public enum Type
         public enum Type
         {
         {
+            [Description("车牌识别")]
             CAR_CAM,
             CAR_CAM,
+            [Description("门禁")]
             ACS
             ACS
         }
         }
 
 

+ 17 - 0
model/Floor.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DeviceCenter.model
+{
+    class Floor
+    {
+        public long id { get; set; }
+        public string name { get; set; }
+        public string remark { get; set; }
+        public long areaId { get; set; }
+        public long buildingId { get; set; }
+    }
+}

+ 13 - 0
model/GetAreasResponse.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DeviceCenter.model
+{
+    class GetAreasResponse
+    {
+        public List<Area> content { get; set; }
+    }
+}

+ 13 - 0
model/GetBuildingResponse.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DeviceCenter.model
+{
+    class GetBuildingResponse
+    {
+        public List<Building> content { get; set; }
+    }
+}

+ 13 - 0
model/GetFloorResponse.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DeviceCenter.model
+{
+    class GetFloorResponse
+    {
+        public List<Floor> content { get; set; }
+    }
+}

BIN
obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache


+ 1 - 1
obj/x86/Debug/DeviceCenter.csproj.CoreCompileInputs.cache

@@ -1 +1 @@
-a1266bb1554c0dad93a2a0391be72a3fc16f4846
+2964c93522cef307e925ba682fe317dfd94e78ea

BIN
obj/x86/Debug/DeviceCenter.csprojAssemblyReference.cache


BIN
obj/x86/Debug/DeviceCenter.exe


BIN
obj/x86/Debug/DeviceCenter.g.resources


BIN
obj/x86/Debug/DeviceCenter.pdb


+ 1 - 1
obj/x86/Debug/DeviceCenter_MarkupCompile.cache

@@ -12,7 +12,7 @@ DEBUG;TRACE
 C:\Users\xiong\Projects\csharp\DeviceCenter\App.xaml
 C:\Users\xiong\Projects\csharp\DeviceCenter\App.xaml
 3-1289623115
 3-1289623115
 
 
-26-172462967
+331937613292
 24-1854166468
 24-1854166468
 views\AddDevice.xaml;views\Login.xaml;views\MainWindow.xaml;
 views\AddDevice.xaml;views\Login.xaml;views\MainWindow.xaml;
 
 

+ 1 - 1
obj/x86/Debug/DeviceCenter_MarkupCompile.i.cache

@@ -12,7 +12,7 @@ DEBUG;TRACE
 C:\Users\xiong\Projects\csharp\DeviceCenter\App.xaml
 C:\Users\xiong\Projects\csharp\DeviceCenter\App.xaml
 3-1289623115
 3-1289623115
 
 
-27-184220451
+341925855808
 24-1854166468
 24-1854166468
 views\AddDevice.xaml;views\Login.xaml;views\MainWindow.xaml;
 views\AddDevice.xaml;views\Login.xaml;views\MainWindow.xaml;
 
 

+ 2 - 4
obj/x86/Debug/DeviceCenter_MarkupCompile.i.lref

@@ -1,6 +1,4 @@
-C:\Users\xiong\Projects\csharp\DeviceCenter\obj\x86\Debug\GeneratedInternalTypeHelper.g.i.cs
-FC:\Users\xiong\Projects\csharp\DeviceCenter\App.xaml;;
+
+
 FC:\Users\xiong\Projects\csharp\DeviceCenter\views\AddDevice.xaml;;
 FC:\Users\xiong\Projects\csharp\DeviceCenter\views\AddDevice.xaml;;
-FC:\Users\xiong\Projects\csharp\DeviceCenter\views\Login.xaml;;
-FC:\Users\xiong\Projects\csharp\DeviceCenter\views\MainWindow.xaml;;
 
 

+ 1 - 1
obj/x86/Debug/DeviceCenter_MarkupCompile.lref

@@ -1,4 +1,4 @@
-
+C:\Users\xiong\Projects\csharp\DeviceCenter\obj\x86\Debug\GeneratedInternalTypeHelper.g.cs
 FC:\Users\xiong\Projects\csharp\DeviceCenter\App.xaml;;
 FC:\Users\xiong\Projects\csharp\DeviceCenter\App.xaml;;
 FC:\Users\xiong\Projects\csharp\DeviceCenter\views\AddDevice.xaml;;
 FC:\Users\xiong\Projects\csharp\DeviceCenter\views\AddDevice.xaml;;
 FC:\Users\xiong\Projects\csharp\DeviceCenter\views\Login.xaml;;
 FC:\Users\xiong\Projects\csharp\DeviceCenter\views\Login.xaml;;

BIN
obj/x86/Debug/views/AddDevice.baml


+ 20 - 8
obj/x86/Debug/views/AddDevice.g.cs

@@ -1,4 +1,4 @@
-#pragma checksum "..\..\..\..\views\AddDevice.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "AEDA380AE841D63A154AB6C24BDE621283D59263651546F661B92DDB849694A3"
+#pragma checksum "..\..\..\..\views\AddDevice.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "F29E232DB630086027EBAFD5F9A5B6556B420385B166D002AFD99D7AEBCD6164"
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 // <auto-generated>
 // <auto-generated>
 //     此代码由工具生成。
 //     此代码由工具生成。
@@ -9,7 +9,7 @@
 // </auto-generated>
 // </auto-generated>
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 
 
-using DeviceCenter;
+using DeviceCenter.utils;
 using System;
 using System;
 using System.Diagnostics;
 using System.Diagnostics;
 using System.Windows;
 using System.Windows;
@@ -73,7 +73,7 @@ namespace DeviceCenter {
         #line hidden
         #line hidden
         
         
         
         
-        #line 35 "..\..\..\..\views\AddDevice.xaml"
+        #line 31 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_name;
         internal System.Windows.Controls.TextBox tb_name;
         
         
@@ -81,7 +81,7 @@ namespace DeviceCenter {
         #line hidden
         #line hidden
         
         
         
         
-        #line 39 "..\..\..\..\views\AddDevice.xaml"
+        #line 35 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_ip;
         internal System.Windows.Controls.TextBox tb_ip;
         
         
@@ -89,7 +89,7 @@ namespace DeviceCenter {
         #line hidden
         #line hidden
         
         
         
         
-        #line 43 "..\..\..\..\views\AddDevice.xaml"
+        #line 39 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_port;
         internal System.Windows.Controls.TextBox tb_port;
         
         
@@ -97,7 +97,7 @@ namespace DeviceCenter {
         #line hidden
         #line hidden
         
         
         
         
-        #line 47 "..\..\..\..\views\AddDevice.xaml"
+        #line 43 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_username;
         internal System.Windows.Controls.TextBox tb_username;
         
         
@@ -105,7 +105,7 @@ namespace DeviceCenter {
         #line hidden
         #line hidden
         
         
         
         
-        #line 51 "..\..\..\..\views\AddDevice.xaml"
+        #line 47 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_password;
         internal System.Windows.Controls.TextBox tb_password;
         
         
@@ -144,9 +144,21 @@ namespace DeviceCenter {
             {
             {
             case 1:
             case 1:
             this.cb_area = ((System.Windows.Controls.ComboBox)(target));
             this.cb_area = ((System.Windows.Controls.ComboBox)(target));
+            
+            #line 12 "..\..\..\..\views\AddDevice.xaml"
+            this.cb_area.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.cb_area_SelectionChanged);
+            
+            #line default
+            #line hidden
             return;
             return;
             case 2:
             case 2:
             this.cb_building = ((System.Windows.Controls.ComboBox)(target));
             this.cb_building = ((System.Windows.Controls.ComboBox)(target));
+            
+            #line 17 "..\..\..\..\views\AddDevice.xaml"
+            this.cb_building.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.cb_building_SelectionChanged);
+            
+            #line default
+            #line hidden
             return;
             return;
             case 3:
             case 3:
             this.cb_floor = ((System.Windows.Controls.ComboBox)(target));
             this.cb_floor = ((System.Windows.Controls.ComboBox)(target));
@@ -171,7 +183,7 @@ namespace DeviceCenter {
             return;
             return;
             case 10:
             case 10:
             
             
-            #line 53 "..\..\..\..\views\AddDevice.xaml"
+            #line 49 "..\..\..\..\views\AddDevice.xaml"
             ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
             ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
             
             
             #line default
             #line default

+ 20 - 8
obj/x86/Debug/views/AddDevice.g.i.cs

@@ -1,4 +1,4 @@
-#pragma checksum "..\..\..\..\views\AddDevice.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "AEDA380AE841D63A154AB6C24BDE621283D59263651546F661B92DDB849694A3"
+#pragma checksum "..\..\..\..\views\AddDevice.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "F29E232DB630086027EBAFD5F9A5B6556B420385B166D002AFD99D7AEBCD6164"
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 // <auto-generated>
 // <auto-generated>
 //     此代码由工具生成。
 //     此代码由工具生成。
@@ -9,7 +9,7 @@
 // </auto-generated>
 // </auto-generated>
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 
 
-using DeviceCenter;
+using DeviceCenter.utils;
 using System;
 using System;
 using System.Diagnostics;
 using System.Diagnostics;
 using System.Windows;
 using System.Windows;
@@ -73,7 +73,7 @@ namespace DeviceCenter {
         #line hidden
         #line hidden
         
         
         
         
-        #line 35 "..\..\..\..\views\AddDevice.xaml"
+        #line 31 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_name;
         internal System.Windows.Controls.TextBox tb_name;
         
         
@@ -81,7 +81,7 @@ namespace DeviceCenter {
         #line hidden
         #line hidden
         
         
         
         
-        #line 39 "..\..\..\..\views\AddDevice.xaml"
+        #line 35 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_ip;
         internal System.Windows.Controls.TextBox tb_ip;
         
         
@@ -89,7 +89,7 @@ namespace DeviceCenter {
         #line hidden
         #line hidden
         
         
         
         
-        #line 43 "..\..\..\..\views\AddDevice.xaml"
+        #line 39 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_port;
         internal System.Windows.Controls.TextBox tb_port;
         
         
@@ -97,7 +97,7 @@ namespace DeviceCenter {
         #line hidden
         #line hidden
         
         
         
         
-        #line 47 "..\..\..\..\views\AddDevice.xaml"
+        #line 43 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_username;
         internal System.Windows.Controls.TextBox tb_username;
         
         
@@ -105,7 +105,7 @@ namespace DeviceCenter {
         #line hidden
         #line hidden
         
         
         
         
-        #line 51 "..\..\..\..\views\AddDevice.xaml"
+        #line 47 "..\..\..\..\views\AddDevice.xaml"
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         internal System.Windows.Controls.TextBox tb_password;
         internal System.Windows.Controls.TextBox tb_password;
         
         
@@ -144,9 +144,21 @@ namespace DeviceCenter {
             {
             {
             case 1:
             case 1:
             this.cb_area = ((System.Windows.Controls.ComboBox)(target));
             this.cb_area = ((System.Windows.Controls.ComboBox)(target));
+            
+            #line 12 "..\..\..\..\views\AddDevice.xaml"
+            this.cb_area.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.cb_area_SelectionChanged);
+            
+            #line default
+            #line hidden
             return;
             return;
             case 2:
             case 2:
             this.cb_building = ((System.Windows.Controls.ComboBox)(target));
             this.cb_building = ((System.Windows.Controls.ComboBox)(target));
+            
+            #line 17 "..\..\..\..\views\AddDevice.xaml"
+            this.cb_building.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.cb_building_SelectionChanged);
+            
+            #line default
+            #line hidden
             return;
             return;
             case 3:
             case 3:
             this.cb_floor = ((System.Windows.Controls.ComboBox)(target));
             this.cb_floor = ((System.Windows.Controls.ComboBox)(target));
@@ -171,7 +183,7 @@ namespace DeviceCenter {
             return;
             return;
             case 10:
             case 10:
             
             
-            #line 53 "..\..\..\..\views\AddDevice.xaml"
+            #line 49 "..\..\..\..\views\AddDevice.xaml"
             ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
             ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
             
             
             #line default
             #line default

+ 73 - 0
utils/EnumerationExtension.cs

@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Markup;
+
+namespace DeviceCenter.utils
+{
+    public class EnumerationExtension : MarkupExtension
+    {
+        private Type _enumType;
+
+
+        public EnumerationExtension(Type enumType)
+        {
+            if (enumType == null)
+                throw new ArgumentNullException("enumType");
+
+            EnumType = enumType;
+        }
+
+        public Type EnumType
+        {
+            get { return _enumType; }
+            private set
+            {
+                if (_enumType == value)
+                    return;
+
+                var enumType = Nullable.GetUnderlyingType(value) ?? value;
+
+                if (enumType.IsEnum == false)
+                    throw new ArgumentException("Type must be an Enum.");
+
+                _enumType = value;
+            }
+        }
+
+        public override object ProvideValue(IServiceProvider serviceProvider)
+        {
+            var enumValues = Enum.GetValues(EnumType);
+
+            return (
+              from object enumValue in enumValues
+              select new EnumerationMember
+              {
+                  Value = enumValue,
+                  Description = GetDescription(enumValue)
+              }).ToArray();
+        }
+
+        private string GetDescription(object enumValue)
+        {
+            var descriptionAttribute = EnumType
+              .GetField(enumValue.ToString())
+              .GetCustomAttributes(typeof(DescriptionAttribute), false)
+              .FirstOrDefault() as DescriptionAttribute;
+
+
+            return descriptionAttribute != null
+              ? descriptionAttribute.Description
+              : enumValue.ToString();
+        }
+
+        public class EnumerationMember
+        {
+            public string Description { get; set; }
+            public object Value { get; set; }
+        }
+    }
+}

+ 8 - 1
utils/http.cs

@@ -96,7 +96,14 @@ namespace DeviceCenter.utils
                 {
                 {
                     foreach (KeyValuePair<string, string> entry in data)
                     foreach (KeyValuePair<string, string> entry in data)
                     {
                     {
-                        req.AddQueryParameter(entry.Key, entry.Value);
+                        if(entry.Key == "query")
+                        {
+                            req.AddQueryParameter(entry.Key, entry.Value, false);
+                        }
+                        else
+                        {
+                            req.AddQueryParameter(entry.Key, entry.Value, true);
+                        }
                     }
                     }
                 }
                 }
                 try
                 try

+ 5 - 9
views/AddDevice.xaml

@@ -3,32 +3,28 @@
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:local="clr-namespace:DeviceCenter"
+        xmlns:my="clr-namespace:DeviceCenter.utils"
         mc:Ignorable="d"
         mc:Ignorable="d"
         Title="添加设备" Height="400" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
         Title="添加设备" Height="400" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
     <StackPanel Orientation="Vertical">
     <StackPanel Orientation="Vertical">
         <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
         <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
             <Label Content="所在区域" Width="80" HorizontalContentAlignment="Right" Margin="0 0 10 0"/>
             <Label Content="所在区域" Width="80" HorizontalContentAlignment="Right" Margin="0 0 10 0"/>
-            <ComboBox x:Name="cb_area" Width="150">
+            <ComboBox x:Name="cb_area" Width="150" DisplayMemberPath="name" SelectedValuePath="id" SelectionChanged="cb_area_SelectionChanged">
             </ComboBox>
             </ComboBox>
         </StackPanel>
         </StackPanel>
         <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
         <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
             <Label Content="所在楼栋" Width="80" HorizontalContentAlignment="Right" Margin="0 0 10 0"/>
             <Label Content="所在楼栋" Width="80" HorizontalContentAlignment="Right" Margin="0 0 10 0"/>
-            <ComboBox x:Name="cb_building" Width="150">
+            <ComboBox x:Name="cb_building" Width="150" DisplayMemberPath="name" SelectedValuePath="id" SelectionChanged="cb_building_SelectionChanged">
             </ComboBox>
             </ComboBox>
         </StackPanel>
         </StackPanel>
         <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
         <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
             <Label Content="所在楼层" Width="80" HorizontalContentAlignment="Right" Margin="0 0 10 0"/>
             <Label Content="所在楼层" Width="80" HorizontalContentAlignment="Right" Margin="0 0 10 0"/>
-            <ComboBox x:Name="cb_floor" Width="150">
+            <ComboBox x:Name="cb_floor" Width="150" DisplayMemberPath="name" SelectedValuePath="id">
             </ComboBox>
             </ComboBox>
         </StackPanel>
         </StackPanel>
         <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
         <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
             <Label Content="设备类型" Width="80" HorizontalContentAlignment="Right" Margin="0 0 10 0"/>
             <Label Content="设备类型" Width="80" HorizontalContentAlignment="Right" Margin="0 0 10 0"/>
-            <ComboBox x:Name="cb_type" Width="150">
-                <ComboBoxItem Content="车牌识别" Tag="1"></ComboBoxItem>
-                <ComboBoxItem Content="人脸门禁" Tag="2"></ComboBoxItem>
-                <ComboBoxItem Content="刷卡门禁" Tag="3"></ComboBoxItem>
-            </ComboBox>
+            <ComboBox x:Name="cb_type" Width="150" ItemsSource="{Binding Source={my:EnumerationExtension {x:Type my:DeviceCenter.Device.Type}}}" />
         </StackPanel>
         </StackPanel>
         <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
         <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
             <Label Content="设备名称" Width="80" HorizontalContentAlignment="Right" Margin="0 0 10 0"/>
             <Label Content="设备名称" Width="80" HorizontalContentAlignment="Right" Margin="0 0 10 0"/>

+ 50 - 7
views/AddDevice.xaml.cs

@@ -1,10 +1,13 @@
 using DeviceCenter.model;
 using DeviceCenter.model;
+using DeviceCenter.utils;
 using RestSharp;
 using RestSharp;
 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;
+using System.Web;
 using System.Windows;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls;
 using System.Windows.Data;
 using System.Windows.Data;
@@ -23,26 +26,66 @@ namespace DeviceCenter
     {
     {
 
 
         private Config config = Config.getInstance();
         private Config config = Config.getInstance();
+        private ObservableCollection<Area> areas = new ObservableCollection<Area>();
+        private ObservableCollection<Building> buildings = new ObservableCollection<Building>();
+        private ObservableCollection<Floor> floors = new ObservableCollection<Floor>();
 
 
         public AddDevice()
         public AddDevice()
         {
         {
             InitializeComponent();
             InitializeComponent();
-            getAreas();
+            cb_area.ItemsSource = areas;
+            cb_building.ItemsSource = buildings;
+            cb_floor.ItemsSource = floors;
+
+            http.get<GetAreasResponse>("/area/all", new Dictionary<string, string> { ["size"] = "1000" }).Then(res =>
+            {
+                Console.WriteLine(res);
+                res.content.ToList().ForEach(areas.Add);
+            });
         }
         }
 
 
         private void Button_Click(object sender, RoutedEventArgs e)
         private void Button_Click(object sender, RoutedEventArgs e)
         {
         {
+            if (cb_type.SelectedValue != null)
+            {
+                Console.WriteLine(cb_type.SelectedValue);
+            }
             this.DialogResult = true;
             this.DialogResult = true;
             Close();
             Close();
         }
         }
 
 
-        async private void getAreas()
+        private void cb_area_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            http.get<GetBuildingResponse>("/building/all", new Dictionary<string, string>
+            {
+                ["size"] = "1000",
+                ["query"] = "%7B%22areaId%22:" + cb_area.SelectedValue + "%7d"
+            }).Then(res =>
+            {
+                buildings.Clear();
+                res.content.ToList().ForEach(buildings.Add);
+            }).Catch(err =>
+            {
+                Console.WriteLine(err);
+            });
+        }
+
+
+        private void cb_building_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
         {
-            var restClient = new RestClient("http://localhost:8080");
-            var request = new RestRequest("area/all", RestSharp.DataFormat.Json);
-            request.AddQueryParameter("size", "10000");
-            var res = await restClient.GetAsync<IRestResponse>(request);
-            Console.WriteLine(res.Content);
+            http.get<GetFloorResponse>("/floor/all", new Dictionary<string, string>
+            {
+                ["size"] = "1000",
+                ["query"] = "%7B%22buildingId%22:" + cb_building.SelectedValue + "%7d"
+            }).Then(res =>
+            {
+                floors.Clear();
+                res.content.ToList().ForEach(floors.Add);
+            }).Catch(err =>
+            {
+                Console.WriteLine(err);
+            });
         }
         }
+
     }
     }
 }
 }

+ 0 - 1
views/Login.xaml.cs

@@ -86,7 +86,6 @@ namespace DeviceCenter
             })
             })
                 .Then(token =>
                 .Then(token =>
                 {
                 {
-                    Console.WriteLine("1111111" + token);
                     config.token = token;
                     config.token = token;
                     MainWindow mainWindow = new MainWindow();
                     MainWindow mainWindow = new MainWindow();
                     mainWindow.Show();
                     mainWindow.Show();