コード例 #1
0
    protected void btn_save_Click(object sender, EventArgs e)
    {
        JsAdapter ja = new JsAdapter();

        if (pVld == null)
        {
            ja.ajaxAlert("缺少有效的代理配置", this);
        }
        else
        {
            try
            {
                sds_pxy_vld.InsertParameters["vld_name"].DefaultValue           = pVld.ValidationName;
                sds_pxy_vld.InsertParameters["vld_url"].DefaultValue            = pVld.ValidationUrl;
                sds_pxy_vld.InsertParameters["vld_request_method"].DefaultValue = pVld.ValidationRequestMethod;
                sds_pxy_vld.InsertParameters["vld_pass_regex"].DefaultValue     = pVld.PassRegex;
                sds_pxy_vld.InsertParameters["vld_timeout"].DefaultValue        = pVld.FailTimeout.ToString();
                sds_pxy_vld.InsertParameters["vld_attemps"].DefaultValue        = pVld.FailAttemps.ToString();
                sds_pxy_vld.InsertParameters["vld_status"].DefaultValue         = pVld.ValidationStatus.ToString();
                sds_pxy_vld.InsertParameters["vld_create_time"].DefaultValue    = pVld.CreateTime.ToString("yyyy-MM-dd HH:mm:ss");
                sds_pxy_vld.Insert();
                ja.ajaxAlert("保存成功", this);
            }
            catch (Exception ex)
            {
                ja.ajaxAlert("保存验证方式失败:" + ex.Message, this);
            }
        }
    }
コード例 #2
0
    protected void saveAlert(Exception ex = null)
    {
        JsAdapter ja = new JsAdapter();

        if (ex == null)
        {
            ja.ajaxAlert("保存成功", this);
        }
        else
        {
            ja.ajaxAlert("保存失败:" + ex.Message, this);
        }
    }
コード例 #3
0
    protected void fv_pxy_vld_ItemInserting(object sender, FormViewInsertEventArgs e)
    {
        JsAdapter       ja = new JsAdapter();
        ProxyValidation pv = new ProxyValidation();

        if (Session["currentPV"] != null)
        {
            pv = (ProxyValidation)Session["currentPV"];
        }
        if (string.IsNullOrEmpty(pv.ValidationName))
        {
            e.Cancel = true;
            ja.ajaxAlert("缺少有效的代理配置", this);
        }
    }
コード例 #4
0
    protected void btn_test_Click(object sender, EventArgs e)
    {
        JsAdapter ja = new JsAdapter();

        try
        {
            string name    = ((TextBox)fv_pxy_vld.FindControl("vld_name")).Text;
            string url     = ((TextBox)fv_pxy_vld.FindControl("vld_url")).Text;
            string method  = ((TextBox)fv_pxy_vld.FindControl("vld_request_method")).Text;
            string regex   = ((TextBox)fv_pxy_vld.FindControl("vld_pass_regex")).Text;
            int    timeout = int.Parse(((TextBox)fv_pxy_vld.FindControl("vld_timeout")).Text);
            int    attemps = int.Parse(((TextBox)fv_pxy_vld.FindControl("vld_attemps")).Text);
            int    status  = int.Parse(((TextBox)fv_pxy_vld.FindControl("vld_status")).Text);

            pVld = new ProxyValidation(name, url, method, regex, timeout, attemps, status, DateTime.Now);

            if (pVld.validateProxyServer())
            {
                ((Button)fv_pxy_vld.FindControl("btn_save")).Enabled = true;
                ja.ajaxAlert("测试成功", this);
            }
            else
            {
                ((Button)fv_pxy_vld.FindControl("btn_save")).Enabled = false;
                ja.ajaxAlert("测试失败,请检查配置", this);
            }
        }
        catch (Exception ex)
        {
            ja.ajaxAlert(ex.Message, this);
        }
        finally {
            if (fv_pxy_vld.CurrentMode == FormViewMode.Edit)
            {
                nav_1.Attributes.Add("class", "active");
                nav_2.Attributes.Remove("class");
            }
            if (fv_pxy_vld.CurrentMode == FormViewMode.Insert)
            {
                nav_2.Attributes.Add("class", "active");
                nav_1.Attributes.Remove("class");
            }
        }
    }
