/// <summary> /// Used as the start of the service /// </summary> public void Start() { if (!(bool)_memoryCache.Get(SERVICE_MEMORY)) { _memoryCache.Set(SERVICE_MEMORY, true); _loggerService.LogMessage(SERVICE_NAME, "Started", LogLevel.Info); } while ((bool)_memoryCache.Get(SERVICE_MEMORY)) { _loggerService.LogMessage(SERVICE_NAME, "Started", LogLevel.Info); _pipeClient.CreatePipe(); var incomingTask = _pipeClient.ReadString(); _loggerService.LogMessage(SERVICE_NAME, incomingTask, LogLevel.Info); _taskToProcess = new TaskModel(incomingTask); ProcessTask(); _pipeClient.WaitForDrain(); _pipeClient = new PipeClient(PIPE_NAME); _pipeServer = new PipeServer(); Thread.Sleep(1000); } }
private void BringUpPipe() { _pipeClient.CreatePipe(); var incomingTask = _pipeClient.ReadString(); _loggerService.LogMessage(SERVICE_NAME, incomingTask, LogLevel.Info); _taskToProcess = new TaskModel(incomingTask); }
/// <summary> /// Processes the task by creating a client pipe to the core /// </summary> /// <param name="task">Requires a <see cref="string" /></param> private string ProcessTask(string task) { if (!IsValidJson(task)) { return(""); } _loggerService.LogMessage(SERVICE_NAME, "Processing Task", LogLevel.Debug); _pipeClient = new PipeClient(); _pipeClient.CreatePipe(); _pipeClient.WriteString(task); _pipeClient.WaitForDrain(); return(_pipeClient.ReadString()); }
/// <summary> /// Starts up the service /// </summary> public void Start() { if (!(bool)_memoryCache.Get(SERVICE_MEMORY)) { _memoryCache.Set(SERVICE_MEMORY, true); } while ((bool)_memoryCache.Get(SERVICE_MEMORY)) { _pipeClient.CreatePipe(); TaskToProcess = new TaskModel(_pipeClient.ReadString()); ProcessTask(); _pipeClient.WaitForDrain(); _pipeClient = new PipeClient(PIPE_NAME); Thread.Sleep(1000); } }
/// <summary> /// Used as a way to start the service /// </summary> public void Start() { if (!(bool)_memoryCache.Get(SERVICE_MEMORY)) { _memoryCache.Set(SERVICE_MEMORY, true); } while ((bool)_memoryCache.Get(SERVICE_MEMORY)) { _pipeClient.CreatePipe(); var taskReceived = _pipeClient.ReadString(); _task = new TaskModel(taskReceived); ProcessTask(); } }
/// <summary> /// Creates a starting task and if stress is passed it will added /// in to the starting task as another message /// </summary> /// <param name="shouldStress">Requires a boolean for shouldStress</param> private void CreateStartTask(bool shouldStress) { var messages = new List <MessageModel>(); var startMessage = new MessageModel { Category = Category.Start, Message = "Start Testing", TimeStamp = DateTime.Now }; var startTask = new TaskModel { Guid = Guid.NewGuid(), Messages = messages, Name = "Start", Priority = 1, SerialNumber = SerialNumber, Timeout = 60, TimeStamp = DateTime.Now, WhereFrom = "CORE", WhereTo = "INTERROGATOR" }; messages.Add(startMessage); if (shouldStress) { var stressMessage = new MessageModel { Category = Category.Stress, Message = "ALL", TimeStamp = DateTime.Now }; messages.Add(stressMessage); } var pipeServer = new PipeClient(); pipeServer.CreatePipe(); pipeServer.WriteString(startTask.ToString()); pipeServer.WaitForDrain(); }
/// <summary> /// Used to process the task /// </summary> private void ProcessTask() { MessageModel messageToAdd; if (Environment.OSVersion.Platform == PlatformID.Win32NT && _task.Messages.Count(m => m.Category == Category.Start) <= 0) { } else if (Environment.OSVersion.Platform == PlatformID.Win32NT) { _pipeClient.WaitForDrain(); _task.WhereTo = "COMMAND"; messageToAdd = new MessageModel { Message = "BEGIN INTERROGATION", Category = Category.Command, TimeStamp = DateTime.Now }; _task.Messages.Add(messageToAdd); _pipeClient = new PipeClient(); _pipeClient.CreatePipe(); _pipeClient.WriteString(_task.ToString()); _pipeClient.WaitForDrain(); } else if (Environment.OSVersion.Platform == PlatformID.Unix) { Thread.Sleep(50); _task.WhereTo = "COMMAND"; messageToAdd = new MessageModel { Message = "BEGIN INTERROGATION", Category = Category.Command, TimeStamp = DateTime.Now }; _task.Messages.Add(messageToAdd); _pipeClient = new PipeClient(); _pipeClient.CreatePipe(); _pipeClient.WriteString(_task.ToString()); _pipeClient.WaitForDrain(); } }