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); } }
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); } } } } }
public void StartRename(ListView ListFiles, DataUser User, Content Files, bool DoubleClick) { if (ListFiles.SelectedIndices.Count == 1) { int index = ListFiles.SelectedItems[0].Index; if (Files.All[index].ContentType == "d:collection") { if (User.Data.Hrefs.Last() != Files.All[index].Href) { if (DoubleClick) { User.InfoFiles(ref Files, ref User, ref ListFiles, Files.All[index].Href, true); } else { ListFiles.SelectedItems[0].BeginEdit(); } } } else { ListFiles.SelectedItems[0].BeginEdit(); } } }
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); }
public MainForm(string Url, string Name, string Password, Form Log) { InitializeComponent(); MakeMenu(); User = new DataUser(); User.GotMessage += GetMessage; User.FillData(Url, Name, Password, "/", Log); User.InfoFiles(ref Files, ref User, ref ListFiles, User.Data.Hrefs.Last(), true); }
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("Вы не подключены к Интернету!"); } } }
public void EndRename(ref Content Files, ref DataUser User, ref ListView ListFiles, LabelEditEventArgs e) { if (CheckName(e.Label, Files)) { if (!MakeNewName(User, e.Item, e.Label, Files)) { e.CancelEdit = true; } else { User.InfoFiles(ref Files, ref User, ref ListFiles, User.Data.Hrefs.Last(), true); } } else { e.CancelEdit = true; } }
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(); } } } }