1、更改用户名OP为001

2、登录用户3分钟不操作,则自动退出
3、权限修改,只有登录后才能修改点位和IO操作
4、版本号:1.20.24.27
Eight
lhiven 1 year ago
parent d17f6ca12e
commit c4d1ee2a31

@ -1,5 +1,7 @@
using Rs.Controls; using NPOI.HSSF.Record.PivotTable;
using Rs.Controls;
using Rs.Framework; using Rs.Framework;
using Rs.MotionPlat.Commom;
using Rs.MotionPlat.Flow; using Rs.MotionPlat.Flow;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -77,13 +79,33 @@ namespace Rs.MotionPlat
public void CheckPermission() 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 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);
}
}
} }
} }
} }

@ -1,6 +1,7 @@
using Rs.Controls; using Rs.Controls;
using Rs.Framework; using Rs.Framework;
using Rs.MotionPlat.Commom; using Rs.MotionPlat.Commom;
using Rs.MotionPlat.Flow;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; 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);
}
}
}
}
} }
} }

@ -29,7 +29,7 @@ namespace Rs.MotionPlat.Commom
} }
public static bool IsOp() public static bool IsOp()
{ {
if (!string.IsNullOrEmpty(UserName) && UserName == "Op") if (!string.IsNullOrEmpty(UserName) && UserName == "001")
{ {
return true; return true;
} }
@ -38,7 +38,7 @@ namespace Rs.MotionPlat.Commom
public static bool IsVender() public static bool IsVender()
{ {
if (!string.IsNullOrEmpty(UserName) && UserName == "Vender") if (!string.IsNullOrEmpty(UserName) && UserName == "002")
{ {
return true; return true;
} }
@ -46,7 +46,7 @@ namespace Rs.MotionPlat.Commom
} }
public static bool IsSuper() public static bool IsSuper()
{ {
if(!string.IsNullOrEmpty(UserName) && UserName=="Admin") if(!string.IsNullOrEmpty(UserName) && UserName=="003")
{ {
return true; return true;
} }

@ -25,6 +25,7 @@ namespace Rs.MotionPlat.Data
private void DataRecords_Load(object sender, EventArgs e) private void DataRecords_Load(object sender, EventArgs e)
{ {
dataGridView1.AutoGenerateColumns = false; dataGridView1.AutoGenerateColumns = false;
CheckPermission();
} }
private void btnSearch_Click(object sender, EventArgs e) private void btnSearch_Click(object sender, EventArgs e)

@ -43,6 +43,7 @@ namespace Rs.MotionPlat
this.Location = new Point(tWidth - Width, tHeight - Height); this.Location = new Point(tWidth - Width, tHeight - Height);
timer1.Enabled = true; timer1.Enabled = true;
HeaderBackgroundColor = Color.FromArgb(192, 0, 192); HeaderBackgroundColor = Color.FromArgb(192, 0, 192);
CheckPermission();
} }
private void Move_MouseDown(object sender, MouseEventArgs e) private void Move_MouseDown(object sender, MouseEventArgs e)

@ -23,6 +23,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using Rs.MotionPlat.Entitys; using Rs.MotionPlat.Entitys;
using Rs.MotionPlat.Flow.SubFlow; using Rs.MotionPlat.Flow.SubFlow;
using System.Runtime.Remoting.Metadata;
namespace Rs.MotionPlat namespace Rs.MotionPlat
{ {
@ -475,9 +476,9 @@ namespace Rs.MotionPlat
{ {
timer3_Tick(null, null); timer3_Tick(null, null);
}); });
if(File.Exists("breakdown.csv")) if(File.Exists("breakdowntesttime.csv"))
{ {
File.Delete("breakdown.csv"); File.Delete("breakdowntesttime.csv");
} }
InitDb(); InitDb();
} }
@ -552,9 +553,20 @@ namespace Rs.MotionPlat
// //lblMachineState.Text=MachineManage.Instance.MachineStatus.ToString(); // //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:", "")) if (MonitorSystemButton.Instance.GetStep() != lblMonitorFlow.Text.Replace("Monitor:", ""))
{ {
lblMonitorFlow.Text = "Monitor:" + MonitorSystemButton.Instance.GetStep(); lblMonitorFlow.Text = "Monitor:" + MonitorSystemButton.Instance.GetStep();
@ -696,10 +708,13 @@ namespace Rs.MotionPlat
dirs = Directory.GetDirectories(dirpath); dirs = Directory.GetDirectories(dirpath);
foreach (var dir in dirs) foreach (var dir in dirs)
{ {
RemoveReadOnlyAttribute(dir);
DirectoryInfo di = new DirectoryInfo(dir); DirectoryInfo di = new DirectoryInfo(dir);
//di.Attributes = FileAttributes.Normal & FileAttributes.Directory;
DateTime dtCreate = di.CreationTime; DateTime dtCreate = di.CreationTime;
if ((DateTime.Now - dtCreate).Days > 15) if ((DateTime.Now - dtCreate).Days > 15)
{ {
di.Delete(true); di.Delete(true);
} }
} }
@ -714,6 +729,7 @@ namespace Rs.MotionPlat
CopyDirectory(workDir, bakDir); CopyDirectory(workDir, bakDir);
string toDir = Path.Combine(Directory.GetParent(bakDir).FullName, zipFileName + ".zip"); string toDir = Path.Combine(Directory.GetParent(bakDir).FullName, zipFileName + ".zip");
ZipHelper.ZipDirectory(bakDir, toDir); ZipHelper.ZipDirectory(bakDir, toDir);
RemoveReadOnlyAttribute(bakDir);
Directory.Delete(bakDir, true); 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) public static void CopyDirectory(string sourceDir, string targetDir)
{ {
DirectoryInfo dir = new DirectoryInfo(sourceDir); DirectoryInfo dir = new DirectoryInfo(sourceDir);
@ -802,5 +844,33 @@ namespace Rs.MotionPlat
} }
return true ; return true ;
} }
/// <summary>
/// 获取鼠标键盘空闲时间
/// </summary>
/// <returns></returns>
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;
}
/// <summary>
/// 调用windows API获取鼠标键盘空闲时间
/// </summary>
/// <param name="plii"></param>
/// <returns></returns>
[DllImport("user32.dll")]
private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
} }
} }

