예제 #1
0
        ///<summary>
        ///Retrieving Folder Contents
        ///How to return
        ///</summary>
        public void foldercontent(string url)
        {
            HttpWebRequest request = WebRequest.Create(url + "/contents") as HttpWebRequest;
            request.Method = "GET";
            request.Headers.Add("Authorization", accessToken);
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(response.GetResponseStream());

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(reader.ReadToEnd());
                List<File> lfil = new List<File>();
                List<Folder> lfol = new List<Folder>();
                foreach (XmlElement xitem in doc.DocumentElement.SelectNodes("//file"))
                {
                    File f = new File();
                    XmlDocument wdoc = new XmlDocument();
                    wdoc.LoadXml("<root>" + xitem.InnerXml + "</root>");
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//displayName"))
                    {
                        f.displayName = citem.InnerText;
                    }
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//ref"))
                    {
                        f.reference = citem.InnerText;
                    }
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//size"))
                    {
                        f.size = citem.InnerText;
                    }
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//lastModified"))
                    {
                        f.lastModified = citem.InnerText;
                    }
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//mediaType"))
                    {
                        f.mediaType = citem.InnerText;
                    }
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//presentOnServer"))
                    {
                        f.presentOnServer = citem.InnerText;
                    }
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//fileData"))
                    {
                        f.fileData = citem.InnerText;
                    }
                    lfil.Add(f);
                }
                foreach (XmlElement xitem in doc.DocumentElement.SelectNodes("//collection"))
                {
                    Folder f = new Folder();
                    XmlDocument wdoc = new XmlDocument();
                    wdoc.LoadXml("<root>" + xitem.InnerXml + "</root>");
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//displayName"))
                    {
                        f.displayName = citem.InnerText;
                    }
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//ref"))
                    {
                        f.reference = citem.InnerText;
                    }
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//contents"))
                    {
                        f.contents = citem.InnerText;
                    }
                    lfol.Add(f);
                }
            }
        }
예제 #2
0
        ///<summary>
        ///Retrieving Folder Information
        ///Return Folder
        ///</summary>
        public Folder folderinfo(string url)
        {
            HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
            request.Method = "GET";
            request.Headers.Add("Authorization", accessToken);
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(response.GetResponseStream());

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(reader.ReadToEnd());
                Folder f = new Folder();
                foreach (XmlElement xitem in doc.DocumentElement.SelectNodes("//folder"))
                {
                    XmlDocument wdoc = new XmlDocument();
                    wdoc.LoadXml("<root>" + xitem.InnerXml + "</root>");
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//displayName"))
                    {
                        f.displayName = citem.InnerText;
                    }
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//dsid"))
                    {
                        f.dsid = citem.InnerText;
                    }
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//timeCreated"))
                    {
                        f.timeCreated = citem.InnerText;
                    }
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//collections"))
                    {
                        f.collections = citem.InnerText;
                    }
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//files"))
                    {
                        f.files = citem.InnerText;
                    }
                    foreach (XmlElement citem in wdoc.DocumentElement.SelectNodes("//contents"))
                    {
                        f.contents = citem.InnerText;
                    }
                }
                return f;
            }
        }
예제 #3
0
 ///<summary>
 ///Updating Folder Information
 ///</summary>
 public void UpdateFolderInfo(string url, Folder fol)
 {
     HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
     request.Method = "PUT";
     request.Headers.Add("Authorization", accessToken);
     string xml_request = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" +
         "<folder>" +
             "<displayName>" + fol.displayName + "</displayName>" +
             "<dsid>" + fol.dsid + "</dsid>" +
             "<timeCreated>" + fol.timeCreated + "</timeCreated>" +
             "<parent>" + fol.parent + "</parent>" +
             "<collections>" + fol.collections + "</collections>" +
             "<files>" + fol.files + "</files>" +
             "<contents>" + fol.contents + "</contents>" +
             "<sharing enabled='" + fol.sharing + "'/>" +
         "</folder>";
     byte[] byteData = UTF8Encoding.UTF8.GetBytes(xml_request);
     request.ContentLength = byteData.Length;
     using (Stream postStream = request.GetRequestStream())
     {
         postStream.Write(byteData, 0, byteData.Length);
     }
     using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
     {
         StreamReader reader = new StreamReader(response.GetResponseStream());
     }
 }