Пример #1
0
        public async Task <ActionResult <DeviceConfigMovingThresholdResponse> > Save(DeviceConfigMovingThresholdRequest deviceConfigMovingThresholdRequest)
        {
            this._loggingService.Info("Saving Moving Thresholds for request : " + JsonConvert.SerializeObject(deviceConfigMovingThresholdRequest), "DeviceConfigMovingThresholdController.Save");

            deviceConfigMovingThresholdRequest = await base.ReadRequestContentAsync(deviceConfigMovingThresholdRequest);

            if (deviceConfigMovingThresholdRequest == null)
            {
                throw new ArgumentNullException("deviceConfigMovingThresholdRequest is null");
            }

            deviceConfigMovingThresholdRequest.ParameterGroupName = "MovingThresholds";
            deviceConfigMovingThresholdRequest.UserUID            = base.GetUserContext(Request);
            deviceConfigMovingThresholdRequest.CustomerUID        = base.GetCustomerContext(Request);

            deviceConfigMovingThresholdRequest.ConfigValues = new Dictionary <string, string>();

            if (deviceConfigMovingThresholdRequest.MovingOrStoppedThreshold.HasValue)
            {
                deviceConfigMovingThresholdRequest.ConfigValues.Add(this._attributeMaps.Values["MovingOrStoppedThreshold"], deviceConfigMovingThresholdRequest.MovingOrStoppedThreshold.ToString());
            }

            if (deviceConfigMovingThresholdRequest.MovingThresholdsDuration.HasValue)
            {
                deviceConfigMovingThresholdRequest.ConfigValues.Add(this._attributeMaps.Values["MovingThresholdsDuration"], deviceConfigMovingThresholdRequest.MovingThresholdsDuration.ToString());
            }

            if (deviceConfigMovingThresholdRequest.Radius.HasValue)
            {
                deviceConfigMovingThresholdRequest.ConfigValues.Add(this._attributeMaps.Values["Radius"], deviceConfigMovingThresholdRequest.Radius.ToString());
            }

            this._loggingService.Info("Started invoking MovingThresholdService with request : " + JsonConvert.SerializeObject(deviceConfigMovingThresholdRequest), "DeviceConfigMovingThresholdController.Save");

            var response = await this._movingThresholdService.Save(deviceConfigMovingThresholdRequest);

            this._loggingService.Info("Ended invoking MovingThresholdService with response : " + JsonConvert.SerializeObject(response), "DeviceConfigMovingThresholdController.Save");

            return(base.SendResponse(HttpStatusCode.OK, new DeviceConfigMovingThresholdResponse(response.Lists, response.Errors.OfType <AssetErrorInfo>().ToList())));
        }
Пример #2
0
        public async Task <ActionResult <DeviceConfigMovingThresholdResponse> > Fetch(DeviceConfigRequestBase deviceConfigBaseRequest)
        {
            this._loggingService.Info("Fetching Moving Thresholds for request : " + JsonConvert.SerializeObject(deviceConfigBaseRequest), "DeviceConfigMovingThresholdController.Fetch");

            deviceConfigBaseRequest = await base.ReadRequestContentAsync(deviceConfigBaseRequest);

            DeviceConfigMovingThresholdRequest deviceConfigMovingThresholdRequest = new DeviceConfigMovingThresholdRequest();

            if (deviceConfigMovingThresholdRequest == null)
            {
                throw new ArgumentNullException("deviceConfigBaseRequest is null");
            }
            else
            {
                deviceConfigMovingThresholdRequest.AssetUIDs = deviceConfigBaseRequest.AssetUIDs;
            }

            deviceConfigMovingThresholdRequest.ParameterGroupName = "MovingThresholds";
            deviceConfigMovingThresholdRequest.DeviceType         = deviceConfigBaseRequest.DeviceType;
            deviceConfigMovingThresholdRequest.UserUID            = base.GetUserContext(Request);
            deviceConfigMovingThresholdRequest.CustomerUID        = base.GetCustomerContext(Request);

            deviceConfigMovingThresholdRequest.ConfigValues = new Dictionary <string, string>
            {
                { this._attributeMaps.Values["Radius"], string.Empty },
                { this._attributeMaps.Values["MovingThresholdsDuration"], string.Empty },
                { this._attributeMaps.Values["MovingOrStoppedThreshold"], string.Empty }
            };

            this._loggingService.Info("Started invoking MovingThresholdService with request : " + JsonConvert.SerializeObject(deviceConfigBaseRequest), "DeviceConfigMovingThresholdController.Fetch");

            var response = await this._movingThresholdService.Fetch(deviceConfigMovingThresholdRequest);

            this._loggingService.Info("Ended invoking MovingThresholdService  with response : " + JsonConvert.SerializeObject(response), "DeviceConfigMovingThresholdController.Fetch");

            return(base.SendResponse(HttpStatusCode.OK, new DeviceConfigMovingThresholdResponse(response.Lists, response.Errors.OfType <AssetErrorInfo>().ToList())));
        }