コード例 #1
0
        public ProjectFileDTO GetFileByDate(DateTime date, string id)
        {
            List <string> list   = new List <string>();
            var           folder = ProjectRepository.GetFilesByDate(date, id);

            try
            {
                string path = hostingEnvironment.ContentRootPath + "\\" + "Projects" + "\\" + folder.DefaultFolder;
                using (ZipArchive archive = ZipFile.OpenRead(path + "\\" + folder.VersionFolder + "\\" + folder.FileName))
                {
                    foreach (var collection in archive.Entries)
                    {
                        list.Add(collection.FullName);
                    }
                }
                ProjectFileDTO fileDto = new ProjectFileDTO
                {
                    Version  = folder.VersionFolder,
                    listFile = list
                };
                return(fileDto);
            }
            catch (Exception e)
            {
                ProjectFileDTO fileDto = new ProjectFileDTO
                {
                    Version  = "",
                    listFile = new List <string>()
                };
                return(fileDto);
            }
        }
コード例 #2
0
        public ProjectFileDTO GetFileById(string id)
        {
            List <string> files = new List <string>();

            var item = ProjectRepository.GetFilesById(id);

            try
            {
                using (ZipArchive archive = ZipFile.OpenRead(hostingEnvironment.ContentRootPath
                                                             + "\\" + "Projects"
                                                             + "\\" + item.DefaultFolder
                                                             + "\\" + item.VersionFolder
                                                             + "\\" + item.FileName))
                {
                    foreach (var collection in archive.Entries)
                    {
                        files.Add(collection.FullName);
                    }
                }
                ProjectFileDTO fileDto = new ProjectFileDTO
                {
                    listFile = files,
                    Version  = item.VersionFolder
                };
                return(fileDto);
            }
            catch (Exception e)
            {
                ProjectFileDTO fileDto = new ProjectFileDTO
                {
                    listFile = new List <string>(),
                    Version  = ""
                };
                return(fileDto);
            }
        }