CNAS取数仪器端升级
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

94 行
3.4KB

  1. using CNAS_DBSync;
  2. using CnasSynchronousCommon;
  3. using CnasSynchronusClient;
  4. using CnasSynchrousModel;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Configuration;
  8. using System.Linq;
  9. using System.Windows.Forms;
  10. namespace CNAS_RunSync
  11. {
  12. static class Program
  13. {
  14. /// <summary>
  15. /// 应用程序的主入口点。
  16. /// </summary>
  17. [STAThread]
  18. static void Main()
  19. {
  20. Application.EnableVisualStyles();
  21. Application.SetCompatibleTextRenderingDefault(false);
  22. string strMsg = "";
  23. //CheckAvailability(ref strMsg);
  24. if (strMsg == "")
  25. {
  26. // 检查是否已激活
  27. if (!(new ActivationForm()).CheckActivation())
  28. {
  29. // 未激活,显示激活窗口
  30. using (var activationForm = new ActivationForm())
  31. {
  32. if (activationForm.ShowDialog() == DialogResult.OK)
  33. {
  34. // 激活成功,显示主窗口
  35. if (new frmOperationPwd().ShowDialog() == DialogResult.OK)
  36. Application.Run(new frmSynchrousMain());
  37. }
  38. }
  39. }
  40. else
  41. {
  42. // 已激活,直接显示主窗口
  43. if (new frmOperationPwd().ShowDialog() == DialogResult.OK)
  44. Application.Run(new frmSynchrousMain());
  45. }
  46. }
  47. else
  48. MessageBox.Show(strMsg);
  49. }
  50. //检查当前电脑是否可以启动程序
  51. public static void CheckAvailability(ref string strErrorMsg)
  52. {
  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 = "当前电脑没有使用权限,请联系管理员。";
  87. return;
  88. }
  89. }
  90. }
  91. }