/// <summary>
        /// Extracts the primary media-adress from toc And inserts it into the target string.
        /// </summary>
        /// <param name="fromTocString">
        /// The toc string from which the primary media-address will be extracted. 
        /// </param>
        /// <param name="toTargetStr">
        /// The string into which the primary media-adress will be inserted.
        /// </param>
        public static string UpdatePrimaryAccessLink(string itemID, string fromToc, string toTarget)
        {
            ImportOptions directories = new UserSettingsService().GetImportOptions();
            string objectName = GetObjectName(fromToc);
            string toc = fromToc.ToLower();

            if (toc.Contains("arcmusicmp3") || toc.Contains("arcaudiomp3"))
                return new Mp3Album(directories.AudioProjectDirectory + "\\" + objectName, toc.Contains("arcmusicmp3") ? "ArcMusicMP3" : "ArcAudioMP3").InsertPrimaryAccessLink(fromToc, toTarget);
            if (toc.Contains("myvideo"))
                return new M4vAlbum(directories.AudioProjectDirectory + "\\" + objectName).InsertPrimaryAccessLink(fromToc, toTarget);
            if (toc.Contains("mydocs"))
                return new PdfCollection(directories.DocumentProjectDirectory + "\\" + objectName).InsertPrimaryAccessLink(fromToc, toTarget);
            return toTarget;
        }
Beispiel #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;
        }
Beispiel #3
0
        /// <summary>
        /// Builds the actual query. 
        /// </summary>
        /// <param name="queryString">
        /// queryString == null | ""        : Rebuilds actual query from stored query state parameters or returns the default query.
        /// queryString != null             : Builds a new query from queryString and stores it in query state parameters. 
        /// </param>
        /// <param name="stateType">
        /// stateType == ListViewState      : (Re)builds actual query for ListView. 
        /// stateType == BrowseViewState    : (Re)builds actual query for BrowseView.
        /// stateType == ItemViewState      : (Re)builds actual query for SingleItemView.
        /// </param>
        /// <returns>
        /// Actual query.
        /// </returns>
        public static RQquery GetQueryFromState(string queryString, UserState.States stateType)
        {
            RQquery query = null;

            state = (ViewState)UserState.Get(stateType);
            if (state == null)
            {
                if (string.IsNullOrEmpty(queryString))
                    query = new RQquery("$recent$recent additions", "recent");
                else
                    query = new RQquery(queryString);
                state = new ViewState(stateType); //, queryString);
                state.query = query;
                //state.Save();
            }
            else
            {
                string querytest;
                UserSettingsService us = new UserSettingsService();

                query = (RQquery)state.query;
                if (! string.IsNullOrEmpty(queryString) && queryString.StartsWith("$") && queryString.LastIndexOf("$") > 1)
                    querytest = queryString.Substring(0, queryString.LastIndexOf("$")+1) + query.QueryString;
                else
                    querytest = query.QueryString;
                //if (   (! string.IsNullOrEmpty(queryString) && querytest != queryString) 
                //    || (query.QueryExternal == "" && us.GetIncludeExternal() == true) 
                //    || (query.QueryExternal != "" && us.GetIncludeExternal() == false) )
                //{
                //    query = new RQquery(! string.IsNullOrEmpty(queryString) ? queryString : query.QueryString);
                //    query.QueryExternal = us.GetIncludeExternal() == true ? "003" : "";
                //    state.query = query;
                //    //state.Save();
                //}
                if (!string.IsNullOrEmpty(queryString) && querytest != queryString)
                    query = new RQquery(! string.IsNullOrEmpty(queryString) ? queryString : query.QueryString);
                query.QueryExternal = us.GetIncludeExternal() == true ? "003" : "";
                state.query = query;
            }
            return query;
        }
        /// <summary>
        /// Checks and updates the digital object directory and writes changes to the toc and signature strings.
        /// Checks and updates concern the directory name and the names of media and access structure files (f. e. playlist files)
        /// </summary>
        /// <param name="itemId">
        /// Id of the RQItem record of the digital object.
        /// </param>
        /// <param name="tocString">
        /// The toc string (normally stored in the RQItem record of the digital object).
        /// </param>
        /// <param name="signatureStr">
        /// The signature string (normally stored in the RQItem record of the digital object).</param>
        /// <param name="itemDescriptors">
        /// A string dictionary of field names (keys) and field contents (values) of the RQItem record of the digital object.
        /// </param>
        /// <returns>
        /// True if update was successful.
        /// Updated values in tocString and signatureStr.
        /// </returns>
        public static bool UpdateDigitalObjectDirectory(string itemId, ref string tocString, ref string signatureStr, StringDictionary itemDescriptors)
        {
            bool result = false;
            string toc = tocString.ToLower();

            if (toc.Contains("$$toc$$=")) 
            {
                ImportOptions directories = new UserSettingsService().GetImportOptions();
                string objectName = GetObjectName(tocString);

                if (toc.Contains("arcmusicmp3") || toc.Contains("arcaudiomp3") )
                    return new Mp3Album(directories.AudioProjectDirectory + "\\" + objectName.Replace("XXXXX_", ""), toc.Contains("arcmusicmp3") ? "ArcMusicMP3" : "ArcAudioMP3").BindTo(itemId, ref tocString, ref signatureStr, itemDescriptors);
                if (toc.Contains("myvideo"))
                    return new M4vAlbum(directories.VideoProjectDirectory + "\\" + objectName).BindTo(itemId, ref tocString, ref signatureStr, itemDescriptors);
                if (toc.Contains("mydocs"))
                    return new PdfCollection(directories.DocumentProjectDirectory + "\\" + objectName).BindTo(itemId, ref tocString, ref signatureStr, itemDescriptors);
            }
            return result;
        }