예제 #1
0
        public async static Task RefreshOneOneFiveFinFilesCache()
        {
            NoticeService.SendBarkNotice(SettingService.GetSetting().Result.BarkId, $"开始更新115文件缓存");
            var startTime = DateTime.Now;

            var ret = await Get115AllFilesModel(OneOneFiveFolder.Fin, OneOneFiveSearchType.Video);

            RedisService.DeleteHash("115", "allfiles");

            RedisService.SetHash("115", "allfiles", JsonConvert.SerializeObject(ret));

            NoticeService.SendBarkNotice(SettingService.GetSetting().Result.BarkId, $"更新115文件缓存结束,更新了 {ret.Count} 条,耗时 {(DateTime.Now - startTime).TotalSeconds} 秒");
        }
예제 #2
0
        private async static Task <Dictionary <int, List <MyFileInfo> > > GenerateExistingAVs(List <AvModel> avs)
        {
            Dictionary <int, List <MyFileInfo> > fileContainer = new Dictionary <int, List <MyFileInfo> >();
            var oneOneFiveFiles = JsonConvert.DeserializeObject <List <OneOneFiveFileItemModel> >(RedisService.GetHash("115", "allfiles"));

            foreach (var file in oneOneFiveFiles)
            {
                Console.WriteLine(file.n);

                if (file.n.Split('-').Length >= 3)
                {
                    file.AvId   = file.n.Split('-')[0] + "-" + file.n.Split('-')[1];
                    file.AvName = file.n.Replace(file.AvId, "").Substring(1).Replace("." + file.ico, "").Replace("-C", "");
                }

                var match = avs.FirstOrDefault(x => x.Name == file.AvName);

                if (match != null)
                {
                    if (fileContainer.ContainsKey(match.Id))
                    {
                        fileContainer[match.Id].Add(new MyFileInfo()
                        {
                            Extension = "." + file.ico,
                            FullName  = file.n,
                            Length    = file.s,
                            Name      = file.n
                        });
                    }
                    else
                    {
                        fileContainer.Add(match.Id, new List <MyFileInfo> {
                            new MyFileInfo()
                            {
                                Extension = "." + file.ico,
                                FullName  = file.n,
                                Length    = file.s,
                                Name      = file.n
                            }
                        });
                    }
                }
            }

            return(fileContainer);
        }
