Exemple #1
0
 public static string GetIP()
 {
     try
     {
         if (strIP != string.Empty)
         {
             return(strIP);
         }
         IPAddress[] hostAddresses = Dns.GetHostAddresses(Dns.GetHostName());
         if (hostAddresses.Length > 0)
         {
             strIP = hostAddresses[0].ToString();
             return(strIP);
         }
         return(string.Empty);
     }
     catch (Exception exception)
     {
         Logger.e(exception.Message);
         return("0");
     }
 }
Exemple #2
0
 public static int PraseConnect(string strContent, int iLen, int iFlag)
 {
     try
     {
         Dictionary <string, object> dictionary = Json.Deserialize(strContent) as Dictionary <string, object>;
         if (dictionary.ContainsKey("iPdrLibRet"))
         {
             int num  = Convert.ToInt32(dictionary["iPdrLibRet"] as string);
             int num2 = -1;
             if (dictionary.ContainsKey("ret"))
             {
                 num2 = Convert.ToInt32(dictionary["ret"] as string);
             }
             if (num == 0)
             {
                 strCloudConfigInfo = strContent;
                 if (dictionary.ContainsKey("isDebug"))
                 {
                     string str = dictionary["isDebug"] as string;
                     if (str.Equals("1"))
                     {
                         Logger.INEED_LOG_TEXT = 1;
                     }
                     else
                     {
                         Logger.INEED_LOG_TEXT = 0;
                     }
                 }
                 if (dictionary.ContainsKey("log_level"))
                 {
                     string s      = dictionary["log_level"] as string;
                     int    result = 0;
                     int.TryParse(s, out result);
                     Logger.LOG_LEVEL = result;
                 }
                 if (dictionary.ContainsKey("isNetLog"))
                 {
                     string str3 = dictionary["isNetLog"] as string;
                     if (str3 == "1")
                     {
                         Configer.strSendLogFlag = "1";
                     }
                     else
                     {
                         Configer.strSendLogFlag = "0";
                     }
                 }
                 if (dictionary.ContainsKey("totalSwitch"))
                 {
                     Logger.d("ret:" + num2.ToString());
                     if (((num2 != 0) && (num2 != 1)) && (num2 != 2))
                     {
                         Logger.LogNetError(0x3f1, "cgi return exception:" + dictionary["ret"].ToString());
                     }
                     else
                     {
                         Logger.d("cgi return: " + num2.ToString());
                     }
                     if (dictionary.ContainsKey("curr_lua_dir") && (dictionary["curr_lua_dir"].ToString() != string.Empty))
                     {
                         Configer.m_CurHotUpdatePath = dictionary["curr_lua_dir"].ToString();
                         if (Configer.m_CurHotUpdatePath != string.Empty)
                         {
                             Configer.m_CurHotUpdatePath = Configer.m_CurHotUpdatePath + "/res/";
                         }
                         Logger.d("m_CurHotUpdatePath:" + Configer.m_CurHotUpdatePath);
                     }
                     string strCurState = string.Empty;
                     string strFile     = string.Empty;
                     if (dictionary.ContainsKey("filelist"))
                     {
                         strCurState = dictionary["filelist"].ToString();
                     }
                     if (dictionary.ContainsKey("filename"))
                     {
                         strFile = dictionary["filename"].ToString();
                     }
                     if (dictionary.ContainsKey("lua_newversion"))
                     {
                         int curTimestamp;
                         if (!int.TryParse(dictionary["lua_newversion"].ToString(), out curTimestamp))
                         {
                             Logger.d("云端lua_newversion获取不成功,使用时间戳为版本号:" + dictionary["lua_newversion"].ToString());
                             curTimestamp = DateUtils.GetCurTimestamp();
                         }
                         ResourceManager.iLuaVer = curTimestamp;
                     }
                     else if (ResourceManager.iLuaVer == 1)
                     {
                         Logger.d("use time ver");
                         ResourceManager.iLuaVer = DateUtils.GetCurTimestamp();
                     }
                     string strConfigInfo = string.Empty;
                     if (dictionary.ContainsKey("dependency"))
                     {
                         strConfigInfo = dictionary["dependency"].ToString();
                     }
                     Configer.strCtrFlagTotalSwitch = dictionary["totalSwitch"] as string;
                     if (Configer.strCtrFlagTotalSwitch.Equals("1"))
                     {
                         if ((dictionary["ret"].ToString() == "1") || (dictionary["ret"].ToString() == "2"))
                         {
                             Logger.d("初始化下载列表");
                             GetInstance().increaceUpdate.SetUpdateInfo(strConfigInfo, strCurState);
                         }
                         if (dictionary["ret"].ToString() == "0")
                         {
                             Logger.d("下载成功回调:" + strFile);
                             GetInstance().increaceUpdate.AddDownSuccFile(strFile);
                         }
                     }
                 }
                 else
                 {
                     Logger.d("totalSwitch no data");
                 }
             }
             else
             {
                 Logger.d("connect iRet:" + num.ToString());
             }
         }
         else
         {
             Logger.d("no para iPdrLibRet");
         }
     }
     catch (Exception exception)
     {
         Logger.e("connect fail,retry:" + exception.ToString());
     }
     return(0);
 }