|
|
|
@ -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 ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|