ltwork пре 1 година
родитељ
комит
626dcdc486

+ 2 - 0
BlankApp1/BizService/IUserDeviceService.cs

@@ -10,5 +10,7 @@ namespace BizService
     public  interface IUserDeviceService : IBaseService<UserDevice>
     {
         public List<UserDevice> FindAllByUserId(int userId);
+
+        public UserDevice FindByUserIdAndDeviceID(int userId, int deviceId);
     }
 }

+ 7 - 0
BlankApp1/BizService/UserDeviceService.cs

@@ -13,5 +13,12 @@ namespace BizService
         {
             return base.GetList(x => x.UserId == userId);
         }
+
+        public UserDevice FindByUserIdAndDeviceID(int userId,int deviceId)
+        {
+            return base.GetFirst(x => (x.UserId == userId)&&(x.DeviceId==deviceId));
+        }
+
+   
     }
 }

+ 1 - 1
BlankApp1/BlankApp1/App.config

@@ -9,6 +9,6 @@
 		<add key="PLCPort" value="6000"/>
 		<add key="DelayTime" value="20"/>
 		<add key="LongDelayTime" value="60"/>
-	
+		<add key="AutoUpdateServer" value="127.0.0.1"/>
 	</appSettings>
 </configuration>

+ 5 - 2
BlankApp1/BlankApp1/ViewModels/MainWindowViewModel.cs

@@ -18,6 +18,7 @@ using Prism.Regions;
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
+using System.Configuration;
 using System.IO;
 using System.Reflection;
 using System.Threading.Tasks;
@@ -33,6 +34,8 @@ namespace BlankApp1.ViewModels
         private readonly IContainerProvider _containerProvider;
         private string _title = "Prism Application";
         private IRegionNavigationJournal journal;
+        private  string autoUpdateServer = ConfigurationManager.AppSettings["AutoUpdateServer"];
+        
         public string Title
         {
             get { return _title; }
@@ -59,13 +62,13 @@ namespace BlankApp1.ViewModels
             aggregator.GetEvent<BreadEvent>().Subscribe(RecvBreadMsg);
             aggregator.GetEvent<MaskEvent>().Subscribe(DisplayMask);
             //检查更新版本
-            AutoUpdater.Start("http://127.0.0.1/Updates/AutoUpdaterStarter.xml");
+            AutoUpdater.Start($"http://{autoUpdateServer}/Updates/AutoUpdaterStarter.xml");
 
         }
 
         private void UpdateVersion()
         {
-            AutoUpdater.Start("http://127.0.0.1/Updates/AutoUpdaterStarter.xml");
+            AutoUpdater.Start($"http://{autoUpdateServer}/Updates/AutoUpdaterStarter.xml");
         }
 
         private void OnLoad()

+ 9 - 1
BlankApp1/BlankApp1/ViewModels/StatisticsViewModel.cs

@@ -35,6 +35,7 @@ namespace BlankApp1.ViewModels
         private readonly IBizTestRecordService _iBizTestRecordService;
         private readonly IBasicPlcTestSchemeDtlService _iBasicPlcTestSchemeDtlService;
         private readonly IRoleProjectService _iRoleProjectService;
+        private readonly IUserDeviceService _iUserDeviceService;
         private readonly ILogger _logger;
         private readonly IMapper _mapper;
         private readonly IEventAggregator _aggregator;
@@ -42,7 +43,7 @@ namespace BlankApp1.ViewModels
         private List<DeviceDtlWithResultModel> conditionDevices = new List<DeviceDtlWithResultModel>();//符合条件的方案
         private int allSchCount = 0; //所有测试项
         private List<CrumbViewModel> breadCrumbs = new List<CrumbViewModel>();
-        public StatisticsViewModel(IDialogService dialog, IMenuService menuService, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IBizTestRecordDtlService iBizTestRecordDtlService, IBasicDeviceKindService iBasicDeviceKindService, IBasicProjectService iBasicProjectService, IBizTestRecordService iBizTestRecordService, IBasicPlcTestSchemeDtlService iBasicPlcTestSchemeDtlService, IBasicDeviceService iBasicDeviceService, IRoleProjectService iRoleProjectService,IMapper mapper, ILogger logger,IEventAggregator aggregator)
+        public StatisticsViewModel(IDialogService dialog, IMenuService menuService, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IBizTestRecordDtlService iBizTestRecordDtlService, IBasicDeviceKindService iBasicDeviceKindService, IBasicProjectService iBasicProjectService, IBizTestRecordService iBizTestRecordService, IBasicPlcTestSchemeDtlService iBasicPlcTestSchemeDtlService, IBasicDeviceService iBasicDeviceService, IRoleProjectService iRoleProjectService, IUserDeviceService iUserDeviceService,IMapper mapper, ILogger logger,IEventAggregator aggregator)
         {
             _dialog = dialog;
             _optionConfigService = optionConfigService;
@@ -56,6 +57,7 @@ namespace BlankApp1.ViewModels
             _iBasicPlcTestSchemeDtlService = iBasicPlcTestSchemeDtlService;
             _iBasicDeviceService = iBasicDeviceService;
             _iRoleProjectService = iRoleProjectService;
+            _iUserDeviceService = iUserDeviceService;
             _logger = logger;
             _mapper = mapper;
             _aggregator=aggregator;
@@ -105,6 +107,12 @@ namespace BlankApp1.ViewModels
                     {
                         continue;
                     }
+                    //根据用户显示所拥有的设备
+                    var userDevice =_iUserDeviceService.FindByUserIdAndDeviceID(Appsession.UserId, (int)deviceMsg.device_id);
+                    if (userDevice== null)
+                    {
+                        continue;
+                    }
                     string deviceKind = _iBasicDeviceKindService.Find((int)deviceMsg.device_kind_id)?.devicekind_name;
                     string projectName = _iBasicProjectService.Find((int)deviceMsg.project_id)?.project_name;
                    

+ 14 - 1
BlankApp1/BlankApp1/ViewModels/SystemManageViewModel/MenuManageViewModel.cs

@@ -110,6 +110,7 @@ namespace PLCTool.ViewModels.SystemManageViewModel
         }
         private void GetAllMenus()
         {
+            MenuInfoList.Clear();
             var menus = _iMenuService.QueryList();
             allMenuInfoList = _mapper.Map<List<Menu>, List<MenuDto>>(menus);
             foreach(var item in allMenuInfoList)
@@ -119,8 +120,20 @@ namespace PLCTool.ViewModels.SystemManageViewModel
                     item.MenuIcon = System.IO.Path.Combine(basePath, item.MenuIcon);
                 }
             }
