Exemplo n.º 1
0
        // 点击 测试发布按钮
        private void btnPubTest_Click(object sender, EventArgs e)
        {
            tabctrPubform.SelectedTab = tabPubTest;
            setVarValue();  //先将变量中的值更新成当前控件中的值
            bool validateResult = validatePubConfig();

            if (!validateResult)
            {
                MessageBox.Show("必填项未填写完整或未填写正确,请检查表达是否填写完整并正确填写!");
            }
            else
            {
                int      coTypeid          = int.Parse(_coTypeid);
                int      pubTypeid         = int.Parse(_pubTypeid);
                string[] pubFilterKeywords = new string[0];
                if (_pubFilterKeywords != "")
                {
                    pubFilterKeywords = _pubFilterKeywords.Split('|');
                }
                //测试发布一篇文章
                ArticlePublish articlePublishTest = new ArticlePublish(_pubID, _coConnString, _pubConnString, _pubTablePrename, coTypeid, pubTypeid, 1, pubFilterKeywords, _randomDateStart, _randomDateStop);
                cancelTokenSource = new CancellationTokenSource();
                articlePublishTest.CancelTokenSource = cancelTokenSource;
                articlePublishTest.ProcessPublishArticles();
                long aid          = articlePublishTest.LastExportedCoid;
                long cmsAid       = articlePublishTest.LastExportedCmsid;
                int  exportedNums = articlePublishTest.CurrentExportedArticles;
                if (aid == -1 || cmsAid == -1)
                {
                    Exception cancelException = articlePublishTest.CancelException;
                    if (cancelException != null)
                    {
                        tboxPubTestResult.AppendText(cancelException.Message + "\n");
                        if (cancelException.Data != null)
                        {
                            foreach (DictionaryEntry de in cancelException.Data)
                            {
                                tboxPubTestResult.AppendText(string.Format("{0} :  {1} \n", de.Key, de.Value));
                            }
                        }
                    }
                    List <Exception> listException = articlePublishTest.PubException;
                    if (listException.Count > 0)
                    {
                        foreach (Exception item in listException)
                        {
                            tboxPubTestResult.AppendText(item.Message + "\n");
                            if (item.Data != null)
                            {
                                foreach (DictionaryEntry de  in item.Data)
                                {
                                    tboxPubTestResult.AppendText(string.Format("{0} :  {1} \n", de.Key, de.Value));
                                }
                            }
                        }
                    }
                }
                else
                {
                    tboxPubTestResult.AppendText(string.Format("发布文章成功! 采集文章ID是:{0}  CMS文章ID是:{1} \n", aid, cmsAid));
                    tboxPubTestResult.AppendText(string.Format("此次发布数量:{0}\n", exportedNums));
                    updatePublishState(articlePublishTest);
                    printErrors(articlePublishTest);
                }
            }
        }
Exemplo n.º 2
0
 private ArticlePublish ProcessPublishArticles(ArticlePublish articlePublish)
 {
     articlePublish.ProcessPublishArticles();
     return(articlePublish);
 }