private void Delete() { //1.获得表中选中的数据 if (dgResult.ItemsSource == null && dgResult.SelectedItems.Count <= 0) { return; } List <QiNiuFileInfo> list = new List <QiNiuFileInfo>(); foreach (var item in dgResult.SelectedItems) { QiNiuFileInfo info = (QiNiuFileInfo)item; if (info != null) { list.Add(info); } } if (list.Count > 0) { string msg = string.Join(",\r\n", list.Select(q => q.FileName)); MessageBoxResult confirmToDel = MessageBox.Show("确认要删除所选行吗?\r\n" + msg, "提示", MessageBoxButton.YesNo, MessageBoxImage.Question); if (confirmToDel != MessageBoxResult.Yes) { return; } //执行批量删除 List <string> ops = new List <string>(); foreach (var key in list) { string op = bucketManager.DeleteOp(bucket, key.FileName); ops.Add(op); } BatchResult ret = bucketManager.Batch(ops); StringBuilder sb = new StringBuilder(); if (ret.Code / 100 != 2) { MessageBox.Show("批量删除error: " + ret.ToString()); return; } MessageBox.Show("批量删除成功!"); Search(); Thread.Sleep(10); } }
public void BatchStatTest() { BatchCopyTest(); Config config = new Config(); config.Zone = Zone.ZONE_CN_East; //config.Region = Region.Region_CN_East; Mac mac = new Mac(AccessKey, SecretKey); BucketManager bucketManager = new BucketManager(mac, config); string[] keys = { "qiniu-0.png", "qiniu-1.png", "qiniu-2.png" }; List <string> ops = new List <string>(); foreach (string key in keys) { string op = bucketManager.StatOp(Bucket, key); ops.Add(op); } BatchResult ret = bucketManager.Batch(ops); if (ret.Code / 100 != 2) { Assert.Fail("batch error: " + ret.ToString()); } foreach (BatchInfo info in ret.Result) { if (info.Code == (int)HttpCode.OK) { Console.WriteLine("{0}, {1}, {2}, {3}, {4}", info.Data.MimeType, info.Data.PutTime, info.Data.Hash, info.Data.Fsize, info.Data.FileType); } else { Console.WriteLine(info.Data.Error); } } }
public void BatchDeleteAfterDaysTest() { BatchCopyTest(); Config config = new Config(); config.Zone = Zone.ZONE_CN_East; //config.Region = Region.Region_CN_East; Mac mac = new Mac(AccessKey, SecretKey); BucketManager bucketManager = new BucketManager(mac, config); string[] keys = { "qiniu-0.png", "qiniu-1.png", "qiniu-2.png" }; List <string> ops = new List <string>(); foreach (string key in keys) { string op = bucketManager.DeleteAfterDaysOp(Bucket, key, 7); ops.Add(op); } BatchResult ret = bucketManager.Batch(ops); if (ret.Code / 100 != 2) { Assert.Fail("batch error: " + ret.ToString()); } foreach (BatchInfo info in ret.Result) { if (info.Code == (int)HttpCode.OK) { Console.WriteLine("deleteAfterDays success"); } else { Console.WriteLine(info.Data.Error); } } }
private void Delete() { //1.获得表中选中的数据 if (dgResult.ItemsSource == null && dgResult.SelectedItems.Count <= 0) { return; } List <QiNiuFileInfo> list = new List <QiNiuFileInfo>(); foreach (var item in dgResult.SelectedItems) { QiNiuFileInfo info = (QiNiuFileInfo)item; if (info != null) { list.Add(info); } } if (list.Count > 0) { //执行批量删除 List <string> ops = new List <string>(); foreach (var key in list) { string op = bucketManager.DeleteOp(bucket, key.FileName); ops.Add(op); } BatchResult ret = bucketManager.Batch(ops); StringBuilder sb = new StringBuilder(); if (ret.Code / 100 != 2) { MessageBox.Show("批量删除error: " + ret.ToString()); return; } MessageBox.Show("批量删除成功!"); Search(); Thread.Sleep(10); } }