GetDynamicDatasetStorePath() public static method

public static GetDynamicDatasetStorePath ( long datasetId, long datasetVersionOrderNr, string title, string extention ) : string
datasetId long
datasetVersionOrderNr long
title string
extention string
return string
Exemplo n.º 1
0
        private static void storeGeneratedFilePathToContentDiscriptor(long datasetId, DatasetVersion datasetVersion, string title, string ext)
        {
            string name     = "";
            string mimeType = "";

            if (ext.Contains("xml"))
            {
                name     = "metadata";
                mimeType = "text/xml";
            }

            DatasetManager dm        = new DatasetManager();
            int            versionNr = dm.GetDatasetVersionNr(datasetVersion);

            // create the generated FileStream and determine its location
            string dynamicPath = OutputDatasetManager.GetDynamicDatasetStorePath(datasetId, versionNr, title, ext);

            //Register the generated data FileStream as a resource of the current dataset version
            //ContentDescriptor generatedDescriptor = new ContentDescriptor()
            //{
            //    OrderNo = 1,
            //    Name = name,
            //    MimeType = mimeType,
            //    URI = dynamicPath,
            //    DatasetVersion = datasetVersion,
            //};

            try
            {
                datasetVersion = dm.GetDatasetVersion(datasetVersion.Id);

                if (datasetVersion.ContentDescriptors.Count(p => p.Name.Equals(name)) > 0)
                {   // remove the one contentdesciptor
                    foreach (ContentDescriptor cd in datasetVersion.ContentDescriptors)
                    {
                        if (cd.Name == name)
                        {
                            cd.URI = dynamicPath;
                            dm.UpdateContentDescriptor(cd);
                        }
                    }
                }
                else
                {
                    // add current contentdesciptor to list
                    //datasetVersion.ContentDescriptors.Add(generatedDescriptor);
                    dm.CreateContentDescriptor(name, mimeType, dynamicPath, 1, datasetVersion);
                }

                //dm.EditDatasetVersion(datasetVersion, null, null, null);
            }
            finally
            {
                dm.Dispose();
            }
        }
Exemplo n.º 2
0
        public static string CreateConvertedMetadata(long datasetId, TransmissionType type)
        {
            XmlDocument              newXml;
            DatasetManager           datasetManager = new DatasetManager();
            MetadataStructureManager metadataMetadataStructureManager = new MetadataStructureManager();

            try
            {
                DatasetVersion    datasetVersion    = datasetManager.GetDatasetLatestVersion(datasetId);
                MetadataStructure metadataStructure = metadataMetadataStructureManager.Repo.Get(datasetVersion.Dataset.MetadataStructure.Id);
                XmlDatasetHelper  xmlDatasetHelper  = new XmlDatasetHelper();

                int    versionNr   = datasetManager.GetDatasetVersionNr(datasetVersion);
                string mappingName = metadataStructure.Name;

                string mappingFileName = xmlDatasetHelper.GetTransmissionInformation(datasetVersion.Id, type, mappingName);
                //if mapping file not exist
                if (string.IsNullOrEmpty(mappingFileName))
                {
                    return("");
                }
                string pathMappingFile = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DIM"), mappingFileName);

                XmlMapperManager xmlMapperManager = new XmlMapperManager(TransactionDirection.InternToExtern);
                xmlMapperManager.Load(pathMappingFile, "exporttest");

                newXml = xmlMapperManager.Export(datasetVersion.Metadata, datasetVersion.Id, mappingName, true);

                string title = datasetVersion.Title;

                // store in content descriptor
                string filename = "metadata";
                if (String.IsNullOrEmpty(mappingName) || mappingName.ToLower() == "generic")
                {
                    storeGeneratedFilePathToContentDiscriptor(datasetId, datasetVersion, filename, ".xml");
                }
                else
                {
                    filename = "metadata_" + mappingName;
                    storeGeneratedFilePathToContentDiscriptor(datasetId, datasetVersion, filename,
                                                              ".xml");
                }

                return(OutputDatasetManager.GetDynamicDatasetStorePath(datasetId, versionNr, filename, ".xml"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                datasetManager.Dispose();
                metadataMetadataStructureManager.Dispose();
            }
        }