Esempio n. 1
0
        public void OnUpdataUrlLog(UrlInfo urlinfo)
        {
            UrlInfo temp = DataHistoryOperate.GetInfo(urlinfo.PsnUrl);

            if (temp != null)
            {
                if (!string.IsNullOrEmpty(temp.ReplacePath) && !File.Exists(temp.ReplacePath))
                {
                    temp.ReplacePath = "";
                }
                urlinfo = temp;
            }

            this.UpdataUrl?.Invoke(this, new UpdataUrlEventArgs(urlinfo));
        }
Esempio n. 2
0
        public void AddUrl(UrlInfo urlinfo)
        {
            if (flp_log.InvokeRequired)
            {
                AddUrldelegate d = AddUrl;
                flp_log.Invoke(d, urlinfo);
            }
            else
            {
                if (AppConfig.Instance().Rule.Length <= 0)
                {
                    MessageBox.Show(_rm.GetString("rulealert"));
                    return;
                }
                if (!MonitorLog.RegexUrl(urlinfo.PsnUrl))
                {
                    return;
                }

                bool iscdn = urlinfo.IsCdn;
                if (_ctrls.Contains(urlinfo.PsnUrl))
                {
                    if (flp_log.Controls.ContainsKey((string)_ctrls[urlinfo.PsnUrl]))
                    {
                        urlinfo.MarkTxt =
                            ((UrlReplace)
                             flp_log.Controls.Find((string)_ctrls[urlinfo.PsnUrl], true).FirstOrDefault()).MarkTxt;
                        flp_log.Controls.RemoveByKey((string)_ctrls[urlinfo.PsnUrl]);
                        _ctrls.Remove(urlinfo.PsnUrl);
                    }
                    if (flp_lixian.Controls.ContainsKey((string)_ctrls[urlinfo.PsnUrl]))
                    {
                        urlinfo.MarkTxt =
                            ((UrlReplace)
                             flp_lixian.Controls.Find((string)_ctrls[urlinfo.PsnUrl], true).FirstOrDefault())
                            .MarkTxt;
                        flp_lixian.Controls.RemoveByKey((string)_ctrls[urlinfo.PsnUrl]);
                        _ctrls.Remove(urlinfo.PsnUrl);
                    }
                }


                UrlInfo temp = DataHistoryOperate.GetInfo(urlinfo.PsnUrl);
                if (temp != null)
                {
                    if (!string.IsNullOrEmpty(temp.ReplacePath) && !File.Exists(temp.ReplacePath))
                    {
                        temp.ReplacePath = "";
                    }
                    urlinfo = temp;
                }

                var u = new UrlReplace
                {
                    Name      = "url_replace" + (_lognum++).ToString(),
                    PsnUrl    = urlinfo.PsnUrl,
                    LocalPath =
                        String.IsNullOrEmpty(urlinfo.ReplacePath)
                                ? _rm.GetString("replacetip")
                                : urlinfo.ReplacePath,
                    LogTime   = DateTime.Now,
                    MarkTxt   = urlinfo.MarkTxt,
                    IsLixian  = urlinfo.IsLixian,
                    LixianUrl = urlinfo.LixianUrl,
                    IsCdn     = iscdn,
                    Host      = urlinfo.Host
                };
                u.ClickReplaceEvent += u_ClickReplaceEvent;
                u.NameTextChanged   += u_NameTextChanged;
                u.EnableLixian      += u_EnableLixian;
                u.DragDropFileto    += u_DragDropFileto;
                u.PingClick         += u_PingClick;
                u.SetLixian(AppConfig.Instance().EnableLixian);
                if (u.IsLixian)
                {
                    flp_lixian.Controls.Add(u);
                    var scrollp = new Point(0, flp_lixian.Height - flp_lixian.AutoScrollPosition.Y);
                    flp_lixian.AutoScrollPosition = scrollp;
                }
                else
                {
                    flp_log.Controls.Add(u);
                    var scrollp = new Point(0, flp_log.Height - flp_log.AutoScrollPosition.Y);
                    flp_log.AutoScrollPosition = scrollp;
                }
                tab_lixian.Text = _rm.GetString("tab_lixian.Text") + "(" + flp_lixian.Controls.Count.ToString() +
                                  ")";
                tabPage_log.Text = _rm.GetString("tabPage_log.Text") + "(" + flp_log.Controls.Count.ToString() + ")";
                if (!_ctrls.ContainsKey(urlinfo.PsnUrl))
                {
                    _ctrls.Add(urlinfo.PsnUrl, u.Name);
                }
            }
        }