public override string OnPush(ParameterizedMap map) { dynamic response = null; bool deviceRemoved = false; StringBuilder responseJson = new StringBuilder(); GSMCommunication.Feature.BasicInformation basic = map.TryGet <BasicInformation>("base"); if (basic != null) { try { basic.OnBeginExecuting(); List <string> command = map.TryGet <List <string> >("command"); if (command.Where(s => s.ToLower() == "help").Any()) { // if command contains 'help' word ActionInvoker invoker = actions.ToList().Where(d => d.InterfaceType.Name.ToLower() == command[1].ToLower()).SingleOrDefault(); if (invoker != null) { responseJson = new StringBuilder(Newtonsoft.Json.JsonConvert.SerializeObject(invoker.Commands, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore })); } } else { ActionInvoker invoker = actions.ToList().Where(d => d.InterfaceType.Name.ToLower() == command[0].ToLower()).SingleOrDefault(); if (invoker != null) { response = invoker.TryInvoke(command[1], new object[] { map }); if (response != null) { responseJson = new StringBuilder(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore })); } } } } catch (UnauthorizedAccessException uae) { IErrorLogging log = ObjectPool.Instance.Resolve <IErrorLogging>(); log.Write(uae.Message + " - push command (unauthorized access)"); log.Write("plug the device..."); deviceRemoved = true; } catch (System.IO.IOException ioe) { IErrorLogging log = ObjectPool.Instance.Resolve <IErrorLogging>(); log.Write(ioe.Message + " - push command (I/O)"); log.Write("plug the device..."); deviceRemoved = true; } finally { basic.OnEndExecuting(); } } if (deviceRemoved) { Thread.Sleep(1000); IServer server = ObjectPool.Instance.Resolve <IServer>(); server.OnDeviceRemoved(); } return(responseJson.ToString()); }