Example #1
0
 public void Activity(ref Content Files, ref DataUser User, ListView ListFiles, ProgressBar Loading, int Count, bool SelIt, string Function)
 {
     if (User.CheckIntConnect())
     {
         handle = new AutoResetEvent(false);
         int ThreadCount = Count;
         Loading.Maximum = ThreadCount;
         InterUser       = User;
         InterFiles      = Files;
         for (int index = 0; index < ThreadCount; index++)
         {
             Thread thread = new Thread(new ParameterizedThreadStart(Capabilities[Function]));
             thread.IsBackground = true;
             if (SelIt)
             {
                 thread.Start(ListFiles.SelectedItems[index].Index);
             }
             else
             {
                 thread.Start(index);
             }
         }
         while (ThreadCount > 0)
         {
             handle.WaitOne();
             Loading.Increment(1);
             ThreadCount--;
         }
         Loading.Value = 0;
         User.InfoFiles(ref Files, ref User, ref ListFiles, User.Data.Hrefs.Last(), true);
     }
 }
Example #2
0
        public void MakeDirectory(ref Content Files, ref DataUser User, ListView ListFiles, TextBox NewFolder, string Folder)
        {
            Rename Active = new Rename();

            if (Active.CheckName(Folder, Files))
            {
                if (User.CheckIntConnect())
                {
                    ReqRes Act = new ReqRes();
                    try
                    {
                        HttpWebRequest Request = Act.MakeRequest(User.Data.UrlServer, User.Data.Hrefs.Last() + Folder, User.Data.Name, User.Data.Password);
                        if (Request != null)
                        {
                            Request.Method = WebRequestMethods.Http.MkCol;
                            Act.GetResponse(Request);
                            User.InfoFiles(ref Files, ref User, ref ListFiles, User.Data.Hrefs.Last(), true);
                            NewFolder.Text = "";
                        }
                    }
                    catch (WebException ex)
                    {
                        if (GotMessage != null)
                        {
                            GotMessage(ex.Message);
                        }
                    }
                }
            }
        }
Example #3
0
 public bool MakeNewName(DataUser User, int Item, string Name, Content Files)
 {
     if (User.CheckIntConnect())
     {
         ReqRes Act = new ReqRes();
         try
         {
             HttpWebRequest Request = Act.MakeRequest(User.Data.UrlServer, Files.All[Item].Href, User.Data.Name, User.Data.Password);
             Request.Method = "MOVE";
             Request.Accept = "*/*";
             string NewName = User.Data.Hrefs.Last() + Name;
             if (Files.All[Item].ContentType == "d:collection")
             {
                 NewName += "/";
             }
             Request.Headers.Add("Destination: " + HttpUtility.UrlPathEncode(NewName));
             Act.GetResponse(Request);
             return(true);
         }
         catch (WebException ex)
         {
             if (GotMessage != null)
             {
                 GotMessage(ex.Message);
             }
             return(false);
         }
     }
     return(false);
 }
Example #4
0
 private void Paste(object it)
 {
     if (InterUser.CheckIntConnect())
     {
         int    index = (int)it;
         ReqRes Act   = new ReqRes();
         try
         {
             HttpWebRequest Request = Act.MakeRequest(InterUser.Data.UrlServer, InterFiles.CopyHref[index], InterUser.Data.Name, InterUser.Data.Password);
             Request.Method = "COPY";
             Request.Accept = "*/*";
             Request.Headers.Add("Destination: " + HttpUtility.UrlPathEncode(InterUser.Data.Hrefs.Last() + InterFiles.CopyName[index]));
             Act.GetResponse(Request);
         }
         catch (WebException ex)
         {
             if (GotMessage != null)
             {
                 GotMessage(ex.Message);
             }
         }
     }
     handle.Set();
 }
Example #5
0
 public void InfoFiles(ref Content Files, ref DataUser User, ref ListView ListFiles, string Folder, bool forward)
 {
     if (User.CheckIntConnect())
     {
         ReqRes Act = new ReqRes();
         try
         {
             HttpWebRequest Request = Act.MakeRequest(User.Data.UrlServer, Folder, User.Data.Name, User.Data.Password);
             Request.Accept = "*/*";
             Request.Headers.Add("Depth: 1");
             Request.Method = "PROPFIND";
             HttpWebResponse Response       = Act.GetResponseStream(Request);
             Stream          ResponseStream = Response.GetResponseStream();
             Files.All.Clear();
             ListFiles.Items.Clear();
             Files.SetInfoContent(ResponseStream, ref Files.All, ref ListFiles);
             ResponseStream.Close();
             Response.Close();
             if (forward)
             {
                 if (!User.Data.Hrefs.Contains(Folder))
                 {
                     User.Data.Hrefs.Add(Folder);
                 }
             }
             else
             {
                 User.Data.Hrefs.RemoveAt(User.Data.Hrefs.Count - 1);
             }
         }
         catch (WebException ex)
         {
             if (GotMessage != null)
             {
                 GotMessage(ex.Message);
             }
         }
     }
     else
     {
         if (GotMessage != null)
         {
             GotMessage("Вы не подключены к Интернету!");
         }
     }
 }
Example #6
0
        private void Connection(string UserName, string Password)
        {
            DataUser User = new DataUser();

            if (User.CheckIntConnect())
            {
                ReqRes         Act       = new ReqRes();
                string         UrlServer = "https://webdav.yandex.ru";
                HttpWebRequest Request   = Act.MakeRequest(UrlServer, "", UserName, Password);
                if (Request != null)
                {
                    Request.Accept = "*/*";
                    Request.Headers.Add("Depth: 1");
                    Request.Method = "PROPFIND";
                    Act.GetResponse(Request);
                    {
                        MainForm Main = new MainForm(UrlServer, UserName, Password, this);
                        Main.Show();
                        this.Hide();
                    }
                }
            }
        }