读取txt 修改数据

作者在 2014-07-30 13:45:16 发布以下内容
public void DealEfileReturn(FileInfo file)
{
long totalRecords = 0;
IList<EfileList> list = Baosight.BPMS.Core.Adapter.BPMSDocUtil.QueryEfileList(0, -1, new SqlFilter("projectNo='090410'and BusinessKey1='13CNSHG3200019A0' "), new SqlSort("order by BusinessKey1"), out totalRecords);
if (list.Count > 0)
{
//预存字符串的变量
string str = "";

if (file.Exists)
{
using (StreamReader streamReader = new StreamReader(file.FullName, Encoding.Default))
{
while (streamReader.Peek() >= 0)
{
str = streamReader.ReadLine();
if (str.Length > 0)
{
//调用事务处理
using (DbTransactionWrapper wrapper = new DbTransactionWrapper())
{
string[] data = Regex.Split(str, "&&");
#region MyRegion

//foreach (string item in data)
//{
EfileList entity = new EfileList();

entity.ProjectNo = StringFormat(data[0].Trim());
entity.BusinessKey1 = StringFormat(data[1].Trim());
entity.BusinessKey2 = StringFormat(data[2].Trim());

string flas = StringFormat(data[3].Trim());

entity.EfileConfirmDate = DateTimeFormat(data[4]);

if (flas == "1")
{
Database db = DatabaseFactory.CreateDatabase(DATABASE_INSTANCE_NAME);

string sql = string.Format(@"UPDATE T_SYS_EFILE_LIST SET EfileStatus='02',EfileConfirmDate='" + entity.EfileConfirmDate + "' WHERE projectNo='" + entity.ProjectNo + "'and BusinessKey1='" + entity.BusinessKey1 + "' and BusinessKey2='" + entity.BusinessKey2 + "'");

int i = db.ExecuteNonQuery(CommandType.Text, sql);
}

else if (flas == "0")
{
Database db = DatabaseFactory.CreateDatabase(DATABASE_INSTANCE_NAME);

string sql = string.Format(@"UPDATE T_SYS_EFILE_LIST SET EfileStatus='11',EfileConfirmDate='" + entity.EfileConfirmDate + "' WHERE projectNo='" + entity.ProjectNo + "'and BusinessKey1='" + entity.BusinessKey1 + "' and BusinessKey2='" + entity.BusinessKey2 + "'");

int i = db.ExecuteNonQuery(CommandType.Text, sql);
}
//}
#endregion
wrapper.Commit();


}
}
}
streamReader.Close();
}
}
else
{
throw (new Exception());
}

}

}

默认分类 | 阅读 1660 次
文章评论,共0条
游客请输入验证码
文章分类
文章归档
最新评论