static void SaveNewsPaper2(string connectionString, Newspaper newsPaper) { if (string.IsNullOrEmpty(connectionString)) { return; } if (newsPaper.ArticleTitle.StartsWith("AD.", true, System.Globalization.CultureInfo.CurrentCulture)) { log.Error("广告新闻不导入:" + newsPaper.ArticleTitle); return; } try { Regex regex = new Regex(@"<br\s*\/?>", RegexOptions.IgnoreCase); SqlParameter[] sqlParams = new SqlParameter[] { new SqlParameter("@ArticleTitle", regex.Replace(newsPaper.ArticleTitle, "")), //新闻标题 new SqlParameter("@ReporterName", newsPaper.Author), //专栏作家名称 new SqlParameter("@SourceName", newsPaper.Name), // 来源 new SqlParameter("@ArticleThumb", GetNewsThumb(newsPaper.Materials, newsPaper.PeriodDate.ToString("yyyyMMdd"))), //新闻封面图 new SqlParameter("@ArticleLength", GetBodyLength(newsPaper.Content)), //新闻长度,文字新闻=字数,图集=图片张数,视频=时长单位秒 new SqlParameter("@ArticleNotes", GetNewsNote(newsPaper.Content)), //编者按 new SqlParameter("@ArticleBody", removeEmptyStr(newsPaper.Content)), //新闻正文:如果是文字新闻 = 新闻正文 如果是图集 = 图集内图片json 如果是视频 = 视频播放地址 }; SqlHelper.ExecteNonQuery(connectionString, System.Data.CommandType.StoredProcedure, "Store_Articles_CreateImport", sqlParams); } catch (Exception e) { string dataSource = connectionString.Split(';')[0]; log.Error(string.Format("服务器:{0} 导入版面:{1} 时出错:{2}", dataSource, newsPaper.Edition, e.ToString())); Console.WriteLine(string.Format("服务器:{0} 导入版面:{1} 时出错:{2}", dataSource, newsPaper.Edition, e.ToString())); } }
static void SaveNewsPaper(string connectionString, Newspaper newsPaper) { if (string.IsNullOrEmpty(connectionString)) { return; } try { SqlParameter[] sqlParams = new SqlParameter[] { new SqlParameter("@NewsType", 1), // 新闻类型:1=文字新闻,2=图集,3=视频,5=文字新闻跳链,6=图集跳链,7=视频跳链,8=专题跳链,9=外链 new SqlParameter("@NewsTitle", newsPaper.ArticleTitle), //新闻标题 new SqlParameter("@TerminalID", 4), //产品端编号:1=一财新媒体APP,4=日报IPAD new SqlParameter("@ChannelRoot", GetChannelRootId(newsPaper.Edition)), //产品端栏目组编号 (如116 A叠) new SqlParameter("@ChannelID", GetSubChannelId(newsPaper.Edition)), //产品端子栏目编号 (如119 A01_第A01版:头版) new SqlParameter("@AdminID", Convert.ToInt32(ConfigurationManager.AppSettings["AdminId"])), //发布新闻的编辑ID:10197=胡志新 new SqlParameter("@AdminName", ConfigurationManager.AppSettings["AdminName"]), //发布新闻的编辑姓名:还是用胡志新吧 new SqlParameter("@Categorys", ""), //新闻领域,比如“钢铁、房地产、银行”等 new SqlParameter("@SourceName", newsPaper.Name), //来源媒体名称 new SqlParameter("@ExpertName", newsPaper.Author), //专栏作家名称 new SqlParameter("@ProgramName", ""), //细分的节目名称,如“谈股论金”,为了方便以后按节目汇总调取视频用 new SqlParameter("@NewsWeight", System.Data.SqlDbType.Int, 4), //权重 new SqlParameter("@NewsLength", GetBodyLength(newsPaper.Content)), //新闻长度,文字新闻=字数,图集=图片张数,视频=时长单位秒 new SqlParameter("@Tags", ""), //新闻特殊标签,如APP用到的“独家”特殊字样 new SqlParameter("@NewsSigns", newsPaper.Author), //新闻署名 new SqlParameter("@NewsNotes", GetNewsNote(newsPaper.Content)), //编者按 new SqlParameter("@NewsThumb", GetNewsThumb(newsPaper.Materials, newsPaper.PeriodDate.ToString("yyyyMMdd"))), //新闻封面图 new SqlParameter("@ThumbNotes", GetThumbNotes(newsPaper.Materials)), //新闻封面图图说,就是封面图配的文字 new SqlParameter("@NewsProvince", -1), //省份,默认 -1=未选择 new SqlParameter("@StockCode", ""), //股票代码,如“600123” new SqlParameter("@Keywords", ""), //关键字,如“我擦 牛叉”,用空格分割每个关键词 new SqlParameter("@NewsBody", removeEmptyStr(newsPaper.Content)), //新闻正文:如果是文字新闻 = 新闻正文 如果是图集 = 图集内图片json 如果是视频 = 视频播放地址 new SqlParameter("@NewsParaStr", ""), //备用字段,现在没用 new SqlParameter("@NewsParaInt", ""), //备用字段,现在没用 new SqlParameter("@OuterURL", ""), //外链地址,必须以http:// 开头,如果新闻有外链地址,那么在页面或APP打开新闻时会直接打开该地址访问 new SqlParameter("@PushState", System.Data.SqlDbType.Int, 4), //推送状态,暂时没用,默认=0即可 new SqlParameter("@IsPub", newsPaper.IsPublish == 2), //是否发布状态,即是否能被产品接口获取到 new SqlParameter("@PartnerID", 100), //100=第一财经 new SqlParameter("@EBookEvents", newsPaper.PeriodDate.ToString("yyyyMMdd")), //期次 new SqlParameter("@EBookParas", newsPaper.ArticleTitle.Contains("导读") ? "1" : "0") //电子报类型0:原始状态 1 导读 }; sqlParams[11].Value = 0; sqlParams[25].Value = 0; SqlHelper.ExecteNonQuery(connectionString, System.Data.CommandType.StoredProcedure, "Pub_News_ImportNews", sqlParams); //SqlHelper.ExecteNonQueryProducts("Pub_News_ImportNews", sqlParams); } catch (Exception e) { string dataSource = connectionString.Split(';')[0]; log.Error(string.Format("服务器:{0} 导入版面:{1} 时出错:{2}", dataSource, newsPaper.Edition, e.ToString())); Console.WriteLine(string.Format("服务器:{0} 导入版面:{1} 时出错:{2}", dataSource, newsPaper.Edition, e.ToString())); } }
static void SaveNewsPaper2(string connectionString, Newspaper newsPaper) { if (string.IsNullOrEmpty(connectionString)) { return; } if (newsPaper.ArticleTitle.StartsWith("AD.", true, System.Globalization.CultureInfo.CurrentCulture)) { log.Error("广告新闻不导入:" + newsPaper.ArticleTitle); return; } try { Regex regex = new Regex(@"<br\s*\/?>", RegexOptions.IgnoreCase); SqlParameter[] sqlParams = new SqlParameter[] { new SqlParameter("@ArticleTitle",regex.Replace(newsPaper.ArticleTitle,"")),//新闻标题 new SqlParameter("@ReporterName",newsPaper.Author),//专栏作家名称 new SqlParameter("@SourceName",newsPaper.Name),// 来源 new SqlParameter("@ArticleThumb",GetNewsThumb(newsPaper.Materials,newsPaper.PeriodDate.ToString("yyyyMMdd"))),//新闻封面图 new SqlParameter("@ArticleLength",GetBodyLength(newsPaper.Content)),//新闻长度,文字新闻=字数,图集=图片张数,视频=时长单位秒 new SqlParameter("@ArticleNotes",GetNewsNote(newsPaper.Content)),//编者按 new SqlParameter("@ArticleBody",removeEmptyStr(newsPaper.Content)),//新闻正文:如果是文字新闻 = 新闻正文 如果是图集 = 图集内图片json 如果是视频 = 视频播放地址 }; SqlHelper.ExecteNonQuery(connectionString, System.Data.CommandType.StoredProcedure, "Store_Articles_CreateImport", sqlParams); } catch (Exception e) { string dataSource = connectionString.Split(';')[0]; log.Error(string.Format("服务器:{0} 导入版面:{1} 时出错:{2}", dataSource, newsPaper.Edition, e.ToString())); Console.WriteLine(string.Format("服务器:{0} 导入版面:{1} 时出错:{2}", dataSource, newsPaper.Edition, e.ToString())); } }
static void SaveNewsPaper(string connectionString, Newspaper newsPaper) { if (string.IsNullOrEmpty(connectionString)) { return; } try { SqlParameter[] sqlParams = new SqlParameter[] { new SqlParameter("@NewsType",1),// 新闻类型:1=文字新闻,2=图集,3=视频,5=文字新闻跳链,6=图集跳链,7=视频跳链,8=专题跳链,9=外链 new SqlParameter("@NewsTitle",newsPaper.ArticleTitle),//新闻标题 new SqlParameter("@TerminalID",4),//产品端编号:1=一财新媒体APP,4=日报IPAD new SqlParameter("@ChannelRoot",GetChannelRootId(newsPaper.Edition)),//产品端栏目组编号 (如116 A叠) new SqlParameter("@ChannelID",GetSubChannelId(newsPaper.Edition)),//产品端子栏目编号 (如119 A01_第A01版:头版) new SqlParameter("@AdminID", Convert.ToInt32(ConfigurationManager.AppSettings["AdminId"])),//发布新闻的编辑ID:10197=胡志新 new SqlParameter("@AdminName",ConfigurationManager.AppSettings["AdminName"]),//发布新闻的编辑姓名:还是用胡志新吧 new SqlParameter("@Categorys",""),//新闻领域,比如“钢铁、房地产、银行”等 new SqlParameter("@SourceName",newsPaper.Name),//来源媒体名称 new SqlParameter("@ExpertName",newsPaper.Author),//专栏作家名称 new SqlParameter("@ProgramName",""),//细分的节目名称,如“谈股论金”,为了方便以后按节目汇总调取视频用 new SqlParameter("@NewsWeight",System.Data.SqlDbType.Int,4),//权重 new SqlParameter("@NewsLength", GetBodyLength(newsPaper.Content)),//新闻长度,文字新闻=字数,图集=图片张数,视频=时长单位秒 new SqlParameter("@Tags","") ,//新闻特殊标签,如APP用到的“独家”特殊字样 new SqlParameter("@NewsSigns",newsPaper.Author),//新闻署名 new SqlParameter("@NewsNotes",GetNewsNote(newsPaper.Content)),//编者按 new SqlParameter("@NewsThumb",GetNewsThumb(newsPaper.Materials,newsPaper.PeriodDate.ToString("yyyyMMdd"))),//新闻封面图 new SqlParameter("@ThumbNotes",GetThumbNotes(newsPaper.Materials)),//新闻封面图图说,就是封面图配的文字 new SqlParameter("@NewsProvince",-1),//省份,默认 -1=未选择 new SqlParameter("@StockCode",""),//股票代码,如“600123” new SqlParameter("@Keywords",""),//关键字,如“我擦 牛叉”,用空格分割每个关键词 new SqlParameter("@NewsBody",removeEmptyStr(newsPaper.Content)),//新闻正文:如果是文字新闻 = 新闻正文 如果是图集 = 图集内图片json 如果是视频 = 视频播放地址 new SqlParameter("@NewsParaStr",""),//备用字段,现在没用 new SqlParameter("@NewsParaInt",""),//备用字段,现在没用 new SqlParameter("@OuterURL",""),//外链地址,必须以http:// 开头,如果新闻有外链地址,那么在页面或APP打开新闻时会直接打开该地址访问 new SqlParameter("@PushState",System.Data.SqlDbType.Int,4),//推送状态,暂时没用,默认=0即可 new SqlParameter("@IsPub",newsPaper.IsPublish == 2),//是否发布状态,即是否能被产品接口获取到 new SqlParameter("@PartnerID",100),//100=第一财经 new SqlParameter("@EBookEvents",newsPaper.PeriodDate.ToString("yyyyMMdd")),//期次 new SqlParameter("@EBookParas",newsPaper.ArticleTitle.Contains("导读") ? "1" : "0")//电子报类型0:原始状态 1 导读 }; sqlParams[11].Value = 0; sqlParams[25].Value = 0; SqlHelper.ExecteNonQuery(connectionString, System.Data.CommandType.StoredProcedure, "Pub_News_ImportNews", sqlParams); //SqlHelper.ExecteNonQueryProducts("Pub_News_ImportNews", sqlParams); } catch (Exception e) { string dataSource = connectionString.Split(';')[0]; log.Error(string.Format("服务器:{0} 导入版面:{1} 时出错:{2}", dataSource, newsPaper.Edition, e.ToString())); Console.WriteLine(string.Format("服务器:{0} 导入版面:{1} 时出错:{2}", dataSource, newsPaper.Edition, e.ToString())); } }