Exemplo n.º 1
0
 protected void upload_file(string path, int id_file, xml_node n)
 {
     try {
         lbl_message(log.log_info($"upload file {n.get_attr("http_path")}"));
         System.Text.Encoding e = encoding_type.GetType(path);
         var file = new {
             action    = "save_file", id = id_file, bin_data = e.GetString(File.ReadAllBytes(path)), enc = e.HeaderName
             , user_id = n.get_int("user_id"), user_name = n.get_val("user_name")
         };
         json_request.post(_c.base_url + _c.config.get_var("client.io-page").value, file);
         lbl_message(log.log_info($"uploaded file {n.get_attr("http_path")}!"), 2);
     } catch (Exception ex) {
         log.log_err(ex);
         lbl_message($"uploaded error {ex.Message}!", 5, true);
         n.set_attr("upload_err", $"error at {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}: {ex.Message}"); throw ex;
     }
 }
Exemplo n.º 2
0
        public xml_node parse_node(xml_node n, Dictionary <string, object> keys, DataRow dr = null)
        {
            // text
            if (!string.IsNullOrEmpty(n.text))
            {
                n.text = parse(n.text, keys, dr);
            }

            // attributes
            foreach (string a in n.get_attrs())
            {
                n.set_attr(a, parse(n.get_attr(a), keys, dr));
            }

            // childs
            foreach (xml_node nc in n.childs)
            {
                parse_node(nc, keys, dr);
            }

            return(n);
        }