/// <summary> Add a quality control profile with user settings, such as which 
        /// division types to include for selection </summary>
        /// <param name="New_Profile"> New profile to add </param>
        public static void Add_Profile(QualityControl_Profile New_Profile)
        {
            // Add to the dictionary of profiles
            profiles[New_Profile.Profile_Name] = New_Profile;

            // Was this the default profile?
            if (New_Profile.Default_Profile)
                defaultProfile = New_Profile;
        }
        /// <summary> Add a quality control profile with user settings, such as which
        /// division types to include for selection </summary>
        /// <param name="New_Profile"> New profile to add </param>
        public static void Add_Profile(QualityControl_Profile New_Profile)
        {
            // Add to the dictionary of profiles
            profiles[New_Profile.Profile_Name] = New_Profile;

            // Was this the default profile?
            if (New_Profile.Default_Profile)
            {
                defaultProfile = New_Profile;
            }
        }
        /// <summary> Static constructor for the QualityControl_Configuration class </summary>
        static QualityControl_Configuration()
        {
            // Declare all the new collections in this configuration
            profiles = new Dictionary<string, QualityControl_Profile>();

            // Set some default values
            attemptedRead = false;
            defaultProfile = null;

            // Set default reader/writer values to have a baseline in case there is
            // no file to be read
            Set_Default_Values();
        }
        /// <summary> Static constructor for the QualityControl_Configuration class </summary>
        static QualityControl_Configuration()
        {
            // Declare all the new collections in this configuration
            profiles = new Dictionary <string, QualityControl_Profile>();

            // Set some default values
            attemptedRead  = false;
            defaultProfile = null;

            // Set default reader/writer values to have a baseline in case there is
            // no file to be read
            Set_Default_Values();
        }
        /// <summary> Static constructor for the QualityControl_Configuration class </summary>
        static QualityControl_Configuration()
        {
            // Declare all the new collections in this configuration
            profiles = new Dictionary<string, QualityControl_Profile>();

            // Set some default values
            attemptedRead = false;
            defaultProfile = null;

            string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
            sobekcm_qc_configfilePath=(baseDirectory + "config\\default\\sobekcm_qc.config");

            if (!Read_Metadata_Configuration(sobekcm_qc_configfilePath))
                // Set default reader/writer values to have a baseline in case there is
                // no file to be read
                Set_Default_Values();
        }
