ComparVersion.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #include "ComparVersion.h"
  2. VertionResultType ComparVersion::GetProductInfo(wstring productName,wstring productUrl)
  3. {
  4. DeviceProduct deviceProduct = DeviceProduct(productName);
  5. OnlineProduct onlineProduct = OnlineProduct();
  6. onlineProduct.GetInstallPageVersion(productUrl);
  7. int re = GetCompareNETFramework(deviceProduct.GetNETTargetVersion(), deviceProduct.GetNETVersion());
  8. if (re == 1)
  9. {
  10. NetFramework = InstallNetFrameworkType::V46;
  11. }
  12. else if (re == 2)
  13. {
  14. NetFramework = InstallNetFrameworkType::V40_46;
  15. }
  16. int vc = GetCompareVCPlusPlus(deviceProduct.GetVsCPulsPulsVersion());
  17. if (vc == 1) {
  18. VcPlusPlus = InstallVCPlusPlusType::V14_3;
  19. }
  20. return GetCompareVersion(deviceProduct.GetVersion(), onlineProduct.GetVersionW());
  21. }
  22. VertionResultType ComparVersion::GetCompareVersion(wstring deviceVersion,wstring onlineVersion)
  23. {
  24. std::map<wstring, wstring> map{ {L"DeviceVersion", deviceVersion}, { L"OnlineVersion",onlineVersion }};
  25. LogIni::GetLogToIniMaps(map);
  26. VertionResultType state = VertionResultType::None;
  27. if (deviceVersion.find(onlineVersion) != -1)
  28. {
  29. state = VertionResultType::Same;
  30. }
  31. else
  32. {
  33. if (deviceVersion == L"")
  34. {
  35. state = VertionResultType::None;
  36. }
  37. else
  38. {
  39. int n = deviceVersion.compare(onlineVersion);
  40. if (n < 0)
  41. {
  42. state = VertionResultType::Low;
  43. }
  44. else
  45. {
  46. state = VertionResultType::Hight;
  47. }
  48. }
  49. }
  50. return state;
  51. }
  52. //值:0为已存在4.0和4.6以上版本;1为只存在4.0;2为4.0和4.6以上都不存在
  53. int ComparVersion::GetCompareNETFramework(wstring minVersion, wstring maxVersion)
  54. {
  55. if (minVersion == L"" || maxVersion == L"")
  56. return 0;
  57. wstring minVersionStr = minVersion.substr(0, 3);
  58. wstring maxVersionStr = maxVersion.substr(0, 3);
  59. int n = minVersionStr.compare(L"4.0");
  60. int n2 = maxVersion.compare(L"4.6");
  61. if (n < 0)
  62. return 2;
  63. if(n2 < 0)
  64. return 1;
  65. return 0;
  66. }
  67. int ComparVersion::GetCompareVCPlusPlus(wstring Version)
  68. {
  69. if (Version == L"")
  70. return 0;
  71. wstring minVersionStr = Version.substr(0, 5);
  72. int n = minVersionStr.compare(L"v14.3");
  73. if (n ==0 )
  74. return 1;
  75. return 0;
  76. }