Пример #1
0
        public BasicResponse DeleteJC_AlarmNotificationPersonnelConfig(AlarmNotificationPersonnelConfigDeleteRequest jC_Alarmnotificationpersonnelconfigrequest)
        {
            TransactionsManager.BeginTransaction(() =>
            {
                if (!string.IsNullOrWhiteSpace(jC_Alarmnotificationpersonnelconfigrequest.Id))
                {
                    //删除报警推送信息的时候将存在的报警处理记录填上EndTime
                    JC_AlarmnotificationpersonnelconfigModel alarmnotificationpersonnelconfigModel = _Repository.GetJC_AlarmNotificationPersonnelConfigById(jC_Alarmnotificationpersonnelconfigrequest.Id);
                    _AlarmHandleService.CloseUnclosedAlarmHandleByAnalysisModelId(new Sys.Safety.Request.AlarmHandle.AlarmHandleGetByAnalysisModelIdRequest()
                    {
                        AnalysisModelId = alarmnotificationpersonnelconfigModel.AnalysisModelId
                    });

                    _Repository.DeleteJC_AlarmNotificationPersonnelConfig(jC_Alarmnotificationpersonnelconfigrequest.Id);
                    _AlarmNotificationPersonnelRepository.DeleteJC_AlarmNotificationPersonnelByAlarmConfigId(jC_Alarmnotificationpersonnelconfigrequest.Id);
                }
                else
                {
                    foreach (var item in jC_Alarmnotificationpersonnelconfigrequest.ids)
                    {
                        //删除报警推送信息的时候将存在的报警处理记录填上EndTime
                        JC_AlarmnotificationpersonnelconfigModel alarmnotificationpersonnelconfigModel = _Repository.GetJC_AlarmNotificationPersonnelConfigById(item);
                        _AlarmHandleService.CloseUnclosedAlarmHandleByAnalysisModelId(new Sys.Safety.Request.AlarmHandle.AlarmHandleGetByAnalysisModelIdRequest()
                        {
                            AnalysisModelId = alarmnotificationpersonnelconfigModel.AnalysisModelId
                        });

                        _Repository.DeleteJC_AlarmNotificationPersonnelConfig(item);
                        _AlarmNotificationPersonnelRepository.DeleteJC_AlarmNotificationPersonnelByAlarmConfigId(item);
                    }
                }
            });

            if (Basic.Framework.Data.PlatRuntime.Items.ContainsKey(DataContract.UserRoleAuthorize.KeyConst.AlarmNotificationChangedKey))
            {
                Basic.Framework.Data.PlatRuntime.Items[DataContract.UserRoleAuthorize.KeyConst.AlarmNotificationChangedKey] = DateTime.Now;
            }
            else
            {
                Basic.Framework.Data.PlatRuntime.Items.Add(DataContract.UserRoleAuthorize.KeyConst.AlarmNotificationChangedKey, DateTime.Now);
            }

            var jC_Alarmnotificationpersonnelconfigresponse = new BasicResponse();

            return(jC_Alarmnotificationpersonnelconfigresponse);
        }
 public BasicResponse CloseUnclosedAlarmHandleByAnalysisModelId(AlarmHandleGetByAnalysisModelIdRequest getByAnalysisModelIdRequest)
 {
     return(alarmHandleService.CloseUnclosedAlarmHandleByAnalysisModelId(getByAnalysisModelIdRequest));
 }
        /// <summary>
        /// 删除分析模型
        /// </summary>
        /// <param name="jc_LargedataAnalysisConfigRsequest">删除分析模型的请求对象</param>
        /// <returns>Mas应答对象</returns>
        public BasicResponse DeleteLargeDataAnalysisConfig(LargedataAnalysisConfigDeleteRequest jc_LargedataAnalysisConfigRsequest)
        {
            var jC_Largedataanalysisconfigresponse = new BasicResponse();

            try
            {
                //检查, 报警,控制,应急联动配置
                BasicResponse <bool> hasAlarmNotificationResponse = _AlarmNotificationPersonnelConfigService.HasAlarmNotificationForAnalysisModel(new Sys.Safety.Request.AlarmNotificationPersonnelConfig.GetAlarmNotificationByAnalysisModelIdRequest()
                {
                    AnalysisModelId = jc_LargedataAnalysisConfigRsequest.Id
                });
                if (hasAlarmNotificationResponse.IsSuccess && hasAlarmNotificationResponse.Data)
                {
                    return(new BasicResponse()
                    {
                        Code = -100, Message = "此分析模型存在报警配置信息, 请先删除报警配置然后再删除此模型."
                    });
                }
                BasicResponse <bool> hasRegionOutageResponse = _RegionOutageConfigService.HasRegionOutageForAnalysisModel(new Sys.Safety.Request.RegionOutageConfig.GetByAnalysisModelIdRequest()
                {
                    AnalysisModelId = jc_LargedataAnalysisConfigRsequest.Id
                });
                if (hasRegionOutageResponse.IsSuccess && hasRegionOutageResponse.Data)
                {
                    return(new BasicResponse()
                    {
                        Code = -100, Message = "此分析模型存在区域断电配置信息, 请先删除区域断电配置然后再删除此模型."
                    });
                }

                //删除分析模型
                _Repository.DeleteJC_Largedataanalysisconfig(jc_LargedataAnalysisConfigRsequest.Id);

                BasicResponse <JC_LargedataAnalysisConfigInfo> cachedLargedataAnalysisConfigInfo = _LargeDataAnalysisConfigCacheService.GetLargeDataAnalysisConfigCacheByKey(new Sys.Safety.Request.Cache.LargeDataAnalysisConfigCacheGetByKeyRequest()
                {
                    Id = jc_LargedataAnalysisConfigRsequest.Id
                });
                if (cachedLargedataAnalysisConfigInfo != null && cachedLargedataAnalysisConfigInfo.Data != null)
                {
                    try
                    {
                        //删除分析模型时,关闭和模型有关的未关闭的报警处理信息.
                        alarmHandleService.CloseUnclosedAlarmHandleByAnalysisModelId(new AlarmHandleGetByAnalysisModelIdRequest()
                        {
                            AnalysisModelId = cachedLargedataAnalysisConfigInfo.Data.Id
                        });
                    }
                    catch (Exception ex)
                    {
                        Basic.Framework.Logging.LogHelper.Error(string.Format("删除分析模型时,关闭和模型有关的未关闭的报警处理信息出错. 错误消息:{0}", ex.StackTrace));
                    }
                    try
                    {
                        //删除分析模型时,解除和模型有关的控制
                        BasicResponse <List <Jc_JcsdkzInfo> > analysisZKResponse = manualCrossControlService.GetManualCrossControlByTypeZkPoint(new ManualCrossControlGetByTypeZkPointRequest()
                        {
                            ZkPoint = cachedLargedataAnalysisConfigInfo.Data.Id, Type = (short)Enums.ControlType.LargeDataAnalyticsAreaPowerOff
                        });
                        if (analysisZKResponse != null && analysisZKResponse.Data != null && analysisZKResponse.Data.Count > 0)
                        {
                            manualCrossControlService.DeleteManualCrossControls(new ManualCrossControlsRequest()
                            {
                                ManualCrossControlInfos = analysisZKResponse.Data
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        Basic.Framework.Logging.LogHelper.Error(string.Format("删除分析模型时,解除和模型有关的控制出错. 错误消息:{0}", ex.StackTrace));
                    }
                    try
                    {
                        //删除缓存
                        _LargeDataAnalysisConfigCacheService.DeleteLargeDataAnalysisConfigCache(new LargeDataAnalysisConfigCacheDeleteRequest()
                        {
                            LargeDataAnalysisConfigInfo = cachedLargedataAnalysisConfigInfo.Data
                        });
                    }
                    catch (Exception ex)
                    {
                        Basic.Framework.Logging.LogHelper.Error(string.Format("删除分析模型后再删除缓存出错:{0}", ex.StackTrace));
                    }
                }

                if (Basic.Framework.Data.PlatRuntime.Items.ContainsKey(DataContract.UserRoleAuthorize.KeyConst.AnalysisModelChangedKey))
                {
                    Basic.Framework.Data.PlatRuntime.Items[DataContract.UserRoleAuthorize.KeyConst.AnalysisModelChangedKey] = DateTime.Now;
                }
                else
                {
                    Basic.Framework.Data.PlatRuntime.Items.Add(DataContract.UserRoleAuthorize.KeyConst.AnalysisModelChangedKey, DateTime.Now);
                }
            }
            catch (Exception ex)
            {
                jC_Largedataanalysisconfigresponse.Code    = 2;
                jC_Largedataanalysisconfigresponse.Message = ex.Message;
            }

            return(jC_Largedataanalysisconfigresponse);
        }