private static List <Folder> process(string folder) { List <Folder> listaFolders = new List <Folder>(); Folder dir; FolderOrder folderOrder = new FolderOrder(-1, 0); Console.WriteLine("Processing folders!"); List <PreFile> listaPrefiles = VisitFoldersUtil.getListFromFiles(folder); foreach (PreFile pf in listaPrefiles) { dir = ProcessFolders.createFolder(pf, folderOrder); listaFolders.Add(dir); } foreach (Folder item in listaFolders) { string pathChild = item.getOriginalPath().Substring(0, item.getOriginalPath().LastIndexOf(item.separatorChar)); Folder pathFather = listaFolders.Find(f => f.getOriginalPath().Equals(pathChild)); if (pathFather != null) { item.setParentCodFolder(pathFather.getOrder()); item.setParentName(pathFather.getName()); item.setParentPath(pathFather.getPath()); } } listaFolders.Sort(); return(listaFolders); }
public static void Main(string[] args) { string folder = ""; bool tojson = false, tofile = false, toinsert = false, tocvs = false; if (args.Length > 0) { foreach (string opt in args) { if (!opt.Contains("--")) { folder = opt; } if (opt.Contains("--version")) { Console.WriteLine("hfsfolder 1.0"); } if (opt.Contains("--tojson")) { tojson = true; } if (opt.Contains("--tofile")) { tofile = true; } if (opt.Contains("--toinsert")) { toinsert = true; } if (opt.Contains("--tocvs")) { tocvs = true; } } if (folder.Length > 0) { string data = "", outFile = "hfsfolder"; if (tojson) { outFile += ".json"; data = ProcessFolders.processFoldersToJson(folder); } if (toinsert) { Console.Write("Inform tab number: "); int naba = Convert.ToInt32(Console.ReadLine()); outFile += "-insert.sql"; data = ProcessFolders.processFoldersToInsert(folder, naba); } if (tocvs) { outFile += ".csv"; data = ProcessFolders.processFoldersToCSV(folder); } if (tofile && data.Length > 0) { ProcessFolders.processFoldersToFile(data, outFile); Console.WriteLine("Finish process folders!"); } else if (data.Length > 0) { Console.WriteLine(data); } if (!tojson && !toinsert && !tocvs && !tofile) { Console.WriteLine("Inform option!"); } } else { if (tojson || toinsert || tocvs || tofile) { Console.WriteLine("Inform folder!"); } } } else { Console.WriteLine("HFSFolder \n" + "Usage:\n" + " dotnet run /folder\n\n" + "Options:\n" + " --version\n" + " --tojson\n" + " --toinsert\n" + " --tocvs\n" + " --tofile\n\n" + "Example:\n" + " dotnet run /folder --tojson --tofile --version\n"); } }