コード例 #5
0
ファイル: Main.cs プロジェクト: svn2github/autowikibrowser
        public MainForm()
        {
            DiffScriptingAdapter = new JsAdapter(this);

            Updater.UpdateUpdaterFile();

            SplashScreen.Show(this);
            RightToLeft = System.Globalization.CultureInfo.CurrentCulture.TextInfo.IsRightToLeft
                ? RightToLeft.Yes : RightToLeft.No;

            SplashScreen.SetProgress(1);

            InitializeComponent();

            SplashScreen.SetProgress(5);
            try
            {
                btntsShowHide.Image = Resources.Showhide;
                btntsShowHideParameters.Image = Resources.Showhideparameters;
                btntsSave.Image = Resources.Save;

                btntsIgnore.Image = Resources.RightArrow;
                btntsStop.Image = Resources.Stop;
                btntsPreview.Image = Resources.preview;
                btntsChanges.Image = Resources.changes;
                btntsFalsePositive.Image = Resources.RollBack;
                btntsStart.Image = Resources.Run;
                btntsDelete.Image = Resources.Vista_trashcan_empty;

                SplashScreen.SetProgress(10);
                try
                {
                    Parser = new Parsers(Properties.Settings.Default.StubMaxWordCount,
                                         Properties.Settings.Default.AddHummanKeyToCats);
                }
                catch (Exception ex)
                {
                    Parser = new Parsers();
                    ErrorHandler.Handle(ex);
                }

                addToWatchList.SelectedIndex = 3;
                cmboCategorise.SelectedIndex = 0;
                cmboImages.SelectedIndex = 0;

                listMaker.UserInputTextBox.ContextMenuStrip = mnuMakeFromTextBox;
                listMaker.BusyStateChanged += SetProgressBar;
                listMaker.NoOfArticlesChanged += UpdateButtons;
                listMaker.StatusTextChanged += UpdateListStatus;
                listMaker.cmboSourceSelect.SelectedIndexChanged += ListMakerSourceSelectHandler;

                TheSession = new Session(this);
                CreateEditor();

                Profiles = new WikiFunctions.Profiles.AWBProfilesForm(TheSession);
                Profiles.LoggedIn += ProfileLoggedIn;

                SplashScreen.SetProgress(15);

                _pasteMoreItems = new[]
                {
                    PasteMore1, PasteMore2, PasteMore3, PasteMore4, PasteMore5, PasteMore6, PasteMore7, PasteMore8, PasteMore9, PasteMore10
                };

                // to avoid saving to app data
                saveXML.InitialDirectory = openXML.InitialDirectory =
                    Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            }
            catch (Exception ex)
            {
                ErrorHandler.Handle(ex);
            }
        }
