懒人记时 代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.1 KiB

  1. 
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data.OleDb;
  5. using System.Diagnostics;
  6. using System.Drawing;
  7. using System.Drawing.Imaging;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading;
  12. using System.Windows.Forms;
  13. namespace AppTime
  14. {
  15. static class Program
  16. {
  17. public const int Port = 15720;
  18. public static InitDB init;
  19. public static Recorder recorder;
  20. public static WebServer server;
  21. public static Controller controller;
  22. public static FrmMain frmMain;
  23. /// <summary>
  24. /// 应用程序的主入口点。
  25. /// </summary>
  26. [STAThread]
  27. static void Main()
  28. {
  29. #if DEBUG
  30. CopyWebUI();
  31. #endif
  32. init = new InitDB();
  33. init.Start();
  34. recorder = new Recorder();
  35. recorder.Start();
  36. controller = new Controller();
  37. server = new WebServer();
  38. server.Start(Port, controller, "./webui");
  39. Application.EnableVisualStyles();
  40. Application.SetCompatibleTextRenderingDefault(false);
  41. Application.Run(frmMain = new FrmMain());
  42. }
  43. static void CopyWebUI()
  44. {
  45. CopyDirectory("../../webui", "./webui");
  46. }
  47. static void CopyDirectory(string src, string dest)
  48. {
  49. if (!Directory.Exists(dest))
  50. {
  51. Directory.CreateDirectory(dest);
  52. }
  53. foreach (var srcfile in Directory.GetFiles(src))
  54. {
  55. var destfile = Path.Combine(dest, Path.GetFileName(srcfile));
  56. //只复制更新的文件
  57. if (File.Exists(destfile) && File.GetLastWriteTime(srcfile) == File.GetLastWriteTime(destfile))
  58. {
  59. continue;
  60. }
  61. File.Copy(srcfile, destfile, true);
  62. }
  63. foreach (var srcdir in Directory.GetDirectories(src))
  64. {
  65. var destdir = Path.Combine(dest, Path.GetFileName(srcdir));
  66. CopyDirectory(srcdir, destdir);
  67. }
  68. }
  69. }
  70. }