## 📅2025-11-13 星期四更新

### TimeClock    V1.0.2511.1301
本版本作为备份,即将将定时软件从分级升级为秒级,以防万一,故此备份。
- *.[改进]定时功能调整为System.Timers.Timer timer。
- *.[改进]RyTimeClock需要传窗体参数。
This commit is contained in:
紫林软件 2025-11-13 10:40:37 +08:00
parent 23816767b3
commit 1a1426d4d9
14 changed files with 125 additions and 108 deletions

Binary file not shown.

View File

@ -15040,6 +15040,13 @@
</summary> </summary>
<param name="Timeout">超时时间</param> <param name="Timeout">超时时间</param>
</member> </member>
<member name="M:RyWeb.QuickWeb.#ctor(System.Int32,System.Int32)">
<summary>
</summary>
<param name="Timeout">超时时间</param>
<param name="RetryCount">重试次数</param>
</member>
<member name="M:RyWeb.QuickWeb.Post(System.String,System.String,System.String)"> <member name="M:RyWeb.QuickWeb.Post(System.String,System.String,System.String)">
<summary> <summary>
以post方式获取网页源码 以post方式获取网页源码
@ -15075,6 +15082,11 @@
<param name="post"></param> <param name="post"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="P:RyWeb.QuickWeb.RetryCount">
<summary>
重试次数
</summary>
</member>
<member name="P:RyWeb.QuickWeb.HeadText"> <member name="P:RyWeb.QuickWeb.HeadText">
<summary> <summary>
头信息 头信息

Binary file not shown.

View File

@ -1,2 +1,2 @@
[TimeClock] [TimeClock]
hwnd=6239280 hwnd=5651228

View File

@ -1,3 +1,3 @@
<root> <root>
<list id="LastUpdateTime" Value="2025/8/23 17:19:57" /> <list id="LastUpdateTime" Value="2025/11/13 10:27:02" />
</root> </root>

View File

@ -1,4 +1,11 @@
## :date:2025-08-23 星期六更新 ## :date:2025-11-13 星期四更新
### TimeClock V1.0.2511.1301
本版本作为备份,即将将定时软件从分级升级为秒级,以防万一,故此备份。
- :100:[改进]定时功能调整为System.Timers.Timer timer。
- :100:[改进]RyTimeClock需要传窗体参数。
## :date:2025-08-23 星期六更新
### TimeClock V1.0.2508.2301 ### TimeClock V1.0.2508.2301
- :x:[删除]删除对XPTable控件的依赖,界面列表控件全面使用ObjectListView。 - :x:[删除]删除对XPTable控件的依赖,界面列表控件全面使用ObjectListView。

View File

@ -42,7 +42,7 @@
this.LblName = new System.Windows.Forms.Label(); this.LblName = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
this.LblState = new System.Windows.Forms.Label(); this.LblState = new System.Windows.Forms.Label();
this.ryTimeClock1 = new TimeClock.RyTimeClock(); this.ryTimeClock1 = new TimeClock.RyTimeClock(this);
this.LblVer = new System.Windows.Forms.Label(); this.LblVer = new System.Windows.Forms.Label();
this.contextMenuStrip1.SuspendLayout(); this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: : // 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.2508.2301")] [assembly: AssemblyVersion("1.0.2511.1301")]
[assembly: AssemblyFileVersion("1.0.2508.2301")] [assembly: AssemblyFileVersion("1.0.2511.1301")]

View File

@ -28,18 +28,9 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer(this.components);
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.Timer1_Tick);
} }
#endregion #endregion
private System.Windows.Forms.Timer timer1;
} }
} }

View File

