Exemplo n.º 1
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");
		}
Exemplo n.º 2
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");
     }
 }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
        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; //锁定题目获取按钮
                }

            }
        }
Exemplo n.º 6
0
 public bool FileStat(string key)
 {
     RSClient client = new RSClient();
     Entry entry = client.Stat(new EntryPath(Bucket, key));
     return entry.OK;
 }