public static bool DownloadDocument(AssemblaDoc doc, string path, string user, string password)
        {
            if (!doc.isValid)
            {
                return(false);
            }
            string         url = doc.Url;
            HttpWebRequest hr  = WebRequest.Create(url) as HttpWebRequest;

            hr.Credentials     = new System.Net.NetworkCredential(user, password);
            hr.PreAuthenticate = true;
            hr.Method          = "GET";
            hr.ContentType     = "application/xml";
            HttpWebResponse wr     = (HttpWebResponse)hr.GetResponse();
            Stream          stream = wr.GetResponseStream();

            byte[] buff = new byte[(int)wr.ContentLength];
            int    n    = stream.Read(buff, 0, (int)wr.ContentLength);

            if (n == 0)
            {
                return(false);
            }
            try
            {
                stream.Close();
                wr.Close();
                FileStream fs = new FileStream(path + "//" + doc.Name, FileMode.Create);
                fs.Write(buff, 0, (int)buff.Length);
                fs.Close();
                return(true);
            }
            catch { }
            return(false);
        }
示例#2
0
 public static bool DownloadDocument(AssemblaDoc doc, string path, string user, string password)
 {
     if (!doc.isValid) return false;
     string url = doc.Url;
     HttpWebRequest hr = WebRequest.Create(url) as HttpWebRequest;
     hr.Credentials = new System.Net.NetworkCredential(user, password);
     hr.PreAuthenticate = true;
     hr.Method = "GET";
     hr.ContentType = "application/xml";
     HttpWebResponse wr = (HttpWebResponse)hr.GetResponse();
     Stream stream = wr.GetResponseStream();
     byte[] buff = new byte[(int)wr.ContentLength];
     int n = stream.Read(buff, 0, (int)wr.ContentLength);
     if (n == 0) return false;
     try
     {
         stream.Close();
         wr.Close();
         FileStream fs = new FileStream(path + "//" + doc.Name, FileMode.Create);
         fs.Write(buff, 0, (int)buff.Length);
         fs.Close();
         return true;
     }
     catch { }
     return false;
 }
示例#3
0
        public static bool Create(string space, string user, string password, string filename, int ticketid, bool prependdatetime, bool showprogress)
        {
            string url = GetDocumentsUrl(space);
            try
            {

                string unique = prependdatetime ? Util.ToTLDate(DateTime.Now).ToString() + Util.DT2FT(DateTime.Now) + Path.GetFileName(filename) : Path.GetFileName(filename);
                
                FileInfo fi = new FileInfo(filename);
                int maxwaitsec = (int)(fi.Length / (double)50000);
                string result = string.Empty;
                bool ok = qc.gomultipartpost(url, user, password, unique,filename,ticketid,maxwaitsec, showprogress,SendDebug, out result);
                string node = ok ? "document" : "error";
                XmlDocument xd = new XmlDocument();
                xd.LoadXml(result);
                List<AssemblaDoc> docs = new List<AssemblaDoc>();
                XmlNodeList xnl = xd.GetElementsByTagName(node);
                foreach (XmlNode xn in xnl)
                {
                    AssemblaDoc doc = new AssemblaDoc();
                    doc.Space = space;
                    foreach (XmlNode dc in xn.ChildNodes)
                    {
                        string m = dc.InnerText;
                        if (ok)
                        {
                            if (dc.Name == "id")
                                doc.Id = m;
                            else if (dc.Name == "filesize")
                                doc.Size = Convert.ToInt32(m);
                            else if (dc.Name == "description")
                                doc.Desc = m;
                            else if (dc.Name == "name")
                                doc.Name = m;
                        }
                        else if (SendDebug!=null)
                        {
                            SendDebug(m);
                        }
                    }
                    if (doc.isValid)
                        docs.Add(doc);
                }

                
                
                return true;
            }
            catch (Exception ex)
            {
                if (SendDebug != null)
                    SendDebug("exception: " + ex.Message + ex.StackTrace);

                return false;
            }

        }
