Exemplo n.º 1
0
        public BasicResponse <JC_AlarmNotificationPersonnelConfigInfo> UpdateJC_AlarmNotificationPersonnelConfig(AlarmNotificationPersonnelConfigUpdateRequest jC_Alarmnotificationpersonnelconfigrequest)
        {
            var _jC_Alarmnotificationpersonnelconfig = ObjectConverter.Copy <JC_AlarmNotificationPersonnelConfigInfo, JC_AlarmnotificationpersonnelconfigModel>(jC_Alarmnotificationpersonnelconfigrequest.JC_AlarmNotificationPersonnelConfigInfo);

            var _jC_AlarmNotificationPersonnel = ObjectConverter.CopyList <JC_AlarmNotificationPersonnelInfo, JC_AlarmNotificationPersonnelModel>
                                                     (jC_Alarmnotificationpersonnelconfigrequest.JC_AlarmNotificationPersonnelInfoList);

            TransactionsManager.BeginTransaction(() =>
            {
                _Repository.UpdateJC_AlarmNotificationPersonnelConfig(_jC_Alarmnotificationpersonnelconfig);

                _AlarmNotificationPersonnelRepository.DeleteJC_AlarmNotificationPersonnelByAlarmConfigId(_jC_Alarmnotificationpersonnelconfig.Id);

                _AlarmNotificationPersonnelRepository.AddJC_AlarmNotificationPersonnelList(_jC_AlarmNotificationPersonnel.ToList());
            });

            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 <JC_AlarmNotificationPersonnelConfigInfo>();

            jC_Alarmnotificationpersonnelconfigresponse.Data = jC_Alarmnotificationpersonnelconfigrequest.JC_AlarmNotificationPersonnelConfigInfo;
            return(jC_Alarmnotificationpersonnelconfigresponse);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 批量新增
        /// </summary>
        /// <param name="jC_AlarmNotificationPersonnelrequest"></param>
        /// <returns></returns>
        public BasicResponse <List <JC_AlarmNotificationPersonnelInfo> > AddJC_AlarmNotificationPersonnelList(AlarmNotificationPersonnelAddRequest jC_AlarmNotificationPersonnelrequest)
        {
            DataTable dataTable = _Repository.QueryTable("global_AlarmNotificationPersonnelService_GetAlarmNotificationPersonnelListByAnalysisModelId", jC_AlarmNotificationPersonnelrequest.AnalysisModelId);

            List <JC_AlarmNotificationPersonnelModel> listResult = ObjectConverter.Copy <JC_AlarmNotificationPersonnelModel>(dataTable);
            var _jC_AlarmNotificationPersonnel = ObjectConverter.CopyList <JC_AlarmNotificationPersonnelInfo, JC_AlarmNotificationPersonnelModel>
                                                     (jC_AlarmNotificationPersonnelrequest.JC_AlarmNotificationPersonnelInfoList);

            try
            {
                TransactionsManager.BeginTransaction(() =>
                {
                    _Repository.DeleteJC_AlarmNotificationPersonnelList(listResult);

                    _Repository.AddJC_AlarmNotificationPersonnelList(_jC_AlarmNotificationPersonnel.ToList());
                });
            }
            catch
            {
            }

            var jC_AlarmNotificationPersonnelresponse = new BasicResponse <List <JC_AlarmNotificationPersonnelInfo> >();

            jC_AlarmNotificationPersonnelresponse.Data = jC_AlarmNotificationPersonnelrequest.JC_AlarmNotificationPersonnelInfoList;
            return(jC_AlarmNotificationPersonnelresponse);
        }
        public BasicResponse AddEmergencyLinkHistoryAndAss(AddEmergencyLinkHistoryAndAssRequest request)
        {
            var primaryId = IdHelper.CreateLongId().ToString();

            request.EmergencyLinkHistoryInfo.Id = primaryId;
            foreach (var item in request.LinkageHistoryMasterPointAssInfoList)
            {
                item.Id = IdHelper.CreateLongId().ToString();
                item.EmergencyLinkHistoryId = primaryId;
            }
            var model =
                ObjectConverter.Copy <EmergencyLinkHistoryInfo, EmergencyLinkHistoryModel>(
                    request.EmergencyLinkHistoryInfo);
            var models =
                ObjectConverter
                .CopyList <EmergencyLinkageHistoryMasterPointAssInfo, EmergencyLinkageHistoryMasterPointAssModel>(
                    request.LinkageHistoryMasterPointAssInfoList);

            TransactionsManager.BeginTransaction(() =>
            {
                _Repository.AddEmergencyLinkHistory(model);
                foreach (var item in models)
                {
                    _emergencyLinkageHistoryMasterPointAssRepository.AddEmergencyLinkageHistoryMasterPointAss(item);
                }
            });
            return(new BasicResponse());
        }
Exemplo n.º 4
0
        /// <summary>
        /// 批量添加\更新\删除接口
        /// </summary>
        /// <param name="NetworkModuleRequest"></param>
        /// <returns></returns>
        public BasicResponse BatchOperationManualCrossControls(ManualCrossControlsRequest manualCrossControlRequest)
        {
            BasicResponse        Result = new BasicResponse();
            List <Jc_JcsdkzInfo> ManualCrossControlInfos = manualCrossControlRequest.ManualCrossControlInfos;

            //向网关同步数据
            List <Jc_JcsdkzInfo> SendItemList = ManualCrossControlInfos;
            var resultSync = SynchronousDataToGateway(SendItemList);

            if (!resultSync)
            {
                Result.Code    = 1;
                Result.Message = "向网关同步数据失败!";
                return(Result);
            }
            TransactionsManager.BeginTransaction(() =>
            {
                foreach (Jc_JcsdkzInfo item in ManualCrossControlInfos)
                {
                    if (item.InfoState == InfoState.AddNew)
                    {
                        //数据库操作
                        var _jc_Jcsdkz      = ObjectConverter.Copy <Jc_JcsdkzInfo, Jc_JcsdkzModel>(item);
                        var resultjc_Jcsdkz = _Repository.AddManualCrossControl(_jc_Jcsdkz);
                        //缓存操作
                        ManualCrossControlCacheAddRequest AddManualCrossControlCacheRequest = new ManualCrossControlCacheAddRequest();
                        AddManualCrossControlCacheRequest.ManualCrossControlInfo            = item;
                        _ManualCrossControlCacheService.AddManualCrossControlCache(AddManualCrossControlCacheRequest);
                    }
                    else if (item.InfoState == InfoState.Modified)
                    {
                        //数据库操作
                        var _jc_Jcsdkz = ObjectConverter.Copy <Jc_JcsdkzInfo, Jc_JcsdkzModel>(item);
                        _Repository.UpdateManualCrossControl(_jc_Jcsdkz);
                        //缓存操作
                        ManualCrossControlCacheUpdateRequest UpdateManualCrossControlCacheRequest = new ManualCrossControlCacheUpdateRequest();
                        UpdateManualCrossControlCacheRequest.ManualCrossControlInfo = item;
                        _ManualCrossControlCacheService.UpdateManualCrossControlCache(UpdateManualCrossControlCacheRequest);
                    }
                    else if (item.InfoState == InfoState.Delete)
                    {
                        //数据库操作
                        _Repository.DeleteManualCrossControl(item.ID);
                        //缓存操作
                        ManualCrossControlCacheDeleteRequest DeleteManualCrossControlCacheRequest = new ManualCrossControlCacheDeleteRequest();
                        DeleteManualCrossControlCacheRequest.ManualCrossControlInfo = item;
                        _ManualCrossControlCacheService.DeleteManualCrossControlCache(DeleteManualCrossControlCacheRequest);
                    }
                }
            });

            //调用驱动重新加载控制信息
            DriverManualCrossControlReLoadRequest reLoadRequest = new DriverManualCrossControlReLoadRequest();

            _DriverManualCrossControlService.ReLoad(reLoadRequest);

            return(Result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 批量删除手动/交叉控制
        /// </summary>
        /// <param name="ManualCrossControlRequest"></param>
        /// <returns></returns>
        public BasicResponse DeleteManualCrossControls(ManualCrossControlsRequest ManualCrossControlRequest)
        {
            BasicResponse        Result = new BasicResponse();
            List <Jc_JcsdkzInfo> DeleteManualCrossControlInfos = ManualCrossControlRequest.ManualCrossControlInfos;

            ManualCrossControlCacheGetAllRequest manualCrossControlCacheRequest = new ManualCrossControlCacheGetAllRequest();
            var result = _ManualCrossControlCacheService.GetAllManualCrossControlCache(manualCrossControlCacheRequest);
            List <Jc_JcsdkzInfo> DeleteManualCrossControlCaches = result.Data;

            if (DeleteManualCrossControlInfos.Count < 1)
            {
                Result.Code    = 1;
                Result.Message = "当前删除列表中无数据!";
                return(Result);
            }
            foreach (Jc_JcsdkzInfo item in DeleteManualCrossControlInfos)
            {
                Jc_JcsdkzInfo olditem = DeleteManualCrossControlCaches.Find(a => a.ID == item.ID);
                //增加重复判断
                if (olditem == null)
                { //缓存中存在此测点
                    Result.Code    = 1;
                    Result.Message = "当前删除列表中的数据不存在!";
                    return(Result);
                }
            }
            //向网关同步数据
            List <Jc_JcsdkzInfo> SendItemList = DeleteManualCrossControlInfos;
            var resultSync = SynchronousDataToGateway(SendItemList);

            if (!resultSync)
            {
                Result.Code    = 1;
                Result.Message = "向网关同步数据失败!";
                return(Result);
            }
            TransactionsManager.BeginTransaction(() =>
            {
                foreach (Jc_JcsdkzInfo item in DeleteManualCrossControlInfos)
                {
                    //数据库操作
                    _Repository.DeleteManualCrossControl(item.ID);

                    //缓存操作
                    ManualCrossControlCacheDeleteRequest DeleteManualCrossControlCacheRequest = new ManualCrossControlCacheDeleteRequest();
                    DeleteManualCrossControlCacheRequest.ManualCrossControlInfo = item;
                    _ManualCrossControlCacheService.DeleteManualCrossControlCache(DeleteManualCrossControlCacheRequest);
                }
            });

            //调用驱动重新加载控制信息
            DriverManualCrossControlReLoadRequest reLoadRequest = new DriverManualCrossControlReLoadRequest();

            _DriverManualCrossControlService.ReLoad(reLoadRequest);

            return(Result);
        }
        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="NetworkModuleRequest"></param>
        /// <returns></returns>
        public BasicResponse AddNetworkModules(NetworkModulesRequest NetworkModuleRequest)
        {
            BasicResponse     Result = new BasicResponse();
            List <Jc_MacInfo> items  = NetworkModuleRequest.NetworkModulesInfo;
            List <Jc_MacInfo> NetworkModuleCaches = new List <Jc_MacInfo>();
            Jc_MacInfo        olditem             = null;

            NetworkModuleCacheGetAllRequest NetworkModuleCacheRequest = new NetworkModuleCacheGetAllRequest();
            var result = _NetworkModuleCacheService.GetAllNetworkModuleCache(NetworkModuleCacheRequest);

            NetworkModuleCaches = result.Data;

            foreach (Jc_MacInfo item in items)
            {
                olditem = NetworkModuleCaches.Find(a => a.MAC == item.MAC);
                //增加重复判断
                if (olditem != null)
                { //缓存中存在此测点
                    Result.Code    = 1;
                    Result.Message = "当前添加列表中的数据在数据库中已经存在!";
                    return(Result);
                }
            }

            //向网关同步数据
            List <Jc_MacInfo> SendItemList = items;
            var resultSync = SynchronousDataToGateway(SendItemList);

            if (!resultSync)
            {
                Result.Code    = 1;
                Result.Message = "向网关同步数据失败!";
                return(Result);
            }

            TransactionsManager.BeginTransaction(() =>
            {
                foreach (Jc_MacInfo item in items)
                {
                    item.IsMemoryData = false;
                    //保存数据库
                    var _jc_Mac = ObjectConverter.Copy <Jc_MacInfo, Jc_MacModel>(item);
                    //保存数据库不存连接号  20170713
                    _jc_Mac.NetID    = 0;
                    var resultjc_Def = _Repository.AddNetworkModule(_jc_Mac);
                }


                //添加到缓存
                NetworkModuleCacheBatchAddRequest BatchAddNetworkModuleCacheRequest = new NetworkModuleCacheBatchAddRequest();
                BatchAddNetworkModuleCacheRequest.NetworkModuleInfos = items;
                _NetworkModuleCacheService.BacthAddNetworkModuleCache(BatchAddNetworkModuleCacheRequest);
            });

            return(Result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="jc_Defrequest"></param>
        /// <returns></returns>
        public BasicResponse UpdatePointDefines(PointDefinesUpdateRequest PointDefineRequest)
        {
            BasicResponse     Result       = new BasicResponse();
            List <Jc_DefInfo> items        = PointDefineRequest.PointDefinesInfo;
            List <Jc_DefInfo> Jc_DefCaches = new List <Jc_DefInfo>();     //人员定位测点缓存
            Jc_DefInfo        olditem      = null;

            B_DefCacheGetByConditionRequest bDefCacheRequest = new B_DefCacheGetByConditionRequest();

            bDefCacheRequest.predicate = a => a.Activity == "1";
            var result = _b_DefCacheService.Get(bDefCacheRequest);

            Jc_DefCaches = result.Data;

            foreach (Jc_DefInfo item in items)
            {
                olditem = Jc_DefCaches.Find(a => a.Point == item.Point && a.Activity == "1");

                //增加重复判断
                if (olditem == null)
                { //缓存中存在此测点
                    Result.Code    = 1;
                    Result.Message = "当前更新列表中的数据在数据库中不存在!";
                    return(Result);
                }
            }
            //向网关同步数据
            List <Jc_DefInfo> SendItemList = items;
            var resultSync = SynchronousDataToGateway(SendItemList);

            if (!resultSync)
            {
                Result.Code    = 1;
                Result.Message = "向网关同步数据失败!";
                return(Result);
            }
            TransactionsManager.BeginTransaction(() =>
            {
                foreach (Jc_DefInfo item in items)
                {
                    olditem = Jc_DefCaches.Find(a => a.Point == item.Point && a.Activity == "1");
                    //保存数据库
                    var _jc_Def = ObjectConverter.Copy <Jc_DefInfo, B_DefModel>(item);
                    _repository.UpdateDef(_jc_Def);

                    //置下发初始化标记
                    PointInitializes(item, olditem);

                    //更新缓存
                    UpdatePointDefineCacheByProperty(item);
                }
            });

            return(Result);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="ManualCrossControlRequest"></param>
        /// <returns></returns>
        public BasicResponse AddManualCrossControls(ManualCrossControlsRequest ManualCrossControlRequest)
        {
            BasicResponse        Result = new BasicResponse();
            List <Jc_JcsdkzInfo> items  = ManualCrossControlRequest.ManualCrossControlInfos;
            List <Jc_JcsdkzInfo> ManualCrossControlCaches = new List <Jc_JcsdkzInfo>();

            ManualCrossControlCacheGetAllRequest manualCrossControlCacheRequest = new ManualCrossControlCacheGetAllRequest();
            var result = _ManualCrossControlCacheService.GetAllManualCrossControlCache(manualCrossControlCacheRequest);

            ManualCrossControlCaches = result.Data;

            foreach (Jc_JcsdkzInfo item in items)
            {
                Jc_JcsdkzInfo itemCache = ManualCrossControlCaches.Find(a => a.ID == item.ID);
                if (itemCache != null)
                {
                    //缓存中存在此测点
                    Result.Code    = 1;
                    Result.Message = "当前添加的手动/交叉控制信息已存在!";
                    return(Result);
                }
            }
            //向网关同步数据
            List <Jc_JcsdkzInfo> SendItemList = items;
            var resultSync = SynchronousDataToGateway(SendItemList);

            if (!resultSync)
            {
                Result.Code    = 1;
                Result.Message = "向网关同步数据失败!";
                return(Result);
            }

            TransactionsManager.BeginTransaction(() =>
            {
                foreach (Jc_JcsdkzInfo item in items)
                {
                    //数据库操作
                    var _jc_Jcsdkz      = ObjectConverter.Copy <Jc_JcsdkzInfo, Jc_JcsdkzModel>(item);
                    var resultjc_Jcsdkz = _Repository.AddManualCrossControl(_jc_Jcsdkz);

                    //缓存操作
                    ManualCrossControlCacheAddRequest AddManualCrossControlCacheRequest = new ManualCrossControlCacheAddRequest();
                    AddManualCrossControlCacheRequest.ManualCrossControlInfo            = item;
                    _ManualCrossControlCacheService.AddManualCrossControlCache(AddManualCrossControlCacheRequest);
                }
            });

            //调用驱动重新加载控制信息
            DriverManualCrossControlReLoadRequest reLoadRequest = new DriverManualCrossControlReLoadRequest();

            _DriverManualCrossControlService.ReLoad(reLoadRequest);

            return(Result);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="DeviceDefineRequest"></param>
        /// <returns></returns>
        public BasicResponse AddDeviceDefines(DeviceDefinesRequest DeviceDefineRequest)
        {
            BasicResponse     Result       = new BasicResponse();
            List <Jc_DevInfo> items        = DeviceDefineRequest.Jc_DevsInfo;
            List <Jc_DevInfo> Jc_DevCaches = new List <Jc_DevInfo>();
            Jc_DevInfo        olditem      = null;

            DeviceDefineCacheGetAllRequest DeviceDefineCacheRequest = new DeviceDefineCacheGetAllRequest();
            var result = _DeviceDefineCacheService.GetAllPointDefineCache(DeviceDefineCacheRequest);

            Jc_DevCaches = result.Data;

            foreach (Jc_DevInfo item in items)
            {
                olditem = Jc_DevCaches.Find(a => a.Devid == item.Devid);
                //增加重复判断
                if (olditem != null)
                { //缓存中存在此测点
                    Result.Code    = 1;
                    Result.Message = "当前添加列表中的数据在数据库中已经存在!";
                    return(Result);
                }
            }
            //向网关同步数据
            List <Jc_DevInfo> SendItemList = items;
            var resultSync = SynchronousDataToGateway(SendItemList);

            if (!resultSync)
            {
                Result.Code    = 1;
                Result.Message = "向网关同步数据失败!";
                return(Result);
            }
            TransactionsManager.BeginTransaction(() =>
            {
                foreach (Jc_DevInfo item in items)
                {
                    //保存数据库
                    var _Jc_Dev      = ObjectConverter.Copy <Jc_DevInfo, Jc_DevModel>(item);
                    var resultJc_Dev = _Repository.AddDeviceDefine(_Jc_Dev);
                }

                //添加到缓存
                DeviceDefineCacheBatchAddRequest BacthAddPointDefineRequest = new DeviceDefineCacheBatchAddRequest();
                BacthAddPointDefineRequest.DeviceDefineInfos = items;
                _DeviceDefineCacheService.BacthAddPointDefineCache(BacthAddPointDefineRequest);
            });

            return(Result);
        }
        public BasicResponse EndAll(EndAllRequest request)
        {
            var notEndRec = _Repository.GetNotEndEmergencyLinkHistory();

            TransactionsManager.BeginTransaction(() =>
            {
                foreach (var item in notEndRec)
                {
                    item.EndTime = request.EndTime;
                    _Repository.UpdateEmergencyLinkHistory(item);
                }
            });
            return(new BasicResponse());
        }
        public BasicResponse BatchAddEmergencyLinkHistory(BatchAddEmergencyLinkHistoryRequest request)
        {
            var lisModel =
                ObjectConverter.CopyList <EmergencyLinkHistoryInfo, EmergencyLinkHistoryModel>(
                    request.LisEmergencyLinkHistoryInfo);

            TransactionsManager.BeginTransaction(() =>
            {
                foreach (var itmem in lisModel)
                {
                    _Repository.AddEmergencyLinkHistory(itmem);
                }
            });
            return(new BasicResponse());
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        public BasicResponse <JC_AlarmNotificationPersonnelConfigInfo> AddJC_AlarmNotificationPersonnelConfig(AlarmNotificationPersonnelConfigAddRequest jC_Alarmnotificationpersonnelconfigrequest)
        {
            var _jC_AlarmNotificationPersonnel = ObjectConverter.CopyList <JC_AlarmNotificationPersonnelInfo, JC_AlarmNotificationPersonnelModel>
                                                     (jC_Alarmnotificationpersonnelconfigrequest.JC_AlarmNotificationPersonnelInfoList);

            var _jC_Alarmnotificationpersonnelconfig = ObjectConverter.Copy <JC_AlarmNotificationPersonnelConfigInfo, JC_AlarmnotificationpersonnelconfigModel>(
                jC_Alarmnotificationpersonnelconfigrequest.JC_AlarmNotificationPersonnelConfigInfo
                );

            IList <JC_AlarmnotificationpersonnelconfigModel> alarmConfig = _Repository.GetAlarmNotificationPersonnelConfigByAnalysisModelId(_jC_Alarmnotificationpersonnelconfig.AnalysisModelId);

            if (alarmConfig != null && alarmConfig.ToList().Count > 0)
            {
                return new BasicResponse <JC_AlarmNotificationPersonnelConfigInfo>()
                       {
                           Message = "分析模型已配置报警通知!", Code = -100, Data = jC_Alarmnotificationpersonnelconfigrequest.JC_AlarmNotificationPersonnelConfigInfo
                       }
            }
            ;

            JC_AlarmnotificationpersonnelconfigModel addedAlarmnotificationpersonnelconfigModel = null;

            TransactionsManager.BeginTransaction(() =>
            {
                addedAlarmnotificationpersonnelconfigModel = _Repository.AddJC_AlarmNotificationPersonnelConfig(_jC_Alarmnotificationpersonnelconfig);
                if (jC_Alarmnotificationpersonnelconfigrequest.JC_AlarmNotificationPersonnelInfoList != null)
                {
                    _AlarmNotificationPersonnelRepository.AddJC_AlarmNotificationPersonnelList(_jC_AlarmNotificationPersonnel.ToList());
                }
            });

            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 <JC_AlarmNotificationPersonnelConfigInfo>();

            jC_Alarmnotificationpersonnelconfigresponse.Data = jC_Alarmnotificationpersonnelconfigrequest.JC_AlarmNotificationPersonnelConfigInfo;
            return(jC_Alarmnotificationpersonnelconfigresponse);
        }
        public BasicResponse EndByLinkageId(EndByLinkageIdRequest request)
        {
            var models = _Repository.GetNotEndEmergencyLinkHistoryByLinkageId(request.Id);

            TransactionsManager.BeginTransaction(() =>
            {
                foreach (var item in models)
                {
                    if (item.EndTime != new DateTime(1900, 1, 1))
                    {
                        continue;
                    }

                    item.EndTime = request.EndTime;
                    _Repository.UpdateEmergencyLinkHistory(item);
                }
            });
            return(new BasicResponse());
        }
        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="PositionRequest"></param>
        /// <returns></returns>
        public BasicResponse AddPositions(PositionsRequest PositionRequest)
        {
            BasicResponse    Result         = new BasicResponse();
            List <Jc_WzInfo> items          = PositionRequest.PositionsInfo;
            List <Jc_WzInfo> PositionCaches = new List <Jc_WzInfo>();
            Jc_WzInfo        olditem        = null;

            PositionCacheGetAllRequest positionCacheRequest = new PositionCacheGetAllRequest();
            var result = _PositionCacheService.GetAllPositongCache(positionCacheRequest);

            PositionCaches = result.Data;

            foreach (Jc_WzInfo item in items)
            {
                olditem = PositionCaches.Find(a => a.WzID == item.WzID);
                //增加重复判断
                if (result.Data != null)
                { //缓存中存在此测点
                    Result.Code    = 1;
                    Result.Message = "当前添加的安装位置已存在!";
                    return(Result);
                }
            }


            TransactionsManager.BeginTransaction(() =>
            {
                foreach (Jc_WzInfo item in items)
                {
                    //保存数据库
                    var _jc_Wz      = ObjectConverter.Copy <Jc_WzInfo, Jc_WzModel>(item);
                    var resultjc_Wz = _Repository.AddPosition(_jc_Wz);
                }

                //保存缓存
                PositionCacheBatchAddRequest BatchAddPositionCacheRequest = new PositionCacheBatchAddRequest();
                BatchAddPositionCacheRequest.PositionInfos = items;
                _PositionCacheService.BatchAddPositionCache(BatchAddPositionCacheRequest);
            });

            return(Result);
        }
Exemplo n.º 16
0
 public BasicResponse EndBcallDbByBcallInfoList(EndBcallDbByBcallInfoListRequest request)
 {
     TransactionsManager.BeginTransaction(() =>
     {
         foreach (var item in request.Info)
         {
             if (item.CallType == 1)
             {
                 item.CallType = 2;
                 var req       = new B_CallUpdateRequest()
                 {
                     CallInfo = item
                 };
                 var _call = ObjectConverter.Copy <B_CallInfo, B_CallModel>(item);
                 _Repository.UpdateCall(_call);
             }
         }
     });
     return(new BasicResponse());
 }
Exemplo n.º 17
0
        public BasicResponse <List <JC_AlarmNotificationPersonnelConfigInfo> > AddAlarmNotificationPersonnelConfig(AlarmNotificationPersonnelConfigListAddRequest addRequest)
        {
            var addConfigParameter    = addRequest.JC_AlarmNotificationPersonnelConfigListInfo;
            var addPersonnelParameter = addRequest.JC_AlarmNotificationPersonnelInfoList;

            TransactionsManager.BeginTransaction(() =>
            {
                foreach (var item in addConfigParameter)
                {
                    IList <JC_AlarmnotificationpersonnelconfigModel> alarmConfig = _Repository.GetAlarmNotificationPersonnelConfigByAnalysisModelId(item.AnalysisModelId);
                    if (alarmConfig != null && alarmConfig.ToList().Count > 0)
                    {
                        continue;
                    }
                    //item.Id = IdHelper.CreateGuidId();
                    item.Id       = IdHelper.CreateLongId().ToString();
                    var config    = ObjectConverter.Copy <JC_AlarmNotificationPersonnelConfigInfo, JC_AlarmnotificationpersonnelconfigModel>(item);
                    var personnel = ObjectConverter.CopyList <JC_AlarmNotificationPersonnelInfo, JC_AlarmNotificationPersonnelModel>(addPersonnelParameter);
                    foreach (var p in personnel)
                    {
                        p.Id            = IdHelper.CreateLongId().ToString();
                        p.AlarmConfigId = item.Id;
                    }

                    _Repository.AddJC_AlarmNotificationPersonnelConfig(config);
                    _AlarmNotificationPersonnelRepository.AddJC_AlarmNotificationPersonnelList(personnel.ToList());
                }
            });
            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 response = new BasicResponse <List <JC_AlarmNotificationPersonnelConfigInfo> >();

            response.Data = addConfigParameter;
            return(response);
        }
Exemplo n.º 18
0
        public BasicResponse EndRcallByRcallInfoList(EndRcallByRcallInfoListEequest request)
        {
            //var dicInPar = new Dictionary<string, object>();
            //dicInPar.Add("CallType", 2);
            //var dicPar = new Dictionary<string, Dictionary<string, object>>();
            //foreach (var item in request.RcallInfo)
            //{
            //    if (item.CallType == 1)
            //    {
            //        dicPar.Add(item.Id, dicInPar);
            //    }
            //}
            //var req4 = new R_CallUpdateProperitesRequest()
            //{
            //    updateItems = dicPar
            //};
            //this.BachUpdateAlarmInfoProperties(req4);

            //var models = ObjectConverter.CopyList<R_CallInfo, R_CallModel>(request.RcallInfo);
            TransactionsManager.BeginTransaction(() =>
            {
                foreach (var item in request.RcallInfo)
                {
                    if (item.CallType == 1)
                    {
                        item.CallType = 2;
                        //_Repository.UpdateCall(item);
                        var req = new R_CallUpdateRequest()
                        {
                            CallInfo = item
                        };
                        UpdateCall(req);
                    }
                }
            });

            return(new BasicResponse());
        }
        public BasicResponse DeleteJC_Analysistemplate(AnalysisTemplateDeleteRequest jC_Analysistemplaterequest)
        {
            TransactionsManager.BeginTransaction(() =>
            {
                foreach (var item in jC_Analysistemplaterequest.Ids)
                {
                    _Repository.DeleteJC_Analysistemplate(item);

                    //1.删除表达式
                    //根据模板ID 查询表达式信息
                    //global_AnalyticalExpressionService_GetAnalyticalExpressionListByTempleteId
                    _analyticalExpressionRepository.DeleteJC_AnalyticalexpressionByTempleteId(item);

                    //2.删除分析模板配置表
                    _analysisTemplateConfigRepository.DeleteJC_AnalysistemplateconfigByTempleteId(item);
                    //3.删除表达式配置表
                    _expressionConfigRepository.DeleteJC_ExpressionconfigByTempleteId(item);
                }
            });
            var jC_Analysistemplateresponse = new BasicResponse();

            return(jC_Analysistemplateresponse);
        }
        /// <summary>
        /// 更新分析模型。
        /// </summary>
        /// <param name="jc_LargedataAnalysisConfigRsequest">更新模型请求对象</param>
        /// <returns>Mas应答对象包含分析模型</returns>
        public BasicResponse <JC_LargedataAnalysisConfigInfo> UpdateLargeDataAnalysisConfig(LargedataAnalysisConfigUpdateRequest jc_LargedataAnalysisConfigRsequest)
        {
            BasicResponse validationResponse = largeDataAnalysisConfigValidation(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo);

            if (!validationResponse.IsSuccess)
            {
                return new BasicResponse <JC_LargedataAnalysisConfigInfo>()
                       {
                           Code = validationResponse.Code, Message = validationResponse.Message, Data = jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo
                       }
            }
            ;
            if (string.IsNullOrEmpty(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.Id))
            {
                return(new BasicResponse <JC_LargedataAnalysisConfigInfo>()
                {
                    Code = 1, Message = "分析模型ID为空", Data = jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo
                });
            }
            var _jC_Largedataanalysisconfig        = ObjectConverter.Copy <JC_LargedataAnalysisConfigInfo, JC_LargedataanalysisconfigModel>(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo);
            var _jcSetAnalysisModelPointRecordList = ObjectConverter.CopyList <JC_SetAnalysisModelPointRecordInfo, JC_SetanalysismodelpointrecordModel>(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.AnalysisModelPointRecordInfoList);

            bool isSingleExpressionAndParameter1 = isSingleExpressionAndParameter(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.TempleteId);
            bool isBindDevType = jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.AnalysisModelPointRecordInfoList[0].DevTypeId > -1;

            if (isSingleExpressionAndParameter1 && _jcSetAnalysisModelPointRecordList.Count > 0 && !isBindDevType)
            {
                _jC_Largedataanalysisconfig.Name = System.Text.RegularExpressions.Regex.Replace(_jC_Largedataanalysisconfig.Name, "\\(\\w+\\)", string.Format("({0})", jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.AnalysisModelPointRecordInfoList[0].Point));
            }


            JC_LargedataanalysisconfigModel existsModel = _Repository.GetLargeDataAnalysisConfigByName(_jC_Largedataanalysisconfig.Name);

            if (null != existsModel && existsModel.Id != _jC_Largedataanalysisconfig.Id)
            {
                return new BasicResponse <JC_LargedataAnalysisConfigInfo>()
                       {
                           Code = -100, Message = "分析模型名称已存在", Data = jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo
                       }
            }
            ;


            TransactionsManager.BeginTransaction(() =>
            {
                //更新分析模型
                //_jC_Largedataanalysisconfig.UpdatedTime = DateTime.Now;
                //更新时间不变化,这里将分析模型名称改了再改回来。
                string analysisModelName         = _jC_Largedataanalysisconfig.Name;
                _jC_Largedataanalysisconfig.Name = analysisModelName + "1";
                _Repository.UpdateJC_Largedataanalysisconfig(_jC_Largedataanalysisconfig);
                _jC_Largedataanalysisconfig.Name = analysisModelName;
                _Repository.UpdateJC_Largedataanalysisconfig(_jC_Largedataanalysisconfig);
                //先删除再插入
                _AnalysisModelPointRecordRepository.DeleteAnalysisModelPointRecordByAnalysisModelId(_jC_Largedataanalysisconfig.Id);
                foreach (var item in _jcSetAnalysisModelPointRecordList)
                {
                    //item.Id = IdHelper.CreateGuidId();
                    item.Id = IdHelper.CreateLongId().ToString();
                    item.AnalysisModelId = _jC_Largedataanalysisconfig.Id;
                }
                //插入模型测点关联记录
                _AnalysisModelPointRecordRepository.Insert(_jcSetAnalysisModelPointRecordList);
            });
            var jC_Largedataanalysisconfigresponse = new BasicResponse <JC_LargedataAnalysisConfigInfo>();

            jC_Largedataanalysisconfigresponse.Data = ObjectConverter.Copy <JC_LargedataanalysisconfigModel, JC_LargedataAnalysisConfigInfo>(_jC_Largedataanalysisconfig);
            BasicResponse <IList <JC_SetAnalysisModelPointRecordInfo> > pointListResponse = _AnalysisModelPointRecordService.GetCustomizationAnalysisModelPointRecordInfoByModelId(new SetAnalysisModelPointRecordByModelIdGetRequest()
            {
                AnalysisModelId = _jC_Largedataanalysisconfig.Id
            });

            if (pointListResponse != null && pointListResponse.Data != null)
            {
                jC_Largedataanalysisconfigresponse.Data.AnalysisModelPointRecordInfoList = pointListResponse.Data.ToList();
            }
            try
            {
                jC_Largedataanalysisconfigresponse.Data.AnalysisResult = 0;
                jC_Largedataanalysisconfigresponse.Data.AnalysisTime   = null;

                //更新实时显示到缓存,这样客户端刷新就可以看到。不用等到分析周期. 开始
                jC_Largedataanalysisconfigresponse.Data.ExpressionRealTimeResultList = new List <ExpressionRealTimeResultInfo>();
                if (jC_Largedataanalysisconfigresponse.Data.AnalysisModelPointRecordInfoList != null && jC_Largedataanalysisconfigresponse.Data.AnalysisModelPointRecordInfoList.Count > 0)
                {
                    IEnumerable <IGrouping <string, JC_SetAnalysisModelPointRecordInfo> > expressionGroup = jC_Largedataanalysisconfigresponse.Data.AnalysisModelPointRecordInfoList.GroupBy(p => p.ExpressionId);
                    foreach (IGrouping <string, JC_SetAnalysisModelPointRecordInfo> expressionParameterList in expressionGroup)
                    {
                        if (expressionParameterList.FirstOrDefault().DevTypeId == -1)//绑定测点的情况才更新实时显示的表达式
                        {
                            ExpressionRealTimeResultInfo addInitializeResultInfo = new ExpressionRealTimeResultInfo();
                            addInitializeResultInfo.AnalysisModelId     = jC_Largedataanalysisconfigresponse.Data.Id;
                            addInitializeResultInfo.AnalysisModelName   = jC_Largedataanalysisconfigresponse.Data.Name;
                            addInitializeResultInfo.ExpressionId        = expressionParameterList.FirstOrDefault().ExpressionId;
                            addInitializeResultInfo.Expression          = expressionParameterList.FirstOrDefault().Expresstion;
                            addInitializeResultInfo.ExpressionText      = expressionParameterList.FirstOrDefault().Expresstion;
                            addInitializeResultInfo.FirstSuccessfulTime = DateTime.MinValue;
                            addInitializeResultInfo.LastAnalysisTime    = DateTime.MinValue;
                            addInitializeResultInfo.AnalysisResult      = 0;
                            addInitializeResultInfo.AnalysisResultText  = "未知";
                            addInitializeResultInfo.ContinueTime        = expressionParameterList.FirstOrDefault().ContinueTime;
                            addInitializeResultInfo.MaxContinueTime     = expressionParameterList.FirstOrDefault().MaxContinueTime;
                            addInitializeResultInfo.ActualContinueTime  = 0;
                            foreach (var pointMapping in expressionParameterList)
                            {
                                addInitializeResultInfo.ExpressionText = addInitializeResultInfo.ExpressionText.Replace(pointMapping.ExpressionConfigId, string.Format("{0}->{1}", pointMapping.PointId, pointMapping.FactorName));
                            }
                            jC_Largedataanalysisconfigresponse.Data.ExpressionRealTimeResultList.Add(addInitializeResultInfo);
                        }
                    }
                }
                //更新实时显示到缓存,这样客户端刷新就可以看到。不用等到分析周期. 结束

                //更新缓存
                _LargeDataAnalysisConfigCacheService.UpdateLargeDataAnalysisConfigCahce(new LargeDataAnalysisConfigCacheUpdateRequest()
                {
                    LargeDataAnalysisConfigInfo = jC_Largedataanalysisconfigresponse.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);
            }
            return(jC_Largedataanalysisconfigresponse);
        }
        public BasicResponse AddEmergencylinkageconfigMasterInfoPassiveInfo(
            AddEmergencylinkageconfigMasterInfoPassiveInfoRequest request)
        {
            var exist = _Repository.AnySysEmergencyLinkageByLambda(a => a.Name == request.SysEmergencyLinkageInfo.Name && a.Activity == 1);

            if (exist)
            {
                return(new BasicResponse()
                {
                    Code = 1,
                    Message = "应急联动名称已存在!"
                });
            }

            //同一个大数据分析模型只能配置一个联动
            var masterModelId = request.SysEmergencyLinkageInfo.MasterModelId;

            if (masterModelId != "0")
            {
                var req4 = new EmergencyLinkageConfigCacheGetByConditonRequest
                {
                    Predicate = a => a.MasterModelId == masterModelId
                };
                var res4 = _sysEmergencyLinkageCacheService.GetSysEmergencyLinkageCache(req4);
                if (res4.Data.Count != 0)
                {
                    return(new BasicResponse()
                    {
                        Code = 2,
                        Message = "同一个大数据分析模型只能配置一个应急联动!"
                    });
                }
            }

            request.SysEmergencyLinkageInfo.Id = IdHelper.CreateLongId().ToString();

            //主控测点关联id
            if (request.EmergencyLinkageMasterPointAssInfo.Count != 0)
            {
                request.SysEmergencyLinkageInfo.MasterPointAssId = IdHelper.CreateLongId().ToString();
            }
            else
            {
                request.SysEmergencyLinkageInfo.MasterPointAssId = "0";
            }

            //主控设备类型关联id
            if (request.EmergencyLinkageMasterDevTypeAssInfo.Count != 0)
            {
                request.SysEmergencyLinkageInfo.MasterDevTypeAssId = IdHelper.CreateLongId().ToString();
            }
            else
            {
                request.SysEmergencyLinkageInfo.MasterDevTypeAssId = "0";
            }

            //主控区域关联id
            if (request.EmergencyLinkageMasterAreaAssInfo.Count != 0)
            {
                request.SysEmergencyLinkageInfo.MasterAreaAssId = IdHelper.CreateLongId().ToString();
            }
            else
            {
                request.SysEmergencyLinkageInfo.MasterAreaAssId = "0";
            }

            request.SysEmergencyLinkageInfo.MasterTriDataStateAssId = IdHelper.CreateLongId().ToString();       //主控触发数据状态

            //被控测点关联id
            if (request.EmergencyLinkagePassivePointAssInfo.Count != 0)
            {
                request.SysEmergencyLinkageInfo.PassivePointAssId = IdHelper.CreateLongId().ToString();
            }
            else
            {
                request.SysEmergencyLinkageInfo.PassivePointAssId = "0";
            }

            //被控区域关联id
            if (request.EmergencyLinkagePassiveAreaAssInfo.Count != 0)
            {
                request.SysEmergencyLinkageInfo.PassiveAreaAssId = IdHelper.CreateLongId().ToString();
            }
            else
            {
                request.SysEmergencyLinkageInfo.PassiveAreaAssId = "0";
            }

            //被控人员关联id
            if (request.EmergencyLinkagePassivePersonAssInfo.Count != 0)
            {
                request.SysEmergencyLinkageInfo.PassivePersonAssId = IdHelper.CreateLongId().ToString();
            }
            else
            {
                request.SysEmergencyLinkageInfo.PassivePersonAssId = "0";
            }

            foreach (var item in request.EmergencyLinkageMasterAreaAssInfo)
            {
                item.Id = IdHelper.CreateLongId().ToString();
                item.MasterAreaAssId = request.SysEmergencyLinkageInfo.MasterAreaAssId;
            }

            foreach (var item in request.EmergencyLinkageMasterDevTypeAssInfo)
            {
                item.Id = IdHelper.CreateLongId().ToString();
                item.MasterDevTypeAssId = request.SysEmergencyLinkageInfo.MasterDevTypeAssId;
            }

            foreach (var item in request.EmergencyLinkageMasterPointAssInfo)
            {
                item.Id = IdHelper.CreateLongId().ToString();
                item.MasterPointAssId = request.SysEmergencyLinkageInfo.MasterPointAssId;
            }

            foreach (var item in request.EmergencyLinkageMasterTriDataStateAssInfo)
            {
                item.Id = IdHelper.CreateLongId().ToString();
                item.MasterTriDataStateAssId = request.SysEmergencyLinkageInfo.MasterTriDataStateAssId;
            }

            foreach (var item in request.EmergencyLinkagePassiveAreaAssInfo)
            {
                item.Id = IdHelper.CreateLongId().ToString();
                item.PassiveAreaAssId = request.SysEmergencyLinkageInfo.PassiveAreaAssId;
            }

            foreach (var item in request.EmergencyLinkagePassivePersonAssInfo)
            {
                item.Id = IdHelper.CreateLongId().ToString();
                item.PassivePersonAssId = request.SysEmergencyLinkageInfo.PassivePersonAssId;
            }

            var req = new V_DefCacheGetAllRequest();
            var res = _vDefCacheService.GetAll(req);

            if (res.Code != 100)
            {
                throw new Exception(res.Message);
            }
            var allVideoPoint = res.Data;     //所有视频系统测点

            var res2 = _personPointDefineService.GetAllPointDefineCache();

            if (res2.Code != 100)
            {
                throw new Exception(res2.Message);
            }
            var allPersonPoint = res2.Data;     //所有人员定位系统测点

            var req3 = new B_DefCacheGetAllRequest();
            var res3 = _bDefCacheService.GetAll(req3);

            if (res3.Code != 100)
            {
                throw new Exception(res3.Message);
            }
            var allBroadcastPoint = res3.Data;      //所有广播系统测点


            foreach (var item in request.EmergencyLinkagePassivePointAssInfo)
            {
                item.Id = IdHelper.CreateLongId().ToString();
                item.PassivePointAssId = request.SysEmergencyLinkageInfo.PassivePointAssId;

                var existMonitoringPoint = allVideoPoint.Any(a => a.Id == item.PointId);
                if (existMonitoringPoint)
                {
                    item.Sysid = 74;
                }

                var existPersonPoint = allPersonPoint.Any(a => a.PointID == item.PointId);
                if (existPersonPoint)
                {
                    item.Sysid = 11;
                }

                var existBroadcastPoint = allBroadcastPoint.Any(a => a.PointID == item.PointId);
                if (existBroadcastPoint)
                {
                    item.Sysid = 12;
                }
            }

            request.SysEmergencyLinkageInfo.EditTime     = DateTime.Now;
            request.SysEmergencyLinkageInfo.Activity     = 1;
            request.SysEmergencyLinkageInfo.DeletePerson = "";
            request.SysEmergencyLinkageInfo.DeleteTime   = Convert.ToDateTime("1900-01-01");
            request.SysEmergencyLinkageInfo.Bz1          = "";
            request.SysEmergencyLinkageInfo.Bz2          = "";
            request.SysEmergencyLinkageInfo.Bz3          = "";

            TransactionsManager.BeginTransaction(() =>
            {
                var model = ObjectConverter.Copy <SysEmergencyLinkageInfo, SysEmergencyLinkageModel>(request.SysEmergencyLinkageInfo);
                _Repository.AddSysEmergencyLinkage(model);

                foreach (var item in request.EmergencyLinkageMasterAreaAssInfo)
                {
                    var model2 = ObjectConverter
                                 .Copy <EmergencyLinkageMasterAreaAssInfo, EmergencyLinkageMasterAreaAssModel>(item);
                    _emergencyLinkageMasterAreaAssRepository.AddEmergencyLinkageMasterAreaAss(model2);
                }
                foreach (var item in request.EmergencyLinkageMasterDevTypeAssInfo)
                {
                    var model3 = ObjectConverter
                                 .Copy <EmergencyLinkageMasterDevTypeAssInfo, EmergencyLinkageMasterDevTypeAssModel>(item);
                    _emergencyLinkageMasterDevTypeAssRepository.AddEmergencyLinkageMasterDevTypeAss(model3);
                }
                foreach (var item in request.EmergencyLinkageMasterPointAssInfo)
                {
                    var model4 = ObjectConverter
                                 .Copy <EmergencyLinkageMasterPointAssInfo, EmergencyLinkageMasterPointAssModel>(item);
                    _emergencyLinkageMasterPointAssRepository.AddEmergencyLinkageMasterPointAss(model4);
                }
                foreach (var item in request.EmergencyLinkageMasterTriDataStateAssInfo)
                {
                    var model5 = ObjectConverter
                                 .Copy <EmergencyLinkageMasterTriDataStateAssInfo, EmergencyLinkageMasterTriDataStateAssModel>(
                        item);
                    _emergencyLinkageMasterTriDataStateAssRepository.AddEmergencyLinkageMasterTriDataStateAss(model5);
                }
                foreach (var item in request.EmergencyLinkagePassiveAreaAssInfo)
                {
                    var model6 = ObjectConverter
                                 .Copy <EmergencyLinkagePassiveAreaAssInfo, EmergencyLinkagePassiveAreaAssModel>(item);
                    _emergencyLinkagePassiveAreaAssRepository.AddEmergencyLinkagePassiveAreaAss(model6);
                }
                foreach (var item in request.EmergencyLinkagePassivePersonAssInfo)
                {
                    var model7 = ObjectConverter
                                 .Copy <EmergencyLinkagePassivePersonAssInfo, EmergencyLinkagePassivePersonAssModel>(item);
                    _emergencyLinkagePassivePersonAssRepository.AddEmergencyLinkagePassivePersonAss(model7);
                }
                foreach (var item in request.EmergencyLinkagePassivePointAssInfo)
                {
                    var model8 = ObjectConverter
                                 .Copy <EmergencyLinkagePassivePointAssInfo, EmergencyLinkagePassivePointAssModel>(item);
                    _emergencyLinkagePassivePointAssRepository.AddEmergencyLinkagePassivePointAss(model8);
                }
            });

            //更新缓存
            request.SysEmergencyLinkageInfo.MasterAreas           = request.EmergencyLinkageMasterAreaAssInfo;
            request.SysEmergencyLinkageInfo.MasterDevTypes        = request.EmergencyLinkageMasterDevTypeAssInfo;
            request.SysEmergencyLinkageInfo.MasterPoint           = request.EmergencyLinkageMasterPointAssInfo;
            request.SysEmergencyLinkageInfo.MasterTriDataStates   = request.EmergencyLinkageMasterTriDataStateAssInfo;
            request.SysEmergencyLinkageInfo.PassiveAreas          = request.EmergencyLinkagePassiveAreaAssInfo;
            request.SysEmergencyLinkageInfo.PassivePersons        = request.EmergencyLinkagePassivePersonAssInfo;
            request.SysEmergencyLinkageInfo.PassivePoints         = request.EmergencyLinkagePassivePointAssInfo;
            request.SysEmergencyLinkageInfo.EmergencyLinkageState = 0;

            var req2 = new EmergencyLinkageConfigCacheAddRequest
            {
                SysEmergencyLinkageInfo = request.SysEmergencyLinkageInfo
            };

            _sysEmergencyLinkageCacheService.AddSysEmergencyLinkageCache(req2);

            return(new BasicResponse());
        }
        /// <summary>
        /// 批量新增区域断点设置
        /// </summary>
        /// <param name="jC_RegionOutageConfigListAddRequest"></param>
        /// <returns></returns>
        public BasicResponse <List <JC_RegionOutageConfigInfo> > AddJC_RegionOutageConfigList(RegionOutageConfigListAddRequest jC_RegionOutageConfigListAddRequest)
        {
            string analysisModelId        = jC_RegionOutageConfigListAddRequest.AnalysisModelId;
            var    _jC_RegionOutageConfig = ObjectConverter.CopyList <JC_RegionOutageConfigInfo, JC_RegionoutageconfigModel>(jC_RegionOutageConfigListAddRequest.JC_RegionOutageConfigInfoList);
            List <JC_RegionoutageconfigModel> updateList = _jC_RegionOutageConfig == null ? new List <JC_RegionoutageconfigModel>() : _jC_RegionOutageConfig.ToList();
            List <JC_RegionoutageconfigModel> regionOutageByModelList = _Repository.GetRegionOutageConfigListByAnalysisModelId(analysisModelId);
            List <JC_RegionoutageconfigModel> removeList = new List <JC_RegionoutageconfigModel>();
            List <Jc_JcsdkzInfo> removeSDKZControlList   = new List <Jc_JcsdkzInfo>();


            if (regionOutageByModelList != null && regionOutageByModelList.Count > 0)
            {
                var oriControlList = regionOutageByModelList.Where(q => q.ControlStatus == 1).ToList();
                //var oriRemoveControlList = regionOutageByModelList.Where(q => q.ControlStatus == 0).ToList();
                foreach (var item in oriControlList)
                {
                    if (!updateList.Where(q => q.ControlStatus == 1).ToList().Exists(q => q.PointId == item.PointId))
                    {
                        removeList.Add(item);
                    }
                }

                /*
                 * foreach (var item in oriRemoveControlList)
                 * {
                 *  if (!updateList.Where(q => q.ControlStatus == 0).ToList().Exists(q => q.PointId == item.PointId))
                 *  {
                 *      var switchModelId = ObjectConverter.Copy<JC_RegionoutageconfigModel, JC_RegionoutageconfigModel>(item);
                 *      switchModelId.AnalysisModelId = switchModelId.RemoveModelId;
                 *      removeList.Add(switchModelId);
                 *  }
                 * }
                 */
            }
            if (removeList.Count > 0)
            {
                IEnumerable <IGrouping <string, JC_RegionoutageconfigModel> > removeSDKZModelGroup = removeList.GroupBy(p => p.AnalysisModelId);
                foreach (var removeSDKZModelList in removeSDKZModelGroup)
                {
                    string queryAnalysisModelId = removeSDKZModelList.FirstOrDefault().AnalysisModelId;
                    BasicResponse <List <Jc_JcsdkzInfo> > analysisZKResponse = manualCrossControlService.GetManualCrossControlByTypeZkPoint(new ManualCrossControlGetByTypeZkPointRequest()
                    {
                        ZkPoint = queryAnalysisModelId, Type = (short)Enums.ControlType.LargeDataAnalyticsAreaPowerOff
                    });
                    if (analysisZKResponse != null && analysisZKResponse.Data != null && analysisZKResponse.Data.Count > 0)
                    {
                        foreach (var removeSDKZModel in removeSDKZModelList)
                        {
                            BasicResponse <Jc_DefInfo> cachedPoint = pointDefineCacheService.PointDefineCacheByPointIdRequeest(new Sys.Safety.Request.Cache.PointDefineCacheByPointIdRequeest()
                            {
                                PointID = removeSDKZModel.PointId
                            });
                            if (null != cachedPoint && cachedPoint.Data != null)
                            {
                                Jc_JcsdkzInfo removeSDKZInfo = analysisZKResponse.Data.FirstOrDefault(q => q.Bkpoint == cachedPoint.Data.Point);
                                if (null != removeSDKZInfo)
                                {
                                    removeSDKZControlList.Add(removeSDKZInfo);
                                }
                            }
                        }
                    }
                }
            }

            TransactionsManager.BeginTransaction(() =>
            {
                if (removeSDKZControlList.Count > 0)
                {
                    manualCrossControlService.DeleteManualCrossControls(new ManualCrossControlsRequest()
                    {
                        ManualCrossControlInfos = removeSDKZControlList
                    });
                }
                _Repository.DeleteUserRoleByAnalysisModelId(analysisModelId);
                _Repository.AddJC_RegionOutageConfigList(_jC_RegionOutageConfig.ToList());
            });
            if (Basic.Framework.Data.PlatRuntime.Items.ContainsKey(DataContract.UserRoleAuthorize.KeyConst.RegionOutageChangedKey))
            {
                Basic.Framework.Data.PlatRuntime.Items[DataContract.UserRoleAuthorize.KeyConst.RegionOutageChangedKey] = DateTime.Now;
            }
            else
            {
                Basic.Framework.Data.PlatRuntime.Items.Add(DataContract.UserRoleAuthorize.KeyConst.RegionOutageChangedKey, DateTime.Now);
            }
            var jC_RegionOutageConfig = new BasicResponse <List <JC_RegionOutageConfigInfo> >();

            jC_RegionOutageConfig.Data = jC_RegionOutageConfigListAddRequest.JC_RegionOutageConfigInfoList;
            return(jC_RegionOutageConfig);
        }
        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="NetworkModuleRequest"></param>
        /// <returns></returns>
        public BasicResponse UpdateNetworkModules(NetworkModulesRequest NetworkModuleRequest)
        {
            BasicResponse     Result = new BasicResponse();
            List <Jc_MacInfo> items  = NetworkModuleRequest.NetworkModulesInfo;
            List <Jc_MacInfo> NetworkModuleCaches = new List <Jc_MacInfo>();
            Jc_MacInfo        olditem             = null;

            NetworkModuleCacheGetAllRequest NetworkModuleCacheRequest = new NetworkModuleCacheGetAllRequest();
            var result = _NetworkModuleCacheService.GetAllNetworkModuleCache(NetworkModuleCacheRequest);

            NetworkModuleCaches = result.Data;

            foreach (Jc_MacInfo item in items)
            {
                olditem = NetworkModuleCaches.Find(a => a.MAC == item.MAC);
                //增加重复判断
                if (olditem == null)
                { //缓存中存在此测点
                    Result.Code    = 1;
                    Result.Message = "当前更新列表中的数据在数据库中不存在!";
                    return(Result);
                }
                else
                {
                    if (olditem.IsMemoryData)//如果内存中存在数据,则重置添加、修改标记  20170415
                    {
                        if (olditem.InfoState == InfoState.AddNew)
                        {
                            if (item.InfoState == InfoState.Modified)
                            {
                                item.InfoState = InfoState.AddNew;
                            }
                        }
                        if (olditem.InfoState == InfoState.Delete)
                        {
                            if (item.InfoState == InfoState.AddNew)
                            {
                                item.InfoState = InfoState.Modified;
                            }
                        }
                        item.IsMemoryData = false;//置完标记后,将内存数据变成非内存数据标记  20170415
                    }
                }
            }
            //向网关同步数据
            List <Jc_MacInfo> SendItemList = items;
            var resultSync = SynchronousDataToGateway(SendItemList);

            if (!resultSync)
            {
                Result.Code    = 1;
                Result.Message = "向网关同步数据失败!";
                return(Result);
            }
            TransactionsManager.BeginTransaction(() =>
            {
                foreach (Jc_MacInfo item in items)
                {
                    if (item.InfoState == InfoState.AddNew)
                    {
                        //保存数据库
                        var _jc_Mac = ObjectConverter.Copy <Jc_MacInfo, Jc_MacModel>(item);
                        _Repository.AddNetworkModule(_jc_Mac);
                    }
                    else
                    {
                        //保存数据库
                        var _jc_Mac = ObjectConverter.Copy <Jc_MacInfo, Jc_MacModel>(item);
                        _Repository.UpdateNetworkModule(_jc_Mac);
                    }
                    //更新到缓存
                    UpdateNetworkModuleCacheByProperty(item);
                }
            });

            return(Result);
        }
        /// <summary>
        /// 添加分析模型,及其关联的测点。
        /// </summary>
        /// <param name="jc_LargedataAnalysisConfigRsequest">分析模型的添加请求</param>
        /// <returns>Mas应答对象包含分析模型</returns>
        public BasicResponse <JC_LargedataAnalysisConfigInfo> AddLargeDataAnalysisConfig(LargedataAnalysisConfigAddRequest jc_LargedataAnalysisConfigRsequest)
        {
            BasicResponse validationResponse = largeDataAnalysisConfigValidation(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo);

            if (!validationResponse.IsSuccess)
            {
                return new BasicResponse <JC_LargedataAnalysisConfigInfo>()
                       {
                           Code = validationResponse.Code, Message = validationResponse.Message, Data = jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo
                       }
            }
            ;
            var jC_Largedataanalysisconfigresponse = new BasicResponse <JC_LargedataAnalysisConfigInfo>();
            var _jC_Largedataanalysisconfig        = ObjectConverter.Copy <JC_LargedataAnalysisConfigInfo, JC_LargedataanalysisconfigModel>(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo);
            var _jcSetAnalysisModelPointRecordList = ObjectConverter.CopyList <JC_SetAnalysisModelPointRecordInfo, JC_SetanalysismodelpointrecordModel>(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.AnalysisModelPointRecordInfoList);

            bool isSingleExpressionAndParameter1 = isSingleExpressionAndParameter(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.TempleteId);
            bool isBindDevType = jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.AnalysisModelPointRecordInfoList[0].DevTypeId > -1;


            if (isSingleExpressionAndParameter1 && !isBindDevType /*&& jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.AnalysisModelPointRecordInfoList.Count > 1*/)
            {
                List <JC_SetAnalysisModelPointRecordInfo> listOfPoint = jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.AnalysisModelPointRecordInfoList;

                string[] pointIds = listOfPoint[0].PointId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (pointIds.Length > 1)
                {
                    foreach (var pointId in pointIds)
                    {
                        List <JC_SetAnalysisModelPointRecordInfo> toAddPointList = new List <JC_SetAnalysisModelPointRecordInfo>();
                        foreach (var oriPoint in listOfPoint)
                        {
                            JC_SetAnalysisModelPointRecordInfo addPoint = ObjectConverter.DeepCopy(oriPoint);
                            addPoint.PointId = pointId;
                            BasicResponse <Jc_DefInfo> pointDefine = pointDefineCacheService.PointDefineCacheByPointIdRequeest(new Sys.Safety.Request.Cache.PointDefineCacheByPointIdRequeest()
                            {
                                PointID = pointId
                            });
                            if (pointDefine.IsSuccess && pointDefine.Data != null)
                            {
                                addPoint.Point = pointDefine.Data.Point;
                            }
                            toAddPointList.Add(addPoint);
                        }

                        //JC_LargedataAnalysisConfigInfo largedataAnalysisConfigInfo = ObjectConverter.Copy<JC_LargedataAnalysisConfigInfo, JC_LargedataAnalysisConfigInfo>(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo);
                        JC_LargedataAnalysisConfigInfo largedataAnalysisConfigInfo = ObjectConverter.DeepCopy <JC_LargedataAnalysisConfigInfo>(jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo);

                        largedataAnalysisConfigInfo.AnalysisModelPointRecordInfoList = toAddPointList;
                        jC_Largedataanalysisconfigresponse = AddLargeDataAnalysisConfig(new LargedataAnalysisConfigAddRequest()
                        {
                            JC_LargedataAnalysisConfigInfo = largedataAnalysisConfigInfo
                        });
                    }
                    return(jC_Largedataanalysisconfigresponse);
                }
            }

            //给模型赋默认值 Start
            _jC_Largedataanalysisconfig.Id = IdHelper.CreateLongId().ToString();
            StringBuilder points = new StringBuilder();

            foreach (var jcSetAnalysisModelPointRecord in _jcSetAnalysisModelPointRecordList)
            {
                jcSetAnalysisModelPointRecord.Id = IdHelper.CreateLongId().ToString();
                jcSetAnalysisModelPointRecord.AnalysisModelId = _jC_Largedataanalysisconfig.Id;

                JC_SetAnalysisModelPointRecordInfo analysisModelPointRecordInfo = jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo.AnalysisModelPointRecordInfoList.FirstOrDefault(q => q.PointId == jcSetAnalysisModelPointRecord.PointId);
                if (string.IsNullOrEmpty(points.ToString()))
                {
                    points.Append(analysisModelPointRecordInfo.Point);
                }
                //points.Append(analysisModelPointRecordInfo.Point).Append(",");
            }
            if (string.IsNullOrEmpty(_jC_Largedataanalysisconfig.Name))
            {
                _jC_Largedataanalysisconfig.Name = _AnalysisTemplateRepository.GetJC_AnalysistemplateById(_jC_Largedataanalysisconfig.TempleteId).Name;
            }
            if (isSingleExpressionAndParameter1 && !isBindDevType)
            {
                _jC_Largedataanalysisconfig.Name = string.Format("{0}({1})", _jC_Largedataanalysisconfig.Name, points.ToString().Trim(','));
            }
            //给模型赋默认值 End

            JC_LargedataanalysisconfigModel existsModel = _Repository.GetLargeDataAnalysisConfigByName(_jC_Largedataanalysisconfig.Name);

            if (null != existsModel)
            {
                return new BasicResponse <JC_LargedataAnalysisConfigInfo>()
                       {
                           Code = -100, Message = "分析模型名称已存在", Data = jc_LargedataAnalysisConfigRsequest.JC_LargedataAnalysisConfigInfo
                       }
            }
            ;

            JC_LargedataanalysisconfigModel resultjC_Largedataanalysisconfig = null;

            TransactionsManager.BeginTransaction(() =>
            {
                //保存分析模型
                resultjC_Largedataanalysisconfig = _Repository.AddJC_Largedataanalysisconfig(_jC_Largedataanalysisconfig);
                //保持分析模型中表达式参数与测点的关联关系.
                _AnalysisModelPointRecordRepository.Insert(_jcSetAnalysisModelPointRecordList);
            });

            if (resultjC_Largedataanalysisconfig != null)
            {
                jC_Largedataanalysisconfigresponse.Data = ObjectConverter.Copy <JC_LargedataanalysisconfigModel, JC_LargedataAnalysisConfigInfo>(resultjC_Largedataanalysisconfig);

                BasicResponse <IList <JC_SetAnalysisModelPointRecordInfo> > pointListResponse = _AnalysisModelPointRecordService.GetCustomizationAnalysisModelPointRecordInfoByModelId(new SetAnalysisModelPointRecordByModelIdGetRequest()
                {
                    AnalysisModelId = resultjC_Largedataanalysisconfig.Id
                });
                if (pointListResponse != null && pointListResponse.Data != null)
                {
                    jC_Largedataanalysisconfigresponse.Data.AnalysisModelPointRecordInfoList = pointListResponse.Data.ToList();
                }
                try
                {
                    //添加到缓存
                    _LargeDataAnalysisConfigCacheService.AddLargeDataAnalysisConfigCache(new LargeDataAnalysisConfigCacheAddRequest()
                    {
                        LargeDataAnalysisConfigInfo = jC_Largedataanalysisconfigresponse.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);
                }
            }
            return(jC_Largedataanalysisconfigresponse);
        }