Exemple #1
0
        public MonitorDataResponse RetriveClientIP(MonitorData data)
        {
            if (data == null)
                return null;

            //if (data.ExpectedOperator.StartsWith("中国"))
            //{
            //    data.ExpectedOperator = data.ExpectedOperator.Replace("中国", "");
            //}

            string postData = JSON.Serialize(data);
            MonitorDataResponse result = new MonitorDataResponse();
            try
            {
                string returnData = HttpCommunicatior.Post(Constants.CenterServerBaseUrl + "/apis/v1/monitordata", "POST", postData);

                result = JSON.Deserialize<MonitorDataResponse>(returnData);
                if (String.IsNullOrEmpty(result.RealOperator))
                {
                    result.RealOperator = "未知";
                }
                return result;
            }
            catch (WebException ex)
            {
                HttpWebResponse response = (HttpWebResponse)ex.Response;

                if (response != null && response.StatusCode == HttpStatusCode.Unauthorized)
                {
                    throw new Exception("无效的token或token已过期,请重新登录!");
                }
                else
                {
                    throw;
                }
            }
        }
Exemple #2
0
 private void SaveRetriveCondition(MonitorData data)
 {
     try
     {
         MonitorBiz biz = new MonitorBiz();
         biz.SaveRetriveConditionToLocal(data);
     }
     catch (Exception ex)
     {
     }
 }
Exemple #3
0
        public void SaveRetriveConditionToLocal(MonitorData data)
        {
            string serializedText = JSON.Serialize(data);

            if (String.IsNullOrEmpty(serializedText))
            {
                return;
            }

            DataManager.Save(Constants.SEPARATE_CHAR_CONDITION, serializedText);
        }
Exemple #4
0
        private void btnIPRetrive_Click(object sender, EventArgs e)
        {
            try
            {
                if (OnIPRetriveProgress != null)
                {
                    OnIPRetriveProgress(0);
                }
                //this.p2_lbl_progressStatus.Text = String.Format(_progessbarStatusDisplay, "检测本机出口IP");

                MonitorData data = new MonitorData();
                data.ClientRecordor = this.txtRecordor.Text.Trim();

                if ((this.cmbProvince1.SelectedItem as RegionModel).Code != "-1")
                {
                    data.ExpectedOperatorProvice = (this.cmbProvince1.SelectedItem as RegionModel).Name;
                }

                if ((this.cmbCity1.SelectedItem as RegionModel).Code != "-1")
                {
                    data.ExpectedOperatorCity = (this.cmbCity1.SelectedItem as RegionModel).Name;
                }

                if ((this.cmbProvince2.SelectedItem as RegionModel).Code != "-1")
                {
                    data.ClientProvince = (this.cmbProvince2.SelectedItem as RegionModel).Name;
                }

                if ((this.cmbCity2.SelectedItem as RegionModel).Code != "-1")
                {
                    data.ClientCity = (this.cmbCity2.SelectedItem as RegionModel).Name;
                }

                if ((this.cmbDistinct.SelectedItem as RegionModel).Code != "-1")
                {
                    data.ClientDistinct = (this.cmbDistinct.SelectedItem as RegionModel).Name;
                }

                data.ClientDetailAddress = this.txtDetailAddress.Text.Trim();

                if (cmbOperators.SelectedIndex == 4)
                {
                    data.ExpectedOperator = this.txtOperatorOther.Text.Trim();
                }
                else if (cmbOperators.SelectedIndex > 0)
                {
                    data.ExpectedOperator = this.cmbOperators.SelectedItem as string;
                }

                // client internal ip
                data.ClientPrivateIP = NetworkHelper.GetLocalIPAddress();

                // check required field
                bool inputRecorderInfo = false;
                bool inputOperatorInfo = false;
                bool inputClientAddress = false;

                if (!String.IsNullOrEmpty(data.ClientRecordor))
                {
                    inputRecorderInfo = true;
                }

                if (!String.IsNullOrEmpty(data.ExpectedOperatorProvice)
                   && !String.IsNullOrEmpty(data.ExpectedOperatorCity)
                   && !String.IsNullOrEmpty(data.ExpectedOperator))
                {
                    inputOperatorInfo = true;
                }

                if (!String.IsNullOrEmpty(data.ClientProvince)
                   && !String.IsNullOrEmpty(data.ClientCity)
                   && !String.IsNullOrEmpty(data.ClientDetailAddress))
                {
                    inputClientAddress = true;
                }

                // input is invalid
                if (!inputRecorderInfo || !inputOperatorInfo || !inputClientAddress)
                {
                    StringBuilder sbMessage = new StringBuilder();
                    if (!inputRecorderInfo)
                        sbMessage.Append("录入人");

                    if (!inputOperatorInfo)
                    {
                        if (sbMessage.Length > 0)
                        {
                            if (!inputClientAddress)
                            {
                                sbMessage.Append(",");
                            }
                            else
                            {
                                sbMessage.Append("和");
                            }
                        }

                        sbMessage.Append("所属宽带运营商");
                    }

                    if (!inputClientAddress)
                    {
                        if (sbMessage.Length > 0) sbMessage.Append("和");

                        sbMessage.Append("详细地址");
                    }

                    sbMessage.Insert(0, "请输入");
                    sbMessage.Append("信息。");
                    MessageBox.Show(sbMessage.ToString(), "警告");
                    return;
                }

                // save to local
                SaveRetriveCondition(data);

                // hide current panel and show ip retriving panel
                this.Panel_P2_IPRetriving.BringToFront();
                //this.Panel_P1_IPRetrive.Visible = false;
                //this.Panel_P2_IPRetriving.Visible = true;

                this.p2_progressBar.Visible = true;
                this.p2_lbl_progressStatus.Visible = true;
                this.p2_lbl_IsRetriving.Visible = true;
                this.p2_lbl_progress.Visible = true;
                this.ActiveControl = this.p2_label1;

                this.p2_btnSearchagain.Visible = false;
                this.p2_btnBack.Visible = false;
                this.p2_lblViewRouteDetail.Visible = false;

                // init UI data
                this.p2_lblProvice_text.Text = data.ExpectedOperatorProvice;
                this.p2_lblCity_text.Text = data.ExpectedOperatorCity;
                this.p2_lblISP_text.Text = data.ExpectedOperator;
                this.p2_lbl_ip.Text = "";
                this.p2_lbl_ipbelongto.Text = "";

                CurrentRouteItems.Clear();
                Thread t = new Thread(new ParameterizedThreadStart(RetriveHandleStatus));

                // parameter
                ObjectEntity objEntity = new ObjectEntity();
                objEntity.Data = data;
                objEntity.UIControl = this;
                t.Start(objEntity);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误");
            }
        }