예제 #3
0
        public async static Task UpdateKeepAvs()
        {
            var drivers         = Environment.GetLogicalDrives();
            var oneOneFiveFiles = JsonConvert.DeserializeObject <List <OneOneFiveFileItemModel> >(RedisService.GetHash("115", "allfiles"));

            foreach (var driver in drivers)
            {
                if (Directory.Exists(driver + "keep\\"))
                {
                    var files = new DirectoryInfo(driver + "keep\\").GetFiles();

                    foreach (var file in files)
                    {
                        var wangPanFiles = oneOneFiveFiles.Where(x => x.n.Contains(file.Name.Split('-')[0] + "-" + file.Name.Split('-')[1], StringComparison.OrdinalIgnoreCase)).ToList();

                        if (file.Name.Contains("-C."))
                        {
                            if (wangPanFiles.Exists(x => x.s > file.Length && x.n.Contains("-C.", StringComparison.OrdinalIgnoreCase)))
                            {
                                await Copy(wangPanFiles.Where(x => x.s > file.Length && x.n.Contains("-C.", StringComparison.OrdinalIgnoreCase)).Select(x => x.fid).ToList(), OneOneFiveFolder.MoveBackToLocal);
                            }
                        }
                        else
                        {
                            if (wangPanFiles.Exists(x => x.s > file.Length))
                            {
                                await Copy(wangPanFiles.Where(x => x.s > file.Length).Select(x => x.fid).ToList(), OneOneFiveFolder.MoveBackToLocal);
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
        public async static Task MoveNeedToUpload115AvsBackToFin()
        {
            var drivers = Environment.GetLogicalDrives();

            await RefreshOneOneFiveFinFilesCache();

            var oneOneFiveFiles = JsonConvert.DeserializeObject <List <OneOneFiveFileItemModel> >(RedisService.GetHash("115", "allfiles"));
            Dictionary <string, List <string> > uplpadFilesDic = new();

            foreach (var driver in drivers)
            {
                if (Directory.Exists(driver + "upload115\\") && Directory.Exists(driver + "fin\\"))
                {
                    var files = new DirectoryInfo(driver + "upload115\\").GetFiles("*.*", new EnumerationOptions {
                        RecurseSubdirectories = true
                    });

                    foreach (var file in files)
                    {
                        if (oneOneFiveFiles.FirstOrDefault(x => x.n.Equals(file.Name, StringComparison.OrdinalIgnoreCase) && x.s == file.Length) != null)
                        {
                            if (uplpadFilesDic.ContainsKey(driver + "fin\\"))
                            {
                                uplpadFilesDic[driver + "fin\\"].Add(file.FullName);
                            }
                            else
                            {
                                uplpadFilesDic.Add(driver + "fin\\", new List <string> {
                                    file.FullName
                                });
                            }
                        }
                    }

                    if (uplpadFilesDic.ContainsKey(driver + "fin\\"))
                    {
                        FileUtility.TransferFileUsingSystem(uplpadFilesDic[driver + "fin\\"], driver + "fin\\", true, false);
                    }

                    foreach (var subFolder in new DirectoryInfo(driver + "upload115\\").GetDirectories())
                    {
                        if (subFolder.GetFiles().Length == 0)
                        {
                            subFolder.Delete();
                        }
                    }
                }
            }
        }
예제 #5
0
        public static string GetNeedToUpload115Avs()
        {
            var ret = "";

            var drivers         = Environment.GetLogicalDrives();
            var oneOneFiveFiles = JsonConvert.DeserializeObject <List <OneOneFiveFileItemModel> >(RedisService.GetHash("115", "allfiles"));
            Dictionary <string, List <string> > uplpadFilesDic = new();

            try
            {
                foreach (var driver in drivers)
                {
                    if (Directory.Exists(driver + "fin\\"))
                    {
                        if (!Directory.Exists(driver + "upload115\\"))
                        {
                            Directory.CreateDirectory(driver + "upload115\\");
                        }

                        var files = new DirectoryInfo(driver + "fin\\").GetFiles();

                        foreach (var file in files)
                        {
                            if (oneOneFiveFiles.FirstOrDefault(x => x.n.Equals(file.Name, StringComparison.OrdinalIgnoreCase) && x.s == file.Length) == null)
                            {
                                if (uplpadFilesDic.ContainsKey(driver + "upload115\\"))
                                {
                                    uplpadFilesDic[driver + "upload115\\"].Add(file.FullName);
                                }
                                else
                                {
                                    uplpadFilesDic.Add(driver + "upload115\\", new List <string> {
                                        file.FullName
                                    });
                                }
                            }
                        }

                        if (uplpadFilesDic.ContainsKey(driver + "upload115\\") && uplpadFilesDic[driver + "upload115\\"] != null && uplpadFilesDic[driver + "upload115\\"].Count > 0)
                        {
                            var pageSize = uplpadFilesDic[driver + "upload115\\"].Count % 5 == 0 ? uplpadFilesDic[driver + "upload115\\"].Count / 5 : (uplpadFilesDic[driver + "upload115\\"].Count % 5) + 1;
                            var contiune = true;
                            int index    = 1;
                            int page     = 0;
                            while (contiune)
                            {
                                var tempFolder = driver + "upload115\\" + driver.Replace("\\", "").Replace(":", "") + "-" + DateTime.Today.ToString("yyyyMMdd") + "-" + index++;
                                Directory.CreateDirectory(tempFolder);
                                FileUtility.TransferFileUsingSystem(uplpadFilesDic[driver + "upload115\\"].Skip(page++ *pageSize).Take(pageSize).ToList(), tempFolder, true, false);

                                if (page == 5)
                                {
                                    contiune = false;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ee)
            {
                ret = ee.ToString();
            }

            ret = $"共移动{uplpadFilesDic.Values.Count}个文件";

            return(ret);
        }