public static void ConvertDB(LiteCollection <Entry> collection, DBProcessor updater) { var res = collection.FindAll().ToList(); // var resOut = collection.Find(x => x.DatePageCreated <= DateTime.Today.AddDays(-15) && x.DatePageCreated >= DateTime.Today.AddDays(-20)).ToList(); List <json> populatedLink = new List <json>(); for (int i = 0; i < res.Count; i++) { for (int j = 0; j < res[i].Download.FileType.Count; j++) { for (int k = 0; k < res[i].Download.FileType[j].Link.Count; k++) { populatedLink.Add(new json(res[i].Download.FileType[j].Link[k].Url, res[i].Download.FileType[j].Link[k].IsConverted)); } } } string json = JsonConvert.SerializeObject(populatedLink); JsonObj.DoCall(json, out populatedLink); int indexing = 0; for (int i = 0; i < res.Count; i++) { var resConverted = true; for (int j = 0; j < res[i].Download.FileType.Count; j++) { var fileTypeConverted = true; for (int k = 0; k < res[i].Download.FileType[j].Link.Count; k++) { res[i].Download.FileType[j].Link[k] = new Link(populatedLink[indexing].url, res[i].Download.FileType[j].Link[k].Site, populatedLink[indexing].isConverted); indexing++; if (!res[i].Download.FileType[j].Link[k].IsConverted) { fileTypeConverted = false; } } if (!fileTypeConverted) { resConverted = false; } } res[i].IsConverted = resConverted; } updater.Insert(res); Console.WriteLine("Finished"); }
public static void ConvertManualList(List <Entry> res, DBProcessor updater, out List <Entry> resOut) { resOut = res; List <json> populatedLink = new List <json>(); for (int i = 0; i < resOut.Count; i++) { for (int j = 0; j < resOut[i].Download.FileType.Count; j++) { for (int k = 0; k < resOut[i].Download.FileType[j].Link.Count; k++) { populatedLink.Add(new json(resOut[i].Download.FileType[j].Link[k].Url, resOut[i].Download.FileType[j].Link[k].IsConverted)); } } } string json = JsonConvert.SerializeObject(populatedLink); JsonObj.DoCall(json, out populatedLink); int indexing = 0; for (int i = 0; i < resOut.Count; i++) { var resConverted = true; for (int j = 0; j < resOut[i].Download.FileType.Count; j++) { var fileTypeConverted = true; for (int k = 0; k < resOut[i].Download.FileType[j].Link.Count; k++) { resOut[i].Download.FileType[j].Link[k] = new Link(populatedLink[indexing].url, resOut[i].Download.FileType[j].Link[k].Site, populatedLink[indexing].isConverted); indexing++; if (!resOut[i].Download.FileType[j].Link[k].IsConverted) { fileTypeConverted = false; } } if (!fileTypeConverted) { resConverted = false; } } resOut[i].IsConverted = resConverted; } updater.Insert(resOut); Console.WriteLine("Finished"); }
public static void ConvertEntries(DBProcessor updater) // CHANGE SO ONLY SEND AFTER CHECKED { updater.CheckAndRemove(Entries); List <json> populatedLink = new List <json>(); foreach (var entry in Entries) { foreach (var type in entry.Download.FileType) { foreach (var linkI in type.Link) { populatedLink.Add(new json(linkI.Url, linkI.IsConverted)); } } } string json = JsonConvert.SerializeObject(populatedLink); JsonObj.DoCall(json, out populatedLink); Console.WriteLine("Finished"); var indexing = 0; for (int i = 0; i < Entries.Count; i++) { var resConverted = true; for (int j = 0; j < Entries[i].Download.FileType.Count; j++) { var fileTypeConverted = true; for (int k = 0; k < Entries[i].Download.FileType[j].Link.Count; k++) { Entries[i].Download.FileType[j].Link[k] = new Link(populatedLink[indexing].url, Entries[i].Download.FileType[j].Link[k].Site, populatedLink[indexing].isConverted); indexing++; if (!Entries[i].Download.FileType[j].Link[k].IsConverted) { fileTypeConverted = false; } } if (!fileTypeConverted) { resConverted = false; } } Entries[i].IsConverted = resConverted; } updater.Insert(Entries); }