@ -4,11 +4,13 @@ using Rs.Motion.Base;
using Rs.Motion.Base.Config; using Rs.Motion.Base.Config;
using Rs.Motion.GugaoEcat; using Rs.Motion.GugaoEcat;
using Rs.Motion.GugaoPulse; using Rs.Motion.GugaoPulse;
using Rs.MotionPlat.Commom;
using Rs.MotionPlat.Flow; using Rs.MotionPlat.Flow;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
using System.Diagnostics.Contracts;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -125,7 +127,17 @@ namespace Rs.MotionPlat
private void MonitorConfig_Load(object sender, EventArgs e) 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;
}
} }
} }
} }

@ -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: AssemblyVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")] //[assembly: AssemblyFileVersion("1.0.0.0")]

@ -115,6 +115,7 @@ namespace Rs.MotionPlat.SysConfig
comBoxRelCategory.DataSource = list; comBoxRelCategory.DataSource = list;
comBoxRelCategory.SelectedItem = GlobalVar.RelCategory; comBoxRelCategory.SelectedItem = GlobalVar.RelCategory;
CheckPermission();
} }
private void BindMenu() private void BindMenu()

@ -1423,7 +1423,7 @@
<value>panelEx1</value> <value>panelEx1</value>
</data> </data>
<data name="&gt;&gt;panelEx1.Type" xml:space="preserve"> <data name="&gt;&gt;panelEx1.Type" xml:space="preserve">
<value>Rs.Controls.PanelEx, Rs.Controls, Version=2.20.24.5, Culture=neutral, PublicKeyToken=null</value> <value>Rs.Controls.PanelEx, Rs.Controls, Version=2.20.24.6, Culture=neutral, PublicKeyToken=null</value>
</data> </data>
<data name="&gt;&gt;panelEx1.Parent" xml:space="preserve"> <data name="&gt;&gt;panelEx1.Parent" xml:space="preserve">
<value>groupBox1</value> <value>groupBox1</value>
@ -2809,6 +2809,6 @@
<value>CommonConfig</value> <value>CommonConfig</value>
</data> </data>
<data name="&gt;&gt;$this.Type" xml:space="preserve"> <data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>Rs.MotionPlat.BaseForm, Rs.MotionPlat, Version=1.20.24.24, Culture=neutral, PublicKeyToken=null</value> <value>Rs.MotionPlat.BaseForm, Rs.MotionPlat, Version=1.20.24.27, Culture=neutral, PublicKeyToken=null</value>
</data> </data>
</root> </root>

