예제 #1
0
 public static void RSDel(string bucket,string key)
 {
     RSClient target = new RSClient(); // TODO: 初始化为适当的值
     EntryPath scope = new EntryPath(bucket,key); // TODO: 初始化为适当的值
     CallRet actual;
     actual = target.Delete(scope);
 }
예제 #2
0
        public static bool Delete(string bucket_name, string key)
        {
            //实例化一个RSClient对象,用于操作BucketManager里面的方法
            RSClient client = new RSClient();
            CallRet ret = client.Delete(new EntryPath(bucket_name, key));

            return ret.OK;
        }
예제 #3
0
		public void StatTest()
		{
			RSClient target = new RSClient();
			//YES
		
			EntryPath scope = new EntryPath(Bucket, tmpKeys[0]); 
			Entry actual;
			actual = target.Stat(scope);
			Assert.IsTrue(actual.OK, "StatTest Failure");
		}
예제 #4
0
        public int DeleteAttachment(string key)
        {
            Config.Init();
            String bucket = System.Configuration.ConfigurationManager.AppSettings["QN-Bucket"] ?? "zngc-intfactory";
            //实例化一个RSClient对象,用于操作BucketManager里面的方法
            RSClient client = new RSClient();
            CallRet ret = client.Delete(new EntryPath(bucket, key));

            return ret.OK ? 1 : 0;
        }
예제 #5
0
파일: QiniuSDK.cs 프로젝트: doscanner/GF
 public static void BatchMove(string bucket, string[] keys)
 {
     List<EntryPathPair> pairs = new List<EntryPathPair>();
     foreach (string key in keys)
     {
         EntryPathPair entry = new EntryPathPair(bucket, key, Guid.NewGuid().ToString());
         pairs.Add(entry);
     }
     RSClient client = new RSClient();
     client.BatchMove(pairs.ToArray());
 }
예제 #6
0
파일: QiniuSDK.cs 프로젝트: doscanner/GF
 //批量操作
 public static void BatchStat(string bucket, string[] keys)
 {
     RSClient client = new RSClient();
     List<EntryPath> EntryPaths = new List<EntryPath>();
     foreach (string key in keys)
     {
         Console.WriteLine("\n===> Stat {0}:{1}", bucket, key);
         EntryPaths.Add(new EntryPath(bucket, key));
     }
     client.BatchStat(EntryPaths.ToArray());
 }
예제 #7
0
파일: QiniuSDK.cs 프로젝트: doscanner/GF
 /// <summary>
 /// 复制单个文件
 /// </summary>
 /// <param name="bucketSrc">需要复制的文件所在的空间名</param>
 /// <param name="keySrc">需要复制的文件key</param>
 /// <param name="bucketDest">目标文件所在的空间名</param>
 /// <param name="keyDest">标文件key</param>
 public static void Copy(string bucketSrc, string keySrc, string bucketDest, string keyDest)
 {
     RSClient client = new RSClient();
     CallRet ret = client.Copy(new EntryPathPair(bucketSrc, keySrc, bucketDest, keyDest));
     if (ret.OK)
     {
         Console.WriteLine("Copy OK");
     }
     else
     {
         Console.WriteLine("Failed to Copy");
     }
 }
예제 #8
0
		public void MoveTest()
		{

			RSClient target = new RSClient(); // TODO: 初始化为适当的值
			string key = NewKey;
			EntryPathPair pathPair = new EntryPathPair(Bucket, tmpKeys[0], key); ; // TODO: 初始化为适当的值
			CallRet actual;
			//YES
			actual = target.Move(pathPair);
			if (actual.OK) {
				tmpKeys [0] = key;
			}
			Assert.IsTrue(actual.OK, "MoveTest Failure");          
		}
예제 #9
0
        public void BatchCopyTest()
        {
            RSClient target = new RSClient(); // TODO: 初始化为适当的值

            EntryPathPair[] entryPathPairs = new EntryPathPair[2]; // TODO: 初始化为适当的值
            string tmpKey = NewKey;
            string tmpKey2 = NewKey;
            entryPathPairs[0] = new EntryPathPair(Bucket, tmpKeys[0], tmpKey);
            entryPathPairs[1] = new EntryPathPair(Bucket, tmpKeys[1], tmpKey2);
            CallRet actual;
            actual = target.BatchCopy(entryPathPairs);
            if (actual.OK) {
                RSHelper.RSDel (Bucket, tmpKey);
                RSHelper.RSDel (Bucket, tmpKey2);
            }
            Assert.IsTrue(actual.OK, "BatchStatTest Failure"); ;
        }
