示例#1
0
        public async Task <HttpResponseMessage> SetFileAttributes()
        {
            if (!Request.Content.IsFormData())
            {
                return(new HttpResponseMessage(HttpStatusCode.UnsupportedMediaType));
                // HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.UnsupportedMediaType);
            }

            string authorizationString = DecodeAuthorizationString();

            SPHelper.SetSharePointCredentials(authorizationString);
            NameValueCollection formData = await Request.Content.ReadAsFormDataAsync();

            if (formData.Keys.Count > 0)
            {
                SharePointDocument doc = new SharePointDocument();
                doc.FileId       = formData.Get("FileId").ToGuid();
                doc.MasterId     = formData.Get("MasterId");
                doc.MasterNumber = formData.Get("MasterNumber");
                doc.DocumentType = StringToLookupItem("DocumentType", formData.Get("DocumentType"));
                doc.MasterName   = formData.Get("MasterName");

                ListItem file = SPHelper.FindFile(doc.FileId);
                SPHelper.AddDocumentProperties(file, doc);
            }
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }