string IAdapter.Evaluate(Syn.Bot.Siml.Context context)
 {
     try {
         string task = context.Element.Attribute("Task").Value;
         string name = context.Element.Attribute("Name").Value;
         switch (task.ToLower())
         {
         default: break;
         }
     } catch (Exception ex) { SimlBot.Logger.Error(ex); }
     return(Resources.EvaluateErrorMessage);
 }
Beispiel #2
0
 string IAdapter.Evaluate(Syn.Bot.Siml.Context context)
 {
     try
     {
         string task = context.Element.Attribute("Task").Value;
         string name = context.Element.Attribute("Name").Value;
         string link = LinkVariables.FindSearchAddress(LinkVariables.GoogleMap, name);
         ProcessHelper.Start(link, string.Empty);
         return(string.Format(Resources.ShowMapSucessMessage, link));
     }
     catch (Exception ex) { SimlBot.Logger.Error(ex); }
     return(Resources.EvaluateErrorMessage);
 }
        string IAdapter.Evaluate(Syn.Bot.Siml.Context context)
        {
            try
            {
                string task = context.Element.Attribute("Task").Value;
                string name = context.Element.Attribute("Name").Value;
                switch (task.ToLower())
                {
                case "quote-bible":
                {
                    KJBiblePlugin kjBiblePlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <KJBiblePlugin>();
                    kjBiblePlugin.QueryName      = name;
                    kjBiblePlugin.IsQueryLimited = false;
                    kjBiblePlugin.QueryTestament = BibleNet.KJV.TestamentType.Old | BibleNet.KJV.TestamentType.New;
                    var quotationResult = kjBiblePlugin.GetQuotationResult();
                    if (quotationResult != null)
                    {
                        context.Data.Add(quotationResult);
                        return(string.Format(Resources.OpenBibleSucessMessage, quotationResult.CommonQuotation));
                    }
                    return(string.Format(Resources.OpenBibleFailedMessage, name));
                }

                case "search-verse":
                {
                    KJBiblePlugin kjBiblePlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <KJBiblePlugin>();
                    kjBiblePlugin.QueryName      = name;
                    kjBiblePlugin.IsQueryLimited = false;
                    kjBiblePlugin.QueryTestament = BibleNet.KJV.TestamentType.Old | BibleNet.KJV.TestamentType.New;
                    var verseResult = kjBiblePlugin.GetVerseResult();
                    if (verseResult != null)
                    {
                        context.Data.Add(verseResult);
                        return(string.Format(Resources.OpenBibleSucessMessage, verseResult.CommonQuotation));
                    }
                    return(string.Format(Resources.OpenBibleFailedMessage, name));
                }
                }
            }
            catch (Exception ex) { SimlBot.Logger.Error(ex); }
            return(Resources.EvaluateErrorMessage);
        }
Beispiel #4
0
        string IAdapter.Evaluate(Syn.Bot.Siml.Context context)
        {
            try
            {
                string task = context.Element.Attribute("Task").Value;
                string name = context.Element.Attribute("Name").Value;
                switch (task.ToLower())
                {
                case "play-media":
                {
                    DSearchPlugin dSearchPlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <DSearchPlugin>();
                    dSearchPlugin.QueryName = name;
                    dSearchPlugin.QueryKind = FileKind.Videos | FileKind.Music;
                    var pathResult = dSearchPlugin.GeneratePathResult();
                    if (pathResult != null)
                    {
                        context.Data.Add(pathResult);
                        ProcessHelper.Start(pathResult.CommonPath.FullName, string.Empty);
                        return(string.Format(Resources.PlayMediaSucessMessage, name));
                    }
                    return(string.Format(Resources.PlayMediaFailedMessage, name));
                }

                case "stop-media":
                {
                    DSearchPlugin dSearchPlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <DSearchPlugin>();
                    dSearchPlugin.QueryName = name;
                    dSearchPlugin.QueryKind = FileKind.Videos | FileKind.Music;
                    var pathResult = dSearchPlugin.GeneratePathResult();
                    if (pathResult != null)
                    {
                        context.Data.Add(pathResult);
                        ProcessHelper.Close(pathResult.CommonPath.FullName, true);
                        return(string.Format(Resources.StopMediaSucessMessage, name));
                    }
                    return(string.Format(Resources.StopMediaFailedMessage, name));
                }
                }
            }
            catch (Exception ex) { SimlBot.Logger.Error(ex); }
            return(Resources.EvaluateErrorMessage);
        }
