YUtilsAuth.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //************************************************************************
  2. // https://github.com/yuzhengyang
  3. // author: yuzhengyang
  4. // date: 2017.9.12 - 2017.9.12
  5. // desc: 工具类验证
  6. // Copyright (c) yuzhengyang. All rights reserved.
  7. //************************************************************************
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. namespace Y.Utils.YUtils
  15. {
  16. public class YUtilsAuth
  17. {
  18. private static bool IsStart = false;
  19. private static DateTime StartTime = DateTime.Now;
  20. /// <summary>
  21. /// 工具类验证
  22. /// </summary>
  23. public static void Start()
  24. {
  25. if (!IsStart)
  26. {
  27. IsStart = true;
  28. if (IsStart)
  29. {
  30. StartTime = DateTime.Now;
  31. Task.Factory.StartNew(() =>
  32. {
  33. CheckObsolete();
  34. });
  35. }
  36. }
  37. if ((DateTime.Now - StartTime).TotalHours > 1) IsStart = false;
  38. }
  39. /// <summary>
  40. /// 验证有效期
  41. /// </summary>
  42. private static void CheckObsolete()
  43. {
  44. if (DateTime.Now > new DateTime(2018, 12, 2, 0, 0, 0))
  45. MessageBox.Show("工具组件超出有效期,请更新工具组件。(https://github.com/yuzhengyang)", "超出有效期");
  46. }
  47. }
  48. }