public String PutFicheiro(string weeId, Ficheiro file) { return PutFicheiros(weeId, new List<Ficheiro>() {file}); }
public List<Ficheiro> getFicheirosFromFolder(String path, string bundleId) { List<Ficheiro> files = new List<Ficheiro>(); foreach (String fpath in Directory.EnumerateFiles(path)) { try { if ((System.IO.File.GetAttributes(fpath) & System.IO.FileAttributes.Hidden) != System.IO.FileAttributes.Hidden) { if (getName(fpath) != "View Metadata.lnk") { Ficheiro file = new Ficheiro(fpath, bundleId, true); files.Add(file); } } } catch (Exception e){ try{ String tempPath = System.IO.Path.GetTempPath(); String filePath = tempPath + System.IO.Path.GetFileName(fpath); System.IO.File.Copy(fpath, filePath, true); files.Add(new Ficheiro(filePath, bundleId,true)); } catch (IOException e2){ return null; } } } return files; }
/** * stores the file information * ::Checked:: */ public void UpdateFicheiroInfo(Ficheiro file) { DeleteFicheiroInfo(file.md5, file.name); SaveFicheiroInfo(file); }
public void SaveFicheiroInfo(Ficheiro ficheiro) { if (ficheiro == null) return; SqlConnection con = new SqlConnection(connectionString); con.Open(); SqlCommand query = new SqlCommand(string.Format( "INSERT INTO ficheiro (id, bundleID, nome_ficheiro) Values ('{0}', '{1}', '{2}')", ficheiro.md5, ficheiro.bundleId, ficheiro.path), con); query.ExecuteNonQuery(); con.Close(); }
/** * retrieves the files associated with a bundle * ::Checked:: */ public List<Ficheiro> GetFicheirosIDS(String bundleId) { if (string.IsNullOrEmpty(bundleId)) return null; List<Ficheiro> lista = new List<Ficheiro>(); SqlConnection con = new SqlConnection(connectionString); con.Open(); SqlCommand query = new SqlCommand(string.Format("select * from ficheiro where bundleID = '{0}'", bundleId), con); SqlDataReader reader = query.ExecuteReader(); while (reader.Read()) { Ficheiro file = new Ficheiro(reader.GetString(2), reader.GetString(1), reader.GetString(0)); lista.Add(file); } reader.Close(); con.Close(); return lista; }
///<summary> /// retrieves one bundle stored in the database /// ::Checked:: ///</summary> public Bundle GetBundle(string id) { if (string.IsNullOrEmpty(id)) return null; Bundle bundle = new Bundle(); SqlConnection con = new SqlConnection(connectionString); con.Open(); SqlCommand query = new SqlCommand(string.Format("SELECT * FROM bundle WHERE id = '{0}'", id), con); SqlDataReader reader = query.ExecuteReader(); while (reader.Read()) { bundle.localId = reader.GetString(0); bundle.weeId = reader.GetString(1); } reader.Close(); query = new SqlCommand(string.Format("SELECT * FROM ficheiro where bundleID = '{0}'", id), con); reader = query.ExecuteReader(); var list = new List<Ficheiro>(); while (reader.Read()) { Ficheiro f = new Ficheiro( //path bundleID md5 reader.GetString(2), reader.GetString(1), reader.GetString(0)); list.Add(f); } bundle.filesPath = list; reader.Close(); query = new SqlCommand(string.Format("SELECT * FROM tags where bundleID = '{0}'", id), con); reader = query.ExecuteReader(); while (reader.Read()) { bundle.weeTags.Add(reader.GetString(1)); } reader.Close(); query = new SqlCommand(string.Format("SELECT * FROM metadata where bundleID = '{0}'", id), con); reader = query.ExecuteReader(); while (reader.Read()) { bundle.meta.keyValueData.Add(reader.GetString(1), reader.GetString(2)); } reader.Close(); con.Close(); return bundle; }