Esempio n. 1
0
        /// <summary>
        /// Internal function to process response
        /// </summary>
        /// <param name="errorResources"></param>
        /// <param name="appendResponseNode"></param>
        /// <returns></returns>
        internal static string ProcessErrorRequest(DavProcessErrorCollection errorResources, XmlNode appendResponseNode)
        {
            string _errorRequest = "";

            //Build the response
            using (Stream _responseStream = new MemoryStream())
            {
                var _xmlWriter = new XmlTextWriter(_responseStream, new UTF8Encoding(false));

                _xmlWriter.Formatting = Formatting.Indented;
                _xmlWriter.IndentChar = '\t';
                _xmlWriter.Indentation = 1;
                _xmlWriter.WriteStartDocument();

                //Set the Multistatus
                _xmlWriter.WriteStartElement("D", "multistatus", "DAV:");

                //Append the errors
                foreach (Enum _errorCode in errorResources.AllResourceErrors)
                {
                    foreach (DavResourceBase _resource in errorResources[_errorCode])
                    {
                        //Open the response element
                        _xmlWriter.WriteStartElement("response", "DAV:");
                        _xmlWriter.WriteElementString("href", "DAV:", _resource.ResourcePath);
                        _xmlWriter.WriteElementString("status", "DAV:", GetEnumHttpResponse(_errorCode));
                        //Close the response element section
                        _xmlWriter.WriteEndElement();
                    }
                }

                if (appendResponseNode != null)
                    appendResponseNode.WriteTo(_xmlWriter);

                _xmlWriter.WriteEndElement();
                _xmlWriter.WriteEndDocument();
                _xmlWriter.Flush();

                using (StreamReader _streamReader = new StreamReader(_responseStream, Encoding.UTF8))
                {
                    //Go to the begining of the stream
                    _streamReader.BaseStream.Position = 0;
                    _errorRequest = _streamReader.ReadToEnd();
                }
                _xmlWriter.Close();
            }
            return _errorRequest;
        }
Esempio n. 2
0
 /// <summary>
 /// Internal function to process response
 /// </summary>
 /// <param name="errorResources"></param>
 /// <returns></returns>
 internal static string ProcessErrorRequest(DavProcessErrorCollection errorResources)
 {
     return ProcessErrorRequest(errorResources, null);
 }