Parcourir la source

修改登录界面

ltwork il y a 1 an
Parent
commit
6935df775c

+ 3 - 3
BlankApp1/BlankApp1/App.config

@@ -4,9 +4,9 @@
 		<!--连接字符串 SQL Server-->
 		<add key="MySql" value="Data Source=localhost;Database=plc_point_db5;User Id='root';Password='521125';port=3306;charset=utf8mb4;"/>
 	    <!--1表示欧姆龙PLC,2表示为三菱PLC-->
-		<add key="PLCType" value="2"/>
-		<add key="PLCIp" value="192.168.0.38"/>
-		<add key="PLCPort" value="2000"/>
+		<add key="PLCType" value="1"/>
+		<add key="PLCIp" value="127.0.0.1"/>
+		<add key="PLCPort" value="6000"/>
 		<add key="DelayTime" value="20"/>
 		<add key="LongDelayTime" value="60"/>
 	

+ 8 - 4
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/ProjectTestResultViewModel.cs

@@ -207,18 +207,22 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
 
                 }
 
-                //所有项目
-                //List<string> projectNames = allDeviceList.Select(x => x.ProjectName).Distinct().ToList();
+                //所有有测试记录的项目
+                var projectRecordNames = allDeviceList.Select(x => x.ProjectName).Distinct().ToList();
                 //所有的项目
                 List<string> projectNames = new List<string>();
-                //根据角色显示所拥有的项目
+                ////根据角色显示所拥有的项目
                 var roleProjectIds = _iRoleProjectService.FindAllByRoleId(Appsession.RoleId);
                 foreach (var item in roleProjectIds)
                 {
                     var finPro = _iBasicProjectService.Find((int)item.ProjectId);
                     if (finPro != null)
                     {
-                        projectNames.Add(finPro.project_name);
+                        if(projectRecordNames.Contains(finPro.project_name))
+                        {
+                            projectNames.Add(finPro.project_name);
+                        }
+                      
                     }
                 }
                 //遍历项目

+ 2 - 2
BlankApp1/BlankApp1/Views/LoginView.xaml

@@ -27,11 +27,11 @@
         <DockPanel Margin="15" VerticalAlignment="Center" Grid.Column="1" >
             <TextBlock Margin="0,10" DockPanel.Dock="Top" FontSize="22" FontWeight="Bold" Text="欢迎使用" HorizontalAlignment="Center"/>
             <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
-                <TextBlock Margin="0,10" Width="80"  TextAlignment="Right" FontSize="16"  Text="用户名:" />
+                <TextBlock Margin="0,10" Width="80"  TextAlignment="Right" FontSize="16" VerticalAlignment="Center"  Text="用户名:" />
                 <TextBox Margin="0,10" Width="120" Height="25"  Text="{Binding UserName}" Cursor="IBeam" />
             </StackPanel>
             <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
-                <TextBlock Margin="0,10"  Width="80"  TextAlignment="Right"  FontSize="16"  Text="密码:" />
+                <TextBlock Margin="0,10"  Width="80"  TextAlignment="Right"  FontSize="16" VerticalAlignment="Center"  Text="密码:" />
                 <PasswordBox Margin="0,10" Width="120" Height="25" pass:PassWordExtensions.PassWord="{Binding PassWord, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
         DockPanel.Dock="Top" Cursor="IBeam">
                     <i:Interaction.Behaviors>

+ 31 - 23
BlankApp1/OmronFinsTCP.Net/EtherNetPLC.cs

@@ -42,47 +42,55 @@ namespace OmronFinsTCP.Net
         /// <returns></returns>
         public short Link(string rIP, short rPort, short timeOut = 3000)
         {
-            if(BasicClass.PingCheck(rIP,timeOut))
+            try
             {
-                if(BasicClass.Client.Client==null)
+                if (BasicClass.PingCheck(rIP, timeOut))
                 {
-                    BasicClass.Client = new TcpClient();
-                }
-                BasicClass.Client.Connect(rIP, (int)rPort);
-                BasicClass.Stream = BasicClass.Client.GetStream();
-                Thread.Sleep(10);
+                    if (BasicClass.Client.Client == null)
+                    {
+                        BasicClass.Client = new TcpClient();
+                    }
+                    BasicClass.Client.Connect(rIP, (int)rPort);
+                    BasicClass.Stream = BasicClass.Client.GetStream();
+                    Thread.Sleep(10);
 
-                if (BasicClass.SendData(FinsClass.HandShake()) != 0)
-                {
-                    return -1;
-                }
-                else
-                {
-                    //开始读取返回信号
-                    byte[] buffer = new byte[24];
-                    if (BasicClass.ReceiveData(buffer) != 0)
+                    if (BasicClass.SendData(FinsClass.HandShake()) != 0)
                     {
                         return -1;
                     }
                     else
                     {
-                        if (buffer[15] != 0)//TODO:这里的15号是不是ERR信息暂时不能完全肯定
+                        //开始读取返回信号
+                        byte[] buffer = new byte[24];
+                        if (BasicClass.ReceiveData(buffer) != 0)
+                        {
                             return -1;
+                        }
                         else
                         {
-                            BasicClass.pcNode = buffer[19];
-                            BasicClass.plcNode = buffer[23];
-                            return 0;
+                            if (buffer[15] != 0)//TODO:这里的15号是不是ERR信息暂时不能完全肯定
+                                return -1;
+                            else
+                            {
+                                BasicClass.pcNode = buffer[19];
+                                BasicClass.plcNode = buffer[23];
+                                return 0;
+                            }
                         }
                     }
                 }
+                else
+                {
+                    BasicClass.Client?.Close();
+                    //连接超时
+                    return -1;
+                }
             }
-            else
+            catch(Exception ex)
             {
-                BasicClass.Client?.Close();
-                //连接超时
                 return -1;
             }
+           
         }
 
         /// <summary>