public string GetList() { var selectedItems = new List <string>() { "member_id", "password", "member_name", "privilege", "email", "phone_number" }; var selectQuery = MariaQueryBuilder.SelectQuery(TableName, selectedItems); var member = MariaDBConnector.Instance.GetJsonArray("DynamicQueryExecuter", selectQuery); return(member.ToString()); }
public string GetList(JsonValue jsonObj) { var selectedItems = new List <string>() { "name", "view_type", "view_query", "column_json(view_options) as view_options", "DATE_FORMAT(unixtime, '%Y-%m-%d %H:%i:%s') as `unixtime`" }; var query = MariaQueryBuilder.SelectQuery("data_view", selectedItems, jsonObj); var res = MariaDBConnector.Instance.GetJsonArray("DynamicQueryExecuter", query); return(res.ToString()); }
public string GetList(JsonValue jsonObj) { var userId = jsonObj["member_id"].ReadAs <string>(); var selectedItems = new List <string>() { "category", "column_json(rawdata) as rawdata", "DATE_FORMAT(unixtime, '%Y-%m-%d %H:%i:%s') as `unixtime`" }; var query = MariaQueryBuilder.SelectQuery(TableName.Replace("{user}", userId), selectedItems); var res = MariaDBConnector.Instance.GetJsonArray("DynamicQueryExecuter", query); return(res.ToString()); }
public JsonValue GetTab(JsonValue jsonValue) { var selectedItems = new List <string>() { "name", "view_type", "view_query", "DATE_FORMAT(unixtime, '%Y-%m-%d %H:%i:%s') as `unixtime`" }; var query = MariaQueryBuilder.SelectQuery("data_view", selectedItems, jsonValue); var viewInfo = MariaDBConnector.Instance.GetJsonObject(query); var res = MariaDBConnector.Instance.GetJsonArrayWithSchema("DynamicQueryExecuter", viewInfo["view_query"].ReadAs <string>()); return(res.ToString()); }
public string GetList() { var selectedItems = new List <string>() { "name", "target_source", "analysis_query", "action_type", "COLUMN_JSON(options) as options", "COLUMN_JSON(schedule) as schedule", "status", "DATE_FORMAT(unixtime, '%Y-%m-%d %H:%i:%s') as `unixtime`" }; var query = MariaQueryBuilder.SelectQuery(TableName, selectedItems); var result = MariaDBConnector.Instance.GetJsonArray(query); var state = scheduleThread.Count > 0 ? "running" : "stop"; var res = new JsonObject(new KeyValuePair <string, JsonValue>("state", state), new KeyValuePair <string, JsonValue>("result", result)); return(res.ToString()); }
public string Execute(JsonValue jsonValue) { var res = new JsonObject(); res.Add("code", "200"); res.Add("message", "success"); var name = jsonValue["name"].ReadAs <string>(); var command = jsonValue["command"].ReadAs <string>(); var selectedItems = new List <string>() { "name", "target_source", "analysis_query", "action_type", "COLUMN_JSON(options) as options", "COLUMN_JSON(schedule) as schedule", "status", "DATE_FORMAT(unixtime, '%Y-%m-%d %H:%i:%s') as `unixtime`" }; var whereKV = new JsonObject(); whereKV.Add("name", name); var query = MariaQueryBuilder.SelectQuery(TableName, selectedItems, whereKV); var analysisInfo = MariaDBConnector.Instance.GetJsonObject(query); var status = analysisInfo["status"].ReadAs <string>().ToLower(); if (command != "stop" && (status == "play" || status == "wait" || status == "spinner")) { res["code"] = 400; res["message"] = "fail"; return(res.ToString()); } var setDict = new JsonObject(); setDict.Add("status", status); var action = new Func <string, bool>((switchMode) => { try { if (switchMode == "wait" || switchMode == "stop") { setDict["status"] = "play"; var statusUpdate = MariaQueryBuilder.UpdateQuery(TableName, whereKV, setDict); MariaDBConnector.Instance.SetQuery("DynamicQueryExecuter", statusUpdate); this.Notify(); } this.ExecuteAnalysis(analysisInfo); } catch (Exception ex) { LogWriter.Error(ex.ToString()); } return(true); }); switch (command.ToLower()) { case "start": { var statusUpdate = string.Empty; var thread = new Thread(new ThreadStart(() => { Scheduler.ExecuteScheduler(TableName, analysisInfo["action_type"].ReadAs <string>(), whereKV, analysisInfo["schedule"], setDict, action, this.Notify); })); if (scheduleThread.ContainsKey(name)) { scheduleThread.Remove(name); } scheduleThread.Add(name, thread); thread.Start(); Thread.Sleep(100); break; } case "stop": { scheduleThread[name].Abort(); scheduleThread.Remove(name); setDict["status"] = "stop"; var statusUpdate = MariaQueryBuilder.UpdateQuery(TableName, whereKV, setDict); MariaDBConnector.Instance.SetQuery("DynamicQueryExecuter", statusUpdate); this.Notify(); break; } } return(res.ToString()); }
public string Execute(JsonValue jsonValue) { var res = new JsonObject(); res.Add("code", "200"); res.Add("message", "success"); var name = jsonValue["name"].ReadAs <string>(); var command = jsonValue["command"].ReadAs <string>(); var selectedItems = new List <string>() { "name", "module_name", "method_name", "action_type", "column_json(options) as options", "column_json(schedule) as schedule", "status", "unixtime" }; var whereKV = new JsonObject(); whereKV.Add("name", name); var query = MariaQueryBuilder.SelectQuery(TableName, selectedItems, whereKV); var moduleInfo = MariaDBConnector.Instance.GetJsonObject("DynamicQueryExecuter", query); var status = moduleInfo["status"].ReadAs <string>().ToLower(); if (command != "stop" && (status == "play" || status == "wait")) { res["code"] = 400; res["message"] = "fail"; return(res.ToString()); } var setDict = new JsonObject(); setDict.Add("status", status); var action = new Func <string, bool>((switchMode) => { try { if (switchMode == "wait" || switchMode == "stop") { setDict["status"] = "play"; var statusUpdate = MariaQueryBuilder.UpdateQuery(TableName, whereKV, setDict); MariaDBConnector.Instance.SetQuery("DynamicQueryExecuter", statusUpdate); this.Notify(); } var event_callback = new Func <string, bool>((code) => { this.Notify_Completed(); return(true); }); ModuleManager.Instance.ExecuteModule(moduleInfo, event_callback); } catch (Exception ex) { LogWriter.Error(ex.ToString()); } return(true); }); switch (command.ToLower()) { case "start": { var statusUpdate = string.Empty; var thread = new Thread(new ThreadStart(() => { Scheduler.ExecuteScheduler(TableName, moduleInfo["action_type"].ReadAs <string>(), whereKV, moduleInfo["schedule"], setDict, action, this.Notify); })); if (scheduleThread.ContainsKey(name)) { scheduleThread.Remove(name); } scheduleThread.Add(name, thread); thread.Start(); Thread.Sleep(100); break; } case "stop": { scheduleThread[name].Abort(); scheduleThread.Remove(name); setDict["status"] = "stop"; var statusUpdate = MariaQueryBuilder.UpdateQuery(TableName, whereKV, setDict); MariaDBConnector.Instance.SetQuery("DynamicQueryExecuter", statusUpdate); this.Notify(); break; } } return(res.ToString()); }