private void operationMakeOffline(string websiteKey, Artical artical, ArticalOverview overview) { //TODO: Find a way to save the pdf data in a different folder for future use as folder if (db == null) { throw new InvalidOperationException("Database is not created yet."); } overview.IsDatabaseConfirmed_Offline = true; overview.OfflineAvailableOn = DateTime.Today.ToString("yyyyMMdd"); var obj = OfflineTable.New(websiteKey, artical, overview); try { db.Insert(obj); } catch (Exception) { try { db.Update(obj); } catch (Exception) { } } }
public static InstructionSet MakeOffline(string wesiteKey, Artical artical, ArticalOverview overview) { return(new InstructionSet() { articalOverview = new ArticalOverview[] { overview }, action = ActionToPerformInfo.MakeOffline, artical = artical, tags = new object[] { wesiteKey } }); }
public Artical ToArtical() { Artical a = new Artical(); a.Title = Title; a.Authors = Authors; a.Date = Date; a.Authors = Authors; a.MyLink = LinkOfActualArtical; return(a); }
public static OfflineTable New(string websiteKey, Artical artical, ArticalOverview overview) { return(new OfflineTable() { LinkOfActualArtical = overview.LinkOfActualArtical, Title = overview.Title, SummaryText = overview.SummaryText, Date = overview.Date, SeenOn = overview.SeenOn, HtmlText = artical.HtmlText, ExtrnalLinks = artical.ExternalFileLink, OfflineAvailableOn = DateTime.Today.ToString("yyyyMMdd"), WebsiteKey = websiteKey }); }
public void MakeOffline(string transactionId, string websiteKey, Artical artical, ArticalOverview articalOverview) { pendingRequest.Push(transactionId, InstructionSet.MakeOffline(websiteKey, artical, articalOverview)); handler.Set(); }
public static string GetPrimaryKey(Artical artical) => artical.MyLink;
private void originalResponse(RequestPacket packet) { MyLog.Log(this, nameof(originalResponse) + packet.Url + "..."); var data = packet.DataInString; HtmlAgilityPack.HtmlDocument doc = null; if (!string.IsNullOrEmpty(data)) { MyLog.Log(this, "Loading HTML data" + "..."); doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(data); MyLog.Log(this, "Loading HTML data" + "...Done"); } var currentWebsite = Config.GetWebsite(packet.WebsiteKey); var overviewType = packet.OverviewType; if (overviewType == OverviewType.Null) { //Artical Artical artical = null; MyLog.Log(this, "Reading artical" + "..."); if (doc != null) { artical = currentWebsite.ReadArtical(packet.Tag as ArticalOverview, doc); } else { artical = currentWebsite.ReadArticalExtrnal(packet.Tag as ArticalOverview, packet.ExtrnalLink); } MyLog.Log(this, "Reading artical" + "...Done"); MyLog.Log(this, "Making callback on artical" + "..."); packet.AnalisisModuleResponseUiArtical .ArticalProcessedCallback (packet.Uid, packet.Url, artical); MyLog.Log(this, "Making callback on artical" + "...Done"); } else { string nextPage = string.Empty; switch (overviewType) { case OverviewType.Null: break; case OverviewType.UNKNOWN: break; case OverviewType.IndexPage: MyLog.Log(this, "Reading index page data" + "..."); var iData = currentWebsite.ReadIndexPage(packet.Url, doc, out nextPage); MyLog.Log(this, "Reading index page data" + "...Done"); MyLog.Log(this, "Making index page callback" + "..."); packet.AnalisisModuleResponseUiArticalOverview .ArticalOverviewProcessedCallback (packet.Uid, packet.Url, iData, overviewType, nextPage); MyLog.Log(this, "Making index page callback" + "...Done"); break; case OverviewType.Author: MyLog.Log(this, "Reading author page data" + "..."); var aData = currentWebsite.ReadAuthor(packet.Tag as Author, doc, out nextPage); MyLog.Log(this, "Reading author page data" + "...Done"); MyLog.Log(this, "Making author page callback" + "..."); packet.AnalisisModuleResponseUiArticalOverview .ArticalOverviewProcessedCallback (packet.Uid, packet.Url, aData, overviewType, nextPage); MyLog.Log(this, "Making author page callback" + "...Done"); break; case OverviewType.Category: MyLog.Log(this, "Reading category page data" + "..."); var cData = currentWebsite.ReadCategory(packet.Tag as Category, doc, out nextPage); MyLog.Log(this, "Reading category page data" + "...Done"); MyLog.Log(this, "Making category page callback" + "..."); packet.AnalisisModuleResponseUiArticalOverview .ArticalOverviewProcessedCallback (packet.Uid, packet.Url, cData, overviewType, nextPage); MyLog.Log(this, "Making category page callback" + "...Done"); break; default: break; } if (nextPage != null && nextPage != string.Empty) { //TODO: Think how to hold the next page info } } MyLog.Log(this, nameof(originalResponse) + packet.Url + "...Done"); }