@ -37,10 +37,10 @@ namespace TimeClock
[Description("是否开启提醒功能")] [Description("是否开启提醒功能")]
public bool Enabled public bool Enabled
{ {
get {return timer1.Enabled; } get {return timer.Enabled; }
set set
{ {
if (timer1.Enabled != value && !GetIsDesignMode()) if (timer.Enabled != value && !GetIsDesignMode())
{ {
UpdateTipTime(); UpdateTipTime();
UpdateTipTime_start(false); UpdateTipTime_start(false);
@ -64,7 +64,7 @@ namespace TimeClock
} }
} }
first_start = false; first_start = false;
timer1.Enabled = value; timer.Enabled = value;
} }
} }
} }
@ -335,9 +335,14 @@ namespace TimeClock
} }
bool first_start = true; bool first_start = true;
DateTime Last_CloseTime = DateTime.Now; DateTime Last_CloseTime = DateTime.Now;
public RyTimeClock() private Form _parentForm;
System.Timers.Timer timer = new System.Timers.Timer(1000);
public RyTimeClock(Form parentForm)
{ {
InitializeComponent(); InitializeComponent();
_parentForm = parentForm;
timer.SynchronizingObject = parentForm;
timer.Elapsed += TimeElapsed;
if (!GetIsDesignMode()) if (!GetIsDesignMode())
{ {
TimeClock.Itrycn_Db.CreateTable(); TimeClock.Itrycn_Db.CreateTable();
@ -367,74 +372,15 @@ namespace TimeClock
} }
} }
} }
DateTime lastRunTime = DateTime.Now.AddDays(-1); private void TimeElapsed(object sender, System.Timers.ElapsedEventArgs e)
bool last_fullscreen = false;
bool last_idle = false;
/// <summary>
/// 计算工作信息
/// </summary>
/// <param name="dt_now"></param>
private void CalcWorkInfo(DateTime dt_now)
{
var idle = ryCommon.RySystem.GetLastInputTime() / 1000;
DateTime dt_now2 = dt_now.AddSeconds(-dt_now.Second).AddMilliseconds(-dt_now.Millisecond);
int stype = 0;
if (idle>=60)
{
stype = 0;
}
else { stype = 1; }
DataProvider mydb = new DataProvider();
IDbInterface db = TimeClock.Itrycn_Db.CreateDataProvider(TimeClock.Itrycn_Db.dataType);
if (db.ConnDb(TimeClock.Itrycn_Db.WorkInfo_ConnStr) == 1)
{
RyQuickSQL mySQL = new RyQuickSQL("WorkInfo");
mySQL.AddField("StartTime", dt_now2.AddMinutes(-1));
mySQL.AddField("EndTime", dt_now2);
mySQL.AddField("stype", stype);
mySQL.AddField("totalSecond", 60);
db.ExecuteNonQuery(mySQL.GetInsertSQL());
}
db.Free();
}
/// <summary>
/// 时间循环一轮是否结束,结束后才能开始下一轮
/// </summary>
bool TimeComplete = true;
/// <summary>
/// 开始休息时间
/// </summary>
DateTime dt_start_idle = DateTime.Now;
/// <summary>
/// 添加休息记录
/// </summary>
/// <param name="info"></param>
private void AddRestRecord(RestInfo info)
{
if(Itrycn_Db.list_rest.Count>1000)
{
Itrycn_Db.list_rest.RemoveAt(0);
}
Itrycn_Db.list_rest.Add(info);
OnRestDataChanged?.Invoke(this, new EventArgs());
}
/// <summary>
///最近一次是否是休息状态
/// </summary>
private bool last_IsRestNowing = Itrycn_Info.IsRestNowing;
/// <summary>
/// 最近一次开始休息的时间
/// </summary>
private DateTime last_StartRestTime = DateTime.Now;
private void Timer1_Tick(object sender, EventArgs e)
{ {
if (!TimeComplete) { return; } if (!TimeComplete) { return; }
TimeComplete = false; TimeComplete = false;
DateTime dt_now = DateTime.Now; DateTime dt_now = DateTime.Now;
if(last_IsRestNowing!= Itrycn_Info.IsRestNowing) if (last_IsRestNowing != Itrycn_Info.IsRestNowing)
{ {
last_IsRestNowing = Itrycn_Info.IsRestNowing; last_IsRestNowing = Itrycn_Info.IsRestNowing;
if(!last_IsRestNowing) if (!last_IsRestNowing)
{ {
AddRestRecord(new RestInfo() { UserSecondTime = (DateTime.Now - last_StartRestTime).TotalSeconds.ToInt(), Mode = 3 }); AddRestRecord(new RestInfo() { UserSecondTime = (DateTime.Now - last_StartRestTime).TotalSeconds.ToInt(), Mode = 3 });
} }
@ -477,10 +423,10 @@ namespace TimeClock
} }
if (Itrycn_Info.StopRestByIdle) if (Itrycn_Info.StopRestByIdle)
{ {
var idle =ryCommon.RySystem.GetLastInputTime()/1000; var idle = ryCommon.RySystem.GetLastInputTime() / 1000;
if(idle>=Itrycn_Info.IdleMinute*60)//闲置超过几分钟 if (idle >= Itrycn_Info.IdleMinute * 60)//闲置超过几分钟
{ {
if(!last_idle) if (!last_idle)
{ {
last_idle = true;//从非闲置状态切换到闲置状态 last_idle = true;//从非闲置状态切换到闲置状态
Itrycn_Info.IsStopCalcRestNowing = true; Itrycn_Info.IsStopCalcRestNowing = true;
@ -517,7 +463,7 @@ namespace TimeClock
{ {
Itrycn_Info.Timer_index--; Itrycn_Info.Timer_index--;
var _time = Itrycn_Info.Timer_index; var _time = Itrycn_Info.Timer_index;
if(_time==60)//提前一分钟 if (_time == 60)//提前一分钟
{ {
#region #region
if (Itrycn_Info.TipBeforeRest) if (Itrycn_Info.TipBeforeRest)
@ -536,27 +482,26 @@ namespace TimeClock
} }
} }
} }
catch{ catch
{
} }
if (!is_form_show) if (!is_form_show)
{ {
//System.IO.File.AppendAllText(Application.StartupPath + "\\Logs.txt",
//"\r\n" + DateTime.Now + "\t提前一分钟休息弹窗提醒");
DbOp.FrmBeforeRestTip frm = new DbOp.FrmBeforeRestTip(); DbOp.FrmBeforeRestTip frm = new DbOp.FrmBeforeRestTip();
frm.FormClosing += delegate (object sender2, FormClosingEventArgs e2) frm.FormClosing += delegate (object sender2, FormClosingEventArgs e2)
{ {
if(frm.IsDelay>0) if (frm.IsDelay > 0)
{ {
AddRestRecord(new RestInfo() { UserSecondTime = frm.IsDelay*60, Mode = 4 }); AddRestRecord(new RestInfo() { UserSecondTime = frm.IsDelay * 60, Mode = 4 });
} }
else if (frm.IsDelay == -1) else if (frm.IsDelay == -1)
{ {
AddRestRecord(new RestInfo() { UserSecondTime =0, Mode = 2 }); AddRestRecord(new RestInfo() { UserSecondTime = 0, Mode = 2 });
} }
}; };
frm.Show(); frm.Show();
frm.StartLoad(); frm.StartLoad();
} }
} }
if (Itrycn_Info.SoundBeforeRest) if (Itrycn_Info.SoundBeforeRest)
@ -565,7 +510,7 @@ namespace TimeClock
} }
#endregion #endregion
} }
else if(_time<=0) else if (_time <= 0)
{ {
#region #region
Itrycn_Info.IsRestNowing = true; Itrycn_Info.IsRestNowing = true;
@ -597,17 +542,17 @@ namespace TimeClock
} }
} }
} }
if (dt_now.Second<20) if (dt_now.Second < 20)
{ {
if (lastRunTime.AddSeconds(30) > dt_now) if (lastRunTime.AddSeconds(30) > dt_now)
{ TimeComplete = true; return; } { TimeComplete = true; return; }
if (GetIsDesignMode()) { TimeComplete = true; return; } if (GetIsDesignMode()) { TimeComplete = true; return; }
lastRunTime = dt_now; lastRunTime = dt_now;
if (dt_now.Minute == 0)//整点报时 if (dt_now.Minute == 0)//整点报时
{ {
if (Itrycn_Info.HourlyChime_On)//如果开启了整点报时 if (Itrycn_Info.HourlyChime_On)//如果开启了整点报时
{ {
Thread th = new Thread(delegate() { Itrycn_Info.PlayHours(true); }); Thread th = new Thread(delegate () { Itrycn_Info.PlayHours(true); });
th.Start(); th.Start();
} }
} }
@ -634,7 +579,7 @@ namespace TimeClock
string Pram = tStor.GetAttrValue("Pram"); string Pram = tStor.GetAttrValue("Pram");
bool sound_on = tStor.GetAttrValue("sound_on", true); bool sound_on = tStor.GetAttrValue("sound_on", true);
string sound_path = tStor.GetAttrValue("sound", Itrycn_Info.SysDbFolder + @"\animation\sound\tip.wav"); string sound_path = tStor.GetAttrValue("sound", Itrycn_Info.SysDbFolder + @"\animation\sound\tip.wav");
if (sound_path.Length == 0) { sound_path = Itrycn_Info.SysDbFolder + @"\animation\sound\tip.wav"; } if (sound_path.Length == 0) { sound_path = Itrycn_Info.SysDbFolder + @"\animation\sound\tip.wav"; }
sound_path = Itrycn_Info.GetRealPath(sound_path); sound_path = Itrycn_Info.GetRealPath(sound_path);
bool gif_on = tStor.GetAttrValue("showpic_on", false); bool gif_on = tStor.GetAttrValue("showpic_on", false);
string gif_path = Itrycn_Info.GetRealPath(tStor.GetAttrValue("showpic", "")); string gif_path = Itrycn_Info.GetRealPath(tStor.GetAttrValue("showpic", ""));
@ -650,7 +595,7 @@ namespace TimeClock
case "Mute_Off"://取消静音 case "Mute_Off"://取消静音
case "TimeSync"://时间同步 case "TimeSync"://时间同步
_run_file = Application.StartupPath + "\\RyLine.exe"; _run_file = Application.StartupPath + "\\RyLine.exe";
if(!System.IO.File.Exists(_run_file)) if (!System.IO.File.Exists(_run_file))
{ {
_run_file = AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\') + "\\RyLine.exe"; _run_file = AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\') + "\\RyLine.exe";
} }
@ -832,22 +777,85 @@ namespace TimeClock
TipChanged(); TipChanged();
} }
} }
db.Free(); db.Free();
#endregion #endregion
if(Itrycn_Info.CalcWorkInfo) if (Itrycn_Info.CalcWorkInfo)
{ {
CalcWorkInfo(dt_now); CalcWorkInfo(dt_now);
} }
} }
else if(dt_now.Second==40) else if (dt_now.Second == 40)
{ {
if(dt_now.Minute==0) if (dt_now.Minute == 0)
{ {
UpdateTipTime(true); UpdateTipTime(true);
} }
} }
TimeComplete = true; TimeComplete = true;
} }
DateTime lastRunTime = DateTime.Now.AddDays(-1);
bool last_fullscreen = false;
bool last_idle = false;
/// <summary>
/// 计算工作信息
/// </summary>
/// <param name="dt_now"></param>
private void CalcWorkInfo(DateTime dt_now)
{
var idle = ryCommon.RySystem.GetLastInputTime() / 1000;
DateTime dt_now2 = dt_now.AddSeconds(-dt_now.Second).AddMilliseconds(-dt_now.Millisecond);
int stype = 0;
if (idle>=60)
{
stype = 0;
}
else { stype = 1; }
DataProvider mydb = new DataProvider();
IDbInterface db = TimeClock.Itrycn_Db.CreateDataProvider(TimeClock.Itrycn_Db.dataType);
if (db.ConnDb(TimeClock.Itrycn_Db.WorkInfo_ConnStr) == 1)
{
RyQuickSQL mySQL = new RyQuickSQL("WorkInfo");
mySQL.AddField("StartTime", dt_now2.AddMinutes(-1));
mySQL.AddField("EndTime", dt_now2);
mySQL.AddField("stype", stype);
mySQL.AddField("totalSecond", 60);
db.ExecuteNonQuery(mySQL.GetInsertSQL());
}
db.Free();
}
/// <summary>
/// 时间循环一轮是否结束,结束后才能开始下一轮
/// </summary>
bool TimeComplete = true;
/// <summary>
/// 开始休息时间
/// </summary>
DateTime dt_start_idle = DateTime.Now;
/// <summary>
/// 添加休息记录
/// </summary>
/// <param name="info"></param>
private void AddRestRecord(RestInfo info)
{
if(Itrycn_Db.list_rest.Count>1000)
{
Itrycn_Db.list_rest.RemoveAt(0);
}
Itrycn_Db.list_rest.Add(info);
OnRestDataChanged?.Invoke(this, new EventArgs());
}
/// <summary>
///最近一次是否是休息状态
/// </summary>
private bool last_IsRestNowing = Itrycn_Info.IsRestNowing;
/// <summary>
/// 最近一次开始休息的时间
/// </summary>
private DateTime last_StartRestTime = DateTime.Now;
private void Timer1_Tick(object sender, EventArgs e)
{
}
} }
public class TimeInfo public class TimeInfo
{ {

View File

@ -117,9 +117,6 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 55</value>
</metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value> <value>False</value>
</metadata> </metadata>

View File

@ -47,7 +47,9 @@
<Reference Include="RaUI"> <Reference Include="RaUI">
<HintPath>..\..\..\..\睿元公用控件组\Bin\Release\CommonControls\.NET4\RaUI.dll</HintPath> <HintPath>..\..\..\..\睿元公用控件组\Bin\Release\CommonControls\.NET4\RaUI.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll</HintPath>
</Reference>
<Reference Include="System.configuration" /> <Reference Include="System.configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Design" /> <Reference Include="System.Design" />