AnalysisJXTRespond.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #include "stdafx.h"
  2. #include "AnalysisJXTRespond.h"
  3. AnalysisJXTRespond::AnalysisJXTRespond(void)
  4. {
  5. nStatus = -1;
  6. nSendCount = 0;
  7. fCurConsume = 0.0;
  8. fBalance = 0.0;
  9. memset(szSMSID,0,1024);
  10. }
  11. AnalysisJXTRespond::~AnalysisJXTRespond(void)
  12. {
  13. }
  14. int AnalysisJXTRespond::AnalysisRespondString(IN CString strRespond)
  15. {
  16. // nFindRet,只有全部find不返-1,就表示strRespond是对的返回值;
  17. unsigned int nFindRet = 0;
  18. strRespond.MakeLower();
  19. strRespond.TrimRight("\r\n");
  20. int nIndex = 0;
  21. CString strTemp;
  22. // 1.状态码;
  23. nIndex = strRespond.Find("/send:");
  24. if ( nIndex != -1 )
  25. {
  26. nFindRet &= 1;
  27. }
  28. strTemp = strRespond.Left(nIndex);
  29. nStatus = atoi(strTemp);
  30. // 2.发送条数;
  31. strTemp = "/send:";
  32. strRespond = strRespond.Mid(strRespond.Find("/send:")+ strTemp.GetLength());
  33. nIndex = strRespond.Find("/consumption:");
  34. if ( nIndex != -1 )
  35. {
  36. nFindRet &= 2;
  37. }
  38. strTemp = strRespond.Left(nIndex);
  39. nSendCount = atoi(strTemp);
  40. strTemp = "/consumption:";
  41. strRespond = strRespond.Mid(nIndex+strTemp.GetLength());
  42. // 3.费用;
  43. strTemp = "/tmoney:";
  44. nIndex = strRespond.Find(strTemp);
  45. if ( nIndex != -1)
  46. {
  47. nFindRet &= 4;
  48. }
  49. strTemp = strRespond.Left(nIndex);
  50. if (strTemp.Find(".") != -1)
  51. strTemp += "000000000";
  52. fCurConsume = atof(strTemp);
  53. strTemp = "/tmoney:";
  54. nIndex = strRespond.Find("/tmoney:");
  55. strRespond = strRespond.Mid(nIndex + strTemp.GetLength());
  56. // 4.余额;
  57. strTemp = "/sid:";
  58. nIndex = strRespond.Find(strTemp);
  59. if ( nIndex != -1)
  60. {
  61. nFindRet &= 8;
  62. }
  63. strTemp = strRespond.Left(nIndex);
  64. if (strTemp.Find(".") != -1)
  65. strTemp += "000000000";
  66. fBalance = atof(strTemp);
  67. // 5.短信编号;
  68. strTemp = "/sid:";
  69. nIndex = strRespond.Find("/sid:");
  70. strRespond = strRespond.Mid(nIndex + strTemp.GetLength());
  71. strcpy(szSMSID,strRespond);
  72. return nFindRet;
  73. }