private int AddNewstoDB(NewsModels newsModels, string dateTimeStr, string jsonStr, string cid, string cName, string type)
{
bool flag = false;
string errorMessage = string.Empty;
int num = 0;
int num2 = 0;
int num3 = 1;
foreach (NewsModel model in newsModels.news)
{
model.title = HttpHelper.GetHtmlTxt(model.title).Replace("br", ",");
if (string.IsNullOrEmpty(model.title))
{
base.BeginInvoke(this.logInvoke, new object[] { $"取消当前新闻插入:{"标题信息为空"}" });
flag = true;
errorMessage = "标题信息为空";
}
else
{
string str2;
string str3;
string str4;
int num4;
if ((cid.Equals("20") || cid.Equals("21")) || cid.Equals("22"))
{
if (string.IsNullOrEmpty(model.url))
{
goto Label_042F;
}
if (string.IsNullOrEmpty(model.photo))
{
model.photo = "http://es.whu.edu.cn/hbjc/image/noImage.png";
}
model.content = $"<img src="{model.photo}" title="{model.url}" />";
num3 = 3;
}
else
{
this.ParseImage(model);
}
if (string.IsNullOrEmpty(model.content))
{
if (string.IsNullOrEmpty(model.url))
{
goto Label_042F;
}
model.content = $"<head> <meta http-equiv="refresh" content="0;{model.url}"> </head>";
}
if (type.Contains("Normal"))
{
str2 = "select count(*) from articleInfo where sid =@sid and cid=@cid";
str3 = "UPDATE [articleInfo] SET [articleTitle] = @articleTitle, [articleContent] = @articleContent, [articleType] = @articleType, [cid] = @cid, [articleTime] = @articleTime, [articleAuthor] = @articleAuthor, [uid] = @uid, [articleSource]= @articleSource, [sid] = @sid WHERE sid =@sid and cid=@cid";
str4 = "INSERT INTO [articleInfo] ([articleTitle],[articleContent],[articleType],[cid],[articleTime],[articleAuthor],[uid],[articleSource],[sid]) VALUES(@articleTitle,@articleContent,@articleType,@cid,@articleTime,@articleAuthor,@uid,@articleSource,@sid)";
}
else
{
str2 = "select count(*) from subArticle where sid =@sid and cid=@cid";
str3 = "UPDATE [subArticle] SET [articleTitle] = @articleTitle, [articleContent] = @articleContent, [articleType] = @articleType, [cid] = @cid, [articleTime] = @articleTime, [articleAuthor] = @articleAuthor, [uid] = @uid, [articleSource]= @articleSource, [sid] = @sid WHERE sid =@sid and cid=@cid";
str4 = "INSERT INTO [subArticle] ([articleTitle],[articleContent],[articleType],[cid],[articleTime],[articleAuthor],[uid],[articleSource],[sid]) VALUES(@articleTitle,@articleContent,@articleType,@cid,@articleTime,@articleAuthor,@uid,@articleSource,@sid)";
}
object obj2 = SqlHelper.ExecuteScalar(str2, CommandType.Text, new SqlParameter[] { new SqlParameter("@cid", cid), new SqlParameter("@sid", model.id) });
try
{
num4 = Convert.ToInt32(obj2);
}
catch (Exception)
{
num4 = 1;
}
if (num4 > 0)
{
try
{
SqlHelper.ExecuteNonQuery(str3, CommandType.Text, new SqlParameter[] { new SqlParameter("@articleTitle", model.title), new SqlParameter("@articleContent", model.content), new SqlParameter("@articleType", num3), new SqlParameter("@cid", cid), new SqlParameter("@articleTime", Convert.ToDateTime(model.date)), new SqlParameter("@articleAuthor", model.author), new SqlParameter("@uid", 0x3e8), new SqlParameter("@articleSource", model.from), new SqlParameter("@sid", model.id) });
num2++;
goto Label_042F;
}
catch (Exception exception)
{
base.BeginInvoke(this.logInvoke, new object[] { $"更新数据库出现异常:{exception.Message}" });
this.WriteException(exception);
this.WriteErrorNewsJsonFile(exception.Message, dateTimeStr, jsonStr, cid, cName);
goto Label_042F;
}
}
try
{
SqlHelper.ExecuteNonQuery(str4, CommandType.Text, new SqlParameter[] { new SqlParameter("@articleTitle", model.title), new SqlParameter("@articleContent", model.content), new SqlParameter("@articleType", num3), new SqlParameter("@cid", cid), new SqlParameter("@articleTime", Convert.ToDateTime(model.date)), new SqlParameter("@articleAuthor", model.author), new SqlParameter("@uid", 0x3e8), new SqlParameter("@articleSource", model.from), new SqlParameter("@sid", model.id) });
num++;
}
catch (Exception exception2)
{
base.BeginInvoke(this.logInvoke, new object[] { $"插入数据库出现异常:{exception2.Message}" });
this.WriteException(exception2);
this.WriteErrorNewsJsonFile(exception2.Message, dateTimeStr, jsonStr, cid, cName);
}
Label_042F:;
}
}
if (flag)
{
this.WriteErrorNewsJsonFile(errorMessage, dateTimeStr, jsonStr, cid, cName);
}
base.BeginInvoke(this.logInvoke, new object[] { $"[ {cid}.{cName} ] 新增 {num} 条 , 更新 {num2} 条" });
return num;
}