示例#4
0
        public static List <AssemblaDoc> GetDocuments(string space, string user, string password)
        {
            string         url = GetDocumentsUrl(space);
            HttpWebRequest hr  = WebRequest.Create(url) as HttpWebRequest;

            hr.Credentials     = new System.Net.NetworkCredential(user, password);
            hr.PreAuthenticate = true;
            hr.Method          = "GET";
            hr.ContentType     = "application/xml";
            HttpWebResponse wr     = (HttpWebResponse)hr.GetResponse();
            StreamReader    sr     = new StreamReader(wr.GetResponseStream());
            XmlDocument     xd     = new XmlDocument();
            string          result = sr.ReadToEnd();

            xd.LoadXml(result);
            List <AssemblaDoc> docs = new List <AssemblaDoc>();
            XmlNodeList        xnl  = xd.GetElementsByTagName("document");

            foreach (XmlNode xn in xnl)
            {
                AssemblaDoc doc = new AssemblaDoc();
                doc.Space = space;
                foreach (XmlNode dc in xn.ChildNodes)
                {
                    string m = dc.InnerText;
                    if (dc.Name == "id")
                    {
                        doc.Id = m;
                    }
                    else if (dc.Name == "filesize")
                    {
                        doc.Size = Convert.ToInt32(m);
                    }
                    else if (dc.Name == "description")
                    {
                        doc.Desc = m;
                    }
                    else if (dc.Name == "name")
                    {
                        doc.Name = m;
                    }
                }
                if (doc.isValid)
                {
                    docs.Add(doc);
                }
            }
            return(docs);
        }
        public static List <AssemblaDoc> GetDocuments(string space, string user, string password)
        {
            string url = GetDocumentsUrl(space);

            string             result = string.Empty;
            List <AssemblaDoc> docs   = new List <AssemblaDoc>();

            if (qc.goget(url, user, password, string.Empty, SendDebug, out result))
            {
                XmlDocument xd = new XmlDocument();
                xd.LoadXml(result);

                XmlNodeList xnl = xd.GetElementsByTagName("document");
                foreach (XmlNode xn in xnl)
                {
                    AssemblaDoc doc = new AssemblaDoc();
                    doc.Space = space;
                    foreach (XmlNode dc in xn.ChildNodes)
                    {
                        string m = dc.InnerText;
                        if (dc.Name == "id")
                        {
                            doc.Id = m;
                        }
                        else if (dc.Name == "filesize")
                        {
                            doc.Size = Convert.ToInt32(m);
                        }
                        else if (dc.Name == "description")
                        {
                            doc.Desc = m;
                        }
                        else if (dc.Name == "name")
                        {
                            doc.Name = m;
                        }
                    }
                    if (doc.isValid)
                    {
                        docs.Add(doc);
                    }
                }
            }
            return(docs);
        }
示例#6
0
 public static List<AssemblaDoc> GetDocuments(string space, string user, string password)
 {
     string url = GetDocumentsUrl(space);
     HttpWebRequest hr = WebRequest.Create(url) as HttpWebRequest;
     hr.Credentials = new System.Net.NetworkCredential(user, password);
     hr.PreAuthenticate = true;
     hr.Method = "GET";
     hr.ContentType = "application/xml";
     HttpWebResponse wr = (HttpWebResponse)hr.GetResponse();
     StreamReader sr = new StreamReader(wr.GetResponseStream());
     XmlDocument xd = new XmlDocument();
     string result = sr.ReadToEnd();
     xd.LoadXml(result);
     List<AssemblaDoc> docs = new List<AssemblaDoc>();
     XmlNodeList xnl = xd.GetElementsByTagName("document");
     foreach (XmlNode xn in xnl)
     {
         AssemblaDoc doc = new AssemblaDoc();
         doc.Space = space;
         foreach (XmlNode dc in xn.ChildNodes)
         {
             string m = dc.InnerText;
             if (dc.Name == "id")
                 doc.Id = m;
             else if (dc.Name == "filesize")
                 doc.Size = Convert.ToInt32(m);
             else if (dc.Name == "description")
                 doc.Desc = m;
             else if (dc.Name == "name")
                 doc.Name = m;
         }
         if (doc.isValid)
             docs.Add(doc);
     }
     return docs;
 }
