CNAS取数仪器端升级
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

95 lignes
3.5KB

  1. using CnasSynchronousCommon;
  2. using CnasSynchronusClient;
  3. using CnasSynchrousModel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Configuration;
  7. using System.Linq;
  8. using System.Windows.Forms;
  9. namespace CNAS_DBSync
  10. {
  11. static class Program
  12. {
  13. /// <summary>
  14. /// 应用程序的主入口点。
  15. /// </summary>
  16. [STAThread]
  17. static void Main()
  18. {
  19. Application.EnableVisualStyles();
  20. Application.SetCompatibleTextRenderingDefault(false);
  21. string strMsg = "";
  22. /*CheckAvailability(ref strMsg);*/
  23. if (strMsg == "")
  24. {
  25. // 检查是否已激活
  26. if (! (new ActivationForm()).CheckActivation())
  27. {
  28. // 未激活,显示激活窗口
  29. using (var activationForm = new ActivationForm())
  30. {
  31. if (activationForm.ShowDialog() == DialogResult.OK)
  32. {
  33. // 激活成功,显示主窗口
  34. if (new frmOperationPwd().ShowDialog() == DialogResult.OK)
  35. Application.Run(new frmSyncParams());
  36. }
  37. }
  38. }
  39. else
  40. {
  41. // 已激活,直接显示主窗口
  42. if (new frmOperationPwd().ShowDialog() == DialogResult.OK)
  43. Application.Run(new frmSyncParams());
  44. }
  45. }
  46. else
  47. MessageBox.Show(strMsg);
  48. }
  49. ///检查当前电脑是否可以启动程序
  50. public static void CheckAvailability(ref string strErrorMsg)
  51. {
  52. //0.读取本地系统配置文件
  53. SystemFormatConfig systemFormat = FileOperation.GetSystemFormatConfigData();
  54. GlobalCommonOperation.strStartGeneralVersion = systemFormat.StartGeneralVersion;
  55. GlobalCommonOperation.strStartWebApi = systemFormat.StartWebApi;
  56. GlobalCommonOperation.strWebApiUrl = systemFormat.WebApiUrl;
  57. GlobalCommonOperation.strTargetDbType = systemFormat.TargetDBType;
  58. if (GlobalCommonOperation.strStartGeneralVersion == "1") //此时启动的时通用版本,不需检查Mac地址
  59. {
  60. return;
  61. }
  62. //1.读取本地CNAS数据库配置信息
  63. DataBaseInfo Cnasdb = null;
  64. if (GlobalCommonOperation.strStartWebApi != "1")
  65. Cnasdb = FileOperation.GetLocalCnasDB();
  66. else
  67. Cnasdb = new DataBaseInfo()
  68. {
  69. DataBaseCode = "cnas"
  70. };
  71. if (!CnasDataOperationFact.CnasDataOperation().TestConnect(Cnasdb))
  72. {
  73. strErrorMsg = "无法正常连接CNAS库,请先配置数据库连接。";
  74. return;
  75. }
  76. //2.获取本机MAC地址
  77. string strLocalMac = ComputeMessage.getLocalMac(ref strErrorMsg);
  78. if (strErrorMsg != "")
  79. {
  80. return;
  81. }
  82. //3 验证是否存在于CNAS数据库相应表中
  83. bool bIfChecked = CnasDataOperationFact.CnasDataOperation().CheckMacMessage(Cnasdb, strLocalMac);
  84. if (!bIfChecked)
  85. {
  86. strErrorMsg = $"当前电脑[{strLocalMac}]没有使用权限,请联系管理员。";
  87. return;
  88. }
  89. }
  90. }
  91. }