Beispiel #1
0
        public override PcActionResult Execute(PcActionParam param)
        {
            var p       = param.ConvertParam <AppExecuteAppParam>();
            var appName = ChineseConvertHelper.ToTraditional(p.AppName);
            var appInfo = appList.SingleOrDefault(x => ChineseConvertHelper.ToTraditional(x.AppName) == appName);

            if (appInfo != null)
            {
                if (!File.Exists(appInfo.Path))
                {
                    return(new PcActionResult()
                    {
                        Msg = $"電腦上的{appName}未安裝!",
                        Success = true
                    });
                }

                Process.Start(appInfo.Path);
                return(new PcActionResult()
                {
                    Msg = $"電腦{appName}打開啦!",
                    Success = true
                });
            }

            return(new PcActionResult()
            {
                Msg = $"你所講應用{appName}未設定!",
                Success = true
            });
        }
Beispiel #2
0
        public PcActionResult AutoAction(string msg)
        {
            if (!string.IsNullOrEmpty(msg))
            {
                msg = ChineseConvertHelper.ToTraditional(msg);
            }

            Console.WriteLine($"语音:{msg}");

            var result = new PcActionResult()
            {
                Msg     = "我冇聽明你想做咩!",
                Success = false
            };

            if (!string.IsNullOrEmpty(msg))
            {
                if (this.CheckKeyWork(msg, new string[] { "取消" }, new string[] { "關機", "電腦" }))
                {
                    result = new CancelShutdownAction().Execute(null);
                }
                else if (this.CheckKeyWork(msg, new string[] { "關" }, new string[] { "馬上", "立即", "即刻" }))
                {
                    result = new ShutdownNowAction().Execute(null);
                }
                else if (this.CheckKeyWork(msg, new string[] { "分鐘" }, new string[] { "關機", "電腦" }))
                {
                    string minute = System.Text.RegularExpressions.Regex.Replace(msg, @"[^0-9]+", "");
                    result = new ShutdownWithDelayAction().Execute(new ShutdownDelayParam()
                    {
                        Minute = Convert.ToInt32(minute)
                    });
                }
                else if (this.CheckKeyWork(msg, new string[] { "打開" }, null))
                {
                    var appName = msg.Substring(msg.IndexOf("打開") + 2);
                    result = new ExecuteAppAction().Execute(new AppExecuteAppParam()
                    {
                        AppName = appName
                    });
                }
            }

            return(result);
        }