private Dictionary <string, string> GetCache(string md5Key) { Dictionary <string, string> cache = new Dictionary <string, string>(); string root = SystemConsole.GetInputStr("输入原始目录获取md5对应关系:"); var folder = Path.GetFileName(root); if (folder != "app") { Console.WriteLine("文件夹选择错误,必须以/app结尾"); return(cache); } root += root.EndsWith("\\") ? "" : "\\"; var files = Directory.GetFiles(root, "*.*", SearchOption.AllDirectories) .Select(p => p.Replace(root, "").Replace("\\", "/")) .Where(p => Path.GetFileNameWithoutExtension(p).Length != 32) .ToList(); files.ForEach((file, i, count) => { Console.WriteLine("路径关系获取中..." + ((float)i / count).ToString("P") + "\t" + file); var path = file; var dirName = Path.GetDirectoryName(path).Replace("\\", "/"); var fileName = Path.GetFileName(path); var newPath = dirName.MD5(md5Key) + "/" + fileName.MD5(md5Key); cache[newPath] = file; }); return(cache); }
protected List <string> GetPaths(string extension = ".txt") { extension = Path.GetExtension(extension); var path = SystemConsole.GetInputStr("请拖入选定(文件夹或文件):"); List <string> res = new List <string>(); if (Directory.Exists(path)) { var newPath = Path.ChangeExtension(path, extension); if (File.Exists(newPath)) { res.Add(newPath); } else { res.AddRange(Directory.GetFiles(path, "*" + extension, SearchOption.AllDirectories)); } } else { if (File.Exists(path) && Path.GetExtension(path) == extension) { res.Add(path); } } return(res); }
public ReadCsv() { var path = SystemConsole.GetInputStr("请输入剧情CSV目录:", def: @"D:\Work\yuege\www\assets\res\scenario"); var files = Directory.GetFiles(path, "*.txt").ToList(); files.Sort(); JsonData res = new JsonData(); foreach (string file in files) { Console.WriteLine(file); var text = File.ReadAllText(file, Encoding.UTF8); JsonData jsonData = ConvertCSVToTreeData(text); foreach (JsonData data in jsonData) { var xx = new JsonData(); xx["file"] = Path.GetFileNameWithoutExtension(file); foreach (var key in data.Keys) { if (key != "") { xx[key] = data[key]; } } res.Add(xx); } } File.WriteAllText("scenario.txt", JsonHelper.ToJson(res)); string outpath = Environment.CurrentDirectory + "/scenario.xlsx"; ExcelUtils.ExportToExcel(((ListTable)res).ToDataTable(), outpath); }
private static void Main(string[] args) { Cmd1 = SystemConsole.GetInputStr("1:down\n2:md5还原与解密\nInput:"); FromExcel = SystemConsole.GetInputStr("1:来自excel\n2:来自json\nInput:"); root = SystemConsole.GetInputStr("输入文件目录:"); Dictionary <string, JsonData> cacheMaster = CacheJson("c_master").ToDictionary(p => "master/" + p.Key, q => q.Value); Dictionary <string, JsonData> cacheRresource = CacheJson("c_resource");//.Where(p => p.Key.Contains("unity")).ToDictionary(p => p.Key, q => q.Value); FileHelper.CreateDirectory("log/"); if (File.Exists("log/overList.txt")) { File.Delete("log/overList.txt"); } if (File.Exists("log/errList.txt")) { File.Delete("log/errList.txt"); } cacheRresource.Concat(cacheMaster) .ToDictionary(p => p.Key, q => q.Value) .AsParallel() .WithDegreeOfParallelism(4) .ForAll(RunSingle); GC.Collect(); Console.ReadKey(); }
public ByName() { var ex = SystemConsole.GetInputStr("请输入文件后缀(如\"cs,cpp\":"); var files = CheckPath("*.*").Where(p => p.EndsWith(ex)).ToArray(); var outFile = Path.ChangeExtension(InputPath.Trim('.'), ex); FileHelper.FileMerge(files.ToArray(), outFile); }
public YueGeDencrypt2() { Dictionary <string, string> cache = null; // GetCache(Md5Key); Console.WriteLine("-----------------------------"); Console.WriteLine(""); string root = SystemConsole.GetInputStr("输入目标目录:"); if (Directory.Exists(root)) { var folder = Path.GetFileName(root); root += root.EndsWith("\\") ? "" : "\\"; var files = Directory.GetFiles(root, "*.*", SearchOption.AllDirectories) .Select(p => p.Replace(root, "").Replace("\\", "/")) .Where(p => Path.GetFileNameWithoutExtension(p).Length == 32) .ToList(); files.ForEach(file => { File.WriteAllBytes(file + ".temp", UtilSecurity.DecryptionBytes(File.ReadAllBytes(root + file))); }); return; var dirRoot = root.Replace(folder, ""); files.ForEach((file, i, count) => { var path = folder + "/" + file; var newPath = ""; if (cache.TryGetValue(path, out newPath)) { var outPath = dirRoot + newPath; FileHelper.CreateDirectory(outPath); var p = ((float)i / count).ToString("P") + "\t" + path; if (extensionList.Contains(Path.GetExtension(path))) { Console.WriteLine("路径解码中..." + p); File.Copy(root + file, outPath, true); } else { Console.WriteLine("路径解码并文件解密中..." + p); File.WriteAllBytes(outPath, UtilSecurity.DecryptionBytes(File.ReadAllBytes(root + file))); } } else { Console.WriteLine("不存在的资源文件!"); } }); } }
public CheckCard() { var root = SystemConsole.GetInputStr("itemid:") + "\\"; var xx = File.ReadAllLines("itemid.txt").ToList(); xx = xx.AsParallel().Select(p => new List <string>() { string.Format("{0}", p.ToLower()), }).SelectMany(p => p).Where(p => !File.Exists(root + p + ".png")).ToList(); File.WriteAllLines("checkItem.txt", xx); }
public ReadExcel() { var filePath = SystemConsole.GetInputStr("请输入剧情文件(.xls|.xlsx):", def: @"D:\Work\yuege\www\assets\res\scenario.xls"); var cache = ExcelUtils.ImportFromExcel(filePath, false).Select(p => (JsonData)p.ToListTable()).Select( data => { var dic = data.Cast <JsonData>() .GroupBy(p => p["file"].ToString()) .ToDictionary(p => p.Key, q => q.ToList()); dic.Remove("file"); return(dic); }).ToList(); foreach (Dictionary <string, List <JsonData> > dic in cache) { var index = 0; foreach (KeyValuePair <string, List <JsonData> > pair in dic) { var res = new JsonData(); Console.WriteLine("剧情文件({1}):{0}", pair.Key, (++index) / (float)cache.Count); foreach (JsonData jsonData in pair.Value) { var xx = new JsonData(); var keys = jsonData.Keys.Where(p => !p.Contains("_zh_cn")); foreach (var key in keys) { if (key == "" || key == "file") { continue; } if (jsonData.Keys.Contains(key + "_zh_cn")) { xx[key] = jsonData[key + "_zh_cn"]; } else { xx[key] = jsonData[key]; } } res.Add(xx); } var fileName = Path.ChangeExtension(filePath, "").Trim('.') + "/" + pair.Key + ".json"; DirectoryHelper.CreateDirectory(fileName); File.WriteAllText(fileName, JsonHelper.ToJson(res)); } } }
public override void Run() { try { //应用在某版本库实例中 if (string.IsNullOrEmpty(svnUrl)) { bool yes = false; while (yes == false) { folder = SystemConsole.GetInputStr("请输入目标目录,然后回车:"); if (folder != null && !Directory.Exists(folder)) { Console.WriteLine("未输入目录或不存在!"); //Console.Write("\n是否将本目录作为目标目录(y/n):"); //yes = Console.ReadLine() == "y"; } else { break; } } svnUrl = CmdReadAll("svn info --show-item url").Last(); svnUrl += "/" + folder; } else { folder = Path.GetFileNameWithoutExtension(svnUrl); } Console.WriteLine("库地址:" + svnUrl); Console.WriteLine(""); highVersion = CmdReadAll("svn info --show-item last-changed-revision " + svnUrl).Last().AsInt(); Console.WriteLine("最高版本号:" + highVersion); var logs = CmdReadAll(string.Format("svn log -r 0:{0} \"{1}@{0}\" -q -l1 --stop-on-copy", highVersion, svnUrl)); lowVersion = logs.Skip(1).First().Split('|').First().Replace("r", "").Trim().AsInt(); Console.WriteLine("最低版本号:" + lowVersion); } catch (Exception e) { Console.WriteLine("请判断远程库连接是否正确!" + e.Message); } Console.WriteLine(""); }
public override void Run() { base.Run(); var beforeTip = string.Format("请输入目标版本号(输入数字,[{0}-{1}]),然后回车:", lowVersion, highVersion); endVersion = SystemConsole.GetInputStr(beforeTip, def: lowVersion.ToString()).AsInt(); endVersion = Math.Min(endVersion, highVersion); Console.WriteLine("目标版本号:" + endVersion); Console.WriteLine(); //获取当前目标版本号的list列表 Dictionary <string, FileDetailInfo> cache = GetListCache(endVersion); var targetDir = ExportFile(cache); Common(targetDir, cache); }
public SpliceImage() { bool isIndent = SystemConsole.GetInputStr("json文件是否进行格式化?(true:false)", def: "true").AsBool(false); var cache = CheckPath(".png|.jpg|.bmp|.psd|.tga|.tif|.dds", searchOption: SearchOption.TopDirectoryOnly) .GroupBy(p => Path.GetExtension(p)) .ToDictionary(p => p.Key, p => GetInfo(p.Select(q => { using (Image source = Image.FromFile(q)) { return(new ImageInfo() { Width = source.Width, Height = source.Height, path = q, }); } }).ToList())); // cache.ForEach(p => // { // p.Value // }); //BaseClassE.ForEachPaths( // , re => // { // var key = re.Replace(InputPath, ""); // using (Image source = Image.FromFile(re)) // { // cache[key] = new Info // { // width = source.Width, // height = source.Height, // background_image = key, // background_position = "" // }; // } // }); //File.WriteAllText(Path.ChangeExtension(InputPath, ".json"), JsonHelper.ToJson(cache, indentLevel: 2)); }
public DownIndexM3U8() { var url = SystemConsole.GetInputStr("请输入index.m3u8文件url:", regex: RegexUrl /*"index.m3u8"*/); var uri = new Uri(url); //获取index.m3u8 var firstPath = GetM3U8(url) .Select(p => { if (p.StartsWith("http")) { return(p); } return(uri.AbsoluteUri.Replace(uri.AbsolutePath, p)); }).First(); GetValue(firstPath, uri.AbsolutePath); }
public ImageConvertToBase64() { bool createFile = SystemConsole.GetInputStr("是否生成碎文件?(true:false)", def: "false").AsBool(true); bool isIndent = SystemConsole.GetInputStr("json文件是否进行格式化?(true:false)", def: "true").AsBool(false); Dictionary <string, string> cache = new Dictionary <string, string>(); CheckPath(".png|.jpg|.bmp|.psd|.tga|.tif|.dds", searchOption: SearchOption.AllDirectories).ForEachPaths( re => { var content = Convert.ToBase64String(File.ReadAllBytes(re)); cache[re.Replace(InputPath, "")] = content; if (createFile) { re = Path.ChangeExtension(re, "txt"); File.WriteAllText(re, content); } }); File.WriteAllText(Path.ChangeExtension(InputPath, ".json"), JsonHelper.ToJson(cache, indentLevel: 2)); }
public GetLineCount() { do { var folder = SystemConsole.GetInputStr("请拖入文件夹:"); if (!Directory.Exists(folder)) { continue; } var ex = SystemConsole.GetInputStr("请输入文件后缀(如\"cs,cpp\":"); if (string.IsNullOrEmpty(folder)) { continue; } var files = Directory.GetFiles(folder, "*.*", SearchOption.AllDirectories).ToList(); var res = new List <string>(); ex.Split(',').ToList().ForEach(s => res.AddRange(files.Where(p => Path.GetExtension(p) == s))); File.WriteAllLines(ex + ".txt", res.ToArray()); Console.WriteLine("总行数:" + res.Sum(p => File.Exists(p) ? File.ReadAllLines(p).Length : 0)); } while (SystemConsole.ContinueY()); }
protected virtual void CreateExcel() { var dir1 = SystemConsole.GetInputStr("请拖入选定文件:", "您选择的文件:", def: "new.txt"); var dir2 = SystemConsole.GetInputStr("请拖入选定文件:", "您选择的文件:", def: "old.txt"); var last1 = File.ReadAllLines(dir1); var last2 = File.ReadAllLines(dir2); last1.Except(last2) .Distinct() .Select(p => dir1 + p) .ToList() .ForEachPaths(re => { var newName = re.Replace(dir1, dir1 + "res"); DirectoryHelper.CreateDirectory(newName); File.Copy(re, newName, true); }); var root = dir1 + "res"; RunList(Directory.GetFiles(root, "*.*", SearchOption.AllDirectories), root); }
protected override void CreateExcel() { var dir1 = SystemConsole.GetInputStr("请拖入选定文件夹:", "您选择的文件夹:"); var dir2 = SystemConsole.GetInputStr("请拖入选定文件夹:", "您选择的文件夹:"); var last1 = Directory.GetFiles(dir1, "*.*", SearchOption.AllDirectories).Select(p => p.Replace(dir1, "")); var last2 = Directory.GetFiles(dir2, "*.*", SearchOption.AllDirectories).Select(p => p.Replace(dir2, "")); last1.Except(last2) .Distinct() .Select(p => dir1 + p) .ToList() .ForEachPaths(re => { var newName = re.Replace(dir1, dir1 + "res"); DirectoryHelper.CreateDirectory(newName); File.Copy(re, newName, true); }); var root = dir1 + "res"; RunList(Directory.GetFiles(root, "*.*", SearchOption.AllDirectories), root); }
public DeleteFiles() { var path = SystemConsole.GetInputStr("请拖入选定文件:", "您选择的文件:", def: "new.txt"); if (!File.Exists(path)) { return; } var files = File.ReadAllLines(path); CheckPath("*.*", searchOption: SearchOption.AllDirectories) .ForEachPaths(re => { var xx = re.Replace(InputPath, "").TrimStart('/'); if (files.Contains(xx)) { return; } File.Delete(re); }); }
public ImageConvertToSprite() { bool isIndent = SystemConsole.GetInputStr("json文件是否进行格式化?(true:false)", def: "true").AsBool(false); Dictionary <string, Info> cache = new Dictionary <string, Info>(); CheckPath(".png|.jpg|.bmp|.psd|.tga|.tif|.dds", searchOption: SearchOption.AllDirectories).ForEachPaths( re => { var key = re.Replace(InputPath, ""); using (Image source = Image.FromFile(re)) { cache[key] = new Info { width = source.Width, height = source.Height, background_image = key, background_position = "" }; } }); File.WriteAllText(Path.ChangeExtension(InputPath, ".json"), JsonHelper.ToJson(cache, indentLevel: 2)); }
public YueGeEncrypt() { var md5Key = "kEfGhnNmeu4YYuhv"; var root = SystemConsole.GetInputStr("输入目录:"); if (Directory.Exists(root)) { var folder = Path.GetFileName(root); var files = Directory.GetFiles(root, "*.*", SearchOption.AllDirectories) .Select(p => p.Replace(root, "").Replace("\\", "/")) .ToList(); var dirRoot = root.Replace(folder, ""); files.ForEach((file, i, count) => { var path = folder + file; var dirName = Path.GetDirectoryName(path).Replace("\\", "/"); var fileName = Path.GetFileName(path); var newPath = dirName.MD5(md5Key) + "/" + fileName.MD5(md5Key); var outPath = dirRoot + "md5/" + newPath; var p = ((float)i / count).ToString("P") + "\t" + path; FileHelper.CreateDirectory(outPath); if (extensionList.Contains(Path.GetExtension(path))) { Console.WriteLine("路径编码中..." + p); File.Copy(root + file, outPath, true); } else { Console.WriteLine("路径编码并文件加密中..." + p); File.WriteAllBytes(outPath, UtilSecurity.EncryptionBytes(File.ReadAllBytes(root + file))); } }); } }
public CompareJson() { var dir1 = SystemConsole.GetInputStr("请拖入目标文件(.json):", "您选择的文件:"); var dir2 = SystemConsole.GetInputStr("请拖入比较文件(.json):", "您选择的文件:"); Func <JsonData, string> getKey = p => p["Columns0"].ToString() + "@" + p["Columns1"].ToString() + "@" + p["Columns2"].ToString(); var jsondatas = JsonHelper.ImportJson <JsonData[]>(dir1); var listTables = JsonHelper.ImportJson <JsonData[]>(dir1).Select(p => { p["key"] = getKey(p); return(p); }).ToDictionary(p => p["key"].ToString()); var listTables2 = JsonHelper.ImportJson <JsonData[]>(dir2).Select(p => { p["key"] = getKey(p); return(p); }).ToDictionary(p => p["key"].ToString()); var intersectList = listTables.Keys.Intersect(listTables2.Keys).ToDictionary(p => p, p => listTables[p]); var exceptList = listTables.Keys.Except(listTables2.Keys).ToDictionary(p => p, p => listTables[p]); foreach (KeyValuePair <string, JsonData> data in listTables) { JsonData json; if (intersectList.TryGetValue(data.Key, out json)) { data.Value["Columns4"] = json["Columns4"]; } } var res = listTables.Select(p => { return(p.Value.Remove("key")); }).ToArray(); File.WriteAllText("intersectList.json", JsonHelper.ToJson(res, indentLevel: 2)); }
public CompareExcel() { var dir1 = SystemConsole.GetInputStr("请拖入目标文件(.xls|xlsx):", "您选择的文件:"); var dir2 = SystemConsole.GetInputStr("请拖入比较文件(.xls|xlsx):", "您选择的文件:"); var listTables = ExcelUtils.ImportFromExcel(dir1).Select(p => p.ToListTable()).ToDictionary(p => p.TableName); var listTables2 = ExcelUtils.ImportFromExcel(dir2).Select(p => p.ToListTable()).ToDictionary(p => p.TableName); foreach (var keyValuePair in listTables) { ListTable lst; if (listTables2.TryGetValue(keyValuePair.Key, out lst)) { var intersectList = keyValuePair.Value.Rows.AsParallel().AsOrdered() .Where((objects, i) => { Console.WriteLine(i); return(lst.Rows.Any(objects.SequenceEqual)); }).ToList(); var exceptList = keyValuePair.Value.Rows.Except(intersectList); //var exceptList = keyValuePair.Value.List.Except(lst.List).ToList(); //var intersectList = keyValuePair.Value.List.Intersect(lst.List).ToList(); // ReSharper disable once PossibleNullReferenceException var newName = Path.ChangeExtension(dir1, "").Trim('.') + "-" + Path.GetFileNameWithoutExtension(dir2); keyValuePair.Value.Rows = exceptList.ToList(); ExcelUtils.ExportToExcel(keyValuePair.Value.ToDataTable(), string.Format("{0}-except.xlsx", newName)); keyValuePair.Value.Rows = intersectList.ToList(); ExcelUtils.ExportToExcel(keyValuePair.Value.ToDataTable(), string.Format("{0}-intersect.xlsx", newName)); } else { Console.WriteLine(dir2 + " 不存在的sheet:" + keyValuePair.Key); } } Console.WriteLine("完毕"); }
/// <summary> /// 还原键值对 /// </summary> public void KvExcelTo(bool isArray = true, Func <string, List <List <object> >, string> isCustomAction = null) { var caches = GetFileCaches(); if (caches.Count == 0) { return; } string[] root = { "", new FileInfo(InputPath).Directory.FullName, Path.ChangeExtension(InputPath, "").TrimEnd('.') }; var isBak = SystemConsole.GetInputStr("是否每一个备份文件?(true:false)", def: "false").AsBool(false); List <List <string> > error = new List <List <string> >(); foreach (var table in caches) { foreach (KeyValuePair <string, List <List <object> > > pair in table) { //请注意pair.Key是否以‘/’开头 var fullpath = root.Select(p => p + pair.Key).FirstOrDefault(File.Exists); if (string.IsNullOrEmpty(fullpath)) { Console.WriteLine("不存在的文件 !" + pair.Key); continue; } try { bool isSave = false; Console.WriteLine(" is now : " + fullpath); var data = import(fullpath).FirstOrDefault(); var columns = data.Columns; //if (data.IsArray) if (isArray) { foreach (List <object> objects in pair.Value) { object id = objects[1]; string key = objects[2].ToString(); object value = objects[3]; object value_zh_cn = objects[4]; foreach (DataRow dtr in data.Rows) { if (columns.Contains(key)) { var idTemp = dtr[0].ToString(); var keyTemp = dtr[key]; if (idTemp.Equals(id) /*&& keyTemp.Equals(value)*/) { dtr[key] = value_zh_cn; isSave = true; } } else { Console.WriteLine("不包含列 !\t" + fullpath + "\t" + key); } } } if (!isSave) { continue; } if (isBak) { File.Copy(fullpath, fullpath + ".bak", true); } export.Invoke(data, fullpath); } else { if (isCustomAction == null) { continue; } if (isBak) { File.Copy(fullpath, fullpath + ".bak", true); } File.WriteAllText(fullpath, isCustomAction.Invoke(fullpath, pair.Value)); } } catch (Exception e) { error.Add(new List <string>() { error.Count + Enumerable.Repeat("-", 100).Aggregate("", (a, b) => a + b), fullpath, e.Message, e.StackTrace, "" }); Console.WriteLine(fullpath + "\t" + e.Message); } } } WriteError("export-file", error.Select(p => p.Skip(1).First())); WriteError("export-message", error.SelectMany(p => p)); }
public DownM3U8() { var url = SystemConsole.GetInputStr("请输入m3u8文件url:", regex: RegexUrl /*".m3u8"*/); GetValue(url); }
public DownFile() { GetWebFile(SystemConsole.GetInputStr("请输入文件url:", regex: RegexUrl)); }
public override void Run() { base.Run(); var msg = string.Format("请输入起始版本号(输入数字,[{0}-{1}]),然后回车:", lowVersion, highVersion); startVersion = SystemConsole.GetInputStr(msg, def: lowVersion.ToString()).AsLong(); //startVersion = Math.Max(startVersion, lowVersion); Console.WriteLine("起始版本号:" + startVersion); msg = string.Format("请输入结束版本号(输入数字,[{0}-{1}]),然后回车:", lowVersion, highVersion); endVersion = SystemConsole.GetInputStr(msg, def: startVersion.ToString()).AsLong(); endVersion = Math.Max(endVersion, highVersion); Console.WriteLine("结束版本号:" + endVersion); if (startVersion == endVersion) { return; } Console.WriteLine("\n正在获取版本差异信息..."); var targetList = CmdReadAll(string.Format("svn diff -r {0}:{1} {2} --summarize", startVersion, endVersion, svnUrl)) .Select(Uri.UnescapeDataString) .Where(s => !string.IsNullOrEmpty(s)) .Where(s => !s.EndsWith("/")) //.Where(s => !string.IsNullOrEmpty(s)) .Select(p => p.Replace(svnUrl + "/", "")) .ToArray(); //去除文件夹 Dictionary <string, FileDetailInfo> cache = new Dictionary <string, FileDetailInfo>(); targetList.ForEach((s, index) => { List <string> res = s.Split(' ').Where(s1 => !string.IsNullOrEmpty(s1)).ToList(); var last = res.Skip(1).Join(" ").Replace("\\", "/").Trim(); FileDetailInfo svnFileInfo = new FileDetailInfo() { is_delete = res.First().Trim() == "D", path = last, }; cache[svnFileInfo.path] = svnFileInfo; Console.WriteLine("{0:D5}\t{1}", index, svnFileInfo); }); ExcludeFile(cache); string targetDir = string.Format(Name, folder, startVersion, endVersion); WriteToTxt(targetDir, cache); List <string> del = new List <string>(); cache.ForEach((s, index) => { Console.Clear(); Console.WriteLine("\n正在导出差异文件..."); Console.WriteLine("根据项目大小时间长短不定,请耐心等待..."); Console.WriteLine("正在导出中...{0}", ((float)(++index) / cache.Count).ToString("P")); Console.WriteLine("is now: {0}", s.Key); Console.WriteLine(); if (!s.Value.is_delete) { string fullPath = Environment.CurrentDirectory.Replace("\\", "/") + "/" + targetDir + "/" + s.Key; DirectoryHelper.CreateDirectory(fullPath); //拉取的文件版本号不会小于所在目录版本号,如若小于,说明文件所在目录曾经被移动过 CmdReadAll(string.Format("svn cat -r {0} \"{1}/{2}@{0}\">\"{3}\"", endVersion, svnUrl, s.Key, fullPath)); if (File.Exists(fullPath)) { var array = CmdReadAll(string.Format("svn log -r {0}:{3} \"{1}/{2}@{0}\" -q -l1 --stop-on-copy", endVersion, svnUrl, s.Key, lowVersion)); s.Value.version = array.Skip(1).First().Split(' ').First().Replace("r", "").Trim().AsLong(); SetContent(fullPath, s.Value); Console.WriteLine(); } else { del.Add(s.Key); } } }); foreach (string s in del) { cache.Remove(s); } Common(targetDir, cache); }
public override void Run() { if (string.IsNullOrEmpty(gitUrl)) { bool yes = false; while (yes == false) { folder = SystemConsole.GetInputStr("请输入目标目录,然后回车:"); if (folder != null && !Directory.Exists(folder)) { Console.WriteLine("未输入目录或不存在!"); //Console.Write("\n是否将本目录作为目标目录(y/n):"); //yes = Console.ReadLine() == "y"; } else { break; } } gitUrl = CmdReadAll("git remote -v").First().Replace("origin", "").Replace("(fetch)", "").Trim(); gitUrl += "/" + folder; } else { folder = Path.GetFileNameWithoutExtension(gitUrl); } Console.WriteLine("库地址:" + gitUrl); Console.WriteLine(""); //highVersion = RunCmd("git rev-parse HEAD " + folder).Last().AsInt(); //Console.WriteLine("最高版本号:" + highVersion); //var logs = RunCmd("git log --pretty --oneline " + folder, true); //var highsha_1 = logs.First().Split(' ').First(); //var lowsha_1 = logs.Last().Split(' ').First(); //var logs = RunCmd("git rev-list --all " + folder, true); //var highsha_1 = logs.First(); //var lowsha_1 = logs.Last(); //https://git-scm.com/book/zh/v1/Git-%E5%9F%BA%E7%A1%80-%E6%9F%A5%E7%9C%8B%E6%8F%90%E4%BA%A4%E5%8E%86%E5%8F%B2 var logs = CmdReadAll("git log --reverse --pretty=format:\"%ad,%H\" --date=format:\"%y-%m-%d-%H-%M-%S\" " + gitUrl); Console.WriteLine(""); int index = 0; foreach (var log in logs) { CacheConvert.Add(new ConvertStruct() { index = index, dateTime = log.Split(',').First(), sha1 = log.Split(',').Last() }); ++index; } CacheConvert.Reverse(); foreach (var convertStruct in CacheConvert) { Console.WriteLine(convertStruct); } highVersion = CacheConvert.First().index; lowVersion = CacheConvert.Last().index; Console.WriteLine(""); Console.WriteLine("最高版本号:{0}", highVersion); Console.WriteLine("最低版本号:{0}", lowVersion); Console.WriteLine(""); }