/// <summary> /// 批量添加预案 /// </summary> /// <param name="devicePlanRelationInfoModel"></param> /// <returns></returns> public bool BatchAddDevicePlanData(DevicePlanRelationInfoModel devicePlanRelationInfoModel) { mapContext.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);//创建事务 try { bool result = false; //向预案信息表中添加预案信息 for (var i = 0; i < devicePlanRelationInfoModel.entityList.Count(); i++) { int planId = (int)mapContext.Insert("InsertDevicePlan", devicePlanRelationInfoModel.entityList[i]); if (planId > 0) { result = AddRelatedInfo(planId, devicePlanRelationInfoModel); } else { mapContext.RollBackTransaction(); result = false; } } if (result == true) { mapContext.CommitTransaction();//提交事务 return(result); } else { mapContext.RollBackTransaction();//事务回滚 return(result); } } catch (Exception ex) { mapContext.RollBackTransaction(); throw ex; } finally { //mapContext.CommitTransaction(); } }
/// <summary> /// 修改预案信息 /// </summary> /// <param name="entity">预案信息</param> /// <param name="defaultPlanHandleItemList">默认处置项</param> /// <param name="cnfirmPlanHandleItemList">确认处置项</param> /// <param name="defaultPersonList">默认处置项通知其他责任人</param> /// <param name="cnfirmPlanPersonList">确认处置项通知其他责任人</param> /// <param name="servPlanHandleItemCameraList">关联摄像头</param> /// <returns></returns> public bool UpdateDevicePlanInfo(ServDevicePlanModel entity, ServExecutionTimeModel executionTimeInfo, List <ServPlanHandleItemModel> defaultPlanHandleItemList, List <ServPlanHandleItemModel> cnfirmPlanHandleItemList, List <ServPlanPersonModel> defaultPersonList, List <ServPlanPersonModel> cnfirmPlanPersonList, List <ServPlanHandleItemCameraModel> servPlanHandleItemCameraList) { bool result = false; try { DevicePlanRelationInfoModel devicePlanRelationInfoModel = new DevicePlanRelationInfoModel(); devicePlanRelationInfoModel.entity = entity; devicePlanRelationInfoModel.servExecutionTime = executionTimeInfo; devicePlanRelationInfoModel.defaultPlanHandleItemList = defaultPlanHandleItemList; devicePlanRelationInfoModel.cnfirmPlanHandleItemList = cnfirmPlanHandleItemList; devicePlanRelationInfoModel.cnfirmPlanPersonList = cnfirmPlanPersonList; devicePlanRelationInfoModel.defaultPersonList = defaultPersonList; devicePlanRelationInfoModel.servPlanHandleItemCameraList = servPlanHandleItemCameraList; result = servDevicePlanDAL.UpdateDevicePlan(devicePlanRelationInfoModel); return(result); } catch (Exception ex) { throw ex; } }
/// <summary> /// 批量添加预案信息 /// </summary> /// <param name="entity">预案信息</param> /// <param name="defaultPlanHandleItemList">默认处置项</param> /// <param name="cnfirmPlanHandleItemList">确认处置项</param> /// <param name="defaultPersonList">默认处置项通知其他责任人</param> /// <param name="cnfirmPlanPersonList">确认处置项通知其他责任人</param> /// <param name="servPlanHandleItemCameraList">关联摄像头</param> /// <returns></returns> public bool BatchAddDevicePlanData(List <ServDevicePlanModel> entity, ServExecutionTimeModel servExecutionTime, List <ServPlanHandleItemModel> defaultPlanHandleItemList, List <ServPlanHandleItemModel> cnfirmPlanHandleItemList, List <ServPlanPersonModel> defaultPersonList, List <ServPlanPersonModel> cnfirmPlanPersonList, List <ServPlanHandleItemCameraModel> servPlanHandleItemCameraList) { bool result = false; try { DevicePlanRelationInfoModel devicePlanRelationInfoModel = new DevicePlanRelationInfoModel(); devicePlanRelationInfoModel.servExecutionTime = servExecutionTime; devicePlanRelationInfoModel.entityList = entity; devicePlanRelationInfoModel.defaultPlanHandleItemList = defaultPlanHandleItemList; devicePlanRelationInfoModel.cnfirmPlanHandleItemList = cnfirmPlanHandleItemList; devicePlanRelationInfoModel.cnfirmPlanPersonList = cnfirmPlanPersonList; devicePlanRelationInfoModel.defaultPersonList = defaultPersonList; devicePlanRelationInfoModel.servPlanHandleItemCameraList = servPlanHandleItemCameraList; result = servDevicePlanDAL.BatchAddDevicePlanData(devicePlanRelationInfoModel); return(result); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取预案信息 /// </summary> /// <param name="devicePlanId"></param> /// <param name="planType"></param> /// <returns></returns> public DevicePlanRelationInfoModel GetDevicePlanInfo(int devicePlanId, int planType) { try { //获取预案信息 ServDevicePlanModel entity = servDevicePlanDAL.GetEntity(devicePlanId); //园区信息 BaseRegionConfigModel regionInfo = baseRegionConfigDAL.GetRegionConfigInfo(entity.device_id); //获取时间信息 ServExecutionTimeModel ServExecutionTime = servExecutionTimeDAL.GetTimeEntity(devicePlanId, planType); //获取处置项信息 List <ServPlanHandleItemModel> PlanHandleItemList = servPlanHandleItemDAL.GetPlanHandleItem(devicePlanId, planType); //预案确警前处置项 List <ServPlanHandleItemModel> defaultPlanHandleItemList = new List <ServPlanHandleItemModel>(); //预案确警后处置项 List <ServPlanHandleItemModel> cnfirmPlanHandleItemList = new List <ServPlanHandleItemModel>(); //预案确警前责任人关联表 List <ServPlanPersonModel> defaultPersonList = new List <ServPlanPersonModel>(); //预案确警后责任人关联表 List <ServPlanPersonModel> cnfirmPlanPersonList = new List <ServPlanPersonModel>(); //获取关联摄像头信息 List <ServPlanHandleItemCameraModel> servPlanHandleItemCameraList = new List <ServPlanHandleItemCameraModel>(); if (PlanHandleItemList.Count() > 0) { for (var i = 0; i < PlanHandleItemList.Count(); i++) { if (PlanHandleItemList[i].item_type == (int)CSM.Common.EnumClass.DevicePlanDefaultOptions.通知其他负责人 && PlanHandleItemList[i].confirm_type == (int)CSM.Common.EnumClass.PlanHandleTime.确警前) { defaultPersonList = servPlanPersonDAL.GetPlanPersonInfo(PlanHandleItemList[i].id); } else if (PlanHandleItemList[i].item_type == (int)CSM.Common.EnumClass.DevicePlanConfirmOptions.通知其他负责人 && PlanHandleItemList[i].confirm_type == (int)CSM.Common.EnumClass.PlanHandleTime.确警后) { cnfirmPlanPersonList = servPlanPersonDAL.GetPlanPersonInfo(PlanHandleItemList[i].id); } else if (PlanHandleItemList[i].item_type == (int)CSM.Common.EnumClass.DevicePlanDefaultOptions.关联摄像头) { servPlanHandleItemCameraList = servPlanHandleItemCameraDAL.GetPlanHandleItemCamera(PlanHandleItemList[i].id); } if (PlanHandleItemList[i].confirm_type == (int)CSM.Common.EnumClass.PlanHandleTime.确警前) { defaultPlanHandleItemList.Add(PlanHandleItemList[i]); } else if (PlanHandleItemList[i].confirm_type == (int)CSM.Common.EnumClass.PlanHandleTime.确警后) { cnfirmPlanHandleItemList.Add(PlanHandleItemList[i]); } } } DevicePlanRelationInfoModel model = new DevicePlanRelationInfoModel(); model.entity = entity; model.servExecutionTime = ServExecutionTime; model.BaseRegionConfigInfo = regionInfo; model.defaultPlanHandleItemList = defaultPlanHandleItemList; model.cnfirmPlanHandleItemList = cnfirmPlanHandleItemList; model.cnfirmPlanPersonList = cnfirmPlanPersonList; model.defaultPersonList = defaultPersonList; model.servPlanHandleItemCameraList = servPlanHandleItemCameraList; return(model); } catch (Exception ex) { throw ex; } }
/// <summary> /// 向预案处置项关联摄像头表,预案责任人关联表,预案处置项表表中添加相应信息 /// </summary> /// <param name="Planid">预案id</param> /// <param name="devicePlanRelationInfoModel"></param> /// <returns></returns> public bool AddRelatedInfo(int Planid, DevicePlanRelationInfoModel devicePlanRelationInfoModel) { bool result = false; try { #region 向Serv_Execution_Time添加时间信息 devicePlanRelationInfoModel.servExecutionTime.relate_id = Planid; int TimeId = (int)mapContext.Insert("InsertServExecutionTime", devicePlanRelationInfoModel.servExecutionTime); if (TimeId > 0) { result = true; } else { result = false; } #endregion if (result == true) { #region 向Serv_Plan_HandleItem添加默认处置选项 for (int i = 0; i < devicePlanRelationInfoModel.defaultPlanHandleItemList.Count(); i++) { devicePlanRelationInfoModel.defaultPlanHandleItemList[i].plan_id = Planid; int deviceHandleItemId = devicePlanRelationInfoModel.defaultPlanHandleItemList[i].item_type; #region 向Serv_Plan_Person添加确警前其他责任人信息 if (deviceHandleItemId == (int)DevicePlanDefaultOptions.通知其他负责人) { int HandleId = (int)mapContext.Insert("InsertPlanHandleItem", devicePlanRelationInfoModel.defaultPlanHandleItemList[i]); if (HandleId > 0) { //向Serv_Plan_Person添加确警前其他责任人信息 List <ServPlanPersonModel> defaultPersonlist = devicePlanRelationInfoModel.defaultPersonList as List <ServPlanPersonModel>; for (int f = 0; f < defaultPersonlist.Count(); f++) { defaultPersonlist[f].handleitem_id = HandleId; } int defaultPersonId = (int)mapContext.Insert("BatchAddPlanPerson", defaultPersonlist); if (defaultPersonId > 0) { result = true; } else { result = false; } } else { result = false; } } #endregion #region 向Serv_Plan_HandleItemCamera添加摄像头信息 else if (deviceHandleItemId == (int)DevicePlanDefaultOptions.关联摄像头) { int HandleId = (int)mapContext.Insert("InsertPlanHandleItem", devicePlanRelationInfoModel.defaultPlanHandleItemList[i]); if (HandleId > 0) { //向Serv_Plan_HandleItemCamera添加摄像头信息 List <ServPlanHandleItemCameraModel> Cameralist = devicePlanRelationInfoModel.servPlanHandleItemCameraList as List <ServPlanHandleItemCameraModel>; for (int f = 0; f < Cameralist.Count(); f++) { Cameralist[f].handleitem_id = HandleId; } if (Cameralist.Count > 0) { int CameraId = (int)mapContext.Insert("BatchAddPlanHandleItemCamera", Cameralist); if (CameraId > 0) { result = true; } else { result = false; } } } else { result = false; } } #endregion else { //向Serv_Plan_HandleItem添加默认处置选项 int HandleId = (int)mapContext.Insert("InsertPlanHandleItem", devicePlanRelationInfoModel.defaultPlanHandleItemList[i]); if (HandleId > 0) { result = true; } else { result = false; break; } } } #endregion if (result == true) { #region 向Serv_Plan_HandleItem添加确警后处置选项 for (int i = 0; i < devicePlanRelationInfoModel.cnfirmPlanHandleItemList.Count(); i++) { //向Serv_Plan_HandleItem添加确警后处置选项 devicePlanRelationInfoModel.cnfirmPlanHandleItemList[i].plan_id = Planid; int deviceHandleItemId = devicePlanRelationInfoModel.cnfirmPlanHandleItemList[i].item_type; if (deviceHandleItemId == (int)DevicePlanConfirmOptions.通知其他负责人) { int HandleId = (int)mapContext.Insert("InsertPlanHandleItem", devicePlanRelationInfoModel.cnfirmPlanHandleItemList[i]); if (HandleId > 0) { //向Serv_Plan_Person添加确警前其他责任人信息 List <ServPlanPersonModel> cnfirmPersonlist = devicePlanRelationInfoModel.cnfirmPlanPersonList as List <ServPlanPersonModel>; for (int f = 0; f < cnfirmPersonlist.Count(); f++) { cnfirmPersonlist[f].handleitem_id = HandleId; } int cnfirmPersonId = (int)mapContext.Insert("BatchAddPlanPerson", cnfirmPersonlist); if (cnfirmPersonId > 0) { result = true; } else { result = false; } } else { result = false; } } else { //向Serv_Plan_HandleItem添加确警后处置选项 int HandleId = (int)mapContext.Insert("InsertPlanHandleItem", devicePlanRelationInfoModel.cnfirmPlanHandleItemList[i]); if (HandleId > 0) { result = true; } else { result = false; } } } #endregion } } return(result); } catch (Exception ex) { throw ex; } }
/// <summary> /// 修改预案信息 /// </summary> /// <param name="devicePlanRelationInfoModel"></param> /// <returns></returns> public bool UpdateDevicePlan(DevicePlanRelationInfoModel devicePlanRelationInfoModel) { mapContext.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);//创建事务 try { bool result = false; //修改预案信息.Insert string sql = IBatisHelper.GetRuntimeSql(this.mapContext, "UpdatePartDevicePlanById", devicePlanRelationInfoModel.entity); int planId = (int)mapContext.Update("UpdatePartDevicePlanById", devicePlanRelationInfoModel.entity); if (planId > 0) { int executionTimeId = (int)mapContext.Delete("DeleteServExecutionTime", devicePlanRelationInfoModel.servExecutionTime); if (executionTimeId > 0) { ServPlanHandleItemModel servPlanHandleItemModel = new ServPlanHandleItemModel(); servPlanHandleItemModel.plan_id = devicePlanRelationInfoModel.entity.id; servPlanHandleItemModel.plan_type = (int)PlanType.设备预案; List <ServPlanHandleItemModel> PlanHandleItem = mapContext.QueryForList <ServPlanHandleItemModel>("GetPlanHandleItemByPlanId", servPlanHandleItemModel).ToList(); for (int a = 0; a < PlanHandleItem.Count(); a++) { if (PlanHandleItem[a].item_type == (int)DevicePlanDefaultOptions.通知其他负责人 && PlanHandleItem[a].confirm_type == (int)PlanHandleTime.确警前) { //删除默认处置项中的通知其他责任人信息 result = DeleteRelatedInfo("DeletePlanPersonByHandleId", "DeletePlanHandleItemById", PlanHandleItem[a].id); if (result == false) { break; } } else if (PlanHandleItem[a].item_type == (int)DevicePlanConfirmOptions.通知其他负责人 && PlanHandleItem[a].confirm_type == (int)PlanHandleTime.确警后) { //删除确警后处置项中的通知其他责任人信息 result = DeleteRelatedInfo("DeletePlanPersonByHandleId", "DeletePlanHandleItemById", PlanHandleItem[a].id); if (result == false) { break; } } else if (PlanHandleItem[a].item_type == (int)DevicePlanDefaultOptions.关联摄像头 && PlanHandleItem[a].confirm_type == (int)PlanHandleTime.确警前) { //删除默认处置项中的摄像头信息 result = DeleteRelatedInfo("DeletePlanHandleItemCameraHandleId", "DeletePlanHandleItemById", PlanHandleItem[a].id); if (result == false) { break; } } else { //删除处置项 result = DeleteRelatedInfo("", "DeletePlanHandleItemById", PlanHandleItem[a].id); if (result == false) { break; } } } //添加关联信息 result = AddRelatedInfo(devicePlanRelationInfoModel.entity.id, devicePlanRelationInfoModel); } else { mapContext.RollBackTransaction(); result = false; } } else { mapContext.RollBackTransaction(); result = false; } if (result == true) { mapContext.CommitTransaction();//提交事务 return(result); } else { mapContext.RollBackTransaction();//事务回滚 return(result); } } catch (Exception ex) { mapContext.RollBackTransaction(); throw ex; } finally { //mapContext.CommitTransaction(); } }