Beispiel #5
0
 string IAdapter.Evaluate(Syn.Bot.Siml.Context context)
 {
     try
     {
         string task = context.Element.Attribute("Task").Value;
         string name = context.Element.Attribute("Name").Value;
         switch (task.ToLower())
         {
         case "search-wikipedia":
         {
             if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
             {
                 WikipediaPlugin wikipediaPlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <WikipediaPlugin>();
                 wikipediaPlugin.QueryName = name;
                 var queryResult = wikipediaPlugin.GenerateQueryResult();
                 if (queryResult != null && queryResult.Search.Any())
                 {
                     context.Data.Add(queryResult);
                     return(string.Format(Resources.DefineWordSucessMessage, queryResult.Search.First().GetExtract()));
                 }
             }
             else
             {
                 WordNetPlugin wordNetPlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <WordNetPlugin>();
                 wordNetPlugin.QueryName = name;
                 var synSetResult = wordNetPlugin.GenerateSynSetResult();
                 if (synSetResult != null)
                 {
                     context.Data.Add(synSetResult);
                     return(string.Format(Resources.DefineWordSucessMessage, synSetResult.CommonSynSet));
                 }
             }
             return(string.Format(Resources.NoInternetAccessMessage, name, string.Empty));
         }
         }
     }
     catch (Exception ex) { SimlBot.Logger.Error(ex); }
     return(Resources.EvaluateErrorMessage);
 }
Beispiel #6
0
        string IAdapter.Evaluate(Syn.Bot.Siml.Context context)
        {
            try
            {
                string task = context.Element.Attribute("Task").Value;
                string name = context.Element.Attribute("Name").Value;
                switch (task.ToLower())
                {
                case "open-app":
                {
                    DSearchPlugin dSearchPlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <DSearchPlugin>();
                    dSearchPlugin.QueryName = name;
                    dSearchPlugin.QueryKind = FileKind.Apps | FileKind.Videos | FileKind.Music;
                    var pathResult = dSearchPlugin.GeneratePathResult();
                    if (pathResult != null)
                    {
                        context.Data.Add(pathResult);
                        ProcessHelper.Start(pathResult.CommonPath.FullName, string.Empty);
                        return(string.Format(Resources.OpenAppSucessMessage, name));
                    }

                    KJBiblePlugin kjBiblePlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <KJBiblePlugin>();
                    kjBiblePlugin.QueryName      = name;
                    kjBiblePlugin.IsQueryLimited = false;
                    kjBiblePlugin.QueryTestament = BibleNet.KJV.TestamentType.Old | BibleNet.KJV.TestamentType.New;
                    var quotationResult = kjBiblePlugin.GetQuotationResult();
                    if (quotationResult != null)
                    {
                        context.Data.Add(quotationResult);
                        return(string.Format(Resources.OpenBibleSucessMessage, quotationResult.CommonQuotation));
                    }
                    return(string.Format(Resources.OpenAppFailedMessage, name));
                }

                case "close-app":
                {
                    DSearchPlugin dSearchPlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <DSearchPlugin>();
                    dSearchPlugin.QueryName = name;
                    dSearchPlugin.QueryKind = FileKind.Apps | FileKind.Videos | FileKind.Music;
                    var pathResult = dSearchPlugin.GeneratePathResult();
                    if (pathResult != null)
                    {
                        //context.Data.Add(data.PathResult);
                        if (ProcessHelper.Close(pathResult.CommonPath.FullName, true))
                        {
                            return(string.Format(Resources.CloseAppSucessMessage, name));
                        }
                    }
                    return(string.Format(Resources.CloseAppFailedMessage, name));
                }

                case "search-app":
                {
                    DSearchPlugin dSearchPlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <DSearchPlugin>();
                    dSearchPlugin.QueryName = name;
                    dSearchPlugin.QueryKind = FileKind.Apps | FileKind.Videos | FileKind.Music;
                    var pathResult = dSearchPlugin.GeneratePathResult();
                    if (pathResult != null)
                    {
                        context.Data.Add(pathResult);
                        return(string.Format(Resources.SearchAppSucessMessage, name));
                    }

                    KJBiblePlugin kjBiblePlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <KJBiblePlugin>();
                    kjBiblePlugin.QueryName      = name;
                    kjBiblePlugin.IsQueryLimited = false;
                    kjBiblePlugin.QueryTestament = BibleNet.KJV.TestamentType.Old | BibleNet.KJV.TestamentType.New;
                    var verseResult = kjBiblePlugin.GetVerseResult();
                    if (verseResult != null)
                    {
                        context.Data.Add(verseResult);
                        return(string.Format(Resources.OpenBibleSucessMessage, verseResult.CommonQuotation));
                    }

                    return(string.Format(Resources.SearchAppFailedMessage, name));
                }
                }
            }
            catch (Exception ex) { SimlBot.Logger.Error(ex); }
            return(Resources.EvaluateErrorMessage);
        }
        string IAdapter.Evaluate(Syn.Bot.Siml.Context context)
        {
            try
            {
                string task = context.Element.Attribute("Task").Value;
                string name = context.Element.Attribute("Name").Value;
                switch (task.ToLower())
                {
                case "define":
                {
                    WordNetPlugin wordNetPlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <WordNetPlugin>();
                    wordNetPlugin.QueryName = name;
                    var synSetResult = wordNetPlugin.GenerateSynSetResult();
                    if (synSetResult != null)
                    {
                        context.Data.Add(synSetResult);
                        return(string.Format(Resources.DefineWordSucessMessage, synSetResult.CommonSynSet));
                    }

                    if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
                    {
                        WikipediaPlugin wikipediaPlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <WikipediaPlugin>();
                        wikipediaPlugin.QueryName = name;
                        var queryResult = wikipediaPlugin.GenerateQueryResult();
                        if (queryResult != null && queryResult.Search.Any())
                        {
                            context.Data.Add(queryResult);
                            return(string.Format(Resources.DefineWordSucessMessage, queryResult.Search.First().GetExtract()));
                        }
                    }
                    return(string.Format(Resources.DefineWordFailedMessage, name));
                }

                case "synonyms":
                {
                    WordNetPlugin wordNetPlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <WordNetPlugin>();
                    wordNetPlugin.QueryName = name;
                    var thesResult = wordNetPlugin.GenerateThesResult();
                    if (thesResult != null)
                    {
                        context.Data.Add(thesResult);
                        return(string.Format(Resources.SynonymsWordSucessMessage,
                                             SynUtility.Text.GetFormattedSentence(thesResult.Meanings.SelectMany(i => i.Synonyms).Distinct().ToList())));
                    }
                    return(string.Format(Resources.SynonymsWordFailedMessage, name));
                }

                case "suggestions":
                {
                    WordNetPlugin wordNetPlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <WordNetPlugin>();
                    wordNetPlugin.QueryName = name;
                    var suggestionResult = wordNetPlugin.GenerateSuggestionResult();
                    if (suggestionResult != null)
                    {
                        context.Data.Add(suggestionResult);
                        return(string.Format(Resources.SuggestionsWordSucessMessage,
                                             SynUtility.Text.GetFormattedSentence(suggestionResult.Suggestions.Distinct().ToList())));
                    }
                    return(string.Format(Resources.SuggestionsWordFailedMessage, name));
                }

                case "spell-check":
                {
                    WordNetPlugin wordNetPlugin = VirtualAssistant.Instance.Plugins.GetPluginByType <WordNetPlugin>();
                    wordNetPlugin.QueryName = name;
                    var hyphenResult = wordNetPlugin.GenerateHyphenResult();
                    if (hyphenResult != null)
                    {
                        context.Data.Add(hyphenResult);
                        return(string.Format(Resources.SpellCheckSucessMessage, hyphenResult.HyphenatedWord.Replace("=", "-")));
                    }
                    return(string.Format(Resources.SpellCheckFailedMessage, name));
                }
                }
            }
            catch (Exception ex) { SimlBot.Logger.Error(ex); }
            return(Resources.EvaluateErrorMessage);
        }
