示例#1
0
    private void Awake()
    {
        meter = GetComponent <Image>();
        rect  = GetComponent <RectTransform>();

        cleanHouseMeter = GameObject.Find("cleanHouse").GetComponent <HouseMeter>();
        dirtyHouseMeter = GameObject.Find("dirtyHouse").GetComponent <HouseMeter>();

        Add(startFill);
    }
        public HouseMeterViewModel()
        {
            try
            {
                houseMeter = new HouseMeter();

                StopCommand = new RelayCommand(Stop, param => true);
                client      = new Client();
                Task.Run(GetCommand);
                Task.Run(SendCountCommand);
            }
            catch (Exception)
            {
            }
        }
        public async Task <IActionResult> Switch([FromBody] string serialId)
        {
            var userId = _userManager.GetUserId(User);
            var meter  = new HouseMeter {
                count = "0", serialId = serialId, Switch = true
            };
            var value = new MeterCommand {
                value = meter, type = MeterCommandType.Switch
            };
            var message = Newtonsoft.Json.JsonConvert.SerializeObject(value);
            await _chatHubContext.Clients.Group(userId).SendAsync("ReceiveMessage", message);

            await commandRepository.CreateSwitchCommand(serialId, userId);

            return(Ok());
        }
        public async Task <IActionResult> GetCount([FromBody] string serialId)
        {
            var userId      = _userManager.GetUserId(User);
            var EnergyMeter = await repository.GetById(serialId, userId);

            if (EnergyMeter == null)
            {
                return(BadRequest());
            }
            var meter = new HouseMeter {
                count = EnergyMeter.Count, serialId = EnergyMeter.SerialId, Switch = EnergyMeter.SwitchState
            };
            var value = new MeterCommand {
                value = meter, type = MeterCommandType.Count
            };
            var message = Newtonsoft.Json.JsonConvert.SerializeObject(value);
            await _chatHubContext.Clients.Group(userId).SendAsync("ReceiveMessage", message);

            await commandRepository.GetCountCommand(serialId, userId);

            return(Ok());
        }
 public HouseMeterViewModel()
 {
     StartServerCommand = new RelayCommand(StartServer);
     houseMeter         = new HouseMeter();
 }