예제 #1
0
 /// <summary>Initializes a new instance of <see cref="DropBoxManager"/>.</summary>
 public DropBoxManager(AssignmentProperties assignmentProperties)
 {
     this.assignmentProperties = assignmentProperties;
     store = assignmentProperties.Store;
     this.settings = assignmentProperties.Store.Settings.DropBoxSettings;
     culture = new SlkCulture();
 }
 /// <summary>Initializes a new instance of <see cref="SlkSettings"/>.</summary>
 /// <param name="xmlReader">The XmlReader containing the settings.</param>
 /// <param name="whenUploaded">The date and time when uploaded.</param>
 public SlkSettings(XmlReader xmlReader, DateTime whenUploaded)
 {
     approvedAttachmentTypes = new Collection <string>();
     eLearningIisCompatibilityModeExtensions    = new Collection <string>();
     nonELearningIisCompatibilityModeExtensions = new Collection <string>();
     MimeTypeMappings = new Dictionary <string, string>(50, StringComparer.OrdinalIgnoreCase);
     InitalizeMimeTypeMappings();
     queryDefinitions        = new List <QueryDefinition>(20);
     querySetDefinitions     = new List <QuerySetDefinition>(10);
     WhenUploaded            = whenUploaded;
     DropBoxSettings         = new DropBoxSettings();
     QuickAssignmentSettings = new QuickAssignmentSettings();
     EmailSettings           = new EmailSettings();
     ParseSettingsFile(xmlReader);
 }
        /// <summary>
        /// Parses an SLK Settings XML file, i.e. an XML file with schema
        /// "urn:schemas-microsoft-com:sharepoint-learning-kit:settings".  Returns a new
        /// <c>SlkSettings</c> object containing information from the parsed file.
        /// </summary>
        /// <param name="xmlReader">An <c>XmlReader</c> positioned at the beginning of the SLK Settings
        ///     XML file.  This <c>XmlReader</c> must have "SlkSettings.xsd" (the SLK Setttings XML
        ///     schema) attached using the <c>XmlReaderSettings</c> parameter of the <c>XmlReader</c>
        ///     constructor, with <c>XmlReaderSettings.ValidationType</c> equal to
        ///     <c>ValidationType.Schema</c>.</param>
        /// <exception cref="SlkSettingsException">
        /// The SLK Settings XML file is invalid.  The exception message includes the line number and
        /// other information about the error.
        /// </exception>
        void ParseSettingsFile(XmlReader xmlReader)
        {
            // Check parameters
            if (xmlReader == null)
            {
                throw new ArgumentNullException("xmlReader");
            }

            // parse the SLK Settings XML file, and fill in <slkSettings>; use <queryDictionary> (which
            // maps a query name to a QueryDefinition) and <querySetDictionary> (which maps a query set
            // name to a QuerySetDefinition) to check for duplicate and invalid query and query set
            // names (including a query name the same as query set name, which isn't allowed) -- note
            // that the .xsd file requires that all "<Query>" elements appear before any "<QuerySet>"
            // elements
            try
            {
                while (xmlReader.Read())
                {
                    if (xmlReader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }
                    else if (xmlReader.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }
                    else
                    {
                        switch (xmlReader.Name)
                        {
                        case "Settings":
                            ParseSettingsAttributes(xmlReader);
                            xmlReader.MoveToElement();
                            break;

                        case "MimeTypeMapping":
                            // Add or override standard mime-type mappings
                            string extension = xmlReader.GetAttribute("Extension");
                            if (string.IsNullOrEmpty(extension) == false)
                            {
                                extension = extension.ToUpperInvariant();
                                string mimeType = xmlReader.GetAttribute("MimeType");
                                // Standard slksettings.xml had invalid png mime-type in
                                if (extension != ".PNG" && mimeType != "image/x-png")
                                {
                                    MimeTypeMappings[extension] = mimeType;
                                }
                            }

                            break;

                        case "DropBoxSettings":
                            DropBoxSettings = new DropBoxSettings(xmlReader);
                            break;

                        case "QuickAssignmentSettings":
                            QuickAssignmentSettings = new QuickAssignmentSettings(xmlReader);
                            break;

                        case "EmailSettings":
                            EmailSettings = new EmailSettings(xmlReader);
                            break;

                        case "Query":
                            ParseQuery(xmlReader);
                            break;

                        case "QuerySet":
                            ParseQuerySet(xmlReader);
                            break;

                        case "DomainGroupEnumerator":
                            DomainGroupEnumeratorType     = xmlReader.GetAttribute("Type");
                            DomainGroupEnumeratorAssembly = xmlReader.GetAttribute("Assembly");
                            break;
                        }
                    }
                }
            }
            catch (XmlException ex)
            {
                throw new SlkSettingsException(xmlReader, Resources.SlkUtilitiesSettingsExceptionDefaultFormat, ex.Message);
            }
            catch (XmlSchemaValidationException ex)
            {
                throw new SlkSettingsException(xmlReader, Resources.SlkUtilitiesSettingsExceptionDefaultFormat, ex.Message);
            }
        }