public string error(Responder.JobType jobType, string jobDetail) { int jobValue; jobValue = Array.IndexOf(Enum.GetValues(jobType.GetType()), jobType); if (jobValue > 3 || jobValue < 0) { response = ""; } response = errorMessages[jobValue] + " " + jobDetail + "."; return(response); }
/// Simple usage of these two should be like that, /// str = String which user trying to search /// searchUrlHead + str + searchUrlLast /// We already passing str and assign it to parameter " keyWord ". So you can use that directly. // You don't need to touch here for now. If you want to add something, go ahead. public WikiSearch(Responder.JobType jobType, string inputWord) : base(jobType, inputWord) { }
public Job(Responder.JobType typeJob, string inputWord) { jobType = typeJob; keyWord = inputWord; }
// You probably don't need to touch this. So ... public Launcher(Responder.JobType typeJob, string inputWord) : base(typeJob, inputWord) { }
// This is for understanding the job and doing it. Determine what you are going to do with the cases in your hand. private void understandJob(Responder.JobType jobType) { bool jobResult = false; Job tempJob = null; Console.WriteLine("*DEBUG* Incoming job type is : " + jobType.ToString()); switch (jobType) { case Responder.JobType.GOOGLE: { jobResult = true; if (debug) { Process.Start("https://www.google.com/search?q=" + "sucuk"); } else { Process.Start("https://www.google.com/search?q=" + responderObject.getJobDetail().Replace(" ", "+")); } break; } case Responder.JobType.KILL: { for (int i = 0; i < jobList.Count; i++) { if (jobList[i].getKeyword() == responderObject.getJobDetail()) { Console.WriteLine("Am I here? Job Exe Location: " + ((Launcher)(jobList[i])).getExeLocation()); jobResult = KillApplication(((Launcher)(jobList[i])).getExeLocation()); jobList.RemoveAt(i); } } break; } case Responder.JobType.LAUNCH: { tempJob = new Launcher(jobType, responderObject.getJobDetail()); jobList.Add(tempJob); if (debug) { ((Launcher)tempJob).searchInFolders(); } else { jobResult = tempJob.doJob(); } break; } case Responder.JobType.WIKI: { WikiSearch wikiObject = new WikiSearch(jobType, responderObject.getJobDetail()); wikiObject.resString += wikiResultHandler; jobResult = wikiObject.doJob(); tempJob = wikiObject; break; } case Responder.JobType.IDLE: { jobResult = true; break; } } // If job result is negative, get error. if (!jobResult) { if (jobType == Responder.JobType.KILL) { interfaceObject.setOutput(responderObject.error(jobType, responderObject.getJobDetail())); } else { interfaceObject.setOutput(responderObject.error(jobType, tempJob.getKeyword())); } // If WIKI fails to find, let Google search it. if (jobType == Responder.JobType.WIKI) { understandJob(Responder.JobType.GOOGLE); } } }