public override cmd check_cmd(string cmd) { cmd c = new cmd(cmd), c2 = new cmd("[action] " + cmd); config.table_row tr = null; foreach (config.table_row r in config.get_table("cmds.base-cmds").rows) { string action = r.field("action"), obj = r.field("object") , synobj = r.field("syn-object"), subobj = r.field("subobj"); bool action_opt = r.fld_bool("action-opt"); if (is_like_cmd(action, c.action) && is_like_cmd(obj, c.obj, synobj) && is_like_cmd(subobj, c.sub_obj())) { tr = r; c.obj = obj.Contains("{") ? c.obj : obj; break; } if (action_opt) { if (is_like_cmd(obj, c2.obj, synobj) && is_like_cmd(subobj, c2.sub_obj())) { tr = r; c2.action = action; c2.obj = obj.Contains("{") ? c.obj : obj; c = c2; break; } } } if (tr == null) { return(null); } c.group = tr.field("group"); c.code = tr.field("code"); c.sub_code = tr.field("sub-code"); c.type = tr.field("type"); c.page = tr.field("page"); return(c); }
protected override void OnInit(EventArgs e) { base.OnInit(e); // inizializzazione _cmd = master.check_cmd(qry_val("cmd")); // elab requests & cmds if (this.IsPostBack) { return; } try { io ob = new io(); // js request if (json_request.there_request(this)) { json_result res = new json_result(json_result.type_result.ok); try { json_request jr = new json_request(this); // save_file if (jr.action == "save_file") { synch s = ob.get_synch(jr.val_int("user_id"), jr.val_str("user_name")); Encoding enc = System.Text.Encoding.GetEncoding(jr.val_str("enc")); byte[] bytes = jr.val_bytes("bin_data", enc); string path = ob.file_path(jr.val_int("id")); File.WriteAllBytes(path, bytes); s.set_file_content_db(jr.val_int("id"), Path.GetExtension(path).ToLower(), enc.GetString(bytes), DateTime.Now, DateTime.Now); } // synch folders else if (jr.action == "synch_folders") { synch s = ob.get_synch(jr.val_int("user_id"), jr.val_str("user_name")); s.synch_event += s_synch_event; synch_results rf = s.reload_folders(); res.data = rf; res.contents = _synch_events; } } catch (Exception ex) { log.log_err(ex); res = new json_result(json_result.type_result.error, ex.Message); } write_response(res); return; } // tasks //if(_cmd != null && _cmd.action == "view" && _cmd.obj == "tasks") { // int? fi = qry_val("idt") != "" ? qry_int("idt") : (qry_val("id") != "" ? qry_int("id") : (int?)null) // , sfi = qry_val("sft") != "" ? qry_int("sft") : (qry_val("sf") != "" ? qry_int("sf") : (int?)null); //} else throw new Exception("COMANDO NON RICONOSCIUTO!"); } catch (Exception ex) { log.log_err(ex); if (!json_request.there_request(this)) { master.err_txt(ex.Message); } } }
private void Chat_MessageSent(string author, string message) { var client = Utilities.localClient(); if (client == null) { Console.WriteLine("Error: Local client can't be found !"); } if (message.StartsWith("%")) { if (Utilities.isHost()) { return; } int pos = message.IndexOf(' '); string commandName = (pos > 0 ? message.Substring(1, message.IndexOf(' ')) : message.Substring(1).Trim()); cmd c = cmd.all.getCommand(commandName); if (!c.canUseAsClient && c.perm != PermType.LOCAL) { Utilities.sendMessage("You can't use that command as client"); return; } exec(c, client, pos > 0 ? message.Substring(pos + 1).Trim() : ""); } else { if (!message.StartsWith("!")) { return; } if (message.ToLower().Trim() == "!plugin") { printClient(); return; } if (!Utilities.isHost()) { return; } int pos = message.IndexOf(' '); string commandName = (pos > 0 ? message.Substring(1, message.IndexOf(' ')) : message.Substring(1)).Trim(); cmd c = cmd.all.getCommand(commandName); if (c == null) { Utilities.sendMessage("The command '" + commandName + "' don't exist."); return; } exec(c, client, pos > 0 ? message.Substring(pos + 1).Trim() : ""); } }
private void button2_Click(object sender, EventArgs e) { cmd testCmd = new cmd(new float[] { 1.0f, 1.0f, 1.0f }); float val = 0; for (int i = 0; i < 3; i++) { val += testCmd.command[i] * weight[i]; } label9.Text = lorR(val) == 1 ? "機器人向:1(左)" : "機器人向:-1(右)"; }
public CCommand(string command, cmd callback) { if (callback == null) { throw new NullReferenceException("Callback can not be null!"); } cmd = command; exec = callback; commands.Add(this); }
private void exec(cmd c, ClientPlayerInfo p, string message) { try { c.use(p, message); } catch (Exception error) { Utilities.sendMessage("Error"); Console.WriteLine(error); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); // inizializzazione _cmd = master.check_cmd(qry_val("cmd")); // elab requests & cmds if (this.IsPostBack) { return; } try { //sections hpb = new sections(); if (json_request.there_request(this)) { json_result res = new json_result(json_result.type_result.ok); try { json_request jr = new json_request(this); } catch (Exception ex) { log.log_err(ex); res = new json_result(json_result.type_result.error, ex.Message); } write_response(res); return; } // check cmd if (_cmd == null) { return; } // view if (_cmd.action == "view" && _cmd.obj == "home-page") { } else { throw new Exception("COMANDO NON RICONOSCIUTO!"); } } catch (Exception ex) { log.log_err(ex); if (!json_request.there_request(this)) { master.err_txt(ex.Message); } } }
private void Chat_MessageReceived(string author, string message) { if (!message.StartsWith("!")) { return; } if (message.ToLower().Trim() == "!plugin") { printClient(); return; } if (!Utilities.isHost()) { return; } var client = Utilities.clientFromName(author); if (client == null) { Console.WriteLine("Error: client can't be found"); return; } int pos = message.IndexOf(' '); string commandName = (pos > 0 ? message.Substring(1, pos) : message.Substring(1)).Trim(); cmd c = cmd.all.getCommand(commandName); if (c == null) { Utilities.sendMessage("The command '" + commandName + "' don't exist."); return; } if (c.perm == PermType.LOCAL) { return; } if (c.perm != PermType.ALL) { Utilities.sendMessage("You don't have the permission to do that !"); return; } exec(c, client, pos > 0 ? message.Substring(pos + 1).Trim() : ""); }
private void button3_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = Directory.GetCurrentDirectory(); if (ofd.ShowDialog() == DialogResult.OK) { string[] input = File.ReadAllLines(ofd.FileName); com = new cmd[input.Length]; textBox1.Clear(); for (int i = 0; i < input.Length; i++) { textBox1.Text += input[i] + "\r\n"; com [i] = new cmd(Array.ConvertAll(input[i].Split('\t'), float.Parse)); } } }
private void listCmd(ClientPlayerInfo p) { Utilities.sendMessage("Available commands :"); string list = ""; foreach (var cName in cmd.all.commands()) { cmd c = cmd.all.getCommand(cName); list += cName; if (c.perm == PermType.HOST) { list += "(H)"; } if (c.perm == PermType.LOCAL) { list += "(L)"; } list += ", "; } Utilities.sendMessage(list.Remove(list.Length - 2)); Utilities.sendMessage("(H) = host only / (L) = local client only"); Utilities.sendMessage("Use !help <command> for more information on the command"); }
public override void use(ClientPlayerInfo p, string message) { if (message.Length == 0) { listCmd(p); return; } int pos = message.IndexOf(' '); string commandName = (pos > 0 ? message.Substring(1, message.IndexOf(' ')) : message).Trim(); cmd c = cmd.all.getCommand(commandName); if (c == null) { Utilities.sendMessage("The command '" + commandName + "' don't exist."); return; } c.help(p); Utilities.sendMessage("Permission level : " + c.perm); if (c.perm == PermType.LOCAL) { Utilities.sendMessage("This command can only be used by the local player"); } }
SetCommand(cmd, command);
public static void Main(string[] args) { cmd cmd = new cmd(); LogLevel logLevel = LogLevel.Error; CultureInfo.CurrentCulture = new CultureInfo("ru-RU"); #region Command Line foreach (var line in args) { var g = new Regex("--([^=]+)(='?([^\n\r']+)'?)?").Match(line).Groups; string comand = g[1].Value.ToLower(); string value = g[3].Value; switch (comand) { #region platform case "platform": { switch (value.ToLower()) { case "docker": Platform.Set(IsDocker: true); break; case "demo": Platform.Set(IsDemo: true); break; case "debug": Platform.Set(IsDebug: true); break; } break; } #endregion #region loglevel case "loglevel": { if (Enum.TryParse(typeof(LogLevel), value, out object res)) { logLevel = (LogLevel)res; } break; } #endregion #region conf case "conf": { cmd = Newtonsoft.Json.JsonConvert.DeserializeObject <cmd>(value); break; } #endregion #region timeout case "timeout:core": { if (int.TryParse(value.Replace("s", ""), out int res)) { cmd.Timeout.core = res; } break; } #endregion #region statuscode case "statuscode": { foreach (var item in value.ToLower().Split(',')) { switch (item) { case "iptables": cmd.StatusCode.IPtables = true; break; case "checklink": cmd.StatusCode.Checklink = true; break; } } break; } #endregion } } Startup.cmd = cmd; #endregion // Настройки сервера var host = WebHost.CreateDefaultBuilder(args) .UseKestrel(op => { #region Unix Socket if (Platform.Get == PlatformOS.Unix || Platform.Get == PlatformOS.Docker) { if (File.Exists("/var/run/ispcore.sock")) { File.Delete("/var/run/ispcore.sock"); } Directory.CreateDirectory("/var/run/"); op.ListenUnixSocket("/var/run/ispcore.sock"); } #endregion // TCP op.Listen(Platform.Get == PlatformOS.Docker ? IPAddress.Any : IPAddress.Parse("127.0.0.1"), 4538); // ISPCore Panel op.Listen(IPAddress.Any, 8793, listenOptions => listenOptions.UseHttps("cert.pfx", File.ReadAllText($"{Folders.Passwd}/cert.key"))); }) .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup <Startup>() .ConfigureLogging(logging => logging.SetMinimumLevel(logLevel)) .Build(); // Запускаем крон Timer cronMinutes = new Timer(new TimerCallback(CronMinutes), null, 0, 1000 * 60); Timer cronSeconds = new Timer(new TimerCallback(CronSeconds), null, 0, 1000); Timer writeLogTo = new Timer(new TimerCallback(WriteLogTo.WriteLogToSql), null, 0, 1000); // Запускаем ASP.NET host.Run(); // Что-бы GC.Collect() не сносил таймеры cronSeconds.Dispose(); cronMinutes.Dispose(); writeLogTo.Dispose(); }
protected override void OnInit(EventArgs e) { base.OnInit(e); // inizializzazione _cmd = master.check_cmd(qry_val("cmd")); // elab requests & cmds if (this.IsPostBack) { return; } try { users us = new users(); if (json_request.there_request(this)) { json_result res = new json_result(json_result.type_result.ok); try { json_request jr = new json_request(this); // add_user if (jr.action == "add_user") { string user_name = jr.val_str("user_name"), email = jr.val_str("email") , password = jr.val_str("password"), c_password = jr.val_str("c_password"); string tkey, akey; us.add_utente(user_name, email, password, c_password, out tkey, out akey, 3); send_mail(email, "conferma iscrizione al dipa notes", string.Format(@"<h2>{0}.</h2><p>Sei stato iscritto al <a href='{1}'>Deepa-Notes</a>!</p> <p><i>Ecco la password: {3}</i></p> <h3><a href='{1}confirm.aspx?akey={2}'>entra per confermare la tua iscrizione!</a></h3>" , user_name, core.base_url, akey, password)); } // del_user else if (jr.action == "del_user") { us.del_utente(jr.val_int("id")); } // disable_user else if (jr.action == "disable_user") { us.disable_utente(jr.val_int("id")); } // active_user else if (jr.action == "active_user") { us.riactive_utente(jr.val_int("id")); user u = us.get_user(jr.val_int("id")); send_mail(u.email, "attivazione al deepa-notes", string.Format(@"<h2>{0}.</h2><pSei stato iscritto al <a href='{1}'>Deepa-Notes</a>!</p> <h3><a href='{1}login.aspx?nm={0}'>clicca qui per entrare, ma devi ricordare la password!</a></h3>" , u.name, core.base_url)); } } catch (Exception ex) { log.log_err(ex); res = new json_result(json_result.type_result.error, ex.Message); } write_response(res); return; } // check cmd if (_cmd == null) { return; } // user StringBuilder sb = new StringBuilder(); if (_cmd.action == "view" && _cmd.obj == "user") { cmd_add.Value = master.url_cmd("add user"); page_title.InnerText = "Utente loggato"; sb.Append(core.parse_html_block("logged-user", new Dictionary <string, object>() { { "us", user } })); view.InnerHtml = sb.ToString(); } // users else if (_cmd.action == "view" && _cmd.obj == "users") { cmd_add.Value = master.url_cmd("add user"); page_title.InnerText = "Elenco utenti"; foreach (user u in us.list_users()) { sb.Append(core.parse_html_block("user", new Dictionary <string, object>() { { "us", u } })); } view.InnerHtml = sb.ToString(); } // add user else if (_cmd.action == "add" && _cmd.obj == "user") { cmd_users.Value = master.url_cmd("view utenti"); page_title.InnerText = "Nuovo utente"; view.Visible = false; add.Visible = true; } else { throw new Exception("COMANDO NON RICONOSCIUTO!"); } } catch (Exception ex) { log.log_err(ex); if (!json_request.there_request(this)) { master.err_txt(ex.Message); } } }
ExecuteWriteScreenSpaceShadow(cmd, wsssParams, wsssResources);
public CommandPacket(string cmd, string subcmd = null) => this.Command(cmd, subcmd);
var result = QueryValue(cmd, database, table, fieldName);
protected override void OnInit(EventArgs e) { base.OnInit(e); // inizializzazione _cmd = master.check_cmd(qry_val("cmd")); // elab requests & cmds if (this.IsPostBack) { return; } try { notes ob = new notes(); // upload file if (json_request.there_file(this)) { json_result res = new json_result(json_result.type_result.ok); try { if (Request.Files.Count > 0) { HttpFileCollection files = Request.Files; foreach (string key in files) { HttpPostedFile file = files[key]; string tp_file = key.Split(new char[] { '_' })[0]; if (tp_file == "task-file") { int task_id = int.Parse(key.Split(new char[] { '_' })[2]); byte[] content; using (var streamReader = new MemoryStream()) { file.InputStream.CopyTo(streamReader); content = streamReader.ToArray(); } add_att(ob, task_id, Path.GetFileName(file.FileName), content); } else { throw new Exception("tipo file upload '" + tp_file + "' non supportato!"); } } } else { throw new Exception("nessun file da caricare!"); } } catch (Exception ex) { log.log_err(ex); res = new json_result(json_result.type_result.error, ex.Message); } write_response(res); return; } // js request if (json_request.there_request(this)) { json_result res = new json_result(json_result.type_result.ok); try { json_request jr = new json_request(this); // base if (base_elab_action(jr, res)) { // fatta } // add_att else if (jr.action == "add_att") { add_att(ob, jr.val_int("task_id"), jr.val_str("name")); } // task_state else if (jr.action == "task_state") { List <free_label> fl = ob.load_free_labels(); string folder_path; ob.update_task(jr.val_int("id"), out folder_path, fl, stato: jr.val_str("stato")); List <task_stato> stati = db_conn.dt_table(core.parse_query("menu-states")).Rows.Cast <DataRow>() .Select(r => new task_stato(db_provider.str_val(r["stato"]), 0, "", "" , db_provider.str_val(r["title_singolare"]))).ToList(); res.html_element = parse_task(ob.load_task(jr.val_int("id")), folder_path, stati); } // set_filter_id else if (jr.action == "set_filter_id") { set_cache_var("active-task-filter", jr.val_str("filter_id")); } // remove_task else if (jr.action == "remove_task") { ob.remove_task(jr.val_int("id")); } // update_task else if (jr.action == "update_task") { List <free_label> fl = ob.load_free_labels(); if (!nome_valido(jr.val_str("title"))) { throw new Exception("nome '" + jr.val_str("title") + "' non valido!"); } string folder_path; ob.update_task(jr.val_int("id"), out folder_path, fl, title: jr.val_str("title"), assegna: jr.val_str("assegna") , priorita: jr.val_str("priorita"), stima: jr.val_str("stima"), tipo: jr.val_str("tipo")); List <task_stato> stati = db_conn.dt_table(core.parse_query("menu-states")).Rows.Cast <DataRow>() .Select(r => new task_stato(db_provider.str_val(r["stato"]), 0, "", "" , db_provider.str_val(r["title_singolare"]))).ToList(); res.html_element = parse_task(ob.load_task(jr.val_int("id")), folder_path, stati); } // ren_task else if (jr.action == "ren_task") { if (!nome_valido(jr.val_str("title"))) { throw new Exception("nome '" + jr.val_str("title") + "' non valido!"); } ob.ren_task(jr.val_int("id"), jr.val_str("title")); } // add_task else if (jr.action == "add_task") { if (!nome_valido(jr.val_str("title"))) { throw new Exception("nome '" + jr.val_str("title") + "' non valido!"); } ob.add_task(jr.val_int("synch_folder_id"), jr.val_int("folder_id"), jr.val_int_null("search_id"), jr.val_str("stato") , jr.val_str("title"), jr.val_str("assegna"), jr.val_str("priorita"), jr.val_str("tipo"), jr.val_str("stima")); } // remove_att else if (jr.action == "remove_att") { ob.remove_att(jr.val_int("id")); } // ren_att else if (jr.action == "ren_att") { ob.ren_file(jr.val_int("file_id"), jr.val_str("name")); } // add_folder else if (jr.action == "add_folder") { if (!nome_valido(jr.val_str("title"))) { throw new Exception("nome '" + jr.val_str("title") + "' non valido!"); } ob.add_folder(jr.val_int("synch_folder_id"), jr.val_int("folder_id"), jr.val_str("title")); } // ren_folder else if (jr.action == "ren_folder") { if (!nome_valido(jr.val_str("title"))) { throw new Exception("nome '" + jr.val_str("title") + "' non valido!"); } ob.ren_folder(jr.val_int("synch_folder_id"), jr.val_int("folder_id"), jr.val_str("title")); } // del_folder else if (jr.action == "del_folder") { ob.del_folder(jr.val_int("synch_folder_id"), jr.val_int("folder_id")); res.contents = master.url_cmd("tasks"); } // cut_element else if (jr.action == "cut_element") { int f_id = jr.val_int("element_id"), sf_id = jr.val_int("synch_folder_id"); string tp = jr.val_str("tp_element"); bool?added = null; if (tp == "folder" || tp == "synch-folder") { if (sf_id > 0 && tp == "synch-folder") { foreach (int id in ob.ids_childs_folders(sf_id)) { added = set_element_cut(id, element_cut.element_cut_type.folder, jr.val_bool("copy")); res.list.Add(id.ToString()); } } else { added = set_element_cut(f_id, element_cut.element_cut_type.folder, jr.val_bool("copy")); res.list.Add(f_id.ToString()); } } else if (tp == "task") { added = set_element_cut(f_id, element_cut.element_cut_type.task, jr.val_bool("copy")); } else if (tp == "att") { added = set_element_cut(f_id, element_cut.element_cut_type.attachment, jr.val_bool("copy")); } res.set_var("added", added.HasValue ? (added.Value ? "true" : "false") : "none"); } // paste_elements else if (jr.action == "paste_elements") { string tp_paste = jr.val_str("tp"); int f_id = jr.val_int("folder_id"), sf_id = jr.val_int("synch_folder_id"); bool paste = false; if (elements_cut.Count > 0) { string err = ""; List <element_cut> ecs = new List <element_cut>(); if (tp_paste == "task") { DataRow dr = ob.get_task_info(f_id); if (db_provider.int_val(dr["file_id"]) > 0) { throw new Exception("questo task non può contenere un allegato!"); } string path_task = Path.Combine(db_provider.str_val(dr["synch_local_path"]) , db_provider.str_val(dr["folder_path"]).Length > 0 ? db_provider.str_val(dr["folder_path"]).Substring(1) : ""); foreach (element_cut ec in elements_cut) { try { if (ec.tp == element_cut.element_cut_type.attachment) { paste = true; if (!ec.copy) { ob.move_file(ec.id, db_provider.int_val(dr["folder_id"]), db_provider.int_val(dr["synch_folder_id"]), path_task); } else { ob.copy_file(ec.id, db_provider.int_val(dr["folder_id"]), db_provider.int_val(dr["synch_folder_id"]), path_task); } } } catch (Exception ex) { ecs.Add(ec); if (err == "") { err = ex.Message; } } } } else { if (sf_id <= 0) { sf_id = ob.get_synch_folder_id(f_id); } foreach (element_cut ec in elements_cut) { try { if (ec.tp == element_cut.element_cut_type.folder) { ob.move_folder(ec.id, sf_id, f_id > 0 ? f_id : (int?)null); paste = true; } else if (ec.tp == element_cut.element_cut_type.task) { ob.move_task(ec.id, sf_id, f_id > 0 ? f_id : (int?)null); paste = true; } } catch (Exception ex) { ecs.Add(ec); if (err == "") { err = ex.Message; } } } } res.message = err; elements_cut.Clear(); foreach (element_cut ec2 in ecs) { elements_cut.Add(ec2); } } if (!paste) { throw new Exception("non è stato incollato nessun elemento!"); } } // get_notes else if (jr.action == "get_details") { res.contents = ob.get_task_notes(jr.val_int("task_id")); string html_allegati = ""; foreach (DataRow dr in ob.get_task_allegati(jr.val_int("task_id"), jr.val_int_null("search_id")).Rows) { bool cut = there_element_cut(db_provider.int_val(dr["file_id"]), element_cut.element_cut_type.attachment) , found = db_provider.int_val(dr["found_file"]) > 0, file_task = db_provider.int_val(dr["file_task"]) > 0; string style = cut ? "badge-warning" : (found ? "badge-danger" : (file_task ? "badge-primary" : "badge-light")); html_allegati += master.client_key == "" ? core.parse_html_block("task-allegato", new string[, ] { { "file-id", db_provider.str_val(dr["file_id"]) } , { "http-path", db_provider.str_val(dr["http_path"]) }, { "file-name", db_provider.str_val(dr["file_name"]) }, { "style", style }, { "tp_att", style } }) : core.parse_html_block("task-allegato-client", new string[, ] { { "file-id", db_provider.str_val(dr["file_id"]) }, { "file-name", db_provider.str_val(dr["file_name"]) }, { "style", style }, { "tp_att", style } , { "user-id", ob.user_id.ToString() }, { "user-name", ob.user_name } }); } res.html_element = html_allegati != "" ? core.parse_html_block("task-allegati", new string[, ] { { "html-allegati", html_allegati } }) : ""; } // save_task_notes else if (jr.action == "save_task_notes") { synch s = ob.get_synch(jr.val_int("user_id"), jr.val_str("user_name")); s.save_task_notes(jr.val_int("task_id"), jr.val_str("text")); } else if (jr.action == "synch_folders") { synch s = ob.get_synch(jr.val_int("user_id"), jr.val_str("user_name")); s.synch_event += s_synch_event; synch_results rf = s.reload_folders(force: true); res.data = rf; res.contents = _synch_events; } } catch (Exception ex) { log.log_err(ex); res = new json_result(json_result.type_result.error, ex.Message); } write_response(res); return; } // synch if (_cmd != null && _cmd.action == "synch") { content.InnerHtml = "<p>sincronizzazione cartelle...</p>"; ClientScript.RegisterStartupScript(GetType(), "__action" , "var __action_page = '" + _cmd.action + "';\r\n" + "var __user_id = " + this.user.id + ";\r\n" + "var __user_name = '" + this.user.name + "';\r\n", true); } // tasks else if (_cmd != null && ((_cmd.action == "view" && _cmd.obj == "tasks") || (_cmd.action == "search" && _cmd.obj == "task"))) { int?fi = qry_val("idt") != "" ? qry_int("idt") : (qry_val("id") != "" ? qry_int("id") : (int?)null) , sfi = qry_val("sft") != "" ? qry_int("sft") : (qry_val("sf") != "" ? qry_int("sf") : (int?)null); string search = _cmd.action == "search" ? _cmd.sub_obj() : ""; // ricerca testo int search_cc = 0; int?search_id = search != "" ? ob.search_task(search, this.Session.SessionID, out search_cc) : (int?)null; search_id_active.Value = search_id.HasValue ? search_id.Value.ToString() : ""; // filtro attivo List <task_filter> tfs = db_conn.dt_table(core.parse_query("filters-tasks")).Rows .Cast <DataRow>().Select(r => new task_filter(db_provider.int_val(r["task_filter_id"]) , db_provider.str_val(r["filter_title"]), db_provider.str_val(r["filter_notes"]) , db_provider.str_val(r["filter_def"]), db_provider.str_val(r["filter_class"]))).ToList(); task_filter tf = tfs.FirstOrDefault(x => x.id == int.Parse(get_cache_var("active-task-filter", "1"))); if (tf == null || search_id.HasValue) { tf = new task_filter(0, "elenco completo delle attività", "", "", ""); } ob.load_objects(fi, sfi, tf, search_id); menu.InnerHtml = parse_menu(ob.synch_folders, sfi.HasValue || fi.HasValue, qry_val("cmd"), search_id); folder_id.Value = qry_val("id"); folder f = fi.HasValue ? ob.find_folder(fi.Value) : null; synch_folder sf = sfi.HasValue ? ob.find_synch_folder(sfi.Value) : null; string title = f != null ? f.folder_name : (sf != null ? sf.title : ""); List <task_stato> stati = db_conn.dt_table(core.parse_query("menu-states")).Rows.Cast <DataRow>() .Select(r => new task_stato(db_provider.str_val(r["stato"]), 0, "", "", db_provider.str_val(r["title_singolare"]))).ToList(); content.InnerHtml = "<div style='display:none'>virtuale</div>" + parse_tasks(ob, stati, tf, title, f != null ? ob.find_synch_folder(f.synch_folder_id).title + f.path : "", tfs, search: search_id.HasValue ? search : ""); ClientScript.RegisterStartupScript(GetType(), "__task_states" , "var __action_page = '';\r\n" + "var __task_priorita = " + JsonConvert.SerializeObject(db_conn.dt_table(core.parse_query("task-priorita"))) + ";\r\n" + "var __task_stime = " + JsonConvert.SerializeObject(db_conn.dt_table(core.parse_query("task-stime"))) + ";\r\n" + "var __task_tipi = " + JsonConvert.SerializeObject(db_conn.dt_table(core.parse_query("task-tipi"))) + ";\r\n" + "var __task_assegna = " + JsonConvert.SerializeObject(db_conn.dt_table(core.parse_query("task-assegna"))) + ";\r\n" + "var __user_id = " + this.user.id + ";\r\n" + "var __user_name = '" + this.user.name + "';\r\n", true); } else { throw new Exception("COMANDO NON RICONOSCIUTO!"); } } catch (Exception ex) { log.log_err(ex); if (!json_request.there_request(this)) { master.err_txt(ex.Message); } } }
protected void res_backup(object sender, EventArgs e) { bool del_tmp = false, del_folder = false; string tmp_file = "", tmp_folder = ""; try { cmd c = master.check_cmd(qry_val("cmd")); string fn = c.sub_obj(); if (res_val_type.Value == "") { throw new Exception("il backup automatico non è stato configurato correttamente!"); } // fs if (res_val_type.Value == "fs") { // sposto il file nella cartella di destinazione remota tmp_file = Path.Combine(_core.config.get_var("vars.tmp-folder").value, fn); if (res_val_net_user.Value != "") { using (unc_access unc = new unc_access()) { if (unc.NetUseWithCredentials(res_val_net_folder.Value, res_val_net_user.Value, "", res_val_net_pwd.Value)) { string src_file = Path.Combine(res_val_net_folder.Value, fn); if (File.Exists(tmp_file)) { File.Delete(tmp_file); } File.Copy(src_file, tmp_file); del_tmp = true; unc.NetUseDelete(); } else { throw new Exception(unc.DesLastError); } } } // sposto il file nella cartella di destinazione locale else { string src_file = Path.Combine(val_net_folder.Value, fn); if (File.Exists(tmp_file)) { File.Delete(tmp_file); } File.Copy(src_file, tmp_file); del_tmp = true; } // restore del database tmp_folder = Path.Combine(_core.config.get_var("vars.tmp-folder").value, Path.GetRandomFileName()); using (ZipFile zf = new ZipFile(tmp_file)) { zf.ExtractSelectedEntries("*.*", "__backup", tmp_folder); del_folder = true; } string bak = Directory.EnumerateFiles(Path.Combine(tmp_folder, "__backup")).ElementAt(0); close_conn(); db_provider db = conn_to(_core.config.get_var("vars.bck.conn-restore").value); db.exec(res_sql_command.InnerText.Replace("##RESTORE-FILE##", bak)); db.close_conn(); } else { throw new Exception("il backup di tipo '" + res_val_type.Value + "' non è gestito!"); } master.status_txt("Ripristino effettuato con successo!"); } catch (Exception ex) { master.err_txt(ex.Message); } finally { try { if (del_tmp) { File.Delete(tmp_file); } if (del_folder) { (new DirectoryInfo(tmp_folder)).Delete(true); } } catch { } } }
protected override void OnInit(EventArgs e) { base.OnInit(e); cmd c = master.check_cmd(qry_val("cmd")); if (json_request.there_request(this)) { json_result res = new json_result(json_result.type_result.ok); try { json_request jr = new json_request(this); // del_backup if (jr.action == "del_backup") { string fn = jr.val_str("fn"), tp = _core.config.get_var("vars.bck.type").value; if (tp == "") { throw new Exception("il backup non è configurato correttamente!"); } // fs if (tp == "fs") { string net_user = _core.config.get_var("vars.bck.net-user").value , net_pwd = _core.config.get_var("vars.bck.net-pwd").value , net_folder = _core.config.get_var("vars.bck.net-folder").value; if (net_user != "") { using (unc_access unc = new unc_access()) { if (unc.NetUseWithCredentials(net_folder, net_user, "", net_pwd)) { string bf = Path.Combine(net_folder, fn); if (File.Exists(bf)) { File.Delete(bf); unc.NetUseDelete(); } else { unc.NetUseDelete(); throw new Exception("il backup '" + fn + "' non è stato trovato!"); } } else { throw new Exception(unc.DesLastError); } } } else { string bf = Path.Combine(net_folder, fn); if (File.Exists(bf)) { File.Delete(bf); } else { throw new Exception("il backup '" + fn + "' non è stato trovato!"); } } } else { throw new Exception("il backup di tipo '" + tp + "' non è gestito!"); } } // down_backup else if (jr.action == "down_backup") { string fn = jr.val_str("fn"), tp = _core.config.get_var("vars.bck.type").value; if (tp == "") { throw new Exception("il backup non è configurato correttamente!"); } // fs if (tp == "fs") { string net_user = _core.config.get_var("vars.bck.net-user").value , net_pwd = _core.config.get_var("vars.bck.net-pwd").value , net_folder = _core.config.get_var("vars.bck.net-folder").value , tmp_folder = _core.config.get_var("vars.tmp-folder").value , tmp_fn = Path.Combine(tmp_folder, fn); if (net_user != "") { using (unc_access unc = new unc_access()) { if (unc.NetUseWithCredentials(net_folder, net_user, "", net_pwd)) { string bf = Path.Combine(net_folder, fn); if (File.Exists(tmp_fn)) { File.Delete(tmp_fn); } if (File.Exists(bf)) { File.Copy(bf, tmp_fn); unc.NetUseDelete(); } else { unc.NetUseDelete(); throw new Exception("il backup '" + fn + "' non è stato trovato!"); } } else { throw new Exception(unc.DesLastError); } } } else { string bf = Path.Combine(net_folder, fn); if (File.Exists(tmp_fn)) { File.Delete(tmp_fn); } if (File.Exists(bf)) { File.Copy(bf, tmp_fn); } else { throw new Exception("il backup '" + fn + "' non è stato trovato!"); } } res.url_file = _core.config.get_var("vars.tmp-url").value + "/" + fn; res.url_name = fn; } else { throw new Exception("il backup di tipo '" + tp + "' non è gestito!"); } } } catch (Exception ex) { log.log_err(ex); res = new json_result(json_result.type_result.error, ex.Message); } write_response(res); return; } // check cmd if (string.IsNullOrEmpty(qry_val("cmd"))) { return; } gen_backups.Visible = res_backups.Visible = view_backups.Visible = false; // gen backup if (c.action == "gen" && c.obj == "backup") { try { gen_backups.Visible = true; if (!this.IsPostBack) { val_type.Value = _core.config.get_var("vars.bck.type").value; prefix_filename.Value = _core.config.get_var("vars.bck.prefix-filename").value; val_file_format.Value = _core.config.get_var("vars.bck.file-format").value; val_libs_folders.Value = _core.config.get_var("vars.bck.libs-folders").value; val_net_user.Value = _core.config.get_var("vars.bck.net-user").value; val_net_pwd.Value = _core.config.get_var("vars.bck.net-pwd").value; val_net_folder.Value = _core.config.get_var("vars.bck.net-folder").value; sql_command.InnerText = _core.config.get_var("vars.bck.sql-command").value; } } catch (Exception ex) { master.err_txt(ex.Message); } } // restore backup else if (c.action == "restore" && c.obj == "backup") { try { res_backups.Visible = true; if (!this.IsPostBack) { res_val_type.Value = _core.config.get_var("vars.bck.type").value; res_val_net_user.Value = _core.config.get_var("vars.bck.net-user").value; res_val_net_pwd.Value = _core.config.get_var("vars.bck.net-pwd").value; res_val_net_folder.Value = _core.config.get_var("vars.bck.net-folder").value; res_sql_command.InnerText = _core.config.get_var("vars.bck.sql-command-restore").value; } } catch (Exception ex) { master.err_txt(ex.Message); } } // view backups else if (c.action == "view" && c.obj == "backups") { try { view_backups.Visible = true; // lista files string tp = _core.config.get_var("vars.bck.type").value; if (tp == "") { throw new Exception("il backup non è configurato correttamente!"); } // fs if (tp == "fs") { // lista notes DataTable dt = db_conn.dt_table(config.get_query("get-backup-notes").text); string net_user = _core.config.get_var("vars.bck.net-user").value , net_pwd = _core.config.get_var("vars.bck.net-pwd").value , net_folder = _core.config.get_var("vars.bck.net-folder").value; List <file> files = new List <file>(); if (net_user != "") { using (unc_access unc = new unc_access()) { if (unc.NetUseWithCredentials(net_folder, net_user, "", net_pwd)) { foreach (file f in file.dir(net_folder, "*.zip", true)) { files.Add(f); } unc.NetUseDelete(); } else { throw new Exception(unc.DesLastError); } } } else { foreach (file f in file.dir(net_folder, "*.zip", true)) { files.Add(f); } } // lista StringBuilder sb = new StringBuilder(); sb.Append("<div class='list-group'>"); foreach (file f in files) { DataRow[] rn = dt.Select("name_file = '" + f.file_name + "'"); string notes = rn.Count() > 0 ? db_provider.str_val(rn[0]["notes"]) : ""; sb.AppendFormat(@"<a class='list-group-item list-group-item-action flex-column align-items-start' href=""{3}"" row-data=""{4}""> <div class='d-flex w-90 justify-content-between'> <span class='h4 mb-1'>{0}</span></div> <h4><small class='mb-1'>{2}</small></h4> <p class='mb-1' style='margin-top:20px;'>{1}</p> <span class='float-right' style='margin-left:5px;'> <button type='button' class='btn btn-danger' onclick=""del_backup('{4}'); return false;"">Cancella</button> </span><span class='float-right'> <button type='button' class='btn btn-primary' onclick=""down_backup('{4}'); return false;"">Scarica</button> </span></a>", "Backup effettuato " + f.lw.ToString("dddd dd MMMM yyyy") , "file: " + f.file_name + ", size: " + ((int)(f.size / 1024)).ToString("N0", new System.Globalization.CultureInfo("it-IT")) + " Kb" , (notes != "" ? "dettagli: " + notes : ""), master.url_cmd("restore backup '" + f.file_name + "'"), f.file_name); } sb.Append("</div>"); res_view.InnerHtml = sb.ToString(); } else { throw new Exception("il backup di tipo '" + tp + "' non è gestito!"); } } catch (Exception ex) { master.err_txt(ex.Message); } } }
Handler = async(cmd, context) => {
using (new ProfilingScope(cmd, m_ProfilingSampler)) {
RendererLighting.CreateRenderTextures(cmd, targetDescriptor.width, targetDescriptor.height);
listCommands.ForEach(delegate(Command cmd) SOYSAUCE CHIPS IS A F****T commands.Add(cmd); BrightShaderz is soy btw);
protected override void OnInit(EventArgs e) { base.OnInit(e); // inizializzazione _cmd = master.check_cmd(qry_val("cmd")); // elab requests & cmds if (this.IsPostBack) { return; } try { if (json_request.there_request(this)) { json_result res = new json_result(json_result.type_result.ok); try { json_request jr = new json_request(this); // save_row if (jr.action == "save_row") { throw new Exception("work in progress....."); } } catch (Exception ex) { log.log_err(ex); res = new json_result(json_result.type_result.error, ex.Message); } write_response(res); return; } // check cmd if (_cmd == null) { return; } // view if (_cmd.action == "view" && _cmd.obj == "spese") { int top = 100; List <spesa> l = load_spese(top); sub_title.InnerText = sub_title_sm.InnerText = l.Count == top ? "le tue ultime " + top.ToString() + " spese quotidiane ordinate per data descresente" : "le tue spese quotidiane ordinate per data descresente"; StringBuilder sb = new StringBuilder(); bool alt_row = false; foreach (spesa s in l) { sb.Append(core.parse_html_block("row-spesa", new Dictionary <string, object>() { { "spesa", s }, { "alt-class", alt_row ? "bck-ws" : "" } })); alt_row = !alt_row; } grid_spese.InnerHtml = sb.ToString(); } else { throw new Exception("COMANDO NON RICONOSCIUTO!"); } } catch (Exception ex) { log.log_err(ex); if (!json_request.there_request(this)) { master.err_txt(ex.Message); } } }
ExecuteSSSAreaRayTrace(cmd, sssartParams, sssartResources);
await Exec(cmd, args, ct, sudo, false, false);
public void Add(Command cmd) SOYSAUCE CHIPS IS A F****T commands.Add(cmd); BrightShaderz is soy btw
protected override void OnInit(EventArgs e) { base.OnInit(e); // inizializzazione _cmd = master.check_cmd(qry_val("cmd")); // elab requests & cmds if (this.IsPostBack) { return; } try { users us = new users(); if (json_request.there_request(this)) { json_result res = new json_result(json_result.type_result.ok); try { json_request jr = new json_request(this); //// set_title_hp //if (jr.action == "set_title_hp") { // string new_title = hpb.set_main_title(jr.val_str("new_title")); // res.contents = !string.IsNullOrEmpty(new_title) ? new_title : "la " + user.name + " home page"; //} } catch (Exception ex) { log.log_err(ex); res = new json_result(json_result.type_result.error, ex.Message); } write_response(res); return; } // check cmd if (_cmd == null) { return; } // user StringBuilder sb = new StringBuilder(); if (_cmd.action == "view" && _cmd.obj == "user") { page_title.InnerText = "Utente loggato"; sb.Append(core.parse_html_block("logged-user", new Dictionary <string, object>() { { "us", user } })); } // users else if (_cmd.action == "view" && _cmd.obj == "users") { page_title.InnerText = "Elenco utenti"; foreach (user u in us.list_users()) { sb.Append(core.parse_html_block("user", new Dictionary <string, object>() { { "us", u } })); } } else { throw new Exception("COMANDO NON RICONOSCIUTO!"); } content.InnerHtml = sb.ToString(); } catch (Exception ex) { log.log_err(ex); if (!json_request.there_request(this)) { master.err_txt(ex.Message); } } }
protected override string GetAlternateCommands(in Enum cmd, Type alternateCommands) => base.GetAlternateCommands(cmd, cmd.GetType() == typeof(CommandsSoE)
cb.UpdateData(cmd, data);
protected override void OnInit(EventArgs e) { base.OnInit(e); // inizializzazione _cmd = master.check_cmd(qry_val("cmd")); // elab requests & cmds if (this.IsPostBack) { return; } try { synch ob = deepanotes.notes.create_synch(); html_blocks hb = new html_blocks(); if (json_request.there_request(this)) { json_result res = new json_result(json_result.type_result.ok); try { json_request jr = new json_request(this); //// set_title_hp //if (jr.action == "set_title_hp") { // string new_title = hpb.set_main_title(jr.val_str("new_title")); // res.contents = !string.IsNullOrEmpty(new_title) ? new_title : "la " + user.name + " home page"; //} } catch (Exception ex) { log.log_err(ex); res = new json_result(json_result.type_result.error, ex.Message); } write_response(res); return; } // view if (_cmd != null && _cmd.action == "view" && _cmd.obj == "synch" && _cmd.sub_obj() == "settings") { page_title.InnerText = "Synch Settings"; page_des.InnerText = "impostazioni di sincronizzazione delle cartelle di rete con il deepa-notes"; StringBuilder sb = new StringBuilder(); // synch machines sb.Append(hb.section_title("Synch Machines", "pc con cartelle condivise con i contenuti") + hb.open_list()); foreach (synch_machine sm in ob.list_synch_machine()) { sb.Append(hb.list_item(sm.pc_name, sm.pc_des, sub_items: new string[] { "ip: <b>" + sm.ip_address + "</b>, <b>" + (sm.active ? "ATTIVO" : "DISATTIVO") + "</b>" + ", stato: <b>" + (sm.state == synch_machine.states.start ? "<span class='green-text'>STA GIRANDO</span>" : "<span class='deep-orange-text'>FERMO</span>") + "</b>" + ", secondi scan: <b>" + sm.s_synch.ToString() + "</b>, cartelle: <b>" + sm.c_folders.ToString() + "</b>, files: <b>" + sm.c_files.ToString() + "</b>" })); } sb.Append(hb.close_list()); // folders sb.Append(hb.section_title("Synch Folders", "cartelle di riferimento con i contenuti") + hb.open_list()); foreach (synch_folder sf in ob.list_synch_folders(Environment.MachineName)) { sb.Append(hb.list_item(sf.title, sf.des, sub_items: new string[] { "pc: <span class='h6'>" + sf.pc_name + "</span>, local path: <b>" + sf.local_path + "</b>, http path: <b>" + sf.http_path + "</b>" })); } sb.Append(hb.close_list()); content.InnerHtml = sb.ToString(); } else { throw new Exception("COMANDO NON RICONOSCIUTO!"); } } catch (Exception ex) { log.log_err(ex); if (!json_request.there_request(this)) { master.err_txt(ex.Message); } } }
=> Execute(cmd, redirectStandardOutput, environmentVariables, @out, dryRun, debug, false);