check的更多相关文章

  1. -Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HO 解决办法

    最近在使用maven,项目测试的时候出现了这么一个错.-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2 ...

  2. SQL Server 合并复制遇到identity range check报错的解决

        最近帮一个客户搭建跨洋的合并复制,由于数据库非常大,跨洋网络条件不稳定,因此只能通过备份初始化,在初始化完成后向海外订阅端插入数据时发现报出如下错误: Msg 548, Level 16, S ...

  3. SharePoint 2103 Check user permission on list

    一.需求: check user 对SharePoint list 的permission 代码如下: private static string GetListPermission(SPList l ...

  4. 用SVN check out项目后第三方库丢失

    曾经用Cornerstone check out 一份项目下来,但其中第三方.a库始终丢失,项目报错,研究后找到了以下解决方法: 首先,Xcode默认忽略.a 文件.所以无法提交到svn服务器,但是很 ...

  5. SQL Check

    一款实时性能监测工具 SQL Check? 一款实时监测SQL数据库性能.实时排查的问题的免费工具. 可以实时监测20个左右的SQL关键性能指标,每个指标都已图形化动态直播形式展现. 适合DBA.数据 ...

  6. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' heade

    XMLHttpRequest cannot load http://10.164.153.37:8050/WebService/WebService.asmx/wsGetStreetData. Res ...

  7. check用户协议

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. check time period

    /**     * @author etao     * @description check last time selected     * @param timePeriod     * @pa ...

  9. 修改radio与check样式

    一般的radio与check的样式很难看,这个时候就需要我们自己修改其样式 逻辑思维: 1.用label包裹input标签以及样式标签,然后将radio定位到界面以外,设置样式标签的样式 2.使用伪类 ...

  10. Codeforces Round #344 (Div. 2) B. Print Check

    B. Print Check time limit per test 1 second memory limit per test 256 megabytes input standard input ...

随机推荐

  1. python lxml库生成xml文件-节点命名空间问题

    lxml库,处理xml很强大,官方文档:https://lxml.de/tutorial.html#namespaces 例如: 我们要生成如下格式的报文: <ttt:jesson xmlns: ...

  2. 从零开始学 Web 之 DOM(五)元素的创建

    大家好,这里是「 从零开始学 Web 系列教程 」,并在下列地址同步更新...... +-------------------------------------------------------- ...

  3. CSS 基础:定位元素(3)<思维导图>

    这段时间利用一下间隙时间学习了CSS的基础知识,主要目的是加深对CSS的理解,虽然个人主要工作基本都是后台开发,但是个人觉得系统学习一下CSS的基础还是很有必要的.下面我学习CSS时做的思维导图(全屏 ...

  4. Spring Boot + Spring Cloud 实现权限管理系统 后端篇(十九):服务消费(Ribbon、Feign)

    技术背景 上一篇教程中,我们利用Consul注册中心,实现了服务的注册和发现功能,这一篇我们来聊聊服务的调用.单体应用中,代码可以直接依赖,在代码中直接调用即可,但在微服务架构是分布式架构,服务都运行 ...

  5. winform 窗体关闭枚举类

    switch (e.CloseReason) { case CloseReason.None: break; case CloseReason.WindowsShutDown: break; case ...

  6. NLog日志框架使用探究-1

    目录 前言 为什么是NLog? 目的 配置 基本配置 日志等级 输出例子 目标 参数 规则 日志分发 日志收集 结语 参考文档 前言 日志是每个程序的基本模块.本文是为了探究如何通过NLog方便及记录 ...

  7. Redis服务搭建与基础功能示例

    一.Redis简介 Redis是一个非关系型远程内存数据库,它也是一个Key-value模型的数据库.Redis支持5种数据类型(string.list.set.sorted set.hash),可以 ...

  8. SpringBoot入门之基于Druid配置Mybatis多数据源

    上一篇了解了Druid进行配置连接池的监控和慢sql处理,这篇了解下使用基于基于Druid配置Mybatis多数据源.SpringBoot默认配置数据库连接信息时只需设置url等属性信息就可以了,Sp ...

  9. SQL 同一张表中相同字段的内容合并为一条记录(不同字段的那一列每个记录后面加逗号)

    一.创建表 create table stuUnion ( sid int identity primary key, cid int, id ) ) 二.添加数据 insert into stuUn ...

  10. 【手记】解决“未能创建 SSL/TLS 安全通道”异常

    之前写了一个桌面程序,程序会间歇性访问某个https接口,一直用的好好的,今天突然报错了,异常就发生在访问接口的地方,曰“请求被中止,未能创建 SSL/TLS 安全通道.”,另外有台电脑也有跑该程序, ...