コード例 #6
0
    protected void btn_test_Click(object sender, EventArgs e)
    {
        JsAdapter ja = new JsAdapter();

        try
        {
            int      iptId;
            DateTime iptCTime;
            if (fv_pxy_src.CurrentMode == FormViewMode.Edit)
            {
                iptId    = int.Parse(((TextBox)fv_pxy_src.FindControl("iptId")).Text);
                iptCTime = Convert.ToDateTime(((TextBox)fv_pxy_src.FindControl("iptCTime")).Text);
            }
            else
            {
                iptId    = 0;
                iptCTime = DateTime.Now;
            }
            string iptName              = ((TextBox)fv_pxy_src.FindControl("iptName")).Text;
            int    iptCatheSize         = int.Parse(((TextBox)fv_pxy_src.FindControl("iptCatheSize")).Text);
            string iptUrl               = ((TextBox)fv_pxy_src.FindControl("iptUrl")).Text;
            string iptUrlPara           = ((TextBox)fv_pxy_src.FindControl("iptUrlPara")).Text;
            int    iptRequestTimeSpan   = int.Parse(((TextBox)fv_pxy_src.FindControl("iptRequestTimespan")).Text);
            int    iptRefreshTimeSpan   = int.Parse(((TextBox)fv_pxy_src.FindControl("iptRefreshTimeSpan")).Text);
            string iptCharset           = ((TextBox)fv_pxy_src.FindControl("iptCharset")).Text;
            string iptRequestMethod     = ((TextBox)fv_pxy_src.FindControl("iptRequestMethod")).Text;
            string iptDocType           = ((TextBox)fv_pxy_src.FindControl("iptDocType")).Text;
            string iptSrchType          = ((TextBox)fv_pxy_src.FindControl("iptSrchType")).Text;
            string iptUrlSrch           = ((TextBox)fv_pxy_src.FindControl("iptUrlSrch")).Text;
            string iptPortSrch          = ((TextBox)fv_pxy_src.FindControl("iptPortSrch")).Text;
            string iptProtocalSrch      = ((TextBox)fv_pxy_src.FindControl("iptProtocalSrch")).Text;
            string iptRequesrMethodSrch = ((TextBox)fv_pxy_src.FindControl("iptRequesrMethodSrch")).Text;
            string iptLocationSrch      = ((TextBox)fv_pxy_src.FindControl("iptLocationSrch")).Text;
            string iptTypeSrch          = ((TextBox)fv_pxy_src.FindControl("iptTypeSrch")).Text;
            string iptNameSrch          = ((TextBox)fv_pxy_src.FindControl("iptNameSrch")).Text;
            string iptPassSrch          = ((TextBox)fv_pxy_src.FindControl("iptPassSrch")).Text;
            string iptDomainSrch        = ((TextBox)fv_pxy_src.FindControl("iptDomainSrch")).Text;

            ProxySource ps = new ProxySource(iptName, iptCatheSize, iptUrl, iptUrlPara, iptRequestTimeSpan, iptRefreshTimeSpan, iptCharset, iptRequestMethod, iptDocType, iptSrchType, iptUrlSrch
                                             , iptPortSrch, iptProtocalSrch, iptRequesrMethodSrch, iptLocationSrch, iptTypeSrch, iptNameSrch, iptPassSrch, iptDomainSrch, iptCTime, iptId);

            List <ProxyServer> psList = ps.retrieveProxySource(false, false, false);

            Button svBtn = ((Button)fv_pxy_src.FindControl("btn_save"));
            svBtn.Enabled = false;
            if (psList.Count > 0)
            {
                ja.ajaxAlert("发现" + psList.Count.ToString() + "个代理服务器地址", this);
                string cnt = "";
                for (int i = 0; i < psList.Count; i++)
                {
                    cnt = cnt + "<p>" + (i + 1).ToString() + " - " + psList[i].ProxyIpAddress + ":" + psList[i].ProxyPort + "," + psList[i].ProxyProtocal + "," + psList[i].ProxyLocation + "<p>";
                }
                dv_testResult.InnerHtml = cnt;
                svBtn.Enabled           = true;
            }
            else
            {
                ja.ajaxAlert("未发现代理服务器地址", this);
                dv_testResult.InnerHtml = "";
            }
        }
        catch (Exception ex)
        {
            dv_testResult.InnerHtml = "";
            if (ex.InnerException != null)
            {
                ja.ajaxAlert(ex.Message + "\\n" + ex.InnerException.Message, this);
            }
            else
            {
                ja.ajaxAlert(ex.Message, this);
            }
        }
        finally
        {
            if (fv_pxy_src.CurrentMode == FormViewMode.Edit)
            {
                nav_1.Attributes.Add("class", "active");
                nav_2.Attributes.Remove("class");
            }
            if (fv_pxy_src.CurrentMode == FormViewMode.Insert)
            {
                nav_2.Attributes.Add("class", "active");
                nav_1.Attributes.Remove("class");
            }
        }
    }