Ejemplo n.º 1
0
        private void RecvData(IntPtr ptr)
        {
            this.DNS_LOG_INFO("recv data from DNS server");
            DnResult result = (DnResult)Marshal.PtrToStructure(ptr, typeof(DnResult));

            if (result.domainName.Length != 0)
            {
                if (this.callbackObjectDic.ContainsKey(result.domainName))
                {
                    this.DNS_LOG_INFO(string.Format("recive domainName is [{0}]", result.domainName));
                    this.ParseRecvData(result);
                }
                else
                {
                    this.DNS_LOG_ERROR(string.Format("no such domainName[{0}] in callback object dictionary", result.domainName));
                    this.mErrCode   = DNSErrCode.DNS_INPUT_PARAM_ERROR;
                    this.mErrString = "no domainName's delegate function in callback object dictionary";
                }
            }
            else
            {
                this.DNS_LOG_ERROR("the result domainName is empty");
                this.mErrCode   = DNSErrCode.DNS_INPUT_PARAM_ERROR;
                this.mErrString = "the result domainName is empty";
            }
        }
Ejemplo n.º 2
0
        private void ParseRecvData(DnResult result)
        {
            QueryValue value2;

            this.DNS_LOG_INFO("ParseRecvData begin");
            value2.errCode   = 0L;
            value2.errString = "no error";
            value2.value     = new ListView <DnValue>();
            foreach (KeyValuePair <string, QueryValue> pair in this.mInitDomainNameMap)
            {
                if (pair.Key == result.domainName)
                {
                    QueryValue value3 = pair.Value;
                    if (value3.value.Count != 0)
                    {
                        foreach (DnValue value4 in value3.value)
                        {
                            value2.value.Add(value4);
                        }
                    }
                }
            }
            if (result.errCode == 0)
            {
                this.DNS_LOG_INFO("result is success");
                if (this.ParseJsonValue(ref result.value, ref value2) == DNSErrCode.DNS_NO_ERROR)
                {
                    this.DNS_LOG_INFO("json parse success");
                }
                else
                {
                    this.DNS_LOG_ERROR("parse json date return from DNS server error");
                    this.mErrCode   = DNSErrCode.DNS_JSON_PARSE_ERROR;
                    this.mErrString = "parse json date return from DNS server error";
                    if (value2.value.Count == 0)
                    {
                        value2.errCode   = 0x452L;
                        value2.errString = "json parse error";
                    }
                }
            }
            else
            {
                this.DNS_LOG_ERROR("result is failed");
                this.mErrCode = dns_GetErrorCode(base.ObjectId);
                IntPtr ptr = dns_GetErrorString(base.ObjectId);
                this.mErrString = Marshal.PtrToStringAnsi(ptr);
                if (value2.value.Count == 0)
                {
                    value2.errCode   = result.errCode;
                    value2.errString = result.errString;
                }
                char[] separator = new char[] { '|' };
                foreach (string str in result.domainName.Split(separator))
                {
                    DnValue value5;
                    value5.errCode    = result.errCode;
                    value5.errString  = result.errString;
                    value5.domainName = str;
                    value5.IPList     = new List <string>();
                    value2.value.Add(value5);
                    if (0 < this.mUploadeDomainName.Length)
                    {
                        this.mUploadeDomainName = this.mUploadeDomainName + ":" + str + "_0";
                    }
                    else
                    {
                        this.mUploadeDomainName = this.mUploadeDomainName + str + "_0";
                    }
                }
            }
            foreach (KeyValuePair <string, ListView <ProcessQueryResult> > pair2 in this.callbackObjectDic)
            {
                if (pair2.Key == result.domainName)
                {
                    ListView <ProcessQueryResult> view = pair2.Value;
                    if (view.Count != 0)
                    {
                        this.DNS_LOG_INFO(string.Format("process delegate function for domainNames[{0}]", result.domainName));
                        ProcessQueryResult result2 = view[0];
                        this.UploadStatisticData();
                        result2(value2);
                        view.RemoveAt(0);
                        if (view.Count == 0)
                        {
                            this.mInitDomainNameMap.Remove(result.domainName);
                            this.callbackObjectDic.Remove(result.domainName);
                        }
                    }
                    else
                    {
                        this.DNS_LOG_INFO(string.Format("no delegate function for domainName[{0}]", result.domainName));
                        this.mErrCode   = DNSErrCode.DNS_HANDLE_FAILED;
                        this.mErrString = "no delegate function for domainName";
                    }
                    return;
                }
            }
            this.DNS_LOG_INFO(string.Format("no such domainName[{0}] in dictionary", result.domainName));
            this.mErrCode   = DNSErrCode.DNS_HANDLE_FAILED;
            this.mErrString = "no such domainName in dictionary";
        }