|
|
@@ -0,0 +1,43 @@
|
|
|
+using MvvmScaffoldFrame48.DLL.ConfigTools;
|
|
|
+using MvvmScaffoldFrame48.Model.StorageModel.SystemTools;
|
|
|
+using System;
|
|
|
+using System.Diagnostics;
|
|
|
+using System.IO;
|
|
|
+
|
|
|
+namespace MvvmScaffoldFrame48.DLL.SystemTools
|
|
|
+{
|
|
|
+ public static class SystemRunTimeTools
|
|
|
+ {
|
|
|
+ static Stopwatch SystemRunTime = new Stopwatch();
|
|
|
+ static long InitRunTime;
|
|
|
+ public static void StartSystemRunTime()
|
|
|
+ {
|
|
|
+ string localDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
|
|
+ string systemRunTimePath = Path.Combine(localDataPath, "CCDCount\\SystemRunTime.XML");
|
|
|
+ if (File.Exists(systemRunTimePath))
|
|
|
+ {
|
|
|
+ var systemMessage = XMLReadWrite.DeserializeFromXml<SystemMessageConfigModel>(systemRunTimePath);
|
|
|
+ InitRunTime = systemMessage.SystemRunTime;
|
|
|
+ TimeSpan timeSpan = TimeSpan.FromTicks(InitRunTime);
|
|
|
+ }
|
|
|
+ SystemRunTime.Start();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void StopSystemRunTime()
|
|
|
+ {
|
|
|
+ string localDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
|
|
+ string systemruntimefoundPath = Path.Combine(localDataPath, "CCDCount");
|
|
|
+ if (!Directory.Exists(systemruntimefoundPath))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(systemruntimefoundPath);
|
|
|
+ }
|
|
|
+ string systemRunTimePath = Path.Combine(systemruntimefoundPath, "SystemRunTime.XML");
|
|
|
+ SystemRunTime.Stop();
|
|
|
+ long ticks = SystemRunTime.ElapsedTicks;
|
|
|
+ XMLReadWrite.SerializeToXml(new SystemMessageConfigModel()
|
|
|
+ {
|
|
|
+ SystemRunTime = ticks + InitRunTime
|
|
|
+ }, systemRunTimePath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|