Esempio n. 1
0
        private void MD5Check(FileListItem item)
        {
            IMD5Checker checker = md5CheckerList.Where(q => q.State == 0).FirstOrDefault();

            if (checker == null)
            {
                checker = new IMD5Checker(item.ID);
                checker.AsyncCheckProgress += Checker_AsyncCheckProgress;
                lock (md5CheckerList) { md5CheckerList.Add(checker); }
            }
            else
            {
                checker.ID       = item.ID;
                checker.State    = 1;
                checker.Progress = 0;
            }

            double length = Math.Ceiling(item.FileSize / 1024.0);

            if (length < 1024 * 500)
            {
                string md5Str = checker.MD5Checker.Check(item.FileSource);
                ServerMD5Check(item.ID, md5Str);
            }
            else
            {
                //文件大于500M则启动异步验算
                checker.MD5Checker.AsyncCheck(item.FileSource);
            }
        }
Esempio n. 2
0
 private void Checker_AsyncCheckProgress(IMD5Checker sender, AsyncCheckEventArgs e)
 {
     if (e.State == AsyncCheckState.Checking)
     {
         double pro = Convert.ToDouble(e.Value);
         if (pro - sender.Progress < 1)
         {
             return;
         }
         sender.Progress = pro;
         FileListItem control = uploadList.Where(q => q.ID.Equals(sender.ID)).FirstOrDefault();
         if (control == null)
         {
             return;
         }
         SetFileItemMsg(control, "校验文件中,进度:" + pro + "%");
     }
     else
     {
         ServerMD5Check(sender.ID, e.Value);
     }
 }