Exemplo n.º 1
0
        /// <summary>
        /// Setzt das aktuelle Element (einer Kopie) des digitalen Objekts auf einen vorgegebenen Wert.
        /// </summary>
        /// <param name="index">
        /// Ganzzahl, die die 0-basierte Position des neuen aktuellen Elements (in der zurück gegebenen Kopie des digitalen Objekts) angibt.
        /// </param>
        /// <returns>
        /// Gibt eine Kopie des aktuellen digitalen Objekts zurück, bei der das Element an der Psoition index das aktuelle Element ist.
        /// </returns>
        public override DigitalObject SelectElement(int index)
        {
            Mp3Album newdo = (Mp3Album)this.MemberwiseClone();

            newdo.actlTrack = index;
            return(newdo);
        }
Exemplo n.º 2
0
        public static bool CheckDigitalObjectDirectory(string itemId, ref string tocString, ref string signatureStr, StringDictionary itemDescriptors )
        {
            bool result = false;

            if ((tocString.Contains("$$TOC$$=")) && (tocString.Contains("XXXXX_")))
            {
                ImportOptions directories = new UserSettingsService().GetImportOptions();
                string objectName = tocString.Substring(tocString.IndexOf("XXXXX_") + "XXXXX_".Length,tocString.IndexOf("/",tocString.IndexOf("XXXXX_")) - tocString.IndexOf("XXXXX_") -"XXXXX_".Length); 
                string objectType = tocString.Contains("ArcMusicMp3") ? "ArcMusicMp3" : "ArcAudioMp3";
                Mp3Album digObj = new Mp3Album(directories.AudioProjectDirectory + "\\" + objectName, objectType);

                digObj.Read();
                if (digObj.ElementCount > 0)
                {
                    bool[] includeElements = new bool[digObj.ElementCount];
                    string newSigStr = "JB: MyMusic=" + digObj.GenerateAccessLink(itemId) + "; ";
                    string newTocStr = tocString.Replace("XXXXX_", itemId + "_");

                    for (int i = 0; i < digObj.ElementCount; i++)
                    {
                        string theFileName = digObj.SelectElement(i + 1).DigitalObjectIdentifier(DigitalObject.DOIdentifier.filename);

                        if (includeElements[i] = newTocStr.Contains(theFileName))
                            newTocStr = newTocStr.Replace(theFileName, "TRACK" + (i+1) + ".m3u");
                    }
                    if (itemDescriptors.ContainsKey("Abstract"))
                        itemDescriptors["Abstract"] = newTocStr;
                    tocString = newTocStr;
                    signatureStr += signatureStr.Contains(newSigStr) ? "" : " " + newSigStr;
                    try
                    {
                        digObj.GenerateAccessStructure(itemId, includeElements);
                        digObj.ChangeDescriptionElements(itemDescriptors, includeElements);
                        result = true;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Directory for digital object could not be created. " + ex.Message, ex.InnerException);  
                    }
                }
            }
            return result;
        }