public static int GetFyleTypeId(string fileTypeName) { var fileTypeId = RepositoryFileType.GetFileTypeIdByName(fileTypeName); if (fileTypeId == 0) { FileType fileTypeObj = new FileType(); fileTypeObj.Name = fileTypeName; fileTypeId = AddFileType(fileTypeObj); } return(fileTypeId); }
protected virtual Dictionary<string, string> CalcSums(RepositoryFileType type, bool ignoreDeleted = false) { var dir = type == RepositoryFileType.Pack ? PackFolder : Folder; var dic = new Dictionary<string, string>(); StatusRepo.ResetWithoutClearItems(RepoStatus.Verifying, StatusRepo.Total); var pv = type == RepositoryFileType.Pack ? PackVersion.Pack : PackVersion.WD; var done = new List<string>(); var files = Tools.FileUtil.OrderBySize(GetFiles(dir), true); if (MultiThreadingSettings.IsEnabled && MultiThreadingSettings.Checksums && (MultiThreadingSettings.MaxThreads2 > 1)) { if (ignoreDeleted) { foreach (var file in files) { if (!pv.ContainsKey(file)) { dic[file] = "__:DELETE:__"; done.Add(file); } } } } else { var i = 0; foreach (var file in files) { dic[file] = ignoreDeleted && !pv.ContainsKey(file) ? "__:DELETE:__" : RepoTools.TryGetChecksum(dir.GetChildFileWithName(file), file); i++; StatusRepo.UpdateProgress(i/(double) files.Length*100.0); } StatusRepo.Finish(); } return dic; }
protected virtual bool IncludeMatch(string key, RepositoryFileType type = RepositoryFileType.Wd) { if ((Config.Include == null) || !Config.Include.Any()) return true; return true; }
protected virtual string[][] CompareSums(RepositoryFileType type, int i) { var wd = type == RepositoryFileType.Wd ? WdVersion.WD : WdVersion.Pack; var pack = type == RepositoryFileType.Wd ? PackVersion.WD : PackVersion.Pack; var wdDc = RepoTools.DowncaseDictionary(wd); var packDc = RepoTools.DowncaseDictionary(pack); var removed = new List<string>(); var changed = new List<string>(); var added = new List<string>(); var unchanged = new List<string>(); foreach (var pair in pack) { if (!IncludeMatch(pair.Key, type)) continue; var dc = pair.Key.ToLower(); if (!wdDc.ContainsKey(dc)) { removed.Add(pair.Key); continue; } if (!wd.ContainsKey(pair.Key)) { changed.Add(pair.Key); continue; } if (!wdDc.ContainsKey(dc) || (wdDc[dc] != pair.Value)) { changed.Add(pair.Key); continue; } unchanged.Add(pair.Key); } foreach (var pair in wd) { if (!IncludeMatch(pair.Key, type)) continue; var dc = pair.Key.ToLower(); if (!packDc.ContainsKey(dc)) { added.Add(pair.Key); continue; } if (!pack.ContainsKey(pair.Key)) { added.Add(pair.Key); changed.Add(dc); } } return new[] { removed.Distinct().ToArray(), changed.Distinct().ToArray(), added.Distinct().ToArray(), unchanged.Distinct().ToArray() }; }
public static List <FileType> GetFileTypes() { return(RepositoryFileType.GetFileTypes()); }
public static int AddFileType(FileType fileType) { return(RepositoryFileType.SaveFileTypeInDb(fileType)); }