Ejemplo n.º 1
0
        /// <summary>
        /// DavRefreshEventArgs Clone
        /// </summary>
        /// <remarks>Deep copy</remarks>
        /// <returns></returns>
        public DavRefreshEventArgs Clone()
        {
            // Start with a flat, memberwise copy
            DavRefreshEventArgs _davRefreshEventArgs = (DavRefreshEventArgs)this.MemberwiseClone();

            return(_davRefreshEventArgs);
        }
Ejemplo n.º 2
0
        private void DavLock_RefreshLockDavRequest(object sender, DavRefreshEventArgs e)
        {
            //Check to see if the lock exists
            DirectoryInfo _dirInfo = RequestWrapper.GetParentDirectory(base.RelativeRequestPath);

            FileInfo[] _lockFiles = _dirInfo.GetFiles("*." + e.LockToken + ".locked");
            if (_lockFiles.Length == 0)
                base.AbortRequest(DavLockResponseCode.PreconditionFailed);
            else
            {

                //Deserialize the lock information
                base.ResponseLock = RequestWrapper.GetLockInfo(_lockFiles[0].FullName);

                //Set the requested lockTimeout or overwrite
                base.ResponseLock.LockTimeout = 10;
            }
        }
Ejemplo n.º 3
0
		/// <summary>
		/// Raises the LockRefreshDavRequest event
		/// </summary>
		protected void OnRefreshLockDavRequest(DavRefreshEventArgs e)
		{
			if (RefreshLockDavRequest != null)
				RefreshLockDavRequest(this, e);
		}
Ejemplo n.º 4
0
		private int DavLockBase_InternalProcessDavRequest(object sender, EventArgs e)
		{
			int _responseCode = (int)DavLockResponseCode.Ok;

			string[] _lockTokens = this.RequestLock.GetLockTokens();

			//Check to see if a lock refresh was requested
			if (base.HttpApplication.Request.Headers["If"] != null)
			{
				if (_lockTokens.Length == 1)
				{
					DavRefreshEventArgs _refreshEventArgs = new DavRefreshEventArgs(_lockTokens[0], this.RequestLock.LockTimeout);
					OnRefreshLockDavRequest(_refreshEventArgs);
				}

				base.HttpApplication.Response.AppendHeader("Timeout", "Second-" + this.ResponseLock.LockTimeout);
			}
			else
			{
				//New lock request
				StringBuilder _opaquelockTokens = new StringBuilder();
				foreach (string _lockToken in _lockTokens)
					_opaquelockTokens.Append("<opaquelocktoken:" + _lockToken + ">");

				base.HttpApplication.Response.AppendHeader("Lock-Token", _opaquelockTokens.ToString());
			}

			//Check to see if there were any process errors...
			Enum[] _errorResources = this.ProcessErrorResources;
			if (_errorResources.Length > 0)
			{
				//Append a response node
				XmlDocument _xmlDocument = new XmlDocument();
				XmlNode _responseNode = _xmlDocument.CreateNode(XmlNodeType.Element, _xmlDocument.GetPrefixOfNamespace("DAV:"), "response", "DAV:");

				//Add the HREF
				XmlElement _requestLockHrefElement = _xmlDocument.CreateElement("href", "DAV:");
				_requestLockHrefElement.InnerText = base.RelativeRequestPath;
				_responseNode.AppendChild(_requestLockHrefElement);


				//Add the propstat
				XmlElement _propstatElement = _xmlDocument.CreateElement("propstat", "DAV:");
				XmlElement _propElement = _xmlDocument.CreateElement("prop", "DAV:");
				XmlElement _lockDiscoveryElement = _xmlDocument.CreateElement("lockdiscovery", "DAV:");
				_propElement.AppendChild(_lockDiscoveryElement);
				_propstatElement.AppendChild(_propElement);

				XmlElement _statusElement = _xmlDocument.CreateElement("status", "DAV:");
				_statusElement.InnerText = InternalFunctions.GetEnumHttpResponse(DavLockResponseCode.FailedDependency);
				_propstatElement.AppendChild(_statusElement);

				_responseNode.AppendChild(_propstatElement);

				base.SetResponseXml(InternalFunctions.ProcessErrorRequest(this.ProcessErrors, _responseNode));
				_responseCode = (int)ServerResponseCode.MultiStatus;
			}
			else
			{
				//No issues
				using (Stream _responseStream = new MemoryStream())
				{
					XmlTextWriter _xmlWriter = new XmlTextWriter(_responseStream, new UTF8Encoding(false));

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

					//Open the prop element section
					_xmlWriter.WriteStartElement("D", "prop", "DAV:");
					_xmlWriter.WriteStartElement("lockdiscovery", "DAV:");
					this.ResponseLock.ActiveLock.WriteTo(_xmlWriter);
					_xmlWriter.WriteEndElement();
					_xmlWriter.WriteEndElement();

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

					base.SetResponseXml(_responseStream);
					_xmlWriter.Close();
				}
			}

			return _responseCode;
		}