Ejemplo n.º 1
0
 private void getlistWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         targetPlugin.GetList();
         foreach (BaseItem item in targetPlugin.Items)
         {
             getlistWorker.ReportProgress(1, item);
         }
     }
     catch (WebException)
     {
         getlistWorker.ReportProgress(100, "网络暂时不可用,可能是服务器忙,请稍后再试。\n" + helperMessage);
     }
     catch (FileNotFoundException)
     {
         getlistWorker.ReportProgress(2);
     }
     catch (Exception ex)
     {
         if (ex.Message.Equals("暂时不支持这种网址"))
         {
             getlistWorker.ReportProgress(100, "暂时不支持这种网址,换一个吧");
         }
         else
         {
             Askform.post("错误发生了", "输入为" + targetPlugin.Url + "\r\n错误类型为:" + ex.Message);
             getlistWorker.ReportProgress(100, ex.GetType() + " " + ex.Message + "\r\n" + helperMessage);
         }
     }
 }
Ejemplo n.º 2
0
 public void TestPost()
 {
     Askform.init("78e62f00-4fd5-49f0-ab06-7becd28250e7", 2);
     Assert.AreEqual("OK", Askform.post("test", "test2"));
 }
Ejemplo n.º 3
0
        private void GetVideoList_Click(object sender, EventArgs e)
        {
            String input = TargetUrl.Text.Trim();

            if (String.IsNullOrEmpty(input))
            {
                MessageBox.Show("请输入网址", "出错了", MessageBoxButtons.OK);
                return;
            }

            bool isVaild   = false;
            bool hasPlugin = false;

            targetPlugin = null;

            foreach (IPlugin plugin in AddinManager.GetExtensionObjects <IPlugin>())
            {
                hasPlugin = true;
                if (plugin.isVaild(input))
                {
                    isVaild = true;
                    if (targetPlugin == null)
                    {
                        targetPlugin = plugin;
                    }
                    else if (targetPlugin.GetVersionNumber() < plugin.GetVersionNumber())
                    {
                        targetPlugin = plugin;
                    }
                }
            }

            if (!hasPlugin)
            {
                MessageBox.Show("没有找到插件...\n请检查plugins目录是否存在或者重新下载程序", "出错了", MessageBoxButtons.OK);
                System.Diagnostics.Process.Start("http://vdhelper.sinaapp.com");
                return;
            }

            if (isVaild)
            {
                if (!getlistWorker.IsBusy)
                {
                    VideoInfoList.Items.Clear();
                    ChangeState(true);
                    MessageLabel.Text = "获取中...请等待";
                    getlistWorker.RunWorkerAsync();
                }
                else
                {
                    MessageBox.Show("上一个任务还没有完成,请等待", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                if (DialogResult.OK == MessageBox.Show("你输入的地址错误,请检查后重新输入\r\n如果不清楚要输入何种类型的网址,请点击确认访问http://vdhelper.sinaapp.com/support.html", "出错了", MessageBoxButtons.OKCancel))
                {
                    Askform.post("网址错误", input);
                    System.Diagnostics.Process.Start("http://vdhelper.sinaapp.com/Support?" + versionString);
                }
                TargetUrl.Text = string.Empty;
                TargetUrl.Focus();
            }
        }