Ejemplo n.º 1
0
        public GetDataPointByModuleResponse GetDataPointInfoByModule(GetDataPointByModuleRequest request)
        {
            GetDataPointByModuleResponse response = new GetDataPointByModuleResponse();

            try
            {
                Query query = new Query();
                query.AddCriterion(Criterion.Create <DataPoint>(p => p.ModuleBelongTo.Id, request.ModuleId, CriteriaOperator.Equal));
                query.OrderByProperty = OrderByClause.Create <DataPoint>(p => p.Number, false);

                IEnumerable <DataPoint> dataPoints = _dataPointRepository.FindBy(query);
                response.DataPointInfoViews = dataPoints.ConverToDataPointInfoViews();
            }
            catch (Exception ex)
            {
                string message = "查询失败!错误信息:/n" + ex.Message;
                response = new GetDataPointByModuleResponse()
                {
                    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);
                    }
                }
            }
        }