public void TransferFiles() { var info = new DirectoryInfo(Client.OutputDirectory); if (!info.Exists) { throw new DirectoryNotFoundException("Directory not found"); } string targetZip = Path.Combine(info.FullName, "DebugContent.zip"); if (File.Exists(targetZip)) { File.Delete(targetZip); } ZipFile.CreateFromDirectory(info.FullName, targetZip); communication.Send(Command.DebugContent, new StartDebuggingMessage { AppType = type, DebugContent = File.ReadAllBytes(targetZip), FileName = Client.TargetExe, AppHash = Client.AppHash }); File.Delete(targetZip); Console.WriteLine("Finished transmitting"); }
public void Execute(ApplicationTypes type, Frameworks framework, string targetExe, string arguments, string rootDirectory, string workingDirectory, string url) { var info = new DirectoryInfo(rootDirectory); if (!info.Exists) { throw new DirectoryNotFoundException("Directory not found"); } var msg = new ExecuteMessage() { Command = Commands.Execute, ApplicationType = type, Framework = framework, Executable = targetExe, Arguments = arguments, WorkingDirectory = workingDirectory, Url = url, RootPath = rootDirectory, IsLocal = communication.IsLocal, Debug = true, LocalPath = rootDirectory }; if (!communication.IsLocal) { msg.Files.AddFolder(rootDirectory); } communication.RootPath = rootDirectory; communication.Send(msg); }
public void HandleSession() { try { logger.Trace("New Session from {0}", remoteEndpoint); while (communication.IsConnected) { if (proc != null && proc.HasExited) { return; } MessageBase msg = communication.Receive(); if (msg == null) { logger.Info("Null-Message received"); return; } switch (msg.Command) { case Command.DebugLastContent: case Command.DebugContent: logger.Info($"{msg.Command.ToString()}-Message received"); var successful = StartDebugging((StartDebuggingMessage)msg.Payload); communication.Send(Command.StartedMono, new StatusMessage() { Successful = successful }); break; case Command.Shutdown: logger.Info("Shutdown-Message received"); return; } } } catch (XmlException xmlException) { logger.Info("CommunicationError : " + xmlException); } catch (Exception ex) { logger.Error(ex); } finally { try { if (proc != null && !proc.HasExited) { proc.Kill(); } } catch { } } }
void _tcp_ConnectionEstablished(object sender, EventArgs e) { Logger.InfoFormat("{0}: Opened TCP Connection.", this.DeviceName); Logger.InfoFormat("{0}: There is {1} messages in queue", this.DeviceName, _messages.Count); // loop trought the _messages list and send each one in turn foreach (string message in _messages) { // Process the message for transmission Logger.InfoFormat("{0}: Sending Message - {1}", this.DeviceName, message); _tcp.Send(message + TX_TERMINATOR, 500); // now that we have processes the message, remove it from the queue _messages.Remove(message); } //IsReady = true; }