Beispiel #1
0
        public GetAllModuleResponse GetAllModules(GetAllModuleRequest request)
        {
            GetAllModuleResponse response = new GetAllModuleResponse();

            try
            {
                IEnumerable <Module> modules = _moduleRepository.FindAll();

                response.ModuleViews = modules.ConverToModuleViews();
            }
            catch (Exception ex)
            {
                string message = "查询失败!错误信息:/n" + ex.Message;
                response = new GetAllModuleResponse()
                {
                    ResponseSucceed = false,
                    Message         = "查询失败"
                };
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(response);
            }

            return(response);
        }
        private void InitializeData()
        {
            IModuleService    moduleService    = IocContainerFactory.GetUnityContainer().Resolve <IModuleService>();
            IDataPointService dataPointService = IocContainerFactory.GetUnityContainer().Resolve <IDataPointService>();
            IModbusService    modbusService    = IocContainerFactory.GetUnityContainer().Resolve <IModbusService>();

            GetAllModuleRequest  getAllModuleRequest  = new GetAllModuleRequest();
            GetAllModuleResponse getAllModuleResponse = moduleService.GetAllModules(getAllModuleRequest);

            foreach (var moduleView in getAllModuleResponse.ModuleViews)
            {
                GetDataPointByModuleRequest getDataPointByModuleRequest = new GetDataPointByModuleRequest();
                getDataPointByModuleRequest.ModuleId = moduleView.ModuleId;

                GetDataPointByModuleResponse getDataPointByModuleResponse =
                    dataPointService.GetDataPointInfoByModule(getDataPointByModuleRequest);

                if (getDataPointByModuleResponse.ResponseSucceed)
                {
                    foreach (var dataPointInfoView in getDataPointByModuleResponse.DataPointInfoViews)
                    {
                        DataPointViewModel dataPointViewModel = dataPointInfoView.ConvertToDataPointViewModel();

                        dataPointViewModel.ModuleNumber      = moduleView.Number;
                        dataPointViewModel.ModuleName        = moduleView.Name;
                        dataPointViewModel.ModuleDescription = moduleView.Description;

                        this.DataPoints.Add(dataPointViewModel);
                    }
                }
            }
        }