示例#7
0
 public static bool DownloadDocument(AssemblaDoc doc, string user, string password)
 {
     return DownloadDocument(doc, Environment.CurrentDirectory, user, password);
 }
        public static bool Create(string space, string user, string password, string filename, int ticketid, bool prependdatetime, bool showprogress)
        {
            string url = GetDocumentsUrl(space);

            try
            {
                string unique = prependdatetime ? Util.ToTLDate(DateTime.Now).ToString() + Util.DT2FT(DateTime.Now) + Path.GetFileName(filename) : Path.GetFileName(filename);

                FileInfo    fi         = new FileInfo(filename);
                int         maxwaitsec = (int)(fi.Length / (double)50000);
                string      result     = string.Empty;
                bool        ok         = qc.gomultipartpost(url, user, password, unique, filename, ticketid, maxwaitsec, showprogress, SendDebug, out result);
                string      node       = ok ? "document" : "error";
                XmlDocument xd         = new XmlDocument();
                xd.LoadXml(result);
                List <AssemblaDoc> docs = new List <AssemblaDoc>();
                XmlNodeList        xnl  = xd.GetElementsByTagName(node);
                foreach (XmlNode xn in xnl)
                {
                    AssemblaDoc doc = new AssemblaDoc();
                    doc.Space = space;
                    foreach (XmlNode dc in xn.ChildNodes)
                    {
                        string m = dc.InnerText;
                        if (ok)
                        {
                            if (dc.Name == "id")
                            {
                                doc.Id = m;
                            }
                            else if (dc.Name == "filesize")
                            {
                                doc.Size = Convert.ToInt32(m);
                            }
                            else if (dc.Name == "description")
                            {
                                doc.Desc = m;
                            }
                            else if (dc.Name == "name")
                            {
                                doc.Name = m;
                            }
                        }
                        else if (SendDebug != null)
                        {
                            SendDebug(m);
                        }
                    }
                    if (doc.isValid)
                    {
                        docs.Add(doc);
                    }
                }



                return(true);
            }
            catch (Exception ex)
            {
                if (SendDebug != null)
                {
                    SendDebug("exception: " + ex.Message + ex.StackTrace);
                }

                return(false);
            }
        }
 public static bool DownloadDocument(AssemblaDoc doc, string user, string password)
 {
     return(DownloadDocument(doc, Environment.CurrentDirectory, user, password));
 }
示例#10
0
        public static List<AssemblaDoc> GetDocuments(string space, string user, string password)
        {
            string url = GetDocumentsUrl(space);

            string result = string.Empty;
            List<AssemblaDoc> docs = new List<AssemblaDoc>();
            if (qc.goget(url, user, password, string.Empty,SendDebug, out result))
            {
                XmlDocument xd = new XmlDocument();
                xd.LoadXml(result);
                
                XmlNodeList xnl = xd.GetElementsByTagName("document");
                foreach (XmlNode xn in xnl)
                {
                    AssemblaDoc doc = new AssemblaDoc();
                    doc.Space = space;
                    foreach (XmlNode dc in xn.ChildNodes)
                    {
                        string m = dc.InnerText;
                        if (dc.Name == "id")
                            doc.Id = m;
                        else if (dc.Name == "filesize")
                            doc.Size = Convert.ToInt32(m);
                        else if (dc.Name == "description")
                            doc.Desc = m;
                        else if (dc.Name == "name")
                            doc.Name = m;
                    }
                    if (doc.isValid)
                        docs.Add(doc);
                }
            }
            return docs;

        }