Chinaunix首页 | 论坛 | 博客
  • 博客访问: 490856
  • 博文数量: 33
  • 博客积分: 4168
  • 博客等级: 上校
  • 技术积分: 675
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-26 20:21
文章分类

全部博文(33)

文章存档

2013年(8)

2012年(2)

2011年(7)

2010年(1)

2009年(4)

2008年(11)

分类: 系统运维

2012-11-27 23:54:56

         ///
        /// 多个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) |
给主人留下些什么吧!~~