Exemplo n.º 1
0
 public static void DeleteFile(string projectName, string featureSource, long featureId, long fileId)
 {
     string FilesRepositoryupload =  ConfigurationManager.AppSettings["FilesRepositoryupload"];
     string fileName = HtzFile.DeleteFile(projectName, fileId);
     if (!string.IsNullOrEmpty(fileName))
     {
         DBUploadFiles db = new DBUploadFiles(projectName);
         string filePath = FilesRepositoryupload +string.Format(@"{0}\{1}\{2}\{3}", new object[] { projectName, db.GetFeatureSourceId(featureSource, false), featureId, fileName });
         string folderPath = Path.GetDirectoryName(filePath);
         File.Delete(filePath);
         if (Directory.GetFiles(folderPath).Length == 0)
         {
             Directory.Delete(folderPath);
         }
     }
 }
Exemplo n.º 2
0
        // Methods
        public static HtzFile AddFile(string projectName, string mapName, string featureSource, long uid, string fileName, string description)
        {
            DBUploadFiles _db = new DBUploadFiles(projectName);
            if (!_db.IsExists(fileName, featureSource, uid))
            {
            HtzFile f = new HtzFile {
                UID = uid,
                Description = description,
                FeatureSource = featureSource,
                FeatureSourceId = (int) _db.GetFeatureSourceId(featureSource, false),
                FileName = fileName,
                MapName = mapName,
                UploadDate = DateTime.Now.ToString("dd/MM/yyyy"),
                ProjectName = projectName
            };

            if (_db.AddFile(fileName, description, mapName, featureSource, uid))
            {
                f.ID = _db.GetLastInsertedId();
                f.FeatureSourceId = (int) _db.GetFeatureSourceId(featureSource, false);
                return f;
            }
            }
            return null;
        }
Exemplo n.º 3
0
 public static bool UpdateFile(string projectName, long id, string description)
 {
     DBUploadFiles _db = new DBUploadFiles(projectName);
     return _db.UpdateFile(id, description);
 }
Exemplo n.º 4
0
 public static HtzFile[] GetFiles(string projectName, string featureSource, long uid)
 {
     List<HtzFile> result = new List<HtzFile>();
     DBUploadFiles _db = new DBUploadFiles(projectName);
     IDataReader reader = _db.GetFiles(featureSource, uid);
     while (reader.Read())
     {
         HtzFile file = new HtzFile
         {
             UID = uid,
             FeatureSource = featureSource,
             FeatureSourceId = (int)_db.GetFeatureSourceId(featureSource, false),
             ID = (long)reader["Id"],
             MapName = reader["MapName"].ToString(),
             FileName = reader["FileName"].ToString(),
             Description = reader["Description"].ToString()
         };
         file.UploadDate = ((DateTime)reader["UploadDate"]).ToString("dd/MM/yyyy");
         file.ProjectName = projectName;
         result.Add(file);
     }
     return result.ToArray();
 }
Exemplo n.º 5
0
 public static string DeleteFile(string projectName, long id)
 {
     DBUploadFiles _db = new DBUploadFiles(projectName);
     return _db.DeleteFile(id);
 }