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. 关于appendChild和insertBefore appendTo()和append

    appendChild和insertBefore(原生js) appendTo()和append(jquery)

  2. xlwt set style making error: More than 4094 XFs (styles)

    使用Xlwt,当内容过多时,会报错:More than 4094 XFs (styles) 解决方法: wb = xlwt.Workbook(style_compression=2) 使用style_ ...

  3. static和fianl修饰变量的区别

    参考:http://hllvm.group.iteye.com/group/topic/37682 http://blog.csdn.net/javakuroro/article/details/68 ...

  4. RPC的基础:调研EOS插件http_plugin

    区块链的应用是基于http服务,这种能力在EOS中是依靠http_plugin插件赋予的. 关键字:通讯模式,add_api,http server,https server,unix server, ...

  5. elasticsearch数据过期删除处理

    一.概述 使用elasticsearch收集日志进行处理,时间久了,很老的数据就没用了或者用途不是很大,这个时候就要对过期数据进行清理.这里介绍两种方式清理这种过期的数据. 1.curator 关于版 ...

  6. linux下软件包管理

    挂载光盘:mkdir /mnt/cdrommount /dev/cdrom  /mnt/cdrom 1.rpm包管理1.安装一个包  rpm –ivh < rpm package name> ...

  7. vue 动态组件、父子组件传参

    1.vue中的自定义属性并获得属性的值 自定义属性::data-id语法为 :data-属性  获取属性的值:ev.target.dataset.id 2.vue父子组件传值 3.动态组件使用

  8. C#基础知识汇总(不断更新中)

    ------------------------------目录---------------------------- 1.隐式类型2.匿名类型3.自动属性4.初始化器5.委托6.泛型7.泛型委托8 ...

  9. centos每天自动备份mysql数据库

    #!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin export PATH #数据库用户名 db ...

  10. JWT的相关讲解

    原文链接: http://www.cnblogs.com/chenwolong/p/Token.html