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.

5 年之前
5 年之前
5 年之前
5 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using CnasSynchronousCommon;
  2. using CnasSynchronusClient;
  3. using CnasSynchrousModel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Windows.Forms;
  8. namespace CNAS_DBSync
  9. {
  10. static class Program
  11. {
  12. /// <summary>
  13. /// 应用程序的主入口点。
  14. /// </summary>
  15. [STAThread]
  16. static void Main()
  17. {
  18. Application.EnableVisualStyles();
  19. Application.SetCompatibleTextRenderingDefault(false);
  20. string strMsg = "";
  21. CheckAvailability(ref strMsg);
  22. if (strMsg == "")
  23. {
  24. if (new frmOperationPwd().ShowDialog() == DialogResult.OK)
  25. Application.Run(new frmSyncParams());
  26. }
  27. else
  28. MessageBox.Show(strMsg);
  29. }
  30. //检查当前电脑是否可以启动程序
  31. public static void CheckAvailability(ref string strErrorMsg)
  32. {
  33. //1.读取本地CNAS数据库配置信息
  34. DataBaseInfo Cnasdb = FileOperation.GetLocalCnasDB();
  35. if (!CnasDataOperationFact.CnasDataOperation().TestConnect(Cnasdb.DBHost, Cnasdb.DBName, Cnasdb.DBUser, Cnasdb.DBPwd, Cnasdb.DBPort))
  36. {
  37. strErrorMsg = "无法正常连接CNAS库,请先配置数据库连接。";
  38. return;
  39. }
  40. //2.获取本机MAC地址
  41. string strLocalMac = ComputeMessage.getLocalMac(ref strErrorMsg);
  42. if (strErrorMsg != "")
  43. {
  44. return;
  45. }
  46. //3 验证是否存在于CNAS数据库相应表中
  47. bool bIfChecked = CnasDataOperationFact.CnasDataOperation().CheckMacMessage(Cnasdb, strLocalMac);
  48. if (!bIfChecked)
  49. {
  50. strErrorMsg = $"当前电脑[{strLocalMac}]没有使用权限,请联系管理员。";
  51. return;
  52. }
  53. }
  54. }
  55. }