dialogabout.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #include "dialogabout.h"
  2. #include "ui_dialogabout.h"
  3. #include "SNCDataBase.h"
  4. #include "wssso.h"
  5. #include "wscube.h"
  6. #include "wscube2.h"
  7. #include "respgetsysparam.h"
  8. #include "respgetmfsysparam.h"
  9. #include "respgetmf2sysparam.h"
  10. #include "dialogdbbackupandrecovery.h"
  11. DialogAbout::DialogAbout(QWidget *parent) :
  12. QDialog(parent),
  13. ui(new Ui::DialogAbout)
  14. {
  15. ui->setupUi(this);
  16. ui->buttonBox->button(QDialogButtonBox::Ok)->setText("确定");
  17. ui->buttonBox->button(QDialogButtonBox::Cancel)->setText("取消");
  18. this->ui->lblAppName->setText(SNCDataBase::getProductName());
  19. this->ui->lblAppVersion->setText("软件版本:"+SNCDataBase::getAppVersion2());
  20. this->ui->lblSegVersion->setText("号段版本:"+SNCDataBase::getSegVersion() + "(共" + QString::number(SNCDataBase::getSegCount()) + "个号段)");
  21. this->ui->labelIcon->setPixmap(QPixmap(":/snc.ico"));
  22. this->ui->labelWebsite->setText("<a href=" + SNCDataBase::getWebsiteUrl() + ">" +\
  23. SNCDataBase::getWebsiteTitle()+"</a>");
  24. QObject::connect(ui->labelWebsite,SIGNAL(linkActivated(QString)),this,SLOT(onLinkActivated(QString)));
  25. QString fileName = ":/about.txt";
  26. QFile file(fileName);
  27. if(!file.open(QIODevice::ReadOnly))
  28. {
  29. return ;
  30. this->close();
  31. }
  32. QTextStream in(&file);
  33. QString log = in.readAll();
  34. file.close();
  35. this->ui->labelAbout->setText(log);
  36. setWindowFlags(windowFlags()&~Qt::WindowContextHelpButtonHint);
  37. }
  38. DialogAbout::~DialogAbout()
  39. {
  40. delete ui;
  41. }
  42. void DialogAbout::onLinkActivated(QString url)
  43. {
  44. qDebug()<<url;
  45. QDesktopServices::openUrl(QUrl(url));
  46. }
  47. void DialogAbout::on_pushButtonUpdateConfig_clicked()
  48. {
  49. //bool b1 = updateCubeSrvParam();
  50. setCursor(Qt::WaitCursor);
  51. bool b2 = updateCube2SrvParam();
  52. bool b3 = updateSSOSrvParam();
  53. setCursor(Qt::ArrowCursor);
  54. if(b2&&b3)
  55. {
  56. QMessageBox::information(this,"提示","配置信息更新成功!",QMessageBox::Ok);
  57. }
  58. else
  59. {
  60. QMessageBox::warning(this,"提示","配置信息未更新成功,请重试!",QMessageBox::Ok);
  61. }
  62. }
  63. bool DialogAbout::updateCubeSrvParam()
  64. {
  65. QString src = "mf-" + SNCDataBase::getAppVersion();
  66. QString authCode;
  67. QByteArray ba;
  68. QString str = src + SNCDataBase::getAuthCodeSyspara();
  69. ba = QCryptographicHash::hash ( str.toAscii(), QCryptographicHash::Md5 );
  70. authCode.append(ba.toHex());
  71. WSCube cube;
  72. QString json2 = cube.getSysParam(src,authCode);
  73. qDebug()<<json2;
  74. if(!json2.isEmpty())
  75. {
  76. RespGetMfSysParam response2(json2);
  77. qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")\
  78. <<"WSCube.getSysParam"<<response2.getRtnCode();
  79. SNCDataBase::updateSrvParam("cube",response2.getRs());
  80. qDebug()<<response2.getRs();
  81. return true;
  82. }
  83. return false;
  84. }
  85. bool DialogAbout::updateCube2SrvParam()
  86. {
  87. QString src = "mf-" + SNCDataBase::getAppVersion();
  88. QString authCode;
  89. QByteArray ba;
  90. QString str = src + SNCDataBase::getAuthCodeSyspara();
  91. ba = QCryptographicHash::hash ( str.toAscii(), QCryptographicHash::Md5 );
  92. authCode.append(ba.toHex());
  93. WSCube2 cube;
  94. QString json2 = cube.getSysParam(src,authCode);
  95. qDebug()<<"json2"<<json2;
  96. if(!json2.isEmpty())
  97. {
  98. RespGetMf2SysParam response2(json2);
  99. qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")\
  100. <<"WSCube2.getSysParam"<<response2.getRtnCode();
  101. SNCDataBase::updateSrvParam("cube2",response2.getRs());
  102. qDebug()<<response2.getRs();
  103. return true;
  104. }
  105. return false;
  106. }
  107. bool DialogAbout::updateSSOSrvParam()
  108. {
  109. QString src = "mf-" + SNCDataBase::getAppVersion();
  110. QString authCode;
  111. QByteArray ba;
  112. QString str = src + SNCDataBase::getAuthCodeSeg();
  113. ba = QCryptographicHash::hash ( str.toAscii(), QCryptographicHash::Md5 );
  114. authCode.append(ba.toHex());
  115. WSSSO interface;
  116. QString json = interface.getSysParam(src,authCode);
  117. if(!json.isEmpty())
  118. {
  119. RespGetSysParam response(json);
  120. qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")\
  121. <<"WSSSO.getSysParam"<<response.getRtnCode();
  122. SNCDataBase::updateSrvParam("sso",response.getRs());
  123. return true;
  124. }
  125. return false;
  126. }
  127. void DialogAbout::on_pushButtonDb_clicked()
  128. {
  129. DialogDbBackupAndRecovery dialog;
  130. dialog.exec();
  131. }