public static PlugResponse DoAction(PlugCall call) { switch (call.ACTION) { case "HELLO": return(Hello(call)); case "HUMEUR": return(Humeur(call)); case "EXIT": return(CloseApp(call)); case "CONTEXT": return(ContextChange(call)); case "LOAD CONTEXT": return(null); //LoadContext(call); case "OFF": return(StandBy(call)); default: return(null); } }
private static PlugResponse Humeur(PlugCall call) { PlugResponse response = new PlugResponse(); response.WaitForChainedAction = false; response.Response = "Je vais bien, merci"; return(response); }
private static PlugResponse CloseApp(PlugCall call) { GlobalManager.RUNNING = false; System.Threading.Thread.Sleep(1000); return(new PlugResponse() { Response = "Au revoir" }); }
private static PlugResponse StandBy(PlugCall call) { GlobalManager.STANDBY = true; PlugResponse response = new PlugResponse(); response.WaitForChainedAction = false; response.Response = "Mode espion activé"; return(response); }
public static PlugResponse FireAction(string ActionName, string sentence) { PlugResponse response = new PlugResponse(); PlugCall call = new PlugCall(); call.ACTION = ActionName; call.Text = sentence; SENTENCES tmp = CONTEXT.SENTENCESLIST.Where(t => t.CMD.CMD.Equals(ActionName)).Where(t => t.SENTENCE.Equals(sentence)).Single(); // Todo: recherche une correspondance dans la BDD if (tmp == null) { return(new PlugResponse()); } else { // Chargement de la DLL concernée SENTENCES cmd = GlobalManager.CONTEXT.SENTENCESLIST.Where(t => t.CMD.CMD.Equals(ActionName) && t.SENTENCE.Equals(sentence)).Single(); if (cmd.CMD.MODULE.NAME.Equals("SYSTEM")) { response = SYSMODULE.DoAction(call); LastResponse = response; return(response); } else { /* TEST */ // Chargement de la DLL string DLLPATH = cmd.CMD.MODULE.DLL; List <Assembly> assemblies = new List <Assembly>(); Assembly DLL = Assembly.LoadFrom(@"C:\Users\adasilva\Documents\Visual Studio 2015\Projects\MATHIAS\Mathias\bin\Debug\plugins\EmailPlug.dll"); // Récupération de l'objet à utiliser var typeFromPlug = DLL.GetType(cmd.CMD.FULLTYPEOBJECT); var plug = Activator.CreateInstance(typeFromPlug, new object[] { "imap.gmail.com", "login", "password", 993 }); // Récupération de la méthode var method = typeFromPlug.GetMethod("DoAction"); //Execution de la méthode et retour du cast return((PlugResponse)method.Invoke(plug, new object[] { call })); } response = new PlugResponse(); // LOAD DLL } // Création de l'objet PlugCall // Lancement de la méthode concernée // Si non // Indiquer aucune commande correspondante. return(null); }
private static PlugResponse Hello(PlugCall call) { PlugResponse response = new PlugResponse(); response.WaitForChainedAction = true; response.ChainedQuestion = "Comment ça va ?"; response.Response = "Bonjour !"; response.NextChainedAction = "HUMEUR"; return(response); }
private static PlugResponse ContextChange(PlugCall call) { PlugResponse response = new PlugResponse(); response.Response = "Quel contexte voulez vous charger ?"; response.WaitForChainedAction = true; response.NextChainedAction = "LOAD CONTEXT"; GlobalManager.LastResponse = response; return(response); }
public PlugResponse DoAction(PlugCall Call) { switch (Call.ACTION) { case "GetLastMailSubject": return(GetLastMailSubject()); default: return(new PlugResponse() { Response = "Je ne peux pas traiter votre demande" }); } }
public abstract PlugResponse DoAction(PlugCall Call);