private void catParseWork(refItem _ref, DirectoryInfo di) { int stIndex2 = getStartIndex(_ref.destinationPass); FileInfo[] fi = di.GetFiles(); foreach (var content in fi) { string ins = new String(' ', 20 - "CHANGE".Length); //переписываем данные файла info.txt Console.WriteLine(String.Format("{0}{1}{3}| {2}", CONST._INS, "CHANGE", content.Name, ins)); //1. создаем папкочку string pass = _ref.destinationPass + "//" + stIndex2.ToString(); Directory.CreateDirectory(pass); //2. копируем картинку string fname = content.FullName; string relPath = _ref.destinationPass + "//" + stIndex2.ToString() + "//"; string destname = relPath + content.Name; File.Move(fname, destname); //3. создание txt string newName = relPath + "info.txt"; //File.Create(newName); //4. запись даты FileInfo f = new FileInfo(destname); var d = File.GetLastWriteTime(destname); string tdade = d.ToString("yyyy-MM-dd HH:mm:ss"); string newContent = tdade + "\n\n"; FILEWORK.WriteFileContent(newName, newContent); stIndex2++; // changeInfoContent(content); } }
public void changeInfoContent(DirectoryInfo content) { List <string> txts = new List <string>(); txts = FILEWORK.GetAllFiles(content.FullName, txts, ".txt"); string txtFi = txts[0]; string fc = FILEWORK.ReadFileContent(txtFi); List <string> imgs = new List <string>(); imgs = FILEWORK.GetAllFiles(content.FullName, imgs, ".jpg"); string imgFi = imgs[0]; FileInfo f = new FileInfo(imgFi); var d = File.GetLastWriteTime(imgFi); string tdade = d.ToString("yyyy-MM-dd HH:mm:ss"); string newContent = tdade + "\n\n" + fc; FILEWORK.WriteFileContent(txtFi, newContent); //меняем название на info.txt FileInfo f2 = new FileInfo(txtFi); string newName = content.FullName + "\\info.txt"; System.IO.File.Move(f2.FullName, newName); }
public void createItems() { imgtemplate1 = FILEWORK.ReadFileContent(PATH.templ + "\\" + TRAVEL._type.ToLower() + "\\img1item.txt"); liItem = FILEWORK.ReadFileContent(PATH.templ + "\\" + TRAVEL._type.ToLower() + "\\ulitem.txt"); diItem = FILEWORK.ReadFileContent(PATH.templ + "\\" + TRAVEL._type.ToLower() + "\\diitem.txt"); string template = FILEWORK.ReadFileContent(itemtemplate); template = template.Replace("$header2", CONST.header2); template = template.Replace("$footer2", CONST.footer2); // string itemtemplateitem = FILEWORK.ReadFileContent(PATH.templ + "\\" + WORKOUT._type.ToUpper() + "\\itemworkoutitem.txt"); foreach (var item in DATA._TRAVELS) { string result = template; result = result.Replace("$title", item.name); // result = reseatMainInfo(item, result); result = reseatTextInfo(item, result); result = reseatCreateYoutube(item, result); string path = PATH.site + "\\data\\travel\\" + item.Id + ".html"; FILEWORK.WriteFileContent(path, result); Console.WriteLine("+ " + path); } }
public void createList() { string template = FILEWORK.ReadFileContent(templateList); template = template.Replace("$header1", CONST.header1); template = template.Replace("$footer1", CONST.footer1); string result = template; result = executeType("travel", 1, result); result = executeType("work", 2, result); result = executeType("friends", 3, result); result = executeType("sport", 4, result); result = executeType("dog", 5, result); result = executeType("food", 6, result); result = executeType("book", 7, result); double catalogSize = 0; catalogSize = FILEWORK.sizeOfFolder(PATH.data, ref catalogSize); //Вызываем наш рекурсивный метод sizes = String.Format("{0} ГБ", catalogSize); result = result.Replace("$1", items.ToString()); result = result.Replace("$2", imgs.ToString()); result = result.Replace("$3", youtubs.ToString()); result = result.Replace("$4", sizes); FILEWORK.WriteFileContent(fpath, result); Console.WriteLine("+ " + fpath); }
public void createList() { string template = FILEWORK.ReadFileContent(templateList); string result = template; List <string> urls = new List <string>(); foreach (var travel in DATA._TRAVELS) { string link = "http://kapybara.ru/data/travel/" + travel.Id.ToString() + ".html"; urls.Add("'" + link + "'"); } foreach (var content in DATA._CONTENT) { if (content is FOOD) { continue; } urls.Add("'" + content.link + "'"); } var lr = String.Join(", \n ", urls.ToArray()); result = result.Replace("$urls", lr); FILEWORK.WriteFileContent(fpath, result); Console.WriteLine("+ " + fpath); }
public void saffixWork() { //4. Копирование файлов File.Copy(opath, fpath); //5. Копирование из Pictures FILEWORK.CopyDir(picturesf, htmlfolder); }
//на этом этапе, копируем новый контент в папки data + приводим в порядок ихний info.txt public override void WORK() { if (DATA._newExist) { // Console.WriteLine(CONST._INS + "НЕЧЕГО ДОБАВИТЬ"); return; } foreach (var _ref in PATH.refs) { DirectoryInfo di = new DirectoryInfo(_ref.newPass); if (_ref._type == "FOOD") { //для котов catParseWork(_ref, di); continue; } DirectoryInfo[] diA = di.GetDirectories(); int stIndex = getStartIndex(_ref.destinationPass); foreach (var content in diA) { string ins = new String(' ', 20 - "CHANGE".Length); //переписываем данные файла info.txt Console.WriteLine(String.Format("{0}{1}{3}| {2}", CONST._INS, "CHANGE", content.Name, ins)); changeInfoContent(content); } DirectoryInfo[] diAAfter1 = di.GetDirectories(); foreach (var content in diAAfter1) { FILEWORK.renameDir(content.FullName, stIndex.ToString()); stIndex = stIndex + 1; } DirectoryInfo[] diAAfter2 = di.GetDirectories(); foreach (var content in diAAfter2) { addNewContent(content); string ins = new String(' ', 20 - "COPY".Length); //переписываем данные файла info.txt Console.WriteLine(String.Format("{0}{1}{3}| {2}", CONST._INS, "COPY", content.Name, ins)); string oldName = content.FullName; string newName = _ref.destinationPass + "\\" + content.Name; FILEWORK.moveDir(oldName, newName); // changeInfoContent(content); } } }
public void setProcced() { List <string> res = new List <string>(); res.AddRange(proceed); res.AddRange(newproceed); string result = string.Join("\n", res); FILEWORK.WriteFileContent(PATH.imgProcessedFile, result); }
public void createList() { string template = FILEWORK.ReadFileContent(templateList); template = template.Replace("$header1", CONST.header1); template = template.Replace("$footer1", CONST.footer1); string result = template; FILEWORK.WriteFileContent(fpath, result); Console.WriteLine("+ " + fpath); }
public void saveInfo() { string res = ""; foreach (var d in data) { String r = niceString(d.ModelString, d.Name, d.embededUrl, 50, 50); res = res + r + '\n'; } FILEWORK.WriteFileContent(PATH.videofolderSave, res); }
private void checkContent(DirectoryInfo content, DirectoryInfo di) { string ins = new String(' ', 20 - di.Name.Length); Console.WriteLine(String.Format("{0}{1}{3}| {2}", CONST._INS, di.Name, content.Name, ins)); FileInfo[] fileNews = content.GetFiles(); //не пустой if (fileNews.Length == 0) { throw new Exception(String.Format(" {1} пуста", CONST._INSERR, content.Name)); } //не должно быть вложенных папок DirectoryInfo[] diVlog = content.GetDirectories(); if (diVlog.Length > 0) { throw new Exception(String.Format(" {1} содержит вложенные папки", CONST._INSERR, content.Name)); } //должно содержать хотябы одно изображение и описание List <string> imgs = new List <string>(); imgs = FILEWORK.GetAllFiles(content.FullName, imgs, ".jpg"); if (imgs.Count == 0) { throw new Exception(String.Format("{1} не содержит изображение", CONST._INSERR, content.Name)); } List <string> txts = new List <string>(); txts = FILEWORK.GetAllFiles(content.FullName, txts, ".txt"); if (txts.Count == 0) { throw new Exception(String.Format(" {1} не содержит описание (txt)", CONST._INSERR, content.Name)); } if (txts.Count > 1) { throw new Exception(String.Format(" {1} содержит больше одного описания (txt)", CONST._INSERR, content.Name)); } string opispath = txts[0]; string fcontent = FILEWORK.ReadFileContent(opispath); if (String.IsNullOrEmpty(fcontent)) { throw new Exception(String.Format(" {1} ПУСТОЕ ОПИСАНИЕ (txt)", CONST._INSERR, content.Name)); } }
public void prefixWork() { //0 инит string listname = "index.html"; fpath = PATH.site + "\\" + listname; templateList = PATH.templ + "\\index.html"; opath = outfolder + "\\" + listname; last10templ = FILEWORK.ReadFileContent(PATH.templ + "\\index\\last10item.txt"); //1. Очищение out File.Delete(fpath); }
public void getProcced() { string contentProceed = FILEWORK.ReadFileContent(PATH.imgProcessedFile); String[] row = contentProceed.Split(new string[] { "\n" }, StringSplitOptions.None); foreach (string st in row) { if (String.IsNullOrEmpty(st)) { return; } proceed.Add(st); } }
private void createItems() { string template = FILEWORK.ReadFileContent(itemtemplate); template = template.Replace("$header2", CONST.header2); template = template.Replace("$footer2", CONST.footer2); string itemtemplateitem = FILEWORK.ReadFileContent(PATH.templ + "\\" + FOOD._type.ToUpper() + "\\itemfooditem.txt"); foreach (var item in DATA._FOOD) { string result = template; result = result.Replace("$Id", item.Id.ToString()); result = result.Replace("$date", item.date.ToString("yyyy-MM-dd")); result = result.Replace("$mainImg", item.Id + "/" + item.mainImg); string texts = string.Join("<br> <br>", item.txtContents.ToArray()); result = result.Replace("$text", "<p>" + texts + "</p>"); string imgres = ""; List <string> imgs = item.imgs.Where(o => o != DATA.imageDict[item.mainImg]).ToList(); foreach (string img in imgs) { string itimgs = itemtemplateitem; string ig = DATA.RevImageDict[img]; itimgs = itimgs.Replace("$image", item.Id + "/" + ig); string bi = "build" + item.Id; itimgs = itimgs.Replace("$fancygroupfull", bi); imgres = imgres + itimgs; } string youcont = ""; foreach (string you in item.youtubs) { bool isOne = item.youtubs.Count == 1 || (item.youtubs.Last() == you && item.youtubs.Count % 2 != 0); string itimgs = !isOne ? CONST.youtube1 : CONST.youtube2; itimgs = itimgs.Replace("$srcitem", you); youcont = youcont + itimgs; } result = result.Replace("$youtubs", youcont); result = result.Replace("$images", imgres); string path = PATH.site + "\\data\\food\\" + item.Id + ".html"; FILEWORK.WriteFileContent(path, result); Console.WriteLine("+ " + path); } }
private void addLSText(string number, TRAVEL travel, string ffFullName) { string l; string s; List <string> ll = new List <string>(); List <string> ls = new List <string>(); string stage = ""; string content = FILEWORK.ReadFileContent(ffFullName); String[] lines = content.Split(new string[] { "\n" }, StringSplitOptions.None); foreach (string line in lines) { if (String.IsNullOrEmpty(line)) { continue; } if (line.ToUpper() == "LENA") { stage = "lena"; continue; } if (line.ToUpper() == "SERGEY") { stage = "sergey"; continue; } if (stage == "lena") { ll.Add(line); } if (stage == "sergey") { ls.Add(line); } } l = string.Join("\n", ll.ToArray()); s = string.Join("\n", ls.ToArray()); TRAVEL.LSTEXT tt = new TRAVEL.LSTEXT(); tt.l = l; tt.s = s; tt.day = number; travel.destrictions.Add(number, tt); }
public void createList() { string template = FILEWORK.ReadFileContent(templateList); string itemtemplate = FILEWORK.ReadFileContent(templateListItem); template = template.Replace("$header1", CONST.header1); template = template.Replace("$footer1", ""); template = template.Replace("$numcats", DATA._FOOD.Count.ToString()); string itemFull = ""; List <FOOD> friends = DATA._FOOD.OrderByDescending(o => o.Id).ToList(); foreach (FOOD item in friends) { if (item.Id == 8) { } string itemres = itemtemplate; int index = 1; //foreach (string img in item.mainIng) //{ // string sname = DATA.imageDict[img]; // string rr = "$image" + index; // itemres = itemres.Replace(rr, imglistprefix + "\\" + item.Id + "\\" + img); // index++; //} string rr = "$image" + index; itemres = itemres.Replace(rr, imglistprefix + "\\" + item.Id + "\\" + item.mainImg); //itemres = itemres.Replace("$city", item.name); itemres = itemres.Replace("$date", item.date.ToString("yyyy-MM-dd")); //itemres = itemres.Replace("$price", item.lcount); itemres = itemres.Replace("$link", imglistprefix + "\\" + item.Id + ".html"); string texts = string.Join("<br>", item.txtContents.ToArray()); itemres = itemres.Replace("$text", "<p>" + texts + "</p>"); itemFull = itemFull + itemres; } string result = template.Replace("param_models", itemFull); FILEWORK.WriteFileContent(opath, result); Console.WriteLine("+ " + fpath); }
public void createList() { string template = FILEWORK.ReadFileContent(templateList); template = template.Replace("$header1", CONST.header1); template = template.Replace("$footer1", CONST.footer1); string result = template; result = createLast10(result); result = createBiGWork(result); result = createBiGFriends(result); result = createBiGDog(result); result = createBiGSport(result); result = createBiGFood(result); FILEWORK.WriteFileContent(fpath, result); Console.WriteLine("+ " + fpath); }
public Test1() { string content = FILEWORK.ReadFileContent(logi); String[] lines = content.Split(new string[] { "\n" }, StringSplitOptions.None); User cu = null; foreach (string s in lines) { if (s.Contains("TTD_HOCKEY ENTER Calendar")) { User u = parseUser(s); cu = u; if (!dict.ContainsKey(u.Name)) { dict.Add(u.Name, u); } } if (cu != null) { if (s.Contains("Physical address ........................ :")) { string name = parseName(s); User u = dict[cu.Name]; if (!u.hosts.Contains(name)) { u.hosts.Add(name); } cu = null; } } } foreach (KeyValuePair <string, User> keyValue in dict) { Console.WriteLine("==================="); Console.WriteLine(keyValue.Key); var result = String.Join(", ", keyValue.Value.hosts.ToArray()); Console.WriteLine(result); } }
public void checkDir(String folder) { //если пустая то проходим if (FILEWORK.isEmptyDir(folder)) { return; } //если содержит файл то пропускаем DirectoryInfo di = new DirectoryInfo(folder); //проверка на недопустимые файлы FileInfo[] fi = di.GetFiles(); if (fi.Length > 0) { throw new Exception(String.Format("{0} содержит недопустимые файлы", di.Name)); } //проверка на пустые папки внутри DirectoryInfo[] diA = di.GetDirectories(); foreach (var content in diA) { //проверка конкретный контент int number; bool success = Int32.TryParse(content.Name, out number); if (success) { string newpath = FILEWORK.renameDir(content.FullName, String.Format("a{0}", content.Name)); Console.WriteLine("{0}wrong name: {1} ->renaming", CONST._INS, content.Name); } } DirectoryInfo[] diB = di.GetDirectories(); foreach (var content in diB) { //проверка конкретный контент checkContent(content, di); } }
public void prefixWork() { //0 инит picturesf = PATH.datad; listname = DOGANDCAT._type.ToLower() + ".html"; outfolder = PATH.outf + "\\" + DOGANDCAT._type.ToLower(); fpath = PATH.site + "\\" + listname; htmlfolder = PATH.site + "\\data\\" + DOGANDCAT._type.ToLower(); opath = outfolder + "\\" + listname; templateList = PATH.templ + "\\" + DOGANDCAT._type.ToLower() + "\\catalog.html"; templateListItem = PATH.templ + "\\" + DOGANDCAT._type.ToLower() + "\\listitem.txt"; imglistprefix = "data\\" + DOGANDCAT._type.ToLower(); itemtemplate = PATH.templ + "\\" + DOGANDCAT._type.ToLower() + "\\itemdogandcat.html"; //1. Очищение out File.Delete(fpath); FILEWORK.clearDir(outfolder); //2. Очищаем html FILEWORK.clearDir(htmlfolder); }
public void EXECUTE() { Console.WriteLine("PARSE FILES"); Console.WriteLine(""); Console.WriteLine(""); parseFiles(); content = FILEWORK.ReadFileContent(html.FullName); Console.WriteLine("START PARSING HTML"); Console.WriteLine(""); Console.WriteLine(""); parseHtml(); Console.WriteLine("START FOUND ITEMS"); Console.WriteLine(""); Console.WriteLine(""); foundItems(); saveInfo(); foreach (var d in data) { String r = niceString(d.ModelString, d.Name, d.embededUrl, 50, 50); Console.WriteLine(r); } foreach (var d in data) { if (String.IsNullOrEmpty(d.ModelString)) { Console.WriteLine("!!!!! no found for: " + d.embededUrl); } } }
public override void WORK() { DATA._newExist = FILEWORK.isEmptyDir(PATH._newd) && FILEWORK.isEmptyDir(PATH._neww) && FILEWORK.isEmptyDir(PATH._newf) && FILEWORK.isEmptyDir(PATH._newfood) && FILEWORK.isEmptyDir(PATH._newb); if (DATA._newExist) { // Console.WriteLine(CONST._INS + "НЕЧЕГО ДОБАВИТЬ"); return; } else { // Console.WriteLine(CONST._INS + "ЕСТЬ НОВЫЙ КОНТЕНТ"); } checkDir(PATH._neww); checkDir(PATH._newf); checkDir(PATH._newd); checkDir(PATH._news); checkDir(PATH._newb); //checkDir(PATH._newfood); }
public void createList() { string template = FILEWORK.ReadFileContent(templateList); string itemtemplate = FILEWORK.ReadFileContent(templateListItem); template = template.Replace("$header1", CONST.header1); template = template.Replace("$footer1", ""); string itemFull = ""; List <TRAVEL> travels = DATA._TRAVELS.OrderByDescending(o => o.Id).ToList(); foreach (TRAVEL item in travels) { string itemres = itemtemplate; int index = 1; foreach (string img in item.mainIng) { string sname = DATA.imageDict[img]; string rr = "$image" + index; itemres = itemres.Replace(rr, imglistprefix + "\\" + item.Id + "\\" + img); index++; } itemres = itemres.Replace("$city", item.name); itemres = itemres.Replace("$date", item.ldate); itemres = itemres.Replace("$price", item.lcount); itemres = itemres.Replace("$link", imglistprefix + "\\" + item.Id + ".html"); itemFull = itemFull + itemres; } string result = template.Replace("param_models", itemFull); FILEWORK.WriteFileContent(opath, result); Console.WriteLine("+ " + fpath); }
public override void WORK() { getProcced(); List <string> files = new List <string>(); files = FILEWORK.GetAllFiles(PATH.data, files, ".jpg"); foreach (String f in files) { string fullName = f; String[] ll = f.Split(new string[] { "\\" }, StringSplitOptions.None); string fname = ll.Last(); DATA.imageDict.Add(fname, fullName); //bool isLong = IMAGEWORKER.isLongImage(fname); //DATA.longImgDict.Add(fname, isLong); DATA.RevImageDict.Add(fullName, fname); if (!proceed.Contains(fname)) { newproceed.Add(fname); } } foreach (string s in newproceed) { List <double> res = IMAGEWORKER.lessImageSet(s); size1 = size1 + res[0]; size2 = size2 + res[1]; added = true; } setProcced(); if (added) { Console.WriteLine("{0} {1}->{2}", CONST._INS, size1, size2); } }
private void createItems() { string template = FILEWORK.ReadFileContent(itemtemplate); template = template.Replace("$header2", CONST.header2); template = template.Replace("$footer2", CONST.footer2); string itemtemplateitem = FILEWORK.ReadFileContent(PATH.templ + "\\" + DOGANDCAT._type.ToUpper() + "\\itemdogandcatitem.txt"); foreach (var item in DATA._DOGANDCAT) { string result = template; result = result.Replace("$Id", item.Id.ToString()); result = result.Replace("$date", item.date.ToString("yyyy-MM-dd")); result = result.Replace("$mainImg", item.Id + "/" + item.mainImg); string texts = string.Join("<br> <br>", item.txtContents.ToArray()); result = result.Replace("$text", "<p>" + texts + "</p>"); string bi = "build" + item.Id; //боковые КОНТЕНТ //либо ютуб первый либо картинки if (item.hasYoutube) { //правый ютуб string you = item.you1[0]; string ycont = CONST.youtubeRight; ycont = ycont.Replace("$srcitem", you); result = result.Replace("$leftcontent", ycont); } else { //правые картинки string imgres = ""; List <string> imgs = item.img1; foreach (string img in imgs) { string itimgs = itemtemplateitem; string ig = DATA.RevImageDict[img]; itimgs = itimgs.Replace("$image", item.Id + "/" + ig); imgres = imgres + itimgs; } result = result.Replace("$leftcontent", imgres); } //отстаточные картинки string imgsco = ""; List <string> imgs2 = item.img2; foreach (string img in imgs2) { string itimgs = itemtemplateitem; string ig = DATA.RevImageDict[img]; itimgs = itimgs.Replace("$image", item.Id + "/" + ig); imgsco = imgsco + itimgs; } result = result.Replace("$images", imgsco); string youcont = ""; foreach (string you in item.you2) { bool isOne = item.you2.Count == 1 || (item.you2.Last() == you && item.you2.Count % 2 != 0); string itimgs = !isOne ? CONST.youtube1 : CONST.youtube2; itimgs = itimgs.Replace("$srcitem", you); youcont = youcont + itimgs; } result = result.Replace("$youtubs", youcont); result = result.Replace("$fancygroupfull", bi); string path = PATH.site + "\\data\\dogandcat\\" + item.Id + ".html"; FILEWORK.WriteFileContent(path, result); Console.WriteLine("+ " + path); } }
public void createList() { string template = FILEWORK.ReadFileContent(templateList); string itemtemplate = FILEWORK.ReadFileContent(templateListItem); template = template.Replace("$header1", CONST.header1); template = template.Replace("$footer1", CONST.footer1); string itemFull = ""; List <WORKOUT> works = DATA._WORKOUT.OrderByDescending(o => o.Id).ToList(); foreach (WORKOUT item in works) { string itemres = itemtemplate; string bi = "build" + item.Id; itemres = itemres.Replace("$fancygroupfull", bi); itemres = itemres.Replace("$fancygroupfull", bi); itemres = itemres.Replace("$title", item.date.ToString("yyyy-MM-dd")); string texts = string.Join("<br> <br>", item.txtContents.ToArray()); itemres = itemres.Replace("$text", texts); List <string> used = new List <string>(); string i1 = item.mainImg; string sname = DATA.imageDict[i1]; used.Add(sname); itemres = itemres.Replace("$image1", imglistprefix + "\\" + item.Id + "\\" + i1); string i2 = imgName(used, item); itemres = itemres.Replace("$image2", imglistprefix + "\\" + item.Id + "\\" + i2); string i3 = imgName(used, item); itemres = itemres.Replace("$image3", imglistprefix + "\\" + item.Id + "\\" + i3); string i4 = imgName(used, item); itemres = itemres.Replace("$image4", imglistprefix + "\\" + item.Id + "\\" + i4); string i5 = imgName(used, item); itemres = itemres.Replace("$image5", imglistprefix + "\\" + item.Id + "\\" + i5); string i6 = imgName(used, item); itemres = itemres.Replace("$image6", imglistprefix + "\\" + item.Id + "\\" + i6); string i7 = imgName(used, item); itemres = itemres.Replace("$image7", imglistprefix + "\\" + item.Id + "\\" + i7); itemres = itemres.Replace("$link", imglistprefix + "\\" + item.Id + ".html"); itemFull = itemFull + itemres; } string result = template.Replace("$items", itemFull); FILEWORK.WriteFileContent(opath, result); Console.WriteLine("+ " + fpath); }
public void createTravel(DirectoryInfo f) { TRAVEL travel = new TRAVEL(); string name = f.Name; travel.dataFolderPath = f.FullName; travel.Id = Convert.ToInt32(name); string content = FILEWORK.ReadFileContent(f.FullName + "//info.txt"); String[] lines = content.Split(new string[] { "\n" }, StringSplitOptions.None); #region parse order.txt string order = FILEWORK.ReadFileContent(f.FullName + "//order.txt"); String[] order_lines = order.Split(new string[] { "\n" }, StringSplitOptions.None); travel.order = order_lines.ToList(); #endregion #region youtubs.txt if (File.Exists(f.FullName + "//youtubs.txt")) { string ycontent = FILEWORK.ReadFileContent(f.FullName + "//youtubs.txt"); String[] ycontent_lines = ycontent.Split(new string[] { "\n" }, StringSplitOptions.None); foreach (var you in ycontent_lines) { string syou = parseYoutubs(you); travel.youtubs.Add(syou); } } #endregion travel.description = FILEWORK.ReadFileContent(f.FullName + "//description.txt"); foreach (string line in lines) { if (String.IsNullOrEmpty(line)) { continue; } if (travel.name == null) { travel.name = line; continue; } if (travel.ldate == null) { travel.ldate = line; continue; } if (travel.lcount == null) { travel.lcount = line; continue; } if (line.Contains(".jpg")) { travel.mainIng.Add(line); continue; } if (travel.praceS == null) { travel.praceS = line; continue; } if (travel.praceL == null) { travel.praceL = line; continue; } } List <string> imgs = new List <string>(); travel.imgs = FILEWORK.GetAllFiles(travel.dataFolderPath, imgs, ".jpg"); List <string> txts = new List <string>(); txts = FILEWORK.GetAllFiles(travel.dataFolderPath, txts, ".txt"); foreach (string s in txts) { FileInfo ff = new FileInfo(s); string fname = ff.Name; String[] ll = fname.Split(new string[] { ".txt" }, StringSplitOptions.None); string shortName = ll[0]; bool success = travel.order.Contains(shortName); if (success) { addLSText(shortName, travel, ff.FullName); } } DATA._TRAVELS.Add(travel); }
//для парсинга public void parse() { List <string> imgs = new List <string>(); this.imgs = FILEWORK.GetAllFiles(dataFolderPath, imgs, ".jpg"); this.hasImgs = this.imgs.Count > 0; List <string> txts = new List <string>(); txts = FILEWORK.GetAllFiles(dataFolderPath, txts, ".txt"); this.infoPath = txts[0]; string content = FILEWORK.ReadFileContent(infoPath); String[] lines = content.Split(new string[] { "\n" }, StringSplitOptions.None); foreach (string line in lines) { if (String.IsNullOrEmpty(line)) { continue; } DateTime dateTime; if (DateTime.TryParse(line, out dateTime)) { this.date = dateTime; continue; } if (line.Contains("youtu")) { string youtube = parseYoutubs(line); youtubs.Add(youtube); hasYoutube = true; continue; } if (line.Contains(".jpg")) { mainImg = line; continue; } txtContents.Add(line); } if (String.IsNullOrEmpty(mainImg) && imgs.Count == 1) { string firstImg = imgs.First(); mainImg = DATA.RevImageDict[firstImg]; } //теперь разрешаем title/соntent if (txtContents.Count == 1) { this.title = this.date.ToString("yyyy-MM-dd"); this.mainText = txtContents[0]; } if (txtContents.Count == 2) { txtContents = txtContents.OrderBy(o => o.Length).ToList(); this.title = txtContents[0]; this.mainText = txtContents[1]; } string mainIngFullRef = DATA.getImgFullPath(mainImg); List <string> otherImg = imgs.Where(o => o != mainIngFullRef).ToList(); int MAXIMG1 = 9; int i = 0; youtubeMode = hasYoutube; if (!hasYoutube) { foreach (string s in otherImg) { if (i >= MAXIMG1) { break; } img1.Add(s); i++; } } img2 = otherImg.Where(o => !img1.Contains(o)).ToList(); if (hasYoutube) { you1.Add(youtubs.First()); } you2 = youtubs.Where(o => !you1.Contains(o)).ToList(); if (you2.Count > 0) { } }