private void DeleteRemoteCommand(RemoteCommand command) { try { MobileMiner.ApiContext.DeleteCommand(GetMobileMinerUrl(), MobileMinerApiKey, ApplicationConfiguration.MobileMinerEmailAddress, ApplicationConfiguration.MobileMinerApplicationKey, command.Machine.Name, command.Id); } catch (Exception ex) { if ((ex is WebException) || (ex is ArgumentException)) { //could be error 400, invalid app key, error 500, internal error, Unable to connect, endpoint down //could also be a json parsing error return; } throw; } }
private void ProcessRemoteCommand(RemoteCommand command) { //check this before actually executing the command //point being, say for some reason it takes 2 minutes to restart mining //if we check for commands again in that time, we don't want to process it again if (processedCommandIds.Contains(command.Id)) return; processedCommandIds.Add(command.Id); string commandText = command.CommandText; string machineName = command.Machine.Name; if (deleteRemoteCommandDelegate == null) deleteRemoteCommandDelegate = DeleteRemoteCommand; if (machineName.Equals(Environment.MachineName, StringComparison.OrdinalIgnoreCase)) { ProcessOwnRemoteCommand(commandText); deleteRemoteCommandDelegate.BeginInvoke(command, deleteRemoteCommandDelegate.EndInvoke, null); } else { DeviceViewModel networkDevice = LocalViewModel.GetNetworkDeviceByFriendlyName(machineName); if (networkDevice != null) { ProcessNetworkDeviceRemoteCommand(commandText, networkDevice); deleteRemoteCommandDelegate.BeginInvoke(command, deleteRemoteCommandDelegate.EndInvoke, null); } } }