private void SendArticleContent(WebSiteHelper model, string Title, string Content, string ClassName, string ClassID) { ModelWebSite = model; try { LoadPublishModule(ModelWebSite.PublishName); if (iPublish != null) { //OutFalseOriginal(ref Title, ref Content); Title = Title.Replace("'", "''"); Content = Content.Replace("'", "''"); mGatherItem = new ModelGatherItem(); mGatherItem.Title = Title; mGatherItem.Content = Content; mClassList = new ModelClassItem(); mClassList.ClassID = ClassID; mClassList.ClassName = ClassName; iPublish.Publish_OutResult = OPR_SendData; iPublish.Publish_Init(ModelWebSite.WebSiteUrl, ModelWebSite.WebSiteLoginUrl, ModelWebSite.LoginUserName, ModelWebSite.LoginUserPwd, 0, string.Empty); iPublish.Publish_Type = PublishType.PostData; iPublish.Publish_PostData(mGatherItem, mClassList); } else { MeOutPut.Message = string.Format("插件不存在!或者插件有误!"); if (PublishOP != null) { PublishOP(this, MeOutPut); } } } catch (Exception ex) { MeOutPut.Message = string.Format("网站名称:{0} 网站地址:{1} 信息:{2} 发布失败!", ModelWebSite.WebSiteName, ModelWebSite.WebSiteUrl, ex.Message); if (PublishOP != null) { PublishOP(this, MeOutPut); } } }
private void WorkMethod(int taskindex, int threadindex) { string Title = string.Empty, Content = string.Empty; StringBuilder sbContent = new StringBuilder(); if (Model != null) { IPublish iPublish = Utility.GetIPublishByName(Model.PublishName); iPublish.Publish_Init(Model.WebSiteUrl, Model.WebSiteLoginUrl, Model.LoginUserName, Model.LoginUserPwd, 0, string.Empty); iPublish.Publish_OutResult = OPR_SendData; string[] files = Directory.GetFiles(Model.FileSourcePath, "*.html"); int lLen = files.Length; for (int i = 0; i < lLen; i++) { if (IsOpen) { IsOpen = false; try { string file = files[i]; FileInfo fiFile = new FileInfo(file); Title = fiFile.Name.Replace(fiFile.Extension, ""); int l = fiFile.Name.LastIndexOf("_"); if (l > -1) { Title = Title.Substring(0, l); } StreamReader sr = new StreamReader(file, Encoding.Default); sbContent.Append(sr.ReadToEnd()); sr.Close(); if (sbContent.Length >= 300) { //发布文章 ModelGatherItem mGatherItem = new ModelGatherItem(); mGatherItem.Title = Title; mGatherItem.Content = sbContent.ToString(); ModelClassItem mClassList = new ModelClassItem(); mClassList.ClassID = "1"; mClassList.ClassName = "美容知识"; iPublish.Publish_PostData(mGatherItem, mClassList); } sbContent.Remove(0, sbContent.Length); // File.Delete(file); Thread.Sleep(1000);//这个可以自定义时间 } catch (Exception ex) { Log4Helper.Write(LogLevel.Error, "文件发布错误!", ex); continue; } } else { Thread.Sleep(5000); } } } }