GetZipFileName() 공개 메소드

public GetZipFileName ( long datasetid, long datasetVersionid ) : string
datasetid long
datasetVersionid long
리턴 string
예제 #1
0
        public ActionResult Test()
        {
            UiTestModel model = new UiTestModel();

            model = DynamicListToDataTable();

            SubmissionManager pm = new SubmissionManager();
            DatasetManager dm = new DatasetManager();

            pm.Load();

            DataRepository gfbio = pm.DataRepositories.Where(d => d.Name.ToLower().Equals("gfbio")).FirstOrDefault();

            // get metadata
            long testdatasetId = 1;
            string formatname = "";
            XmlDocument newXmlDoc;
            DatasetVersion dsv = dm.GetDatasetLatestVersion(testdatasetId);
            string title = XmlDatasetHelper.GetInformation(dsv, NameAttributeValues.title);


            if (gfbio != null)
            {
                formatname =
                    XmlDatasetHelper.GetAllTransmissionInformation(1, TransmissionType.mappingFileExport, AttributeNames.name)
                        .First();
                OutputMetadataManager.GetConvertedMetadata(testdatasetId, TransmissionType.mappingFileExport,
                    formatname);


                // get primary data
                // check the data sturcture type ...
                if (dsv.Dataset.DataStructure.Self is StructuredDataStructure)
                {
                    OutputDataManager odm = new OutputDataManager();
                    // apply selection and projection
                    
                    odm.GenerateAsciiFile(testdatasetId, title, gfbio.PrimaryDataFormat);
                }

                string zipName = pm.GetZipFileName(testdatasetId, dsv.Id);
                string zipPath = pm.GetDirectoryPath(testdatasetId, gfbio);
                string zipFilePath = Path.Combine(zipPath, zipName);

                FileHelper.CreateDicrectoriesIfNotExist(Path.GetDirectoryName(zipFilePath));

                

                if (FileHelper.FileExist(zipFilePath))
                {
                    if (FileHelper.WaitForFile(zipFilePath))
                    {
                        FileHelper.Delete(zipFilePath);
                    }
                }

                ZipFile zip = new ZipFile();

                foreach (ContentDescriptor cd in dsv.ContentDescriptors)
                {
                    string path = Path.Combine(AppConfiguration.DataPath, cd.URI);
                    string name = cd.URI.Split('\\').Last();

                    if (FileHelper.FileExist(path))
                    {
                        zip.AddFile(path, "");
                    }
                }
                zip.Save(zipFilePath);
            }
            else
            {
                newXmlDoc = dsv.Metadata;
            }


            

            return View("Index", model);
        }