每日笔记

时间 2018/1/3 20:24:13 加载中...

今日处理:


  1. 处理学位论文项目反馈的导入帐户信息失败的问题

  2. 处理流程服务(WCF服务的WebApi)Post请求的内容过大,提示”The remote server returned an error: (413) Request Entity Too Large“

  3. 处理Wrod导入时,解析其中的表格,转成成对应的HTML中的Table形式


学位论文项目导入帐户失败的原因

 

1、拼接的SQL语句在问题

在数据库中的字段类型为Int类型,在拼接SQL语句时,不能直接将值传递过去,空字符串或者'NULL'都不可以。

注意下面的红色部分内容

 

builder.AppendFormat(@"insert user(UserId,UserCode,Password,UserName,Sex,mobile,email,status,CreateTime,CreateUser,bankaccount,ID,studentId,StudentYear,JoinYear,StudentDegree) values

                    ('{0}','{1}','{2}','{3}',{4},'{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}',{13},{14},{15});",

                   user.UserID,

                   user.UserCode,

                   user.Password,

                   user.UserName,

                   !user.Sex.HasValue ? "NULL" : string.Format("'{0}'", user.Sex),

                   user.mobile,

                   user.email,

                   user.Status,

                   user.CreateTime,

                   user.CreateUser,

                   user.bankaccount,

                   user.ID,

                   user.StudentID,

                   user.StudentYear.HasValue ? user.StudentYear.ToString() : "NULL",

                   user.JoinYear.HasValue ? user.JoinYear.ToString() : "NULL",

                   user.StudentDegree.HasValue ? user.StudentDegree.ToString() : "NULL");

 

2、且用到数字的地方要全部使用枚举类型,此次因角色的数值变化导致角色混乱了。强调、强调、强调:不要直接使用数字,而是使用枚举。


WCF中的Post请求内容过多问题


解决办法在配置文件中添加如下配置:


<webHttpBinding>
    <!--这个是接收大数据加的-->
    <binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                    maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                    maxNameTableCharCount="2147483647"/>
    </binding>
  </webHttpBinding>
</bindings>


Word文件中的表格处理


主要思路,获取到Word中的表格对象,通过GetTxt方法获取到文本,然后通过字符串的替换来实现HTML的表格。

2018-1-4 修改

新创建一个Document,将Table对象添加进去,然后将此Document输出成HTML格式,得到的就时一个HTML格式的Table。然后再添加回之前的队列中。


扫码分享
版权说明
作者:SQBER
文章来源:http://blog.sqber.com/articles/daily-2018-1-3.html
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。