Beispiel #8
0
        string IAdapter.Evaluate(Syn.Bot.Siml.Context context)
        {
            try
            {
                string     result        = string.Empty;
                XAttribute taskAttribute = context.Element.Attribute("Task");
                XAttribute getAttribute  = context.Element.Attribute("Get");
                object     arg;

                if (taskAttribute != null)
                {
                    switch (taskAttribute.Value.ToLower())
                    {
                        #region Lock
                    case "lock":
                        SynUtility.Computer.Lock();
                        break;
                        #endregion

                        #region Shutdown
                    case "shutdown":
                        SynUtility.Computer.Shutdown();
                        break;
                        #endregion

                        #region Restart
                    case "restart":
                        SynUtility.Computer.Restart();
                        break;
                        #endregion

                        #region Log Off
                    case "logo-off":
                        SynUtility.Computer.LogOff();
                        break;
                        #endregion

                        #region Recycle Bin
                    case "clear-trash":
                        SynUtility.Win32.EmptyRecycleBin();
                        break;
                        #endregion

                        #region Restore
                    case "restore":
                        SynUtility.Win32.RestoreWindow(SynUtility.Win32.GetForegroundWindow());
                        break;
                        #endregion

                        #region Maximize
                    case "maximize":
                        SynUtility.Win32.MaximizeWindow(SynUtility.Win32.GetForegroundWindow());
                        break;
                        #endregion

                        #region Minimize
                    case "minimize":
                        SynUtility.Win32.MinimizeWindow(SynUtility.Win32.GetForegroundWindow());
                        break;
                        #endregion

                        #region Close
                    case "close":
                        SynUtility.Win32.CloseWindow(SynUtility.Win32.GetForegroundWindow());
                        break;
                        #endregion

                        #region Tile
                    case "tile":
                        arg = Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"));
                        if (arg == null)
                        {
                            return(string.Empty);
                        }
                        if (CallSiteCommand.P0 == null)
                        {
                            CallSiteCommand.P0 = CallSite <Action <CallSite, object> > .Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "TileHorizontally", null, typeof(WindowAdapter), new CSharpArgumentInfo[]
                            {
                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                            }));
                        }
                        CallSiteCommand.P0.Target(CallSiteCommand.P0, arg);
                        break;
                        #endregion

                        #region Tile Horizontal
                    case "tile-horizontal":
                        arg = Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"));
                        if (arg == null)
                        {
                            return(string.Empty);
                        }
                        if (CallSiteCommand.P1 == null)
                        {
                            CallSiteCommand.P1 = CallSite <Action <CallSite, object> > .Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "TileHorizontally", null, typeof(WindowAdapter), new CSharpArgumentInfo[]
                            {
                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                            }));
                        }
                        CallSiteCommand.P1.Target(CallSiteCommand.P1, arg);
                        break;
                        #endregion

                        #region Tile Vertical
                    case "tile-vertical":
                        arg = Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"));
                        if (arg == null)
                        {
                            return(string.Empty);
                        }
                        if (CallSiteCommand.P2 == null)
                        {
                            CallSiteCommand.P2 = CallSite <Action <CallSite, object> > .Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "TileVertically", null, typeof(WindowAdapter), new CSharpArgumentInfo[]
                            {
                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                            }));
                        }
                        CallSiteCommand.P2.Target(CallSiteCommand.P2, arg);
                        break;
                        #endregion

                        #region Cascade
                    case "cascade":
                        arg = Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"));
                        if (arg == null)
                        {
                            return(string.Empty);
                        }
                        if (CallSiteCommand.P3 == null)
                        {
                            CallSiteCommand.P3 = CallSite <Action <CallSite, object> > .Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "CascadeWindows", null, typeof(WindowAdapter), new CSharpArgumentInfo[]
                            {
                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                            }));
                        }
                        CallSiteCommand.P3.Target(CallSiteCommand.P3, arg);
                        break;
                        #endregion

                        #region Toggle
                    case "toggle":
                        arg = Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"));
                        if (arg == null)
                        {
                            return(string.Empty);
                        }
                        if (CallSiteCommand.P4 == null)
                        {
                            CallSiteCommand.P4 = CallSite <Action <CallSite, object> > .Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "CascadeWindows", null, typeof(WindowAdapter), new CSharpArgumentInfo[]
                            {
                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                            }));
                        }
                        CallSiteCommand.P4.Target(CallSiteCommand.P4, arg);
                        break;
                        #endregion

                        #region Switch
                    case "switch":
                        arg = Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"));
                        if (arg == null)
                        {
                            return(string.Empty);
                        }
                        if (CallSiteCommand.P5 == null)
                        {
                            CallSiteCommand.P5 = CallSite <Action <CallSite, object> > .Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "WindowSwitcher", null, typeof(WindowAdapter), new CSharpArgumentInfo[]
                            {
                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                            }));
                        }
                        CallSiteCommand.P5.Target(CallSiteCommand.P5, arg);
                        break;
                        #endregion

                        #region Minimize All
                    case "minimize-all":
                        arg = Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"));
                        if (arg == null)
                        {
                            return(string.Empty);
                        }
                        if (CallSiteCommand.P6 == null)
                        {
                            CallSiteCommand.P6 = CallSite <Action <CallSite, object> > .Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "MinimizeAll", null, typeof(WindowAdapter), new CSharpArgumentInfo[]
                            {
                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                            }));
                        }
                        CallSiteCommand.P6.Target(CallSiteCommand.P6, arg);
                        break;
                        #endregion

                        #region Undo Minimize All
                    case "undo-minimize-all":
                        arg = Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"));
                        if (arg == null)
                        {
                            return(string.Empty);
                        }
                        if (CallSiteCommand.P7 == null)
                        {
                            CallSiteCommand.P7 = CallSite <Action <CallSite, object> > .Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "UndoMinimizeALL", null, typeof(WindowAdapter), new CSharpArgumentInfo[]
                            {
                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                            }));
                        }
                        CallSiteCommand.P7.Target(CallSiteCommand.P7, arg);
                        break;
                        #endregion
                    }
                }
                else if (getAttribute != null)
                {
                    switch (getAttribute.Value.ToLower())
                    {
                    case "ip":
                        return(SynUtility.Network.GetExternalIp());

                    case "user-name":
                        return(Environment.UserName);

                    case "os-version":
                        return(Environment.OSVersion.Version.Major.ToString(context.Bot.Culture));

                    case "processor-count":
                        return(Environment.ProcessorCount.ToString(context.Bot.Culture));
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                SimlBot.Logger.Error(ex);
            }
            return(string.Empty);
        }