示例#6
0
        /// <summary> Static constructor for the QualityControl_Configuration class </summary>
        static QualityControl_Configuration()
        {
            // Declare all the new collections in this configuration
            profiles = new Dictionary <string, QualityControl_Profile>();

            // Set some default values
            attemptedRead  = false;
            defaultProfile = null;

            string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;

            sobekcm_qc_configfilePath = (baseDirectory + "config\\default\\sobekcm_qc.config");

            if (!Read_Metadata_Configuration(sobekcm_qc_configfilePath))
            {
                // Set default reader/writer values to have a baseline in case there is
                // no file to be read
                Set_Default_Values();
            }
        }
        private static void read_qc_profiles(XmlReader readerXml)
        {
            bool inPackage = false;
            bool inDivision = false;
            bool inFile = false;
            bool inDmdSec = true;
            QualityControl_Profile profile = null;
            int unnamed_profile_counter = 1;

            while (readerXml.Read())
            {
                if (readerXml.NodeType == XmlNodeType.Element)
                {
                    switch (readerXml.Name.ToLower())
                    {
                        case "profile":
                            profile = new QualityControl_Profile();
                            XmlReader child_readerXml = readerXml.ReadSubtree();
                            if (readerXml.MoveToAttribute("name"))
                                profile.Profile_Name = readerXml.Value.Trim();
                            if (readerXml.MoveToAttribute("description"))
                                profile.Profile_Description = readerXml.Value;
                            if (readerXml.MoveToAttribute("isDefault"))
                            {
                                bool tempValue;
                                if (bool.TryParse(readerXml.Value, out tempValue))
                                {
                                    profile.Default_Profile = tempValue;
                                }
                            }
                            // Enforce a name for this profile (should have one according to XSD)
                            if (profile.Profile_Name.Length == 0)
                            {
                                profile.Profile_Name = "Unnamed" + unnamed_profile_counter;
                                unnamed_profile_counter++;
                            }

                            while (child_readerXml.Read())
                            {
                                if (child_readerXml.NodeType == XmlNodeType.Element && child_readerXml.Name.ToLower() == "divisiontype")

                                    //  while (readerXml.ReadToNextSibling("DivisionType"))
                                {
                                    if (child_readerXml.Name.ToLower() == "divisiontype")
                                    {
                                        QualityControl_Division_Config thisConfig = new QualityControl_Division_Config();
                                        if (child_readerXml.MoveToAttribute("type"))
                                        {
                                            thisConfig.TypeName = child_readerXml.Value;
                                        }
                                        if (child_readerXml.MoveToAttribute("isNameable"))
                                            thisConfig.isNameable = Convert.ToBoolean(child_readerXml.Value);
                                        profile.Add_Division_Type(thisConfig);

                                    }
                                }
                            }
                            Add_Profile(profile);
                   //         Add_METS_Writing_Profile(profile);
                            break;

                        case "package_scope":
                            inPackage = true;
                            inDivision = false;
                            inFile = false;
                            break;

                        case "division_scope":
                            inPackage = false;
                            inDivision = true;
                            inFile = false;
                            break;

                        case "file_scope":
                            inPackage = false;
                            inDivision = false;
                            inFile = true;
                            break;

                        case "dmdsec":
                            inDmdSec = true;
                            break;

                        case "amdsec":
                            inDmdSec = false;
                            break;

                        //case "readerwriterref":
                        //    if (readerXml.MoveToAttribute("ID"))
                        //    {
                        //        string id = readerXml.Value.ToUpper();
                        //        if ((readerWriters.ContainsKey(id)) && (profile != null))
                        //        {
                        //            METS_Section_ReaderWriter_Config readerWriter = readerWriters[id];
                        //            if (inPackage)
                        //            {
                        //                if (inDmdSec)
                        //                    profile.Add_Package_Level_DmdSec_Writer_Config(readerWriter);
                        //                else
                        //                    profile.Add_Package_Level_AmdSec_Writer_Config(readerWriter);
                        //            }
                        //            else if (inDivision)
                        //            {
                        //                if (inDmdSec)
                        //                    profile.Add_Division_Level_DmdSec_Writer_Config(readerWriter);
                        //                else
                        //                    profile.Add_Division_Level_AmdSec_Writer_Config(readerWriter);
                        //            }
                        //            else if (inFile)
                        //            {
                        //                if (inDmdSec)
                        //                    profile.Add_File_Level_DmdSec_Writer_Config(readerWriter);
                        //                else
                        //                    profile.Add_File_Level_AmdSec_Writer_Config(readerWriter);
                        //            }
                        //        }
                        //    }
                        //    break;
                    }
                }
            }
        }
 private static void Clear()
 {
     profiles.Clear();
     defaultProfile = null;
 }
        // Set the default profile with the default values
        public static void Set_Default_Values()
        {
            // Clear everything, just in case
            Clear();

            // Create the default profile
            QualityControl_Profile newProfile = new QualityControl_Profile();
            newProfile.Default_Profile = true;
            newProfile.Profile_Name = "System Default";
            newProfile.Profile_Description = "Default profile used when no config file is present";
            Add_Profile(newProfile);

            // Add back cover
            QualityControl_Division_Config div1 = new QualityControl_Division_Config();
            div1.ID = 1;
            div1.TypeName = "Back Cover";
            div1.isActive = true;
            div1.isNameable = false;
            div1.BaseTypeName = "Cover";
            div1.Add_Translation(Web_Language_Enum.Spanish, "Portada Posterior");
            div1.Add_Translation(Web_Language_Enum.French, "Couverture Arrière");
            newProfile.Add_Division_Type(div1);

            // Add back matter
            QualityControl_Division_Config div2 = new QualityControl_Division_Config();
            div2.ID = 2;
            div2.TypeName = "Back Matter";
            div2.isActive = true;
            div2.isNameable = false;
            div2.Add_Translation(Web_Language_Enum.Spanish, "Materia Posterior");
            div2.Add_Translation(Web_Language_Enum.French, "Matière Arrière");
            newProfile.Add_Division_Type(div2);

            // Add chapter ( misorder of the object names here and below matters not)
            QualityControl_Division_Config div4 = new QualityControl_Division_Config();
            div4.ID = 3;
            div4.TypeName = "Chapter";
            div4.isActive = true;
            div4.isNameable = true;
            div4.Add_Translation(Web_Language_Enum.Spanish, "Capítulo");
            div4.Add_Translation(Web_Language_Enum.French, "Chapitre");
            newProfile.Add_Division_Type(div4);

            // Add front cover
            QualityControl_Division_Config div3 = new QualityControl_Division_Config();
            div3.ID = 4;
            div3.TypeName = "Front Cover";
            div3.isActive = true;
            div3.isNameable = false;
            div3.BaseTypeName = "Cover";
            div3.Add_Translation(Web_Language_Enum.Spanish, "Portada Delantera");
            div3.Add_Translation(Web_Language_Enum.French, "Couverture Frente");
            newProfile.Add_Division_Type(div3);

            // Add front matter
            QualityControl_Division_Config div5 = new QualityControl_Division_Config();
            div5.ID = 5;
            div5.TypeName = "Front Matter";
            div5.isActive = true;
            div5.isNameable = false;
            div5.Add_Translation(Web_Language_Enum.Spanish, "Materia Delantera");
            div5.Add_Translation(Web_Language_Enum.French, "Préliminaires");
            newProfile.Add_Division_Type(div5);

            // Add index
            QualityControl_Division_Config div6 = new QualityControl_Division_Config();
            div6.ID = 6;
            div6.TypeName = "Index";
            div6.isActive = true;
            div6.isNameable = true;
            div6.Add_Translation(Web_Language_Enum.Spanish, "Indice");
            div6.Add_Translation(Web_Language_Enum.French, "Indice");
            newProfile.Add_Division_Type(div6);

            // Add introduction
            QualityControl_Division_Config div7 = new QualityControl_Division_Config();
            div7.ID = 7;
            div7.TypeName = "Introduction";
            div7.isActive = true;
            div7.isNameable = false;
            div7.BaseTypeName = "Chapter";
            div7.Add_Translation(Web_Language_Enum.Spanish, "Introducción");
            div7.Add_Translation(Web_Language_Enum.French, "Introduction");
            newProfile.Add_Division_Type(div7);

            // Add spine
            QualityControl_Division_Config div8 = new QualityControl_Division_Config();
            div8.ID = 8;
            div8.TypeName = "Spine";
            div8.isActive = true;
            div8.isNameable = false;
            div8.Add_Translation(Web_Language_Enum.Spanish, "Canto");
            div8.Add_Translation(Web_Language_Enum.French, "Épine de livre");
            newProfile.Add_Division_Type(div8);

            // Add table of contents
            QualityControl_Division_Config div9 = new QualityControl_Division_Config();
            div9.ID = 9;
            div9.TypeName = "Table of Contents";
            div9.isActive = true;
            div9.isNameable = false;
            div9.BaseTypeName = "Contents";
            div9.Add_Translation(Web_Language_Enum.Spanish, "Contenidos");
            div9.Add_Translation(Web_Language_Enum.French, "Table des Matières");
            newProfile.Add_Division_Type(div9);

            // Add title page
            QualityControl_Division_Config div10 = new QualityControl_Division_Config();
            div10.ID = 10;
            div10.TypeName = "Title Page";
            div10.isActive = true;
            div10.isNameable = false;
            div10.BaseTypeName = "Title";
            div10.Add_Translation(Web_Language_Enum.Spanish, "Titre");
            div10.Add_Translation(Web_Language_Enum.French, "Titulario");
            newProfile.Add_Division_Type(div10);
        }
        // Set the default profile with the default values
        public static void Set_Default_Values()
        {
            // Clear everything, just in case
            Clear();

            // Create the default profile
            QualityControl_Profile newProfile = new QualityControl_Profile();

            newProfile.Default_Profile     = true;
            newProfile.Profile_Name        = "System Default";
            newProfile.Profile_Description = "Default profile used when no config file is present";
            Add_Profile(newProfile);

            // Add back cover
            QualityControl_Division_Config div1 = new QualityControl_Division_Config();

            div1.ID           = 1;
            div1.TypeName     = "Back Cover";
            div1.isActive     = true;
            div1.isNameable   = false;
            div1.BaseTypeName = "Cover";
            div1.Add_Translation(Web_Language_Enum.Spanish, "Portada Posterior");
            div1.Add_Translation(Web_Language_Enum.French, "Couverture Arrière");
            newProfile.Add_Division_Type(div1);

            // Add back matter
            QualityControl_Division_Config div2 = new QualityControl_Division_Config();

            div2.ID         = 2;
            div2.TypeName   = "Back Matter";
            div2.isActive   = true;
            div2.isNameable = false;
            div2.Add_Translation(Web_Language_Enum.Spanish, "Materia Posterior");
            div2.Add_Translation(Web_Language_Enum.French, "Matière Arrière");
            newProfile.Add_Division_Type(div2);

            // Add chapter ( misorder of the object names here and below matters not)
            QualityControl_Division_Config div4 = new QualityControl_Division_Config();

            div4.ID         = 3;
            div4.TypeName   = "Chapter";
            div4.isActive   = true;
            div4.isNameable = true;
            div4.Add_Translation(Web_Language_Enum.Spanish, "Capítulo");
            div4.Add_Translation(Web_Language_Enum.French, "Chapitre");
            newProfile.Add_Division_Type(div4);

            // Add front cover
            QualityControl_Division_Config div3 = new QualityControl_Division_Config();

            div3.ID           = 4;
            div3.TypeName     = "Front Cover";
            div3.isActive     = true;
            div3.isNameable   = false;
            div3.BaseTypeName = "Cover";
            div3.Add_Translation(Web_Language_Enum.Spanish, "Portada Delantera");
            div3.Add_Translation(Web_Language_Enum.French, "Couverture Frente");
            newProfile.Add_Division_Type(div3);

            // Add front matter
            QualityControl_Division_Config div5 = new QualityControl_Division_Config();

            div5.ID         = 5;
            div5.TypeName   = "Front Matter";
            div5.isActive   = true;
            div5.isNameable = false;
            div5.Add_Translation(Web_Language_Enum.Spanish, "Materia Delantera");
            div5.Add_Translation(Web_Language_Enum.French, "Préliminaires");
            newProfile.Add_Division_Type(div5);

            // Add index
            QualityControl_Division_Config div6 = new QualityControl_Division_Config();

            div6.ID         = 6;
            div6.TypeName   = "Index";
            div6.isActive   = true;
            div6.isNameable = true;
            div6.Add_Translation(Web_Language_Enum.Spanish, "Indice");
            div6.Add_Translation(Web_Language_Enum.French, "Indice");
            newProfile.Add_Division_Type(div6);

            // Add introduction
            QualityControl_Division_Config div7 = new QualityControl_Division_Config();

            div7.ID           = 7;
            div7.TypeName     = "Introduction";
            div7.isActive     = true;
            div7.isNameable   = false;
            div7.BaseTypeName = "Chapter";
            div7.Add_Translation(Web_Language_Enum.Spanish, "Introducción");
            div7.Add_Translation(Web_Language_Enum.French, "Introduction");
            newProfile.Add_Division_Type(div7);

            // Add spine
            QualityControl_Division_Config div8 = new QualityControl_Division_Config();

            div8.ID         = 8;
            div8.TypeName   = "Spine";
            div8.isActive   = true;
            div8.isNameable = false;
            div8.Add_Translation(Web_Language_Enum.Spanish, "Canto");
            div8.Add_Translation(Web_Language_Enum.French, "Épine de livre");
            newProfile.Add_Division_Type(div8);

            // Add table of contents
            QualityControl_Division_Config div9 = new QualityControl_Division_Config();

            div9.ID           = 9;
            div9.TypeName     = "Table of Contents";
            div9.isActive     = true;
            div9.isNameable   = false;
            div9.BaseTypeName = "Contents";
            div9.Add_Translation(Web_Language_Enum.Spanish, "Contenidos");
            div9.Add_Translation(Web_Language_Enum.French, "Table des Matières");
            newProfile.Add_Division_Type(div9);

            // Add title page
            QualityControl_Division_Config div10 = new QualityControl_Division_Config();

            div10.ID           = 10;
            div10.TypeName     = "Title Page";
            div10.isActive     = true;
            div10.isNameable   = false;
            div10.BaseTypeName = "Title";
            div10.Add_Translation(Web_Language_Enum.Spanish, "Titre");
            div10.Add_Translation(Web_Language_Enum.French, "Titulario");
            newProfile.Add_Division_Type(div10);
        }
 private static void Clear()
 {
     profiles.Clear();
     defaultProfile = null;
 }
        /// <summary> Constructor for a new instance of the QC_ItemViewer class </summary>
        /// <param name="Current_Object"> Digital resource to display </param>
        /// <param name="Current_User"> Current user for this session </param>
        /// <param name="Current_Mode"> Navigation object which encapsulates the user's current request </param>
        public QC_ItemViewer(SobekCM_Item Current_Object, User_Object Current_User, SobekCM_Navigation_Object Current_Mode)
        {
            // Save the current user and current mode information (this is usually populated AFTER the constructor completes,
            // but in this case (QC viewer) we need the information for early processing
            CurrentMode = Current_Mode;
            CurrentUser = Current_User;

            //Assign the current resource object to qc_item
            qc_item = Current_Object;
            //Save to the User's session
            HttpContext.Current.Session[Current_Object.BibID + "_" + Current_Object.VID + " QC Work"] = qc_item;

            // If there is no user, send to the login
            if (CurrentUser == null)
            {
                CurrentMode.Mode = Display_Mode_Enum.My_Sobek;
                CurrentMode.My_Sobek_Type = My_Sobek_Type_Enum.Logon;
                CurrentMode.Redirect();
                return;
            }

            // If the user cannot edit this item, go back
            if (!CurrentUser.Can_Edit_This_Item(Current_Object))
            {
                CurrentMode.ViewerCode = String.Empty;
                CurrentMode.Redirect();
                return;
            }

            //If there are no pages for this item, redirect to the image upload screen
            if (qc_item.Web.Static_PageCount == 0)
            {
                CurrentMode.Mode = Display_Mode_Enum.My_Sobek;
                CurrentMode.My_Sobek_Type = My_Sobek_Type_Enum.Page_Images_Management;
                CurrentMode.Redirect();
                return;
            }

            // Get the links for the METS
            string greenstoneLocation = Current_Object.Web.Source_URL + "/";
            complete_mets = greenstoneLocation + Current_Object.BibID + "_" + Current_Object.VID + ".mets.xml";

            // MAKE THIS USE THE FILES.ASPX WEB PAGE if this is restricted (or dark)
            if ((Current_Object.Behaviors.Dark_Flag) || (Current_Object.Behaviors.IP_Restriction_Membership > 0))
            {
                complete_mets = CurrentMode.Base_URL + "files/" + qc_item.BibID + "/" + qc_item.VID + "/" + qc_item.BibID + "_" + qc_item.VID + ".mets.xml";
            }

            // Get the special qc_item, which matches the passed in Current_Object, at least the first time.
            // If the QC work is already in process, we may find a temporary METS file to read.

            // Determine the in process directory for this
            userInProcessDirectory = SobekCM_Library_Settings.In_Process_Submission_Location + "\\" + Current_User.UserName.Replace(".", "").Replace("@", "") + "\\qcwork\\" + qc_item.METS_Header.ObjectID;
            if (Current_User.ShibbID.Trim().Length > 0)
                userInProcessDirectory = SobekCM_Library_Settings.In_Process_Submission_Location + "\\" + Current_User.ShibbID + "\\qcwork\\" + qc_item.METS_Header.ObjectID;

            // Make the folder for the user in process directory
            if (!Directory.Exists(userInProcessDirectory))
                Directory.CreateDirectory(userInProcessDirectory);

            // Create the name for the tempoary METS file?
            metsInProcessFile = userInProcessDirectory + "\\" + Current_Object.BibID + "_" + Current_Object.VID + ".mets.xml";

            // Is this work in the user's SESSION state?
            qc_item = HttpContext.Current.Session[Current_Object.BibID + "_" + Current_Object.VID + " QC Work"] as SobekCM_Item;
            if (qc_item == null)
            {

                // Is there a temporary METS for this item, which is not expired?
                if ((File.Exists(metsInProcessFile)) &&
                    (File.GetLastWriteTime(metsInProcessFile).Subtract(DateTime.Now).Hours < 8))
                {
                    // Read the temporary METS file, and use that to build the qc_item
                    qc_item = SobekCM_Item_Factory.Get_Item(metsInProcessFile, Current_Object.BibID, Current_Object.VID, null, null, null);
                    qc_item.Source_Directory = Current_Object.Source_Directory;
                }
                else
                {
                    // Just read the normal otherwise ( if we had the ability to deep copy a SobekCM_Item, we could skip this )
                    qc_item = SobekCM_Item_Factory.Get_Item(Current_Object.BibID, Current_Object.VID, null, null, null);
                }

                // Save to the session, so it is easily available for next time
                HttpContext.Current.Session[Current_Object.BibID + "_" + Current_Object.VID + " QC Work"] = qc_item;
            }

            // If no QC item, this is an error
            if (qc_item == null)
            {
                throw new ApplicationException("Unable to retrieve the item for Quality Control in QC_ItemViewer.Constructor");
            }

            // Get the default QC profile
            qc_profile = QualityControl_Configuration.Default_Profile;

            title = "Quality Control";

            // If this was a post-back keep the required height and width for the qc area
            allThumbnailsOuterDiv1Width = -1;
            allThumbnailsOuterDiv1Height = -1;
            string temp_width = HttpContext.Current.Request.Form["QC_window_width"] ?? String.Empty;
            string temp_height = HttpContext.Current.Request.Form["QC_window_height"] ?? String.Empty;

            if ((temp_width.Length > 0) && (temp_height.Length > 0))
            {
                // Parse the values and save to the session
                if (Int32.TryParse(temp_width, out allThumbnailsOuterDiv1Width))
                    HttpContext.Current.Session["QC_AllThumbnailsWidth"] = allThumbnailsOuterDiv1Width;
                if (Int32.TryParse(temp_height, out allThumbnailsOuterDiv1Height))
                    HttpContext.Current.Session["QC_AllThumbnailsHeight"] = allThumbnailsOuterDiv1Height;

            }
            else
            {
                object session_width = HttpContext.Current.Session["QC_AllThumbnailsWidth"];
                if (session_width != null)
                    allThumbnailsOuterDiv1Width = (int) session_width;
                object session_height = HttpContext.Current.Session["QC_AllThumbnailsHeight"];
                if (session_height != null)
                    allThumbnailsOuterDiv1Height = (int) session_height;
            }

            // See if there were hidden requests
            hidden_request = HttpContext.Current.Request.Form["QC_behaviors_request"] ?? String.Empty;
            hidden_main_thumbnail = HttpContext.Current.Request.Form["Main_Thumbnail_File"] ?? String.Empty;
            hidden_move_relative_position = HttpContext.Current.Request.Form["QC_move_relative_position"] ?? String.Empty;
            hidden_move_destination_fileName = HttpContext.Current.Request.Form["QC_move_destination"] ?? String.Empty;
            autonumber_number_system = HttpContext.Current.Request.Form["Autonumber_number_system"] ?? String.Empty;
            string temp = HttpContext.Current.Request.Form["autonumber_mode_from_form"] ?? "0";
            Int32.TryParse(temp, out autonumber_mode_from_form);
            autonumber_text_only = HttpContext.Current.Request.Form["Autonumber_text_without_number"] ?? String.Empty;
            autonumber_number_only = HttpContext.Current.Request.Form["Autonumber_number_only"] ?? String.Empty;
            autonumber_number_system = HttpContext.Current.Request.Form["Autonumber_number_system"] ?? String.Empty;
            hidden_autonumber_filename = HttpContext.Current.Request.Form["Autonumber_last_filename"] ?? String.Empty;
            temp = HttpContext.Current.Request.Form["QC_sortable_option"] ?? "-1";
            if (Int32.TryParse(temp, out makeSortable) && (makeSortable > 0) && (makeSortable <= 3))
            {
                CurrentUser.Add_Setting("QC_ItemViewer:SortableMode",makeSortable);
            }
            temp = HttpContext.Current.Request.Form["QC_autonumber_option"] ?? "-1";
            if ((Int32.TryParse(temp, out autonumber_mode)) && ( autonumber_mode >= 0 ) && ( autonumber_mode <= 2 ))
            {
                CurrentUser.Add_Setting("QC_ItemViewer:AutonumberingMode", autonumber_mode);
            }

            //Get any notes/comments entered by the user
            notes = HttpContext.Current.Request.Form["txtComments"] ?? String.Empty;

            if (!(Int32.TryParse(HttpContext.Current.Request.Form["QC_Sortable"], out makeSortable))) makeSortable = 3;
            // If the hidden move relative position is BEFORE, it is before the very first page
            if (hidden_move_relative_position == "Before")
                hidden_move_destination_fileName = "[BEFORE FIRST]";

            try
            {

                //Call the JavaScript autosave function based on the option selected
                bool autosaveCacheValue = true;
                bool autosaveCache = false;

                //Conversion result of autosaveCacheValue(conversion successful or not) saved in autosaveCache

                if (HttpContext.Current.Session["autosave_option"] != null)
                    autosaveCache = bool.TryParse(HttpContext.Current.Session["autosave_option"].ToString(), out autosaveCacheValue);
                bool convert = bool.TryParse(HttpContext.Current.Request.Form["Autosave_Option"], out autosave_option);
                if (!convert && !autosaveCache)
                {
                    autosave_option = true;
                }
                else if (!convert && autosaveCache)
                {
                    autosave_option = autosaveCacheValue;
                }

                else
                {
                    HttpContext.Current.Session["autosave_option"] = autosave_option;
                }
            }
            catch (Exception e)
            {
                throw new ApplicationException("Error retrieving auto save option. " + e.Message);
            }

            // Check for a previously set main thumbnail, or one from the requesting form
            if (!String.IsNullOrEmpty(hidden_main_thumbnail))
            {
                HttpContext.Current.Session["main_thumbnail_" + qc_item.BibID + "_" + qc_item.VID] = hidden_main_thumbnail;
            }
            else if (HttpContext.Current.Session["main_thumbnail_" + qc_item.BibID + "_" + qc_item.VID] == null )
            {
                hidden_main_thumbnail = qc_item.Behaviors.Main_Thumbnail.Replace("thm.jpg", "");
                HttpContext.Current.Session["main_thumbnail_" + qc_item.BibID + "_" + qc_item.VID] = hidden_main_thumbnail;
            }
            else
            {
                hidden_main_thumbnail = HttpContext.Current.Session["main_thumbnail_" + qc_item.BibID + "_" + qc_item.VID].ToString();
            }

            //Get the list of associated errors for this item from the database
            int itemID = Resource_Object.Database.SobekCM_Database.Get_ItemID(Current_Object.BibID, Current_Object.VID);
            Get_QC_Errors(itemID);

            // Perform any requested actions
            switch (hidden_request)
            {
                case "autosave":
                case "save":
                case "complete":
                    //Save the current time
                    HttpContext.Current.Session["QC_timeUpdated"] = DateTime.Now.ToString("hh:mm tt");

                    // Read the data from the http form, perform all requests, and
                    // update the qc_item (also updates the session and temporary files)
                    // Save this updated information in the temporary folder's METS file for reading later if necessary.
                    if ((Save_From_Form_Request_To_Item(String.Empty, String.Empty)) && (( hidden_request == "save" ) || ( hidden_request == "complete")))
                    {
                        // If the user selected SAVE or COMPLETE, roll out the new version
                        Move_Temp_Changes_To_Production();

                        // Redirect differently depending on SAVE or COMPLETE
                        if (hidden_request == "save")
                        {
                            // Forward back to the QC form
                            HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl, false);
                            HttpContext.Current.ApplicationInstance.CompleteRequest();
                            CurrentMode.Request_Completed = true;
                        }
                        else if (hidden_request == "complete")
                        {
                            // Forward to the item
                            CurrentMode.ViewerCode = String.Empty;
                            CurrentMode.Redirect();
                        }
                    }
                    break;

                case "cancel":
                    Cancel_Current_QC();

                    // Forward back to the default item view
                    CurrentMode.ViewerCode = String.Empty;
                    CurrentMode.Redirect();
                    break;

                case "clear_pagination":
                    ClearPagination();
                    HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl, false);
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                    CurrentMode.Request_Completed = true;
                    break;

                case "clear_reorder":
                    Clear_Pagination_And_Reorder_Pages();
                    HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl, false);
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                    CurrentMode.Request_Completed = true;
                    break;

                case "save_error":
                    string error_code = HttpContext.Current.Request.Form["QC_error_number"] ?? String.Empty;
                    string affected_page_index = HttpContext.Current.Request.Form["QC_affected_file"] ?? String.Empty;
                    SaveQcError(itemID,error_code, affected_page_index);
                    break;

                case "delete_page":
                    // Read the data from the http form, perform all requests, and
                    // update the qc_item (also updates the session and temporary files)
                    string filename_to_delete = HttpContext.Current.Request.Form["QC_affected_file"] ?? String.Empty;
                    if (Save_From_Form_Request_To_Item(String.Empty, filename_to_delete))
                    {
                        Delete_Resource_File(filename_to_delete);
                    }

                    // Since we deleted a page, we need to roll out our new version
                    Move_Temp_Changes_To_Production();

                    HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl, false);
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                    CurrentMode.Request_Completed = true;
                    break;

                case "delete_selected_pages":
                    // Read the data from the http form, perform all requests, and
                    // update the qc_item (also updates the session and temporary files)
                    List<QC_Viewer_Page_Division_Info> selected_page_div_from_form;
                    if (Save_From_Form_Request_To_Item(String.Empty, String.Empty, out selected_page_div_from_form))
                    {
                        foreach (QC_Viewer_Page_Division_Info thisPage in selected_page_div_from_form)
                        {
                            Delete_Resource_File(thisPage.METS_StructMap_Page_Node.Files[0].File_Name_Sans_Extension);
                        }
                    }

                    // Since we deleted a page, we need to roll out our new version
                    Move_Temp_Changes_To_Production();

                    HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl, false);
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                    CurrentMode.Request_Completed = true;
                    break;

                case "move_selected_pages":
                    // Read the data from the http form, perform all requests, and
                    // update the qc_item (also updates the session and temporary files)
                    Save_From_Form_Request_To_Item(hidden_move_destination_fileName, String.Empty);

                    HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl, false);
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                    CurrentMode.Request_Completed = true;
                    break;
            }
        }
