Exemplo n.º 1
0
        public bool SetCentralizedControl(CentralizedControlModel data)
        {
            bool result = false;

            try
            {
                Dictionary <string, string> parameters = new Dictionary <string, string>();
                parameters.Add("terminalId", data.TerminalId);
                parameters.Add("terminalIp", data.TerminalIp);
                Dictionary <string, string> switchs = new Dictionary <string, string>();
                switchs.Add("System", data.CentralizedControlSwitch ? "1" : "0");
                switchs.Add("AirConditioner", data.AirConditionerSwitch ? "1" : "0");
                switchs.Add("Lamp", data.LampSwitch ? "1" : "0");
                parameters.Add("parameters", JsonConvert.SerializeObject(switchs));
                JObject jo = restConnection.Get("api/TerminalOperate/SetParameter", parameters);
                if (null != jo && jo.Value <bool>("success"))
                {
                    result = true;
                }
            }
            catch (Exception e)
            {
                RadWindow.Alert(new DialogParameters
                {
                    OkButtonContent = "确定",
                    Content         = e.Message,
                    Owner           = App.Current.MainWindow,
                    Header          = "错误"
                });
            }
            return(result);
        }
Exemplo n.º 2
0
 private void LoadExpendituresFromServer()
 {
     AsyncOp.Get(
         asyncOp: () => _restConnection.Get(RestCallsConstants.Expenditure),
         onSuccess: x => JsonConvert.DeserializeObject <Expenditure[]>(x.Content).Foreach(AddExpenditureLocally),
         onFailure: x => { },
         onCancel: () => { }
         ).Run();
 }
Exemplo n.º 3
0
 public void GetAll(Action <Category[]> onSuccess)
 {
     AsyncOp.Get(
         asyncOp: () => _restConnection.Get(RestCallsConstants.Category),
         onSuccess: restResult => onSuccess(OnCategoriesLoadSuccess(restResult)),
         onCancel: () => onSuccess(LoadStoredLocally()),
         onFailure: e => onSuccess(LoadStoredLocally())
         ).Run();
 }
Exemplo n.º 4
0
        /// <summary>
        /// Return the telemetry data sinks that can be used to query reporting (and of course could be used to record telemetry data)
        ///
        /// Send GET request to the APIROOT/networks/sinks Url
        /// </summary>
        /// <returns>List of SinkInfos</returns>
        public IEnumerable <SinkInfoDto> GetSinks()
        {
            var response = _restConnection.Get("networks/sinks");

            return(JsonSerializer.Deserialize <IEnumerable <SinkInfoDto> >(response));
        }