示例#1
0
        /// <summary>
        /// This method is used to add a request to the request collection in the request envelope body.
        /// </summary>
        /// <param name="url">Specify the URL of the file to edit.</param>
        /// <param name="subRequests">Specify the sub request array.</param>
        /// <param name="requestToken">Specify the token which uniquely identify the request.</param>
        /// <param name="interval">Specify a nonnegative integer in seconds, which the protocol client will repeat this request.</param>
        /// <param name="metaData">Specify a 32-bit value that specifies information about the scenario and urgency of the request.</param>
        public void AddRequest(string url, SubRequestType[] subRequests, string requestToken, uint?interval, int?metaData)
        {
            Request request = new Request();

            request.RequestToken = requestToken;
            request.Url          = url;
            request.Interval     = interval == null ? null : interval.Value.ToString();
            request.MetaData     = metaData == null ? null : metaData.Value.ToString();

            int index = 0;

            if (subRequests != null)
            {
                request.SubRequest = new SubRequestElementGenericType[subRequests.Length];
                foreach (SubRequestType item in subRequests)
                {
                    if (item != null)
                    {
                        request.SubRequest[index++] = FsshttpConverter.ConvertSubRequestToGenericType <SubRequestElementGenericType>(item);
                    }
                }
            }
            else
            {
                throw new System.ArgumentException("subRequests parameter in FSSHTTPMessageBodyWriter::AddRequest cannot be null.");
            }

            List <Request> requestList = this.requestEnvelope.RequestCollection.Request == null ? new List <Request>(1) : new List <Request>(this.requestEnvelope.RequestCollection.Request);

            requestList.Add(request);

            this.requestEnvelope.RequestCollection.Request = requestList.ToArray();
        }
        /// <summary>
        /// This method is used to add a request to the request collection in the request envelope body.
        /// </summary>
        /// <param name="url">Specify the URL of the file to edit.</param>
        /// <param name="subRequests">Specify the sub request array.</param>
        /// <param name="requestToken">Specify the token which uniquely identify the request.</param>
        /// <param name="interval">Specify a nonnegative integer in seconds, which the protocol client will repeat this request.</param>
        /// <param name="metaData">Specify a 32-bit value that specifies information about the scenario and urgency of the request.</param>
        /// <param name="lastModifiedTime">Specify the last modified time, which is expressed as a tick count.</param>
        /// <param name="parentFolderResourceID">If UseResourceID is true, this parameter tells the host to create a file in the given folder ResourceID, regardless of the request URL value.</param>
        /// <param name="shouldReturnDisambiguatedFileName">If an upload request fails with a coherency failure, this flag specifies whether the host should return a suggested/available file name that the client can try instead</param>
        /// <param name="resourceID">Specify the invariant ResourceID for a file that uniquely identifies the file whose response is being generated</param>
        /// <param name="useResourceID">Specify if the protocol server MAY perform ResourceID specific behavior for the file whose contents or metadata contents are requested for uploading to the server or downloading from the server. </param>
        public void AddRequest(string url, SubRequestType[] subRequests, string requestToken, uint?interval, int?metaData,
                               string lastModifiedTime                = null,
                               string parentFolderResourceID          = null,
                               bool?shouldReturnDisambiguatedFileName = null,
                               string resourceID  = null,
                               bool?useResourceID = null)
        {
            Request request = new Request();

            request.RequestToken           = requestToken;
            request.Url                    = url;
            request.Interval               = interval == null ? null : interval.Value.ToString();
            request.MetaData               = metaData == null ? null : metaData.Value.ToString();
            request.ParentFolderResourceID = parentFolderResourceID;
            request.ResourceID             = resourceID;
            if (shouldReturnDisambiguatedFileName != null)
            {
                request.ShouldReturnDisambiguatedFileName          = (bool)shouldReturnDisambiguatedFileName;
                request.ShouldReturnDisambiguatedFileNameSpecified = true;
            }
            if (useResourceID != null)
            {
                request.UseResourceID = useResourceID.ToString();
            }

            int index = 0;

            if (subRequests != null)
            {
                request.SubRequest = new SubRequestElementGenericType[subRequests.Length];
                foreach (SubRequestType item in subRequests)
                {
                    if (item != null)
                    {
                        int temp = index;
                        request.SubRequest[temp] = FsshttpConverter.ConvertSubRequestToGenericType <SubRequestElementGenericType>(item);
                        if (!string.IsNullOrEmpty(lastModifiedTime))
                        {
                            if (request.SubRequest[temp].SubRequestData == null)
                            {
                                request.SubRequest[temp].SubRequestData = new SubRequestDataGenericType();
                            }
                            request.SubRequest[temp].SubRequestData.LastModifiedTime = lastModifiedTime;
                        }

                        index++;
                    }
                }
            }
            else
            {
                throw new System.ArgumentException("subRequests parameter in FSSHTTPMessageBodyWriter::AddRequest cannot be null.");
            }

            List <Request> requestList = this.requestEnvelope.RequestCollection.Request == null ? new List <Request>(1) : new List <Request>(this.requestEnvelope.RequestCollection.Request);

            requestList.Add(request);

            this.requestEnvelope.RequestCollection.Request = requestList.ToArray();
        }
示例#3
0
        /// <summary>
        /// Get Editor instance from XmlNode.
        /// </summary>
        /// <param name="node">The XmlNode which contents the Editor data.</param>
        /// <returns>Then instance of Editor.</returns>
        private static Editor GetEditor(XmlNode node)
        {
            if (node.ChildNodes.Count == 0)
            {
                return(null);
            }

            Editor editors = new Editor();

            foreach (XmlNode item in node.ChildNodes)
            {
                object propValue;
                if (item.Name == "HasEditorPermission")
                {
                    propValue = Convert.ToBoolean(item.InnerText);
                }
                else if (item.Name == "Timeout")
                {
                    propValue = Convert.ToInt64(item.InnerText);
                }
                else if (item.Name == "Metadata")
                {
                    Dictionary <string, string> metaData = new Dictionary <string, string>();

                    foreach (XmlNode metaNode in item.ChildNodes)
                    {
                        metaData.Add(metaNode.Name, new System.Text.UnicodeEncoding().GetString(Convert.FromBase64String(metaNode.InnerText)));
                    }

                    propValue = metaData;
                }
                else
                {
                    propValue = item.InnerText;
                }

                FsshttpConverter.SetSpecifiedProtyValueByName(editors, item.Name, propValue);
            }

            return(editors);
        }