//删除选中的文件 private void toolStripMenuItem2_Click(object sender, EventArgs e) { System.Windows.Forms.DialogResult Temp = MessageBox.Show( "是否要在七牛云上永久删除选中的全部文件?删除后不可恢复,请谨慎操作。", "删除确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1 ); if (Temp == System.Windows.Forms.DialogResult.OK) { Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected); if (selectedRowCount > 0) { Byte[] TempBytes = System.Text.Encoding.UTF8.GetBytes("bucket"); My.CombineArray(ref TempBytes, System.Text.Encoding.ASCII.GetBytes("=")); My.CombineArray(ref TempBytes, System.Text.Encoding.UTF8.GetBytes(My.LoginedBuckets[ChosenButtomIndex].Name)); Int32 Temp2 = selectedRowCount; for (int i = 0; i < Temp2; i++) { if (dataGridView1.SelectedRows[i].Cells[0].Value != null) { My.CombineArray(ref TempBytes, System.Text.Encoding.ASCII.GetBytes("&")); My.CombineArray(ref TempBytes, System.Text.Encoding.UTF8.GetBytes("keys[]")); My.CombineArray(ref TempBytes, System.Text.Encoding.ASCII.GetBytes("=")); My.CombineArray(ref TempBytes, System.Text.Encoding.UTF8.GetBytes(dataGridView1.SelectedRows[i].Cells[0].Value.ToString())); } else { selectedRowCount = selectedRowCount - 1;//选中了末尾的空行 } } if (selectedRowCount > 0) { My.MainForm.label2.Text = "正在删除共计" + selectedRowCount + "个文件……"; My.MainForm.Refresh(); My.LoginForm.webBrowser1.Navigate( "https://portal.qiniu.com/bucket/moonlord/files/0/delete?bucket=" + My.LoginedBuckets[ChosenButtomIndex].Name, null, TempBytes, "Content-Type:application/x-www-form-urlencoded; charset=UTF-8\r\nReferer:https://portal.qiniu.com/bucket/\r\n" ); } } } }
//定时器进行登陆判定和跳转 private void timer1_Tick(object sender, EventArgs e) { if (webBrowser1.Url != null && webBrowser1.ReadyState == WebBrowserReadyState.Complete) { timer1.Enabled = false; //My.Show(webBrowser1.Document.Cookie); //My.Show(webBrowser1.DocumentText); if (webBrowser1.Url != null && webBrowser1.ReadyState == WebBrowserReadyState.Complete && webBrowser1.Url.ToString() == "https://portal.qiniu.com/") { if (My.Logined < 2) { this.Opacity = 0; this.ShowInTaskbar = false; My.Logined = 1; My.LoginedEmail = My.SeekCode(webBrowser1.DocumentText, "_mail = \"", "\";"); //My.Show(My.LoginEmail); webBrowser1.Navigate("https://portal.qiniu.com/api/rs/buckets"); } else { My.LoginForm.Opacity = 1; My.LoginForm.ShowInTaskbar = true; My.LoginForm.TopMost = true; My.LoginForm.BringToFront(); My.LoginForm.TopMost = false; } } if (webBrowser1.Url != null && webBrowser1.ReadyState == WebBrowserReadyState.Complete && webBrowser1.Url.ToString() == "https://portal.qiniu.com/api/rs/buckets") { Index = 0; string[] TempString = My.SeekCodeArray(webBrowser1.DocumentText, "\"", "\""); My.LoginedBuckets = new My.Buckets[TempString.Length]; for (int i = 0; i < TempString.Length; i++) { My.LoginedBuckets[i] = new My.Buckets(); My.LoginedBuckets[i].Name = TempString[i]; //My.Show(TempString[i]); } if (TempString.Length > Index) { Index = Index + 1; Byte[] TempBytes = System.Text.Encoding.UTF8.GetBytes("bucket"); My.CombineArray(ref TempBytes, System.Text.Encoding.ASCII.GetBytes("=")); My.CombineArray(ref TempBytes, System.Text.Encoding.UTF8.GetBytes(My.LoginedBuckets[Index - 1].Name)); webBrowser1.Navigate( "https://portal.qiniu.com/api/uc/bucketInfo?name=" + My.LoginedBuckets[Index - 1].Name, null, TempBytes, "Content-Type: application/x-www-form-urlencoded\r\nReferer:https://portal.qiniu.com/bucket/\r\n" ); } } if (webBrowser1.Url != null && webBrowser1.ReadyState == WebBrowserReadyState.Complete && webBrowser1.Url.ToString().Contains("https://portal.qiniu.com/api/uc/bucketInfo?name=")) { string TempName = webBrowser1.Url.ToString().Replace("https://portal.qiniu.com/api/uc/bucketInfo?name=", ""); for (int i = 0; i < My.LoginedBuckets.Length; i++) { if (My.LoginedBuckets[i].Name == TempName) { My.LoginedBuckets[i].Domain = My.SeekCodeArray(webBrowser1.DocumentText.Substring(webBrowser1.DocumentText.IndexOf("\"bind_domains\":") + 15), "\"", "\""); //My.Show(My.LoginedBuckets[i].Domain); //这里的My.Show会阻拦下面的代码执行,导致弹出N个对话框 break; } } if (My.LoginedBuckets.Length > Index) { Index = Index + 1; Byte[] TempBytes = System.Text.Encoding.UTF8.GetBytes("bucket"); My.CombineArray(ref TempBytes, System.Text.Encoding.ASCII.GetBytes("=")); My.CombineArray(ref TempBytes, System.Text.Encoding.UTF8.GetBytes(My.LoginedBuckets[Index - 1].Name)); webBrowser1.Navigate( "https://portal.qiniu.com/api/uc/bucketInfo?name=" + My.LoginedBuckets[Index - 1].Name, null, TempBytes, "Content-Type: application/x-www-form-urlencoded\r\nReferer:https://portal.qiniu.com/bucket/\r\n" ); } else { webBrowser1.Navigate("https://portal.qiniu.com/bucket/" + My.LoginedBuckets[0].Name + "/files?marker=" + "" + "&limit=" + My.MainForm.Limit + "&prefix=" + My.MainForm.Prefix); } } if (CheckGetFile() == true) { My.Logined = 2; webBrowser1.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted1); webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted2); } if (My.Logined < 2) { timer1.Enabled = true; } } }