コード例 #1
0
 public xml_node add_file(fi i, DateTime lwt, int user_id, string user_name)
 {
     return(root_node.add_node("file", new Dictionary <string, string>()
     {
         { "id", i.id_file.ToString() }
         , { "user_id", user_id.ToString() }, { "user_name", user_name }
         , { "name", i.file_name }, { "name_local", i.file_name_local }, { "http_path", i.http_path }
         , { "lwt", lwt.ToString("yyyy-MM-dd HH:mm:ss") }
     }));
 }
コード例 #2
0
        public void open_att(int file_id, int user_id, string user_name)
        {
            Task.Factory.StartNew(() => {
                // download file...
                string fp = "";
                try {
                    string folder = Program._c.config.get_var("client.client-tmp-path").value;
                    if (!Directory.Exists(folder))
                    {
                        Directory.CreateDirectory(folder);
                    }
                    fi i = fi.load_fi(file_id);
                    lbl_message(log.log_info($"download file {i.http_path}"));
                    fp = Path.Combine(folder, i.file_name_local);
                    using (WebClient webClient = new WebClient()) {
                        webClient.DownloadFile(i.http_path, fp);
                    }
                    xml_att idoc = xml_att.open(); idoc.set_file(i, DateTime.Now, user_id, user_name); idoc.save();
                    lbl_message(log.log_info($"downloaded file {i.http_path}"));
                } catch (Exception ex) {
                    log.log_err(ex);
                    lbl_message($"download file error: {ex.Message}");
                }

                // apri il file
                try {
                    lbl_message(log.log_info($"open file {fp}"));
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("explorer", "\"" + fp + "\"")
                    {
                        RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true
                    });
                    lbl_message();
                } catch (Exception ex) {
                    log.log_err(ex);
                    lbl_message($"open file error: {ex.Message}");
                }
            });
        }
コード例 #3
0
 public xml_node set_file(fi i, DateTime lwt, int user_id, string user_name)
 {
     del_file(i.id_file); return(add_file(i, lwt, user_id, user_name));
 }