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. [每天解决一问题系列 - 0011] 如何清除Windows中的Icon缓存

    问题描述: 当更换一个应用或者快捷方式的图标后,会看到图标并没有及时更新 问题原因: 原因是Windows为了使图标显示更快,做了缓存%localappdata%\IconCache.db 解决方案: ...

  2. html 空格字符类型

    1,Html中空格     不断行的空白(1个字符宽度)     半个空白(1个字符宽度)     一个空白(2个字符宽度)     窄空白(小于1个字符宽度) 2,Css 的方式空格 CSS中当 w ...

  3. salesforce lightning零基础学习(五) 事件阶段(component events phase)

    上一篇介绍了lightning component events的简单介绍.此篇针对上一篇进行深入,主要讲的内容为component event中的阶段(Phase). 一. 阶段(Phase)的概念 ...

  4. MySQL 设计规范

    一.数据库命令规范 所有数据库对象名称必须使用小写字母并用下划线分割 所有数据库对象名称禁止使用mysql保留关键字(如果表名中包含关键字查询时,需要将其用单引号括起来) 数据库对象的命名要能做到见名 ...

  5. JAVA 面试知识点

    参考:https://www.cnblogs.com/java1024/p/8594784.html 反射: JAVA反射机制是在运行状态中, 对于任意一个类,都能够知道这个类的所有属性和方法: 对于 ...

  6. js获取带#号链接后的参数

    现在许多的主流网站都将'#'大规模用于重要URL中,我们通过正则表达式和window.location.search获取参数已经行不通了. 一.'#'号是什么 1.#代表网页中的一个位置.其后面的字符 ...

  7. [HEOI2016] 字符串

    Description 给定长度为n的字符串,m次询问,每次询问s[a...b]的所有子串与s[c...d]的LCP的最大值.n,m<=10^5. Solution 感觉这种n,m<=10 ...

  8. openssl rsa/pkey

    openssl系列文章:http://www.cnblogs.com/f-ck-need-u/p/7048359.html openssl rsa和openssl pkey分别是RSA密钥的处理工具和 ...

  9. MVC架构介绍-事件机制

    实例产品基于asp.net mvc 5.0框架,源码下载地址:http://www.jinhusns.com/Products/Download 在.net框架中,事件是将事件发送者(触发事件的对象) ...

  10. SQLServer转PowerDesigner(转载)

    将SQLServer中的数据库导入到PowerDesigner 百度得: https://jingyan.baidu.com/article/20095761c98042cb0721b4fc.html ...