private void HandleGetStatusRequest(IApiCall apiCall) { var eventArgs = new ApiRequestReceivedEventArgs(apiCall); StatusRequested?.Invoke(this, eventArgs); StatusRequestCompleted?.Invoke(this, eventArgs); }
public void GetSchedules(IApiCall apiCall) { lock (_schedules) { apiCall.Result = JObject.FromObject(_schedules); } }
public void GetStatus(IApiCall apiCall) { Dictionary <string, Func <object> > values; lock (_values) { values = new Dictionary <string, Func <object> >(_values); } var json = new JObject(); foreach (var value in values) { var effectiveValue = value.Value(); if (effectiveValue == null) { json[value.Key] = JValue.CreateNull(); } else { json[value.Key] = JToken.FromObject(value.Value()); } } apiCall.Result = json; }
public void SetTexts(IApiCall apiCall) { lock (_syncRoot) { var request = apiCall.Parameter.ToObject <SetTextsRequest>(); if (request?.Resources == null || !request.Resources.Any()) { apiCall.ResultCode = ApiResultCode.InvalidParameter; return; } foreach (var updatedResource in request.Resources) { var existingResource = _resources.FirstOrDefault(r => r.Uri.Equals(updatedResource.Uri)); if (existingResource != null) { _resources.Remove(existingResource); } _resources.Add(updatedResource); } SaveResources(); } }
public TableController(ILogger <TableController> logger, ITableService tableService, IApiCall apiCall) { _logger = logger; _tableService = tableService; _apiCall = apiCall; _logger.LogInformation("Constructor TableController"); }
public void GetErrorLogEntries(IApiCall apiCall) { lock (_syncRoot) { CreateGetLogEntriesResponse(_errorLogEntries, apiCall); } }
private void HandleGetConfigurationRequest(IApiCall apiCall) { var eventArgs = new ApiRequestReceivedEventArgs(apiCall); ConfigurationRequested?.Invoke(this, eventArgs); ConfigurationRequestCompleted?.Invoke(this, eventArgs); }
public void ResetErrorLogEntries(IApiCall apiCall) { lock (_syncRoot) { _errorLogEntries.Clear(); } }
public void GetWarningLogEntries(IApiCall apiCall) { lock (_syncRoot) { CreateGetLogEntriesResponse(_warningLogEntries, apiCall); } }
public void ResetWarningLogEntries(IApiCall apiCall) { lock (_syncRoot) { _warningLogEntries.Clear(); } }
public Dictionary <String, List <Station> > getNearStations(string x, string y, int dist) { IApiCall apiCall = this.APICall; string data = apiCall.getData("http://data.metromobilite.fr/api/linesNear/json?x=" + x + "&y=" + y + "&dist=" + dist + "&details=true"); List <Station> stations = JsonConvert.DeserializeObject <List <Station> >(data); Dictionary <String, List <Station> > sortedStations = new Dictionary <string, List <Station> >(); foreach (Station station in stations) { if (!sortedStations.ContainsKey(station.name)) { List <Station> stationList = new List <Station>(); stationList.Add(station); sortedStations.Add(station.name, stationList); } else { sortedStations[station.name].Add(station); } } return(sortedStations); }
public void GetLatestMessageContext(IApiCall apiCall) { if (_latestMessageContext == null) { return; } apiCall.Result = JObject.FromObject(_latestMessageContext); }
public ApiRequestReceivedEventArgs(IApiCall apiCall) { if (apiCall == null) { throw new ArgumentNullException(nameof(apiCall)); } ApiContext = apiCall; }
private void CreateGetLogEntriesResponse(IEnumerable <LogEntry> source, IApiCall apiCall) { var response = new GetLogEntriesResponse { SessionId = _sessionId, LogEntries = source.ToList() }; apiCall.Result = JObject.FromObject(response); }
public string getLineInfo(string id) { IApiCall apiCall = this.APICall; string data = apiCall.getData("http://data.metromobilite.fr/api/routers/default/index/routes?codes=" + id); List <Ligne> lignes = JsonConvert.DeserializeObject <List <Ligne> >(data); string infos = lignes[0].type + " " + lignes[0].shortname + " Ligne : " + lignes[0].longName; return(infos); }
public void RestoreBackup(IApiCall apiCall) { if (apiCall.Parameter.Type != JTokenType.Object) { throw new NotSupportedException(); } var eventArgs = new BackupEventArgs(apiCall.Parameter); RestoringBackup?.Invoke(this, eventArgs); }
public void Import(IApiCall apiCall) { if (apiCall.Parameter.Type == JTokenType.Object) { var request = apiCall.Parameter.ToObject <SettingsServiceApiRequest>(); ImportRawSettings(request.Uri, request.Settings); } else { throw new NotSupportedException(); } }
public void GetSettings(IApiCall apiCall) { if (apiCall.Parameter.Type == JTokenType.Object) { var request = apiCall.Parameter.ToObject <SettingsServiceApiRequest>(); apiCall.Result = GetSettings(request.Uri); } else { throw new NotSupportedException(); } }
public void Create(IApiCall apiCall) { var parameter = apiCall.Parameter.ToObject <ApiParameterForCreate>(); if (parameter == null) { apiCall.ResultCode = ApiResultCode.InvalidParameter; return; } Create(parameter.Type, parameter.Text, parameter.TimeToLive); }
public void GetLastReceivedCode(IApiCall apiCall) { if (_lastReceivedLpd433MhzCode == null) { return; } lock (_syncRoot) { apiCall.Result = JObject.FromObject(_lastReceivedLpd433MhzCode); } }
public void Ask(IApiCall apiCall) { var text = (string)apiCall.Parameter["Message"]; if (string.IsNullOrEmpty(text)) { apiCall.ResultCode = ApiResultCode.InvalidParameter; return; } apiCall.Result["Answer"] = ProcessTextMessage(text); }
public void Send(IApiCall apiCall) { var adapterDeviceId = apiCall.Parameter["AdapterDeviceId"].ToObject <string>(); var code = apiCall.Parameter["Code"].ToObject <Lpd433MhzCode>(); if (code == null) { apiCall.ResultCode = ApiResultCode.InvalidParameter; return; } SendCode(adapterDeviceId, code); }
public OrchestratorService( ILogService logService, IAmqService amqService, IApiCall apiCall) { connectionFactory = new NMSConnectionFactory(Urls.ActiveMQ); connection = connectionFactory.CreateConnection(); connection.Start(); session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge); _logService = logService; _amqService = amqService; _apiCall = apiCall; }
public void ExecuteScriptCode(IApiCall apiCall) { var request = apiCall.Parameter.ToObject <ExecuteScriptCodeRequest>(); if (request == null) { apiCall.ResultCode = ApiResultCode.InvalidParameter; return; } var result = ExecuteScriptInternal(request.ScriptCode, request.EntryMethodName); apiCall.Result = JObject.FromObject(result); }
private void HandleGetActionsRequest(IApiCall apiCall) { var actions = new JArray(); lock (_actions) { foreach (var action in _actions) { actions.Add(action.Key); } } apiCall.Result.Add("Actions", actions); }
public void GetTexts(IApiCall apiCall) { lock (_syncRoot) { var request = apiCall.Parameter.ToObject <GetTextsRequest>(); var matchingResources = _resources; if (!string.IsNullOrEmpty(request.Category)) { matchingResources = _resources.Where(r => r.Uri.StartsWith(request.Category + ".")).ToList(); } apiCall.Result["Resources"] = JToken.FromObject(matchingResources); } }
public void CreateBackup(IApiCall apiCall) { var backup = new JObject { ["Type"] = "HA4IoT.Backup", ["Timestamp"] = DateTime.Now.ToString("O"), ["Version"] = 1 }; var eventArgs = new BackupEventArgs(backup); CreatingBackup?.Invoke(this, eventArgs); apiCall.Result = backup; }
public void ProcessSkillServiceRequest(IApiCall apiCall) { var request = apiCall.Parameter.ToObject <SkillServiceRequest>(); var messageContextFactory = new MessageContextFactory(_areaService, _componentsRegistry, _settingsService); var messageContext = messageContextFactory.Create(request); ProcessMessage(messageContext); var response = new SkillServiceResponse(); response.Response.OutputSpeech.Text = messageContext.Reply; apiCall.Result = JObject.FromObject(response); }
public void ImportMultiple(IApiCall apiCall) { if (apiCall.Parameter.Type == JTokenType.Object) { var request = apiCall.Parameter.ToObject <Dictionary <string, JObject> >(); foreach (var item in request) { ImportSettings(item.Key, item.Value); } } else { throw new NotSupportedException(); } }
public Startup(IConfiguration configuration) { _Configuration = configuration; var appName = _Configuration.GetValue <string>("ApplicationName"); var metricsUrl = _Configuration.GetValue <string>("Metrics:UrlEndpoint"); var apiKey = _Configuration.GetValue <string>("Metrics:ApiKey"); var apiCallTimeoutinMs = _Configuration.GetValue <int>("ApiCall:TimeoutInMilliseconds"); // Set up ApiCall object _ApiCall = new ApiCall(apiCallTimeoutinMs); // populate config _ConfigProvider = new ConfigProvider(); }
public void RegisterApiCall(IApiCall call) { call.RequestComplete += RequestComplete; }