@ -37,6 +37,7 @@ namespace Rs.MotionPlat.SysConfig
PositionHelper.BindPosition(groupBox9); PositionHelper.BindPosition(groupBox9);
PositionHelper.BindPosition(groupBox10); PositionHelper.BindPosition(groupBox10);
PositionHelper.BindPosition(groupBox11); PositionHelper.BindPosition(groupBox11);
CheckPermission();
} }
protected void GotoThis(object sender, EventArgs e) protected void GotoThis(object sender, EventArgs e)

@ -35,7 +35,7 @@ namespace Rs.MotionPlat
{ {
string username = cboxUsers.SelectedItem.ToString(); string username = cboxUsers.SelectedItem.ToString();
string userpwd = txtPassword.Text.Trim(); string userpwd = txtPassword.Text.Trim();
if(username=="Op") if(username=="001")
{ {
if(userpwd == "1") if(userpwd == "1")
{ {
@ -50,22 +50,22 @@ namespace Rs.MotionPlat
txtPassword.Text = ""; txtPassword.Text = "";
} }
} }
if (username == "Engineer") //if (username == "Engineer")
{ //{
if (userpwd == "2") // if (userpwd == "2")
{ // {
OnloginSuccessEvent?.Invoke(username); // OnloginSuccessEvent?.Invoke(username);
GlobalUser.UserLevel = EUserLevel.Engineer; // GlobalUser.UserLevel = EUserLevel.Engineer;
GlobalUser.UserName = username; // GlobalUser.UserName = username;
this.Close(); // this.Close();
} // }
else // else
{ // {
Msgbox.ShowTipDialog(EButtonType.Ok, "userpwd error,please input again"); // Msgbox.ShowTipDialog(EButtonType.Ok, "userpwd error,please input again");
txtPassword.Text = ""; // txtPassword.Text = "";
} // }
} //}
else if (username == "Vender") else if (username == "002")
{ {
if (userpwd == "dxd") if (userpwd == "dxd")
{ {
@ -80,7 +80,7 @@ namespace Rs.MotionPlat
txtPassword.Text = ""; txtPassword.Text = "";
} }
} }
else if (username == "Admin") else if (username == "003")
{ {
if (userpwd == "lhiven") if (userpwd == "lhiven")
{ {

@ -55,10 +55,9 @@
this.cboxUsers.ForeColor = System.Drawing.Color.White; this.cboxUsers.ForeColor = System.Drawing.Color.White;
this.cboxUsers.FormattingEnabled = true; this.cboxUsers.FormattingEnabled = true;
this.cboxUsers.Items.AddRange(new object[] { this.cboxUsers.Items.AddRange(new object[] {
"Op", "001",
"Engineer", "002",
"Vender", "003"});
"Admin"});
this.cboxUsers.Location = new System.Drawing.Point(135, 77); this.cboxUsers.Location = new System.Drawing.Point(135, 77);
this.cboxUsers.Name = "cboxUsers"; this.cboxUsers.Name = "cboxUsers";
this.cboxUsers.Size = new System.Drawing.Size(172, 28); this.cboxUsers.Size = new System.Drawing.Size(172, 28);

Loading…
Cancel
Save