private void GetLicenses() { try { var lics = _mListLicenses; if (lics.Count <= 0) { OnDebug(LogMode.Error, string.Format("No license to get.")); return; } JsonObject json = new JsonObject(); json[LicDefines.KEYWORD_MSG_COMMON_CLASSID] = new JsonProperty(LicDefines.LICENSE_MSG_CLASS_REQRES); json[LicDefines.KEYWORD_MSG_COMMON_CLASSDESC] = new JsonProperty(LicUtils.GetClassDesc(LicDefines.LICENSE_MSG_CLASS_REQRES)); json[LicDefines.KEYWORD_MSG_COMMON_MESSAGEID] = new JsonProperty(LicDefines.LICENSE_MSG_REQUEST_GET_LICENSE); json[LicDefines.KEYWORD_MSG_COMMON_MESSAGEDESC] = new JsonProperty(LicUtils.GetMessageDesc(LicDefines.LICENSE_MSG_CLASS_REQRES, LicDefines.LICENSE_MSG_REQUEST_GET_LICENSE)); json[LicDefines.KEYWORD_MSG_COMMON_CURRENTTIME] = new JsonProperty(DateTime.Now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss")); json[LicDefines.KEYWORD_MSG_COMMON_DATA] = new JsonProperty(new JsonObject()); json[LicDefines.KEYWORD_MSG_COMMON_DATA][LicDefines.KEYWORD_MSG_APPINFO_LICENSES] = new JsonProperty(); for (int i = 0; i < lics.Count; i++) { var lic = lics[i]; lic.ResetValue(); JsonObject jsonLic = new JsonObject(); jsonLic[LicDefines.KEYWORD_MSG_LICENSE_DISPLAY] = new JsonProperty(lic.Name); jsonLic[LicDefines.KEYWORD_MSG_LICENSE_EXPIRATION] = new JsonProperty(lic.Expiration); jsonLic[LicDefines.KEYWORD_MSG_LICENSE_LICENSEID] = new JsonProperty(lic.SerialNo); jsonLic[LicDefines.KEYWORD_MSG_LICENSE_MODULEMARJORTYPEID] = new JsonProperty(lic.MajorID); jsonLic[LicDefines.KEYWORD_MSG_LICENSE_MODULEMINJORTYPEID] = new JsonProperty(lic.MinorID); jsonLic[LicDefines.KEYWORD_MSG_LICENSE_OWNERTYPE] = new JsonProperty((int)lic.Type); jsonLic[LicDefines.KEYWORD_MSG_LICENSE_VALUETYPE] = new JsonProperty((int)lic.DataType); if (lic.DataType == LicDataType.Number) { jsonLic[LicDefines.KEYWORD_MSG_LICENSE_VALUE] = new JsonProperty(lic.RequestValue); } else { jsonLic[LicDefines.KEYWORD_MSG_LICENSE_VALUE] = new JsonProperty(string.Format("\"{0}\"", lic.RequestValue)); } json[LicDefines.KEYWORD_MSG_COMMON_DATA][LicDefines.KEYWORD_MSG_APPINFO_LICENSES].Add(jsonLic); } string strMsg = json.ToString(); if (_mLicConnector != null) { _mLicConnector.SendMessage(strMsg); OnDebug(LogMode.Info, string.Format("Send:\tClass: {0};\tMsg: {1}", LicUtils.GetClassDesc(LicDefines.LICENSE_MSG_CLASS_REQRES), LicUtils.GetMessageDesc(LicDefines.LICENSE_MSG_CLASS_REQRES, LicDefines.LICENSE_MSG_REQUEST_GET_LICENSE))); } } catch (Exception ex) { OnDebug(LogMode.Error, string.Format("GetLicenses fail.\t{0}", ex.Message)); } }
private void QueryLicInfos() { try { List <License> listLics = new List <License>(); License lic = new License(); lic.SerialNo = mLicID; lic.DataType = LicDataType.Number; listLics.Add(lic); JsonObject json = new JsonObject(); json[LicDefines.KEYWORD_MSG_COMMON_CLASSID] = new JsonProperty(LicDefines.LICENSE_MSG_CLASS_REQRES); json[LicDefines.KEYWORD_MSG_COMMON_CLASSDESC] = new JsonProperty(LicUtils.GetClassDesc(LicDefines.LICENSE_MSG_CLASS_REQRES)); json[LicDefines.KEYWORD_MSG_COMMON_MESSAGEID] = new JsonProperty(LicDefines.LICENSE_MSG_REQUEST_QUERY_SPECIFIC_LICENSE); json[LicDefines.KEYWORD_MSG_COMMON_MESSAGEDESC] = new JsonProperty(LicUtils.GetMessageDesc(LicDefines.LICENSE_MSG_CLASS_REQRES, LicDefines.LICENSE_MSG_REQUEST_QUERY_SPECIFIC_LICENSE)); json[LicDefines.KEYWORD_MSG_COMMON_CURRENTTIME] = new JsonProperty(DateTime.Now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss")); json[LicDefines.KEYWORD_MSG_COMMON_DATA] = new JsonProperty(new JsonObject()); json[LicDefines.KEYWORD_MSG_COMMON_DATA][LicDefines.KEYWORD_MSG_APPINFO_LICENSES] = new JsonProperty(); for (int i = 0; i < listLics.Count; i++) { lic = listLics[i]; lic.ResetValue(); JsonObject jsonLic = new JsonObject(); jsonLic[LicDefines.KEYWORD_MSG_LICENSE_DISPLAY] = new JsonProperty(lic.Name); jsonLic[LicDefines.KEYWORD_MSG_LICENSE_EXPIRATION] = new JsonProperty(lic.Expiration); jsonLic[LicDefines.KEYWORD_MSG_LICENSE_LICENSEID] = new JsonProperty(lic.SerialNo); jsonLic[LicDefines.KEYWORD_MSG_LICENSE_MODULEMARJORTYPEID] = new JsonProperty(lic.MajorID); jsonLic[LicDefines.KEYWORD_MSG_LICENSE_MODULEMINJORTYPEID] = new JsonProperty(lic.MinorID); jsonLic[LicDefines.KEYWORD_MSG_LICENSE_OWNERTYPE] = new JsonProperty((int)lic.Type); jsonLic[LicDefines.KEYWORD_MSG_LICENSE_VALUETYPE] = new JsonProperty((int)lic.DataType); if (lic.DataType == LicDataType.Number) { jsonLic[LicDefines.KEYWORD_MSG_LICENSE_VALUE] = new JsonProperty(lic.RequestValue); } else { jsonLic[LicDefines.KEYWORD_MSG_LICENSE_VALUE] = new JsonProperty(string.Format("\"{0}\"", lic.RequestValue)); } json[LicDefines.KEYWORD_MSG_COMMON_DATA][LicDefines.KEYWORD_MSG_APPINFO_LICENSES].Add(jsonLic); } string strMsg = json.ToString(); if (mLicChecker != null) { mLicChecker.SendMessage(strMsg); AppendMessage(string.Format("Send:\tClass: {0};\tMsg: {1}", LicUtils.GetClassDesc(LicDefines.LICENSE_MSG_CLASS_REQRES), LicUtils.GetMessageDesc(LicDefines.LICENSE_MSG_CLASS_REQRES, LicDefines.LICENSE_MSG_REQUEST_QUERY_SPECIFIC_LICENSE))); } } catch (Exception ex) { AppendMessage(string.Format("QueryLicInfos fail.\t{0}", ex.Message)); } }