当前位置: 首页>>代码示例>>C#>>正文


C# SobekCM_Item.Save_METS方法代码示例

本文整理汇总了C#中SobekCM.Resource_Object.SobekCM_Item.Save_METS方法的典型用法代码示例。如果您正苦于以下问题:C# SobekCM_Item.Save_METS方法的具体用法?C# SobekCM_Item.Save_METS怎么用?C# SobekCM_Item.Save_METS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SobekCM.Resource_Object.SobekCM_Item的用法示例。


在下文中一共展示了SobekCM_Item.Save_METS方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoWork

        /// <summary> Check for folders that are not named in BibID or BibiD/VID format and do not have metadata.  For 
        /// these items, creates a BibID/VID folder with minimal metadata from the folder name.  </summary>
        /// <param name="BuilderFolder"> Builder folder upon which to perform all work </param>
        /// <param name="IncomingPackages"> List of valid incoming packages, which may be modified by this process </param>
        /// <param name="Deletes"> List of valid deletes, which may be modifyed by this process </param>
        public override void DoWork(Actionable_Builder_Source_Folder BuilderFolder, List<Incoming_Digital_Resource> IncomingPackages, List<Incoming_Digital_Resource> Deletes)
        {
            string[] subdirs = Directory.GetDirectories(BuilderFolder.Inbound_Folder);
            foreach ( string thisSubDir in subdirs)
            {
                try
                {
                    string thisSubDirName = (new DirectoryInfo(thisSubDir)).Name;

                    // Must have some files to continue
                    if (Directory.GetFiles(thisSubDir).Length == 0)
                        continue;

                    // Need to check if this MAY be a valid BibID.
                    // Need to make this a bit more specific in the future, as it will skip ANY folders
                    // that are ten digits long right now.
                    if ((thisSubDir.Length == 10) || ((thisSubDir.Length == 16) && (thisSubDirName[0] == '_')))
                        continue;

                    // Look for a METS file or any source of metadata in the folder
                    if ((Directory.GetFiles(thisSubDir, "*.mets").Length > 0) || (Directory.GetFiles(thisSubDir, "*.xml").Length > 0))
                        continue;

                    // Clean any additional periods in the filenames first
                    string[] allFiles = Directory.GetFiles(thisSubDir);
                    foreach (string thisFile in allFiles)
                    {
                        string fileName = Path.GetFileName(thisFile);
                        if (Regex.Matches(fileName, "\\.").Count > 1)
                        {
                            string newFileName = fileName;
                            while (Regex.Matches(newFileName, "\\.").Count > 1)
                            {
                                char[] charArr = newFileName.ToCharArray();
                                charArr[newFileName.IndexOf(".")] = '_'; // freely modify the array
                                newFileName = new string(charArr);
                            }

                            File.Move(thisFile, Path.Combine(thisSubDir, newFileName));
                        }
                    }

                    // Create the new object
                    SobekCM_Item newItem = new SobekCM_Item();
                    newItem.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Archival;
                    newItem.Bib_Info.Main_Title.Title = thisSubDirName;
                    newItem.Bib_Info.Add_Identifier(thisSubDirName);
                    newItem.Bib_Info.Source.Code = Arguments[1];
                    newItem.Bib_Info.Source.Statement = Arguments[2];
                    newItem.BibID = Arguments[0];
                    newItem.VID = "00001";

                    // Save this item, for the necessary bibid
                    SobekCM_Item_Database.Save_New_Digital_Resource(newItem, false, false, "Builder", "Created BibID folder from '" + thisSubDirName + "'", -1);

                    string newFolderName = newItem.BibID + "_" + newItem.VID;
                    string newFolder = Path.Combine(BuilderFolder.Inbound_Folder, newFolderName);
                    Directory.Move(thisSubDir, newFolder);

                    newItem.Source_Directory = newFolder;
                    newItem.Save_METS();
                }
                catch (Exception ee)
                {
                    Console.WriteLine("Error moving directory " + ee.Message);
                }
            }
        }
开发者ID:MarkVSullivan,项目名称:SobekCM-Web-Application,代码行数:73,代码来源:UpdateNonBibFolders.cs

示例2: save_to_mets

        protected bool save_to_mets(SobekCM_Item bibPackage, bool preview_mode)
        {
            bibPackage.METS_Header.RecordStatus_Enum = METS_Record_Status.METADATA_UPDATE;

            // Saves the data members in the SobekCM.Bib_Package to a METS file
            try
            {
                // check if the mets file is needed
                if (bibPackage.VID.Length > 0)
                {
                    // Set the directory where the METS file will be saved
                    if (!preview_mode)
                    {
                        string inbound_folder = Library.SobekCM_Library_Settings.Main_Builder_Input_Folder + "\\" + bibPackage.BibID + "_" + bibPackage.VID;
                        bibPackage.Source_Directory = inbound_folder;
                        if (!Directory.Exists(inbound_folder))
                        {
                            Directory.CreateDirectory(inbound_folder);
                        }

                        // create the METS file
                        bibPackage.Save_METS();
                    }
                    else
                    {
                        bibPackage.Source_Directory = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\SMaRT\\Temporary";

                        // create the METS file
                        bibPackage.Save_METS();

                        if (File.Exists(bibPackage.Source_Directory + "\\" + bibPackage.BibID + "_" + bibPackage.VID + ".mets"))
                        {
                            if (File.Exists(bibPackage.Source_Directory + "\\" + bibPackage.BibID + "_" + bibPackage.VID + "_PREVIEW.mets"))
                                File.Delete(bibPackage.Source_Directory + "\\" + bibPackage.BibID + "_" + bibPackage.VID + "_PREVIEW.mets");
                            File.Move(bibPackage.Source_Directory + "\\" + bibPackage.BibID + "_" + bibPackage.VID + ".mets", bibPackage.Source_Directory + "\\" + bibPackage.BibID + "_" + bibPackage.VID + "_PREVIEW.mets");
                        }
                    }

                }

                return true;
            }
            catch (Exception e)
            {
                DLC.Tools.Forms.ErrorMessageBox.Show("Error encountered while creating METS file!\n\n" + e.Message, "DLC Importer Error", e);
                return false;
            }
        }
开发者ID:randomyed,项目名称:SobekCM-Web-Application,代码行数:48,代码来源:baseImporter_Processor.cs


注:本文中的SobekCM.Resource_Object.SobekCM_Item.Save_METS方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。