///
/// 多个DW数据的保存
/// ///
///
///
[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
public string multiDWSave(string[] dataObjectList, string[] dwChangesList)
{
string ret = string.Empty;
if (!CheckLogin(ref ret)) return ret;
try
{
_retJson = new retJson();
List dsList = new List();
_dbHelp = new DBHelp();
_dbHelp.Open();
for (int i = 0; i < dataObjectList.Length; i++)
{
SafeDS ds = new SafeDS(dataObjectList[i]);
ds.SetChanges(dwChangesList[i]);
ds.SetTransaction(_dbHelp.TransAction);
dsList.Add(ds);
}
///////////////////////////////////////////////////////////////
_dbHelp.BeginTransAction();
bool succ = true;
for (int i = 0; i < dsList.Count; i++)
{
if (dsList[i].UpdateData() != 1)
{
_retJson.StatusCode = 401;
_retJson.JsonString = dsList[i].DBError;
succ = false;
break;
}
}
if (succ)
{
_dbHelp.Commit();
_retJson.StatusCode = 200;
_retJson.JsonString = "OK";
}
else
{
_dbHelp.Rollback();
}
}
catch (Exception ex)
{
_retJson.StatusCode = 401;
_retJson.JsonString = ex.Message;
}
finally
{
if (_dbHelp != null) _dbHelp.Close();
}
return JsonHelper.GetJsonStringByObject(_retJson);
}
注: DBHelp 是在原有Demo的基础上改造过的。
阅读(1582) | 评论(0) | 转发(0) |