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. Linux学习笔记之二————Linux系统的文件和目录

    一.Windows和Linux文件系统区别 1.在 windows 平台下,打开“计算机”,我们看到的是一个个的驱动器盘符: 每个驱动器都有自己的根目录结构,这样形成了多个树并列的情形,如图所示:  ...

  2. mysql修改数据路径

    步凑: 1.关闭mysql服务 [root@localhost /]# service mysqld stop 2.移动mysql文件夹到自定义的目录 [root@localhost /]# mv / ...

  3. spring cloud+.net core搭建微服务架构:Api授权认证(六)

    前言 这篇文章拖太久了,因为最近实在太忙了,加上这篇文章也非常长,所以花了不少时间,给大家说句抱歉.好,进入正题.目前的项目基本都是前后端分离了,前端分Web,Ios,Android...,后端也基本 ...

  4. Centos7安装Mysql8(官方整合包)

    1. 下载整合包 [root@master ~]# wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.12-1.el7.x86_ ...

  5. 动态生成二维码并利用canvas合成出一张图片(类似海报、分享页)

    在前端开发并打算推广一个APP的时候,推广页是免不了的,而推广页的展示方式一般是给人家一个二维码,让别人自己去安装APP,这样前段任务也达到了,这次写这篇文章的原因主要还是总结一下,其中有很多不完善的 ...

  6. baguetteBox.js - 简单易用的 lightbox 插件

    baguetteBox.js 是一个简单和易于使用的响应式的图像 Lightbox 插件,支持滑动手势在移动设备上使用.纯 JavaScript 实现,不依赖第三方库和插件,赶紧来体验吧. 在线演示  ...

  7. Asp.net Webform 使用Repository模式实现CRUD操作代码生成工具

    Asp.net Webform 使用Repository模式实现CRUD操作代码生成工具 介绍 该工具是通过一个github上的开源项目修改的原始作者https://github.com/Supere ...

  8. 大数据技术之_08_Hive学习_04_压缩和存储(Hive高级)+ 企业级调优(Hive优化)

    第8章 压缩和存储(Hive高级)8.1 Hadoop源码编译支持Snappy压缩8.1.1 资源准备8.1.2 jar包安装8.1.3 编译源码8.2 Hadoop压缩配置8.2.1 MR支持的压缩 ...

  9. Python 3 进阶 —— 使用 PyMySQL 操作 MySQL

    PyMySQL 是一个纯 Python 实现的 MySQL 客户端操作库,支持事务.存储过程.批量执行等. PyMySQL 遵循 Python 数据库 API v2.0 规范,并包含了 pure-Py ...

  10. 可能会导致循环或多重级联路径。请指定 ON DELETE NO ACTION 或 ON UPDATE NO ACTION,或修改其他 FOREIGN KEY 约束。

    错误提示:可能会导致循环或多重级联路径.请指定 ON DELETE NO ACTION 或 ON UPDATE NO ACTION,或修改其他 FOREIGN KEY 约束. 原因:自表连接(同一张表 ...