private static void UpdateRefreshUi(int jobId = 0) { Random ran = new Random(); Parallel.ForEach(models, new ParallelOptions { MaxDegreeOfParallelism = 5 }, rm => { RemoteScanMag entity = new RemoteScanMag(); entity.JobId = jobId; Console.WriteLine("处理 --> " + rm.Name + models.IndexOf(rm) + "/" + models.Count); var matchFiles = new EverythingHelper().SearchFile(rm.Id + " | " + rm.Id.Replace("-", ""), EverythingSearchEnum.Video); var list = MagService.SearchSukebei(rm.Id); if (list != null && list.Count > 0) { ScanDataBaseManager.DeleteMagUrlById(rm.Id); if (matchFiles.Count > 0) { entity.SearchStatus = 2; entity.MatchFile = matchFiles.FirstOrDefault(x => x.Length == matchFiles.Max(y => y.Length)).FullName; } else { entity.SearchStatus = 1; } foreach (var seed in list) { entity.AvId = rm.Id; entity.AvName = FileUtility.ReplaceInvalidChar(rm.Name); entity.AvUrl = rm.Url; entity.MagDate = seed.Date; entity.MagSize = seed.Size; entity.MagTitle = FileUtility.ReplaceInvalidChar(seed.Title); entity.MagUrl = seed.MagUrl; //entity.SearchStatus = 1; ScanDataBaseManager.InsertRemoteScanMag(entity); } } else { Console.WriteLine("没搜到"); entity.SearchStatus = 0; } Thread.Sleep(10 * ran.Next(5)); }); }