From c4d1ee2a319d085791fc2ea6b2c83ff1dc8b617c Mon Sep 17 00:00:00 2001 From: lhiven Date: Thu, 28 Nov 2024 11:29:50 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=9B=B4=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8DOP=E4=B8=BA001=202=E3=80=81=E7=99=BB=E5=BD=95=E7=94=A8?= =?UTF-8?q?=E6=88=B73=E5=88=86=E9=92=9F=E4=B8=8D=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=EF=BC=8C=E5=88=99=E8=87=AA=E5=8A=A8=E9=80=80=E5=87=BA=203?= =?UTF-8?q?=E3=80=81=E6=9D=83=E9=99=90=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=8F=AA?= =?UTF-8?q?=E6=9C=89=E7=99=BB=E5=BD=95=E5=90=8E=E6=89=8D=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=82=B9=E4=BD=8D=E5=92=8CIO=E6=93=8D=E4=BD=9C=204?= =?UTF-8?q?=E3=80=81=E7=89=88=E6=9C=AC=E5=8F=B7=EF=BC=9A1.20.24.27?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rs.DeweyTester/BaseForm.cs | 30 ++++++- Rs.DeweyTester/BaseFormHeader.cs | 37 +++++++++ Rs.DeweyTester/Commom/GlobalUser.cs | 6 +- Rs.DeweyTester/Data/DataRecords.cs | 1 + Rs.DeweyTester/DebugMove.cs | 1 + Rs.DeweyTester/Home.cs | 78 ++++++++++++++++++- Rs.DeweyTester/MonitorConfig.cs | 14 +++- Rs.DeweyTester/Properties/AssemblyInfo.cs | 2 +- Rs.DeweyTester/SysConfig/CommonConfig.cs | 1 + Rs.DeweyTester/SysConfig/CommonConfig.resx | 4 +- .../SysConfig/UpCameraAndClampCalibration.cs | 1 + Rs.DeweyTester/UserForm.cs | 36 ++++----- Rs.DeweyTester/UserForm.designer.cs | 7 +- 13 files changed, 181 insertions(+), 37 deletions(-) diff --git a/Rs.DeweyTester/BaseForm.cs b/Rs.DeweyTester/BaseForm.cs index d5f171b..9384e93 100644 --- a/Rs.DeweyTester/BaseForm.cs +++ b/Rs.DeweyTester/BaseForm.cs @@ -1,5 +1,7 @@ -using Rs.Controls; +using NPOI.HSSF.Record.PivotTable; +using Rs.Controls; using Rs.Framework; +using Rs.MotionPlat.Commom; using Rs.MotionPlat.Flow; using System; using System.Collections.Generic; @@ -77,13 +79,33 @@ namespace Rs.MotionPlat public void CheckPermission() { - if (MachineManage.Instance.MachineStatus == EMachineStatus.Working) + if (MachineManage.Instance.MachineStatus == EMachineStatus.Working || string.IsNullOrEmpty(GlobalUser.UserName)) { - this.Enabled = false; + //this.Enabled = false; + ControlPermission(this, false); } else { - this.Enabled = true; + //this.Enabled = true; + ControlPermission(this, true); + } + } + + private void ControlPermission(Control ctl,bool enabled) + { + if(ctl!=null && ctl.Controls.Count > 0) + { + foreach(Control ctl2 in ctl.Controls) + { + if(ctl2 is TextBox || ctl2 is CheckBox || ctl2 is Button || ctl2 is TrackBar || ctl2 is ComboBox || ctl2 is DateTimePicker || ctl2 is ContextMenuStrip || ctl2 is RsTray) + { + ctl2.Enabled = enabled; + } + if(ctl2.Controls.Count > 0) + { + ControlPermission(ctl2, enabled); + } + } } } } diff --git a/Rs.DeweyTester/BaseFormHeader.cs b/Rs.DeweyTester/BaseFormHeader.cs index 9a3fd2c..f379733 100644 --- a/Rs.DeweyTester/BaseFormHeader.cs +++ b/Rs.DeweyTester/BaseFormHeader.cs @@ -1,6 +1,7 @@ using Rs.Controls; using Rs.Framework; using Rs.MotionPlat.Commom; +using Rs.MotionPlat.Flow; using System; using System.Collections.Generic; using System.ComponentModel; @@ -164,5 +165,41 @@ namespace Rs.MotionPlat { } + + public void CheckPermission() + { + if (MachineManage.Instance.MachineStatus == EMachineStatus.Working || string.IsNullOrEmpty(GlobalUser.UserName)) + { + //this.Enabled = false; + ControlPermission(this, false); + } + else + { + //this.Enabled = true; + ControlPermission(this, true); + } + } + + private void ControlPermission(Control ctl, bool enabled) + { + if (ctl != null && ctl.Controls.Count > 0) + { + foreach (Control ctl2 in ctl.Controls) + { + if(ctl2.Name=="btnClose") + { + continue; + } + if (ctl2 is TextBox || ctl2 is CheckBox || ctl2 is Button || ctl2 is TrackBar || ctl2 is ComboBox || ctl2 is DateTimePicker || ctl2 is ContextMenuStrip) + { + ctl2.Enabled = enabled; + } + if (ctl2.Controls.Count > 0) + { + ControlPermission(ctl2, enabled); + } + } + } + } } } diff --git a/Rs.DeweyTester/Commom/GlobalUser.cs b/Rs.DeweyTester/Commom/GlobalUser.cs index 486c14a..c6d9e38 100644 --- a/Rs.DeweyTester/Commom/GlobalUser.cs +++ b/Rs.DeweyTester/Commom/GlobalUser.cs @@ -29,7 +29,7 @@ namespace Rs.MotionPlat.Commom } public static bool IsOp() { - if (!string.IsNullOrEmpty(UserName) && UserName == "Op") + if (!string.IsNullOrEmpty(UserName) && UserName == "001") { return true; } @@ -38,7 +38,7 @@ namespace Rs.MotionPlat.Commom public static bool IsVender() { - if (!string.IsNullOrEmpty(UserName) && UserName == "Vender") + if (!string.IsNullOrEmpty(UserName) && UserName == "002") { return true; } @@ -46,7 +46,7 @@ namespace Rs.MotionPlat.Commom } public static bool IsSuper() { - if(!string.IsNullOrEmpty(UserName) && UserName=="Admin") + if(!string.IsNullOrEmpty(UserName) && UserName=="003") { return true; } diff --git a/Rs.DeweyTester/Data/DataRecords.cs b/Rs.DeweyTester/Data/DataRecords.cs index d216d60..3c983c5 100644 --- a/Rs.DeweyTester/Data/DataRecords.cs +++ b/Rs.DeweyTester/Data/DataRecords.cs @@ -25,6 +25,7 @@ namespace Rs.MotionPlat.Data private void DataRecords_Load(object sender, EventArgs e) { dataGridView1.AutoGenerateColumns = false; + CheckPermission(); } private void btnSearch_Click(object sender, EventArgs e) diff --git a/Rs.DeweyTester/DebugMove.cs b/Rs.DeweyTester/DebugMove.cs index 53eb58b..367a85b 100644 --- a/Rs.DeweyTester/DebugMove.cs +++ b/Rs.DeweyTester/DebugMove.cs @@ -43,6 +43,7 @@ namespace Rs.MotionPlat this.Location = new Point(tWidth - Width, tHeight - Height); timer1.Enabled = true; HeaderBackgroundColor = Color.FromArgb(192, 0, 192); + CheckPermission(); } private void Move_MouseDown(object sender, MouseEventArgs e) diff --git a/Rs.DeweyTester/Home.cs b/Rs.DeweyTester/Home.cs index 09b8a2d..65ac68b 100644 --- a/Rs.DeweyTester/Home.cs +++ b/Rs.DeweyTester/Home.cs @@ -23,6 +23,7 @@ using System.Diagnostics; using System.IO; using Rs.MotionPlat.Entitys; using Rs.MotionPlat.Flow.SubFlow; +using System.Runtime.Remoting.Metadata; namespace Rs.MotionPlat { @@ -475,9 +476,9 @@ namespace Rs.MotionPlat { timer3_Tick(null, null); }); - if(File.Exists("breakdown.csv")) + if(File.Exists("breakdowntesttime.csv")) { - File.Delete("breakdown.csv"); + File.Delete("breakdowntesttime.csv"); } InitDb(); } @@ -552,9 +553,20 @@ namespace Rs.MotionPlat // //lblMachineState.Text=MachineManage.Instance.MachineStatus.ToString(); //} - + long idleCount = GetIdleTick(); + if(idleCount> 1000 * 60 * 3) + { + if(!string.IsNullOrEmpty(GlobalUser.UserName)) + { + GlobalUser.UserName = ""; + if(btnPermission.ShowText.IndexOf("-")>=0) + { + btnPermission.ShowText = btnPermission.ShowText.Substring(0, btnPermission.ShowText.IndexOf("-")); + btnPermission.Invalidate(); + } + } + } - if (MonitorSystemButton.Instance.GetStep() != lblMonitorFlow.Text.Replace("Monitor:", "")) { lblMonitorFlow.Text = "Monitor:" + MonitorSystemButton.Instance.GetStep(); @@ -696,10 +708,13 @@ namespace Rs.MotionPlat dirs = Directory.GetDirectories(dirpath); foreach (var dir in dirs) { + RemoveReadOnlyAttribute(dir); DirectoryInfo di = new DirectoryInfo(dir); + //di.Attributes = FileAttributes.Normal & FileAttributes.Directory; DateTime dtCreate = di.CreationTime; if ((DateTime.Now - dtCreate).Days > 15) { + di.Delete(true); } } @@ -714,6 +729,7 @@ namespace Rs.MotionPlat CopyDirectory(workDir, bakDir); string toDir = Path.Combine(Directory.GetParent(bakDir).FullName, zipFileName + ".zip"); ZipHelper.ZipDirectory(bakDir, toDir); + RemoveReadOnlyAttribute(bakDir); Directory.Delete(bakDir, true); } @@ -724,6 +740,32 @@ namespace Rs.MotionPlat } } + + + void RemoveReadOnlyAttribute(string dirPath) + { + DirectoryInfo di = new DirectoryInfo(dirPath); + di.Attributes = FileAttributes.Normal & FileAttributes.Directory; + //查找所有的文件 + string[] files = Directory.GetFiles(dirPath); + if(files!=null && files.Length>0) + { + foreach (string f in files) + { + File.SetAttributes(f, System.IO.FileAttributes.Normal); + } + } + //查找所有的文件夹 + string[] dirs = Directory.GetDirectories(dirPath); + if(dirs!=null && dirs.Length>0) + { + foreach(string d in dirs) + { + RemoveReadOnlyAttribute(d); + } + } + } + public static void CopyDirectory(string sourceDir, string targetDir) { DirectoryInfo dir = new DirectoryInfo(sourceDir); @@ -802,5 +844,33 @@ namespace Rs.MotionPlat } return true ; } + + /// + /// 获取鼠标键盘空闲时间 + /// + /// + public static long GetIdleTick() + { + LASTINPUTINFO lastInputInfo = new LASTINPUTINFO(); + lastInputInfo.cbSize = Marshal.SizeOf(lastInputInfo); + if (!GetLastInputInfo(ref lastInputInfo)) return 0; + return Environment.TickCount - (long)lastInputInfo.dwTime; + } + + [StructLayout(LayoutKind.Sequential)] + private struct LASTINPUTINFO + { + [MarshalAs(UnmanagedType.U4)] + public int cbSize; + [MarshalAs(UnmanagedType.U4)] + public uint dwTime; + } + /// + /// 调用windows API获取鼠标键盘空闲时间 + /// + /// + /// + [DllImport("user32.dll")] + private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii); } } diff --git a/Rs.DeweyTester/MonitorConfig.cs b/Rs.DeweyTester/MonitorConfig.cs index 7eb7b8c..0b2841d 100644 --- a/Rs.DeweyTester/MonitorConfig.cs +++ b/Rs.DeweyTester/MonitorConfig.cs @@ -4,11 +4,13 @@ using Rs.Motion.Base; using Rs.Motion.Base.Config; using Rs.Motion.GugaoEcat; using Rs.Motion.GugaoPulse; +using Rs.MotionPlat.Commom; using Rs.MotionPlat.Flow; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; +using System.Diagnostics.Contracts; using System.Drawing; using System.Linq; using System.Reflection; @@ -125,7 +127,17 @@ namespace Rs.MotionPlat private void MonitorConfig_Load(object sender, EventArgs e) { - + this.axisMove1.Enabled = false; + this.axisProperty1.Enabled = false; + if (GlobalUser.IsOp()) + { + this.axisMove1.Enabled = true; + } + else if(GlobalUser.IsVender()|| GlobalUser.IsSuper()) + { + this.axisMove1.Enabled = true; + this.axisProperty1.Enabled = true; + } } } } diff --git a/Rs.DeweyTester/Properties/AssemblyInfo.cs b/Rs.DeweyTester/Properties/AssemblyInfo.cs index 2bf90d2..c667a67 100644 --- a/Rs.DeweyTester/Properties/AssemblyInfo.cs +++ b/Rs.DeweyTester/Properties/AssemblyInfo.cs @@ -31,6 +31,6 @@ using System.Runtime.InteropServices; // //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: - [assembly: AssemblyVersion("1.20.24.25")] + [assembly: AssemblyVersion("1.20.24.27")] //[assembly: AssemblyVersion("1.0.0.0")] //[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Rs.DeweyTester/SysConfig/CommonConfig.cs b/Rs.DeweyTester/SysConfig/CommonConfig.cs index 9af2ddb..d878635 100644 --- a/Rs.DeweyTester/SysConfig/CommonConfig.cs +++ b/Rs.DeweyTester/SysConfig/CommonConfig.cs @@ -115,6 +115,7 @@ namespace Rs.MotionPlat.SysConfig comBoxRelCategory.DataSource = list; comBoxRelCategory.SelectedItem = GlobalVar.RelCategory; + CheckPermission(); } private void BindMenu() diff --git a/Rs.DeweyTester/SysConfig/CommonConfig.resx b/Rs.DeweyTester/SysConfig/CommonConfig.resx index 400b201..4a1d6dd 100644 --- a/Rs.DeweyTester/SysConfig/CommonConfig.resx +++ b/Rs.DeweyTester/SysConfig/CommonConfig.resx @@ -1423,7 +1423,7 @@ panelEx1 - Rs.Controls.PanelEx, Rs.Controls, Version=2.20.24.5, Culture=neutral, PublicKeyToken=null + Rs.Controls.PanelEx, Rs.Controls, Version=2.20.24.6, Culture=neutral, PublicKeyToken=null groupBox1 @@ -2809,6 +2809,6 @@ CommonConfig - Rs.MotionPlat.BaseForm, Rs.MotionPlat, Version=1.20.24.24, Culture=neutral, PublicKeyToken=null + Rs.MotionPlat.BaseForm, Rs.MotionPlat, Version=1.20.24.27, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/Rs.DeweyTester/SysConfig/UpCameraAndClampCalibration.cs b/Rs.DeweyTester/SysConfig/UpCameraAndClampCalibration.cs index 1c2cb72..4c0b634 100644 --- a/Rs.DeweyTester/SysConfig/UpCameraAndClampCalibration.cs +++ b/Rs.DeweyTester/SysConfig/UpCameraAndClampCalibration.cs @@ -37,6 +37,7 @@ namespace Rs.MotionPlat.SysConfig PositionHelper.BindPosition(groupBox9); PositionHelper.BindPosition(groupBox10); PositionHelper.BindPosition(groupBox11); + CheckPermission(); } protected void GotoThis(object sender, EventArgs e) diff --git a/Rs.DeweyTester/UserForm.cs b/Rs.DeweyTester/UserForm.cs index b4a7b7e..f928ece 100644 --- a/Rs.DeweyTester/UserForm.cs +++ b/Rs.DeweyTester/UserForm.cs @@ -35,7 +35,7 @@ namespace Rs.MotionPlat { string username = cboxUsers.SelectedItem.ToString(); string userpwd = txtPassword.Text.Trim(); - if(username=="Op") + if(username=="001") { if(userpwd == "1") { @@ -50,22 +50,22 @@ namespace Rs.MotionPlat txtPassword.Text = ""; } } - if (username == "Engineer") - { - if (userpwd == "2") - { - OnloginSuccessEvent?.Invoke(username); - GlobalUser.UserLevel = EUserLevel.Engineer; - GlobalUser.UserName = username; - this.Close(); - } - else - { - Msgbox.ShowTipDialog(EButtonType.Ok, "userpwd error,please input again"); - txtPassword.Text = ""; - } - } - else if (username == "Vender") + //if (username == "Engineer") + //{ + // if (userpwd == "2") + // { + // OnloginSuccessEvent?.Invoke(username); + // GlobalUser.UserLevel = EUserLevel.Engineer; + // GlobalUser.UserName = username; + // this.Close(); + // } + // else + // { + // Msgbox.ShowTipDialog(EButtonType.Ok, "userpwd error,please input again"); + // txtPassword.Text = ""; + // } + //} + else if (username == "002") { if (userpwd == "dxd") { @@ -80,7 +80,7 @@ namespace Rs.MotionPlat txtPassword.Text = ""; } } - else if (username == "Admin") + else if (username == "003") { if (userpwd == "lhiven") { diff --git a/Rs.DeweyTester/UserForm.designer.cs b/Rs.DeweyTester/UserForm.designer.cs index af2cc52..dba6587 100644 --- a/Rs.DeweyTester/UserForm.designer.cs +++ b/Rs.DeweyTester/UserForm.designer.cs @@ -55,10 +55,9 @@ this.cboxUsers.ForeColor = System.Drawing.Color.White; this.cboxUsers.FormattingEnabled = true; this.cboxUsers.Items.AddRange(new object[] { - "Op", - "Engineer", - "Vender", - "Admin"}); + "001", + "002", + "003"}); this.cboxUsers.Location = new System.Drawing.Point(135, 77); this.cboxUsers.Name = "cboxUsers"; this.cboxUsers.Size = new System.Drawing.Size(172, 28);