Exemplo n.º 1
0
        /// <summary>
        /// 流程完成时的操作。
        /// </summary>
        /// <returns></returns>
        public int Complete(Guid id)
        {
            RoadFlow.Data.Model.BuildingsModel model = Get(id.ToString());
            #region 去除流程关联字段
            model.State      = null;
            model.CreateTime = null;
            model.UpdateTime = null;
            #endregion
            BuildingsDataBLL buildingsDataBLL = new BuildingsDataBLL();
            if (buildingsDataBLL.Get(id) != null)  //楼栋已存在,更新楼栋信息
            {
                model.ID         = null;
                model.UpdateTime = DateTime.Now;
                buildingsDataBLL.Update(model, id);
            }
            else
            {
                buildingsDataBLL.Add(model);
            }
            //更新合成表
            BuildingsAndBuildingMonthInfoBLL buildingsAndBuildingMonthInfoBLL = new BuildingsAndBuildingMonthInfoBLL();
            if (buildingsAndBuildingMonthInfoBLL.Get(id) != null)
            {
                model.ID         = null;
                model.UpdateTime = DateTime.Now;
                buildingsAndBuildingMonthInfoBLL.Update(model, id);
            }
            else
            {
                buildingsAndBuildingMonthInfoBLL.Add(model);
            }

            return(1);
        }
        /// <summary>
        /// 管理员编辑(除了BuildingsAndBuildingMonthInfo外,需要更新BuildingMonthInfoDataBLL,BuildingMonthInfoBLL,BuildingsBLL,BuildingsDataBLL)
        /// </summary>
        /// <param name="model"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public int ManageUpdate(RoadFlow.Data.Model.BuildingsModel building, RoadFlow.Data.Model.BuildingMonthInfoModel monthInfo, Guid buildingID)
        {
            using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
            {
                bool isUpdate = Update <RoadFlow.Data.Model.BuildingsModel>(building, buildingID) > 0 && Update <RoadFlow.Data.Model.BuildingMonthInfoModel>(monthInfo, buildingID) > 0;//更新组合表
                if (isUpdate)
                {
                    #region BuildingMonthInfo
                    BuildingMonthInfoDataBLL buildingMonthInfoDataBLL = new BuildingMonthInfoDataBLL();
                    var monthDataList = buildingMonthInfoDataBLL.GetListByBuildingID(buildingID);
                    var monthDataLast = monthDataList.OrderByDescending(i => i.TimeArea).FirstOrDefault();
                    if (monthDataLast != null)
                    {//有最新每月信息则更新每月信息
                        BuildingMonthInfoBLL buildingMonthInfoBLL = new BuildingMonthInfoBLL();
                        isUpdate = buildingMonthInfoDataBLL.ManageUpdate(monthInfo, monthDataLast.ID.Value) > 0 && buildingMonthInfoBLL.ManageUpdate(monthInfo, monthDataLast.BuildingMonthInfoID.Value) > 0;
                    }

                    #endregion
                    if (isUpdate)
                    {//更新楼栋基本信息
                        #region Building
                        BuildingsBLL     buildingsBLL     = new BuildingsBLL();
                        BuildingsDataBLL buildingsDataBLL = new BuildingsDataBLL();
                        building.ID = null;
                        isUpdate    = buildingsBLL.ManageUpdate(building, buildingID) > 0 && buildingsDataBLL.ManageUpdate(building, buildingID) > 0;
                        #endregion
                        if (isUpdate)
                        {
                            scope.Complete();
                            return(1);
                        }
                    }
                }
            }
            return(0);
        }
Exemplo n.º 3
0
 public int ManageUpdate(RoadFlow.Data.Model.BuildingsModel model, Guid id)
 {
     model.ID = null;
     return(BaseDb.Update <RoadFlow.Data.Model.BuildingsModel>(model, new KeyValuePair <string, object>("ID", id)));
 }