+            //按照父菜单和子菜单来排序
+            var menuParents=allMenuInfoList.FindAll(x=>x.ParentId==0)?.OrderBy(y => y.Index);
+            foreach(var menu in menuParents)
+            {
+                MenuInfoList.Add(menu);
+                //查找下面的子菜单
+                var menuPs = allMenuInfoList?.FindAll(x => x.ParentId == menu.MenuId)?.OrderBy(y=>y.Index);
+                foreach(var item in menuPs)
+                {
+                    MenuInfoList.Add(item);
+                }
+
+            }
           
-            MenuInfoList = new ObservableCollection<MenuDto>(allMenuInfoList.OrderBy(x=>x.ParentId).ThenBy(x=>x.Index));
         }
 
         /// <summary>

+ 9 - 7
BlankApp1/BlankApp1/Views/MainWindow.xaml

@@ -112,12 +112,14 @@
             <StackPanel  Orientation="Horizontal" HorizontalAlignment="Right" Margin=" 0,0,14,0">
                 <TextBlock x:Name="txtTime" Foreground="#ffffff" VerticalAlignment="Center" Margin="0,0,18,0"/>
                 <Image Source="../Assets/Images/register.png" Height="21" Width="21"></Image>
-               
-                <Menu VerticalAlignment="Center" Width="auto">
-                    <MenuItem Header="{Binding UserName}" Width="auto">
-                        <MenuItem Header="注销" Width="60" Command="{Binding LoginOutCommand}"/>
-                    </MenuItem>
-                </Menu>
+                <TextBlock Name="PopButton" VerticalAlignment="Center" Text="{Binding UserName}" MouseDown="PopButton_MouseDown" Margin="5,0"  >
+                  
+                </TextBlock>
+                <Popup x:Name="pop" PopupAnimation="Slide"  PlacementTarget="{Binding ElementName=PopButton}" Placement="Bottom" AllowsTransparency="True" StaysOpen="False" MouseLeave="pop_MouseLeave" >
+                    <Button VerticalAlignment="Center" Content="注销"  BorderThickness="0" Command="{Binding LoginOutCommand}"/>
+                </Popup>
+           
+            
                 <TextBlock Text="|" Style="{StaticResource txtHeadStyle}" Margin="0,0,17,0" Width="2" Height=" 20"></TextBlock>
                 <Button  x:Name="btnMin" Content="—"  Click="btnMin_Click"  Style="{StaticResource IconButtonStyle}"/>
                 <Button  x:Name="btnMax" Click="btnMax_Click" Content="&#xe60d;" FontFamily="../Assets/Fonts/#iconfont"   Style="{StaticResource IconButtonStyle}"/>
@@ -175,7 +177,7 @@
                     </Path.Data>
                 </Path>
                 <TextBlock Text="{Binding Version}" Style="{StaticResource txtHeadStyle}" Width="auto" Margin="20,0,5,0"/>
-                <Button Content="版本更新" Width="60" Height="25"    Command="{Binding VersisonCommand}" Style="{StaticResource NormalButtonStyle}" />
+                <!--<Button Content="版本更新" Width="60" Height="22"    Command="{Binding VersisonCommand}" Style="{StaticResource NormalButtonStyle}" />-->
             </StackPanel>
 
         </Border>

+ 13 - 0
BlankApp1/BlankApp1/Views/MainWindow.xaml.cs

@@ -73,5 +73,18 @@ namespace BlankApp1.Views
             if (e.LeftButton == MouseButtonState.Pressed)
                 this.DragMove();
         }
+
+        private void PopButton_MouseDown(object sender, MouseButtonEventArgs e)
+        {
+            this.pop.IsOpen = true;
+            this.pop.StaysOpen = true;
+        }
+
+        private void pop_MouseLeave(object sender, MouseEventArgs e)
+        {
+            
+            this.pop.IsOpen = false;
+            this.pop.StaysOpen = true;
+        }
     }
 }