示例#13
0
        private static void read_qc_profiles(XmlReader readerXml)
        {
            bool inPackage  = false;
            bool inDivision = false;
            bool inFile     = false;
            bool inDmdSec   = true;
            QualityControl_Profile profile = null;
            int unnamed_profile_counter    = 1;

            while (readerXml.Read())
            {
                if (readerXml.NodeType == XmlNodeType.Element)
                {
                    switch (readerXml.Name.ToLower())
                    {
                    case "profile":
                        profile = new QualityControl_Profile();
                        XmlReader child_readerXml = readerXml.ReadSubtree();
                        if (readerXml.MoveToAttribute("name"))
                        {
                            profile.Profile_Name = readerXml.Value.Trim();
                        }
                        if (readerXml.MoveToAttribute("description"))
                        {
                            profile.Profile_Description = readerXml.Value;
                        }
                        if (readerXml.MoveToAttribute("isDefault"))
                        {
                            bool tempValue;
                            if (bool.TryParse(readerXml.Value, out tempValue))
                            {
                                profile.Default_Profile = tempValue;
                            }
                        }
                        // Enforce a name for this profile (should have one according to XSD)
                        if (profile.Profile_Name.Length == 0)
                        {
                            profile.Profile_Name = "Unnamed" + unnamed_profile_counter;
                            unnamed_profile_counter++;
                        }



                        while (child_readerXml.Read())
                        {
                            if (child_readerXml.NodeType == XmlNodeType.Element && child_readerXml.Name.ToLower() == "divisiontype")

                            //  while (readerXml.ReadToNextSibling("DivisionType"))
                            {
                                if (child_readerXml.Name.ToLower() == "divisiontype")
                                {
                                    QualityControl_Division_Config thisConfig = new QualityControl_Division_Config();
                                    if (child_readerXml.MoveToAttribute("type"))
                                    {
                                        thisConfig.TypeName = child_readerXml.Value;
                                    }
                                    if (child_readerXml.MoveToAttribute("isNameable"))
                                    {
                                        thisConfig.isNameable = Convert.ToBoolean(child_readerXml.Value);
                                    }
                                    profile.Add_Division_Type(thisConfig);
                                }
                            }
                        }
                        Add_Profile(profile);
                        //         Add_METS_Writing_Profile(profile);
                        break;

                    case "package_scope":
                        inPackage  = true;
                        inDivision = false;
                        inFile     = false;
                        break;

                    case "division_scope":
                        inPackage  = false;
                        inDivision = true;
                        inFile     = false;
                        break;

                    case "file_scope":
                        inPackage  = false;
                        inDivision = false;
                        inFile     = true;
                        break;

                    case "dmdsec":
                        inDmdSec = true;
                        break;

                    case "amdsec":
                        inDmdSec = false;
                        break;

                        //case "readerwriterref":
                        //    if (readerXml.MoveToAttribute("ID"))
                        //    {
                        //        string id = readerXml.Value.ToUpper();
                        //        if ((readerWriters.ContainsKey(id)) && (profile != null))
                        //        {
                        //            METS_Section_ReaderWriter_Config readerWriter = readerWriters[id];
                        //            if (inPackage)
                        //            {
                        //                if (inDmdSec)
                        //                    profile.Add_Package_Level_DmdSec_Writer_Config(readerWriter);
                        //                else
                        //                    profile.Add_Package_Level_AmdSec_Writer_Config(readerWriter);
                        //            }
                        //            else if (inDivision)
                        //            {
                        //                if (inDmdSec)
                        //                    profile.Add_Division_Level_DmdSec_Writer_Config(readerWriter);
                        //                else
                        //                    profile.Add_Division_Level_AmdSec_Writer_Config(readerWriter);
                        //            }
                        //            else if (inFile)
                        //            {
                        //                if (inDmdSec)
                        //                    profile.Add_File_Level_DmdSec_Writer_Config(readerWriter);
                        //                else
                        //                    profile.Add_File_Level_AmdSec_Writer_Config(readerWriter);
                        //            }
                        //        }
                        //    }
                        //    break;
                    }
                }
            }
        }