示例#1
0
        private void ProcessQuerySpecialLicense(JsonObject json)
        {
            try
            {
                if (json[LicDefines.KEYWORD_MSG_COMMON_DATA] != null)
                {
                    if (json[LicDefines.KEYWORD_MSG_COMMON_DATA][LicDefines.KEYWORD_MSG_SERVER_LICPOOL_FREE] != null)
                    {
                        var
                            lics = json[LicDefines.KEYWORD_MSG_COMMON_DATA][LicDefines.KEYWORD_MSG_SERVER_LICPOOL_FREE];
                        for (int i = 0; i < lics.Count; i++)
                        {
                            var lic = lics[i];

                            var temp = new License();
                            temp.SerialNo   = (long)lic[LicDefines.KEYWORD_MSG_LICENSE_LICENSEID].Number;
                            temp.Name       = lic[LicDefines.KEYWORD_MSG_LICENSE_DISPLAY].Value;
                            temp.Type       = (LicOwnerType)(int)lic[LicDefines.KEYWORD_MSG_LICENSE_OWNERTYPE].Number;
                            temp.DataType   = (LicDataType)(int)lic[LicDefines.KEYWORD_MSG_LICENSE_VALUETYPE].Number;
                            temp.Expiration = lic[LicDefines.KEYWORD_MSG_LICENSE_EXPIRATION].Value;
                            temp.MajorID    = (int)lic[LicDefines.KEYWORD_MSG_LICENSE_MODULEMARJORTYPEID].Number;
                            temp.MinorID    = (int)lic[LicDefines.KEYWORD_MSG_LICENSE_MODULEMINJORTYPEID].Number;
                            temp.Value      = lic[LicDefines.KEYWORD_MSG_LICENSE_VALUE].Value;

                            AppendMessage(string.Format("QueryResult Free: {0}", temp));
                        }
                    }
                    if (json[LicDefines.KEYWORD_MSG_COMMON_DATA][LicDefines.KEYWORD_MSG_SERVER_LICPOOL_TOTAL] != null)
                    {
                        var
                            lics = json[LicDefines.KEYWORD_MSG_COMMON_DATA][LicDefines.KEYWORD_MSG_SERVER_LICPOOL_TOTAL];
                        for (int i = 0; i < lics.Count; i++)
                        {
                            var lic = lics[i];

                            var temp = new License();
                            temp.SerialNo   = (long)lic[LicDefines.KEYWORD_MSG_LICENSE_LICENSEID].Number;
                            temp.Name       = lic[LicDefines.KEYWORD_MSG_LICENSE_DISPLAY].Value;
                            temp.Type       = (LicOwnerType)(int)lic[LicDefines.KEYWORD_MSG_LICENSE_OWNERTYPE].Number;
                            temp.DataType   = (LicDataType)(int)lic[LicDefines.KEYWORD_MSG_LICENSE_VALUETYPE].Number;
                            temp.Expiration = lic[LicDefines.KEYWORD_MSG_LICENSE_EXPIRATION].Value;
                            temp.MajorID    = (int)lic[LicDefines.KEYWORD_MSG_LICENSE_MODULEMARJORTYPEID].Number;
                            temp.MinorID    = (int)lic[LicDefines.KEYWORD_MSG_LICENSE_MODULEMINJORTYPEID].Number;
                            temp.Value      = lic[LicDefines.KEYWORD_MSG_LICENSE_VALUE].Value;

                            AppendMessage(string.Format("QueryResult Total: {0}", temp));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                AppendMessage(string.Format("ProcessQuerySpecial fail.\t{0}", ex.Message));
            }
        }
示例#2
0
        void BtnGetLic_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                List <License> listLicenses = new List <License>();
                License        lic          = new License();
                lic.Name         = "UserNumber";
                lic.SerialNo     = 1100001;
                lic.Expiration   = LicDefines.KEYWORD_LICENSE_EXPIRATION_UNLIMITED;
                lic.Type         = LicOwnerType.Mono;
                lic.DataType     = LicDataType.Number;
                lic.MajorID      = 0;
                lic.MinorID      = 1;
                lic.RequestValue = "100";
                lic.Value        = "0";
                listLicenses.Add(lic);
                lic              = new License();
                lic.Name         = "OnlineUserNumber";
                lic.SerialNo     = 1100002;
                lic.Expiration   = LicDefines.KEYWORD_LICENSE_EXPIRATION_UNLIMITED;
                lic.Type         = LicOwnerType.Mono;
                lic.DataType     = LicDataType.Number;
                lic.MajorID      = 0;
                lic.MinorID      = 1;
                lic.RequestValue = "1000";
                lic.Value        = "0";
                listLicenses.Add(lic);

                if (mLicHelper != null)
                {
                    mLicHelper.Stop();
                    mLicHelper = null;
                }
                mLicHelper                 = new LicenseHelper();
                mLicHelper.Debug          += (mode, cat, msg) => AppendMessage(string.Format("{0}\t{1}", cat, msg));
                mLicHelper.LicInfoChanged += mLicHelper_LicInfoChanged;
                mLicHelper.Host            = "192.168.4.182";
                mLicHelper.Port            = 3070;
                mLicHelper.ClearLicense();
                for (int i = 0; i < listLicenses.Count; i++)
                {
                    mLicHelper.ListLicenses.Add(listLicenses[i]);
                }
                mLicHelper.Start();
                AppendMessage("End");
            }
            catch (Exception ex)
            {
                AppendMessage(string.Format("Fail.\t{0}", ex.Message));
            }
        }
示例#3
0
 private void CreatePropertyView(JsonProperty jsonProperty)
 {
     try
     {
         mListProperties.Clear();
         if (jsonProperty != null && jsonProperty.GetValue() != null)
         {
             var lics = jsonProperty;
             for (int i = 0; i < lics.Count; i++)
             {
                 var     lic     = lics[i];
                 License license = new License();
                 license.SerialNo   = (long)lic[LicDefines.KEYWORD_MSG_LICENSE_LICENSEID].Number;
                 license.Name       = lic[LicDefines.KEYWORD_MSG_LICENSE_DISPLAY].Value;
                 license.Expiration = lic[LicDefines.KEYWORD_MSG_LICENSE_EXPIRATION].Value;
                 license.MajorID    =
                     (int)lic[LicDefines.KEYWORD_MSG_LICENSE_MODULEMARJORTYPEID].Number;
                 license.MinorID =
                     (int)lic[LicDefines.KEYWORD_MSG_LICENSE_MODULEMINJORTYPEID].Number;
                 license.Type =
                     (LicOwnerType)
                     (int)lic[LicDefines.KEYWORD_MSG_LICENSE_OWNERTYPE].Number;
                 license.Value    = lic[LicDefines.KEYWORD_MSG_LICENSE_VALUE].Value;
                 license.DataType =
                     (LicDataType)(int)lic[LicDefines.KEYWORD_MSG_LICENSE_VALUETYPE].Number;
                 PropertyViewItem propItem = new PropertyViewItem();
                 propItem.Name       = license.Name;
                 propItem.SerialNo   = license.SerialNo.ToString();
                 propItem.LicType    = license.Type == LicOwnerType.Mono ? "Mono" : "Share";
                 propItem.Catetory   = propItem.LicType;
                 propItem.Expiration = license.Expiration;
                 propItem.Value      = license.Value;
                 propItem.MajorID    = license.MajorID.ToString();
                 propItem.MinorID    = license.MinorID.ToString();
                 propItem.Data       = license;
                 mListProperties.Add(propItem);
             }
         }
     }
     catch (Exception ex)
     {
         ShowErrorMessage(ex.Message);
     }
 }
示例#4
0
        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));
            }
        }