Ejemplo n.º 1
0
        public List <Result> Query(Query query)
        {
            string output = ExecuteQuery(query);

            if (!string.IsNullOrEmpty(output))
            {
                try
                {
                    List <Result> results = new List <Result>();

                    JsonRPCQueryResponseModel queryResponseModel = JsonConvert.DeserializeObject <JsonRPCQueryResponseModel>(output);
                    if (queryResponseModel.Result == null)
                    {
                        return(null);
                    }

                    foreach (JsonRPCResult result in queryResponseModel.Result)
                    {
                        JsonRPCResult result1 = result;
                        result.Action = (c) =>
                        {
                            if (result1.JsonRPCAction == null)
                            {
                                return(false);
                            }

                            if (!string.IsNullOrEmpty(result1.JsonRPCAction.Method))
                            {
                                if (result1.JsonRPCAction.Method.StartsWith("Wox."))
                                {
                                    ExecuteWoxAPI(result1.JsonRPCAction.Method.Substring(4), result1.JsonRPCAction.Parameters);
                                }
                                else
                                {
                                    ThreadPool.QueueUserWorkItem(state =>
                                    {
                                        string actionReponse = ExecuteCallback(result1.JsonRPCAction);
                                        JsonRPCRequestModel jsonRpcRequestModel = JsonConvert.DeserializeObject <JsonRPCRequestModel>(actionReponse);
                                        if (jsonRpcRequestModel != null &&
                                            !string.IsNullOrEmpty(jsonRpcRequestModel.Method) &&
                                            jsonRpcRequestModel.Method.StartsWith("Wox."))
                                        {
                                            ExecuteWoxAPI(jsonRpcRequestModel.Method.Substring(4), jsonRpcRequestModel.Parameters);
                                        }
                                    });
                                }
                            }
                            return(!result1.JsonRPCAction.DontHideAfterAction);
                        };
                        results.Add(result);
                    }
                    return(results);
                }
                catch (System.Exception e)
                {
                    Log.Error(e);
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        public List <Result> Query(Query query)
        {
            string output = ExecuteQuery(query);

            if (!String.IsNullOrEmpty(output))
            {
                try
                {
                    List <Result> results = new List <Result>();

                    JsonRPCQueryResponseModel queryResponseModel = JsonConvert.DeserializeObject <JsonRPCQueryResponseModel>(output);
                    if (queryResponseModel.Result == null)
                    {
                        return(null);
                    }

                    foreach (JsonRPCResult result in queryResponseModel.Result)
                    {
                        JsonRPCResult result1 = result;
                        result.Action = c =>
                        {
                            if (result1.JsonRPCAction == null)
                            {
                                return(false);
                            }

                            if (!String.IsNullOrEmpty(result1.JsonRPCAction.Method))
                            {
                                if (result1.JsonRPCAction.Method.StartsWith("Wox."))
                                {
                                    ExecuteWoxAPI(result1.JsonRPCAction.Method.Substring(4), result1.JsonRPCAction.Parameters);
                                }
                                else
                                {
                                    string actionReponse = ExecuteCallback(result1.JsonRPCAction);
                                    JsonRPCRequestModel jsonRpcRequestModel = JsonConvert.DeserializeObject <JsonRPCRequestModel>(actionReponse);
                                    if (jsonRpcRequestModel != null &&
                                        !String.IsNullOrEmpty(jsonRpcRequestModel.Method) &&
                                        jsonRpcRequestModel.Method.StartsWith("Wox."))
                                    {
                                        ExecuteWoxAPI(jsonRpcRequestModel.Method.Substring(4), jsonRpcRequestModel.Parameters);
                                    }
                                }
                            }
                            return(!result1.JsonRPCAction.DontHideAfterAction);
                        };
                        results.Add(result);
                    }
                    return(results);
                }
                catch (Exception e)
                {
                    Log.Exception($"|Wox.Core.Plugin.JsonRPCPlugin.Query|Exception when query <{query}>", e);
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
        private List <Result> DeserializedResult(string output)
        {
            if (!string.IsNullOrEmpty(output))
            {
                List <Result> results = new List <Result>();

                JsonRPCQueryResponseModel queryResponseModel =
                    JsonConvert.DeserializeObject <JsonRPCQueryResponseModel>(output);
                if (queryResponseModel.Result == null)
                {
                    return(null);
                }

                foreach (JsonRPCResult result in queryResponseModel.Result)
                {
                    JsonRPCResult result1 = result;
                    result.Action = c => {
                        if (result1.JsonRPCAction == null)
                        {
                            return(false);
                        }

                        if (!string.IsNullOrEmpty(result1.JsonRPCAction.Method))
                        {
                            if (result1.JsonRPCAction.Method.StartsWith("Wox."))
                            {
                                ExecuteWoxAPI(result1.JsonRPCAction.Method.Substring(4),
                                              result1.JsonRPCAction.Parameters);
                            }
                            else
                            {
                                string actionReponse = ExecuteCallback(result1.JsonRPCAction);
                                JsonRPCRequestModel jsonRpcRequestModel =
                                    JsonConvert.DeserializeObject <JsonRPCRequestModel>(actionReponse);
                                if (jsonRpcRequestModel != null &&
                                    !string.IsNullOrEmpty(jsonRpcRequestModel.Method) &&
                                    jsonRpcRequestModel.Method.StartsWith("Wox."))
                                {
                                    ExecuteWoxAPI(jsonRpcRequestModel.Method.Substring(4),
                                                  jsonRpcRequestModel.Parameters);
                                }
                            }
                        }

                        return(!result1.JsonRPCAction.DontHideAfterAction);
                    };
                    results.Add(result);
                }

                return(results);
            }

            return(null);
        }
Ejemplo n.º 4
0
 protected abstract string ExecuteCallback(JsonRPCRequestModel rpcRequest);
Ejemplo n.º 5
0
 protected override string ExecuteCallback(JsonRPCRequestModel rpcRequest)
 {
     _startInfo.FileName  = Path.Combine(PythonHome, "pythonw.exe");
     _startInfo.Arguments = $"-B \"{context.CurrentPluginMetadata.ExecuteFilePath}\" \"{rpcRequest}\"";
     return(Execute(_startInfo));
 }
Ejemplo n.º 6
0
 protected override string ExecuteCallback(JsonRPCRequestModel rpcRequest)
 {
     _startInfo.Arguments = $"\"{rpcRequest}\"";
     return(Execute(_startInfo));
 }
Ejemplo n.º 7
0
 protected override string ExecuteCallback(JsonRPCRequestModel rpcRequest)
 {
     startInfo.FileName  = Path.Combine(woxDirectory, "PythonHome\\pythonw.exe");
     startInfo.Arguments = string.Format("-B \"{0}\" \"{1}\"", context.CurrentPluginMetadata.ExecuteFilePath, rpcRequest);
     return(Execute(startInfo));
 }
Ejemplo n.º 8
0
 protected override string ExecuteCallback(JsonRPCRequestModel rpcRequest)
 {
     _startInfo.Arguments        = $"-B \"{context.CurrentPluginMetadata.ExecuteFilePath}\" \"{rpcRequest}\"";
     _startInfo.WorkingDirectory = context.CurrentPluginMetadata.PluginDirectory;
     return(Execute(_startInfo));
 }
Ejemplo n.º 9
0
 protected abstract string ExecuteCallback(JsonRPCRequestModel rpcRequest);
Ejemplo n.º 10
0
 protected override string ExecuteCallback(JsonRPCRequestModel rpcRequest)
 {
     _startInfo.FileName = Path.Combine(PythonHome, "pythonw.exe");
     _startInfo.Arguments = $"-B \"{context.CurrentPluginMetadata.ExecuteFilePath}\" \"{rpcRequest}\"";
     return Execute(_startInfo);
 }
Ejemplo n.º 11
0
 protected override string ExecuteCallback(JsonRPCRequestModel rpcRequest)
 {
     startInfo.FileName = Path.Combine(woxDirectory, "PythonHome\\pythonw.exe");
     startInfo.Arguments = string.Format("-B \"{0}\" \"{1}\"", context.CurrentPluginMetadata.ExecuteFilePath, rpcRequest);
     return Execute(startInfo);
 }