CNAS取数仪器端升级
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.

99 line
3.6KB

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