Inheritance: BaseJob
Ejemplo n.º 1
0
        /// <summary>
        /// Register plugin. All plugin must be registered first.
        /// </summary>
        private static void RegisterPlugin()
        {
            var job = new PluginJob
            {
                AssemblyPath = PluginAssemblyPath,
                JobName = "MyAssemblyPluginJob",
                JobGroup = "MyJobGroup"
            };

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Url);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                var response = client.PostAsJsonAsync("api/plugins/", job).Result;
                string resultStr = response.Content.ReadAsStringAsync().Result;

                dynamic result = JsonConvert.DeserializeObject<dynamic>(resultStr);

                if (result != null)
                {
                    Console.WriteLine(resultStr);
                    _jobId = new Guid(result.id.ToString());
                }
            }
        }
        private QueryResponse CreateJob(PluginJob model)
        {
            var dataMap = new Dictionary<string, object>
            {
                {"pluginPath", model.AssemblyPath},
            };

            return base.CreateJob(model, typeof (AssemblyPluginJob), dataMap, model.Description);
        }