예제 #10
0
 /// <summary>
 /// 查看单个文件属性信息
 /// </summary>
 /// <param name="bucket">七牛云存储空间名</param>
 /// <param name="key">文件key</param>
 public static void Stat(string bucket, string key)
 {
     RSClient client = new RSClient();
     Entry entry = client.Stat(new EntryPath(bucket, key));
     if(entry.OK)
     {
         Console.WriteLine("Hash: " + entry.Hash);
         Console.WriteLine("Fsize: " + entry.Fsize);
         Console.WriteLine("PutTime: " + entry.PutTime);
         Console.WriteLine("MimeType: " + entry.MimeType);
         Console.WriteLine("Customer: " + entry.Customer);
     }
     else
     {
         Console.WriteLine("Failed to Stat");
     }
 }
예제 #11
0
 private void button1_Click(object sender, EventArgs e)
 {
     label5.Visible = false;
     label6.Visible = false;
     Console.WriteLine("\n===> Move {0}:{1} To {2}:{3}",
             textBox1.Text.ToString().Trim(), textBox2.Text.ToString().Trim(), textBox3.Text.ToString().Trim(), textBox4.Text.ToString().Trim());
     RSClient client = new RSClient();
     new EntryPathPair(textBox1.Text.ToString().Trim(), textBox2.Text.ToString().Trim(), textBox3.Text.ToString().Trim(), textBox4.Text.ToString().Trim());
     CallRet ret = client.Move(new EntryPathPair(textBox1.Text.ToString().Trim(), textBox2.Text.ToString().Trim(), textBox3.Text.ToString().Trim(), textBox4.Text.ToString().Trim()));
     if (ret.OK)
     {
         label5.Visible=true;
     }
     else
     {
         label6.Visible = true;
     }
 }
예제 #12
0
        public void BatchDeleteTest()
        {
            List<string> tmps = RSHelper.RSPut(Bucket,2);

            RSClient target = new RSClient(); // TODO: 初始化为适当的值
            EntryPath[] keys = new EntryPath[2]; // TODO: 初始化为适当的值
            int i = 0;
            foreach (string k in tmps) {
                keys [i++] = new EntryPath (Bucket, k);
            }

            CallRet actual;
            actual = target.BatchDelete(keys);
            if (actual.OK) {
                foreach (string k in tmps) {
                    RSHelper.RSDel(Bucket,k);
                }
            }
            Assert.IsTrue(actual.OK, "BatchStatTest Failure"); ;
        }
예제 #13
0
 public bool Delete(string key)
 {
     RSClient client = new RSClient();
     CallRet ret = client.Delete(new EntryPath(Bucket, key));
     if(ret.OK)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
예제 #14
0
 public void CopyTest()
 {
     RSClient target = new RSClient(); // TODO: 初始化为适当的值
     string key = NewKey;
     EntryPathPair pathPair = new EntryPathPair(Bucket, tmpKeys[0], key); // TODO: 初始化为适当的值
     CallRet actual;
     actual = target.Copy(pathPair);
     if (actual.OK) {
         RSHelper.RSDel (Bucket, key);
     }
     Assert.IsTrue(actual.OK, "CopyTest Failure");
 }
예제 #15
0
        // 全局更新检查线程
        private void GlobalUpdateCheck()
        {
            // 检查更新
            RedrawStatusText("正在检查更新...");

            try
            {
                WebClient wb = new WebClient { Proxy = null };
                wb.Headers.Add("Cache-Control", "no-cache");
                var dict =
                    JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(
                        wb.DownloadString("https://raw.github.com/Unknwon/qiniudrive/master/VERSION.json"));
                if (UPDATE_VERSION < (int)dict["version"])
                {
                    CharmMessageBox msgbox = new CharmMessageBox();
                    DialogResult result = msgbox.Show("尊敬的用户您好:\n\n" +
                        "感谢您使用 " + APP_NAME + ",更高版本已经发布。\n\n" +
                        "为了获得更好的用户体验,建议您立即更新!\n\n" +
                        "请到 github.com/Unknwon/qiniudrive 获取最新下载地址。\n\n" +
                        "或单击 是 自动跳转到下载页面。",
                        "版本升级", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                        Process.Start(dict["download_url"]);
                }
            }
            catch (Exception e)
            {
                CharmMessageBox msgbox = new CharmMessageBox();
                msgbox.Show("检查更新失败:\n\n" +
                            e.Message,
                            "错误提示", MessageBoxButtons.OK, CharmMessageBoxIcon.Error);
            }

            // 初始化七牛服务
            mRsfClient = new RSFClient(mBucket);
            mRsClient = new RSClient();
            mServerFileList = new List<SyncFile>();
            mLocalFileList = new List<SyncFile>();
            mLocalFileCache = new List<string>();
            mChangeFileList = new List<ChangeFile>();

            // 检查授权及其它设置
            VerifyAuth();
            RedrawStatusText("正在连接服务器...");

            mIsUpdateChecked = true;

            int count = 0;

            while (true)
            {
            #if(!DEBUG)
            //内存释放
                Process proc = Process.GetCurrentProcess();
                proc.MaxWorkingSet = Process.GetCurrentProcess().MaxWorkingSet;
                proc.Dispose();
            #endif
                if (((mSyncCycle != 0 && count % mSyncCycle == 0) || mIsSyncNow) &&
                    mIsVaildKeys && mIsVaildBucket && mIsVaildSyncDir)
                {
                    count = 0;
                    mIsSyncing = true;
                    Sync();
                    mIsSyncNow = false;
                    mIsSyncing = false;
                    mServerFileList.Clear();
                    mLocalFileList.Clear();
                }

                // 检查是否需要验证授权
                if (mIsNeedVerifyAuth)
                {
                    mIsNeedVerifyAuth = false;
                    VerifyAuth();
                    RedrawStatusText("等待同步");
                }

                count++;
                Thread.Sleep(1000);
            }
            // ReSharper disable once FunctionNeverReturns
        }
예제 #16
0
파일: QiniuSDK.cs 프로젝트: doscanner/GF
 /// <summary>
 /// 删除单个文件
 /// </summary>
 /// <param name="bucket">文件所在的空间名</param>
 /// <param name="key">文件key</param>
 public static void Delete(string bucket, string key)
 {
     Console.WriteLine("\n===> Delete {0}:{1}", bucket, key);
     RSClient client = new RSClient();
     CallRet ret = client.Delete(new EntryPath(bucket, key));
     if (ret.OK)
     {
         Console.WriteLine("Delete OK");
     }
     else
     {
         Console.WriteLine("Failed to delete");
     }
 }
예제 #17
0
 public void BatchStatTest()
 {
     RSClient target = new RSClient(); // TODO: 初始化为适当的值
     EntryPath[] keys = new EntryPath[2]; // TODO: 初始化为适当的值
     keys[0] = new EntryPath(Bucket, tmpKeys[0]);
     keys[1] = new EntryPath(Bucket, tmpKeys[1]);//error params
     List<BatchRetItem> actual;
     actual = target.BatchStat(keys);
     Assert.IsTrue(actual.Count == 2, "BatchStatTest Failure");
 }
예제 #18
0
파일: Main.cs 프로젝트: icorer/CodesJudge
        private void skinButton1_Click(object sender, EventArgs e)
        {
            if (Text_JudgeId.Text != "")
            {
                problemId = Text_JudgeId.Text;
                //MessageBox.Show(problemId);
                CloudInit();
                RSClient client = new RSClient();
                problemJudgeInfo = "data/" + problemId + ".info";
                problemJudgeDate = "data/" + problemId + ".data";
                //MessageBox.Show(problemJudgeInfo);
                //MessageBox.Show(problemJudgeDate);
                Entry CloudJudgeInfoEntry = client.Stat(new EntryPath(Cloud_bucket, problemJudgeInfo));
               // Entry CloudJudgeDataEntry = client.Stat(new EntryPath(Cloud_bucket, problemJudgeDate)); //创建data检测

                if (Cloud_type&&!(CloudJudgeInfoEntry.OK))// 如果七牛云 而且七牛云数据不存在
                {
                    MessageBox.Show("云端不存在此序号的题目信息!","操作提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
                }
                else if ((!Cloud_type) && (CheckCloudFileExist(CloudScriptUrl+"?problemid="+problemId.ToString()) != 3)) //如果是私有云 而且数据不完全存在
                {
                   // MessageBox.Show(CloudScriptUrl + "?problemid=" + problemId.ToString());
                    MessageBox.Show("私有云不存在此序号的完整题目信息!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    //创建题目目录
                    Text_Judge_id.Text = problemId;
                    ProblemDir = RootDir + problemId;
                    if (!Directory.Exists(ProblemDir))
                        Directory.CreateDirectory(ProblemDir);
                    //下载资源文件
                    judgeInfoLocation = ProblemDir + "\\" + problemId + ".info";
                    judgeDataLocation = ProblemDir + "\\" + problemId + ".data";

                    //清理旧的题目INFO DATA数据
                    if (File.Exists(judgeInfoLocation))
                        File.Delete(judgeInfoLocation);
                    if (File.Exists(judgeDataLocation))
                        File.Delete(judgeDataLocation);

                    WebClient wc1 = new WebClient(); //info
                    wc1.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc1_DownloadProgressChanged);
                    wc1.DownloadFileCompleted += new AsyncCompletedEventHandler(wc1_DownloadFileCompleted);
                    wc1.DownloadFileAsync(new Uri(urlLocation + problemJudgeInfo), judgeInfoLocation);//下载题目评测要求到目录

                    // skinButton1.Enabled = false; //锁定题目获取按钮
                }

            }
        }
예제 #19
0
파일: QiniuFile.cs 프로젝트: cposture/QiPIC
 private bool GetFileInfo(string filename, out Entry entry)
 {
     //实例化一个RSClient对象,用于操作BucketManager里面的方法
     RSClient client = new RSClient();
     //调用Stat方法获取文件的信息
     entry = client.Stat(new EntryPath(m_qiniuconf.bucketname, filename));
     return entry.OK;
 }
예제 #20
0
파일: Judge.cs 프로젝트: icorer/CodesJudge
        void downloadDataFile()
        {
            // MessageBox.Show(JudgeStdFile);
            //MessageBox.Show(CloudDataUrl);
            //必须要进行云端文件判断 才能构成评测独立模块
            Qiniu.Conf.Config.ACCESS_KEY = QiniuAK;
            Qiniu.Conf.Config.SECRET_KEY = QiniuSK;
            String bucket = "codejudge";
            String bucketFileName = "data/" + Problem_ID + ".dat";
            RSClient client = new RSClient();
            Entry CloudJudgeInfoEntry = client.Stat(new EntryPath(bucket, bucketFileName));

            if (Cloud_type&&CloudJudgeInfoEntry.OK) //如果云端文件存在 且为 七牛云
            {
                WebClient wc1 = new WebClient();
                wc1.DownloadFileCompleted += new AsyncCompletedEventHandler(wc1_DownloadFileCompleted);
                wc1.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc1_DownloadProgressChanged);
                wc1.DownloadFileAsync(new Uri(CloudDataUrl), JudgeStdFile);
            }
            else if ((!Cloud_type) && (CheckCloudFileExist(CloudScriptUrl + "?problemid=" + Problem_ID.ToString()) == 3))
            {
              //  MessageBox.Show(CloudDataUrl);
                WebClient wc1 = new WebClient();
                wc1.DownloadFileCompleted += new AsyncCompletedEventHandler(wc1_DownloadFileCompleted);
                wc1.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc1_DownloadProgressChanged);
                wc1.DownloadFileAsync(new Uri(CloudDataUrl), JudgeStdFile);
            }
            else
            {  //云端无文件
                pictureBox6.Image = Image.FromFile("./res_pic/error.png");
                toolStripStatusLabel2.Text = "云端不存在此题号文件...";
                MessageBox.Show("云端不存在此序号的评测数据\n请与管理员联系!\n电子邮箱:[email protected]", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #21
0
파일: QiniuSDK.cs 프로젝트: doscanner/GF
 /// <summary>
 /// 移动单个文件
 /// </summary>
 /// <param name="bucketSrc">需要移动的文件所在的空间名</param>
 /// <param name="keySrc">需要移动的文件</param>
 /// <param name="bucketDest">目标文件所在的空间名</param>
 /// <param name="keyDest">目标文件key</param>
 public static void Move(string bucketSrc, string keySrc, string bucketDest, string keyDest)
 {
     Console.WriteLine("\n===> Move {0}:{1} To {2}:{3}",
     bucketSrc, keySrc, bucketDest, keyDest);
     RSClient client = new RSClient();
     new EntryPathPair(bucketSrc, keySrc, bucketDest, keyDest);
     CallRet ret = client.Move(new EntryPathPair(bucketSrc, keySrc, bucketDest, keyDest));
     if (ret.OK)
     {
         Console.WriteLine("Move OK");
     }
     else
     {
         Console.WriteLine("Failed to Move");
     }
 }
예제 #22
0
 public bool FileStat(string key)
 {
     RSClient client = new RSClient();
     Entry entry = client.Stat(new EntryPath(Bucket, key));
     return entry.OK;
 }