#pragma warning restore 0649 // Main entry point. Simply set up a httpClient to access the CI // and switch on the command to invoke underlying logic. private static int Main(string[] args) { Config config = new Config(args); int error = 0; CIClient cic = new CIClient(config); Command currentCommand = config.DoCommand; switch (currentCommand) { case Command.List: { ListCommand.List(cic, config).Wait(); break; } case Command.Copy: { CopyCommand.Copy(cic, config).Wait(); break; } default: { Console.Error.WriteLine("super bad! why no command!"); error = 1; break; } } return(error); }
// 运行 public void Run() { // 备份 if (!string.IsNullOrEmpty(item.srcBak)) { item.srcBak = item.srcBak.Replace("XXXX", time); CopyCommand.Copy(item.src, item.srcBak, true); } if (!string.IsNullOrEmpty(item.dstBak)) { item.dstBak = item.dstBak.Replace("XXXX", time); CopyCommand.Copy(item.dst, item.dstBak, true); } // 处理 try { CheckDirectory(item.src, item.dst); } catch (Exception e) { log($"[Error] {e.ToString()}"); } string logPath = item.log.Replace("XXXX", time); if (!string.IsNullOrEmpty(logPath)) { PathHelper.CheckPath(logPath); File.WriteAllText(logPath, sw.ToString(), UTF8Encoding.Default); } }
static void Main(string[] args) { //注册EncodeProvider Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); Setting.Init(args); string time = DateTime.Now.ToString("yyyy-MM-dd-dddd-HH_mm_ss_fff"); foreach (OptionItem item in Setting.list.enableoverwrites) { item.dst = item.dst.Replace("XXXX", time); CopyCommand.Copy(item.src, item.dst, true); } foreach (OptionItem item in Setting.list.disableoverwrites) { item.dst = item.dst.Replace("XXXX", time); CopyCommand.Copy(item.src, item.dst, false); } foreach (OptionCheckItem item in Setting.list.checks) { new Checker(item).Run(); } Console.WriteLine("完成"); if (!Setting.Options.autoEnd) { Console.Read(); } }
public void Generate() { if (Setting.Options.useGenerate) { // 清理之前的生成目录 if (Directory.Exists(genergateFolderPath)) { Directory.Delete(genergateFolderPath, true); } } // 拷贝spine文件 CopyCommand.Copy(style.fileSpine, genergateFileSpine); // 拷贝image if (Setting.Options.useGenerate) { foreach (string img in images) { string dst = genergateFolderImages + "/" + Path.GetFileName(img); CopyCommand.Copy(img, dst); } } // 检测缺失image foreach (var kvp in style.imageDict) { if (!imageDict.ContainsKey(kvp.Key)) { string dst = genergateFolderImages + "/" + kvp.Key; string lib = Setting.Options.rootLib + "/" + kvp.Key; if (File.Exists(lib)) { CopyCommand.Copy(lib, dst); } else { Console.WriteLine($"【警告】 不存在文件 {lib}"); } } } }
static void Main(string[] args) { //注册EncodeProvider Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); Setting.Init(args); foreach (OptionItem item in Setting.list.enableoverwrites) { CopyCommand.Copy(item.src, item.dst, true); } foreach (OptionItem item in Setting.list.disableoverwrites) { CopyCommand.Copy(item.src, item.dst, false); } Console.WriteLine("完成"); if (!Setting.Options.autoEnd) { Console.Read(); } }
public void CheckModify(TableReader langTable) { List <DataField> fields = new List <DataField>(); foreach (DataField field in langTable.dataStruct.fields) { string fieldName = field.field; foreach (string langFieldPrefix in Setting.Options.langFieldPrefixs) { if (fieldName.StartsWith(langFieldPrefix)) { field.isLangField = true; fields.Add(field); break; } } } bool hasModify = false; var xlsx = new FileInfo(path); using (var package = new ExcelPackage(xlsx)) { ExcelWorksheet ws = null; if (package.Workbook.Worksheets.Count > 0) { IEnumerator enumerator = package.Workbook.Worksheets.GetEnumerator(); while (enumerator.MoveNext() && ws == null) { if (string.IsNullOrEmpty(sheetName)) { ws = (ExcelWorksheet)enumerator.Current; } else { if (((ExcelWorksheet)enumerator.Current).Name == sheetName) { ws = (ExcelWorksheet)enumerator.Current; } } } } if (ws == null) { Log.Error($"没有找到sheet path:{path}, sheetName:{sheetName}"); return; } if (ws.Cells.Rows < 3) { Log.Error($" path:{path}, sheetName:{sheetName}, rows:{ws.Cells.Rows}, 行数小于3行, 必须要有(type, cn, field)"); return; } foreach (Dictionary <string, string> langRowData in langTable.dataList) { if (!langRowData.ContainsKey("id")) { return; } string id = langRowData["id"]; if (!id2RowDataDict.ContainsKey(id)) { continue; } Dictionary <string, string> sourceRowData = id2RowDataDict[id]; foreach (DataField field in fields) { if (sourceRowData.ContainsKey(field.field)) { if (langRowData[field.field] != sourceRowData[field.field]) { ExcelRange excelCell = ws.Cells[id2RowDict[id], fieldDict[field.field].index]; excelCell.Value = langRowData[field.field]; hasModify = true; ws.Comments.Add(excelCell, sourceRowData[field.field], "zf"); excelCell.Style.Fill.PatternType = ExcelFillStyle.Solid; excelCell.Style.Fill.BackgroundColor.SetColor(Color.Yellow); } } } } if (hasModify) { Process.Start("C:/Windows/System32/attrib.exe", " -R"); Process p = Process.Start("C:/Windows/System32/attrib.exe", $" -R {path}"); p.WaitForExit(); p.Close(); PathHelper.CheckPath(savePath); package.SaveAs(new FileInfo(savePath)); CopyCommand.Copy(savePath, path, true); } package.Dispose(); } }