/// <summary> /// Parse data from the item. /// </summary> /// <param name="oSource">Source object.</param> /// <param name="item">Item object.</param> /// <returns>Result of executing SQL-query.</returns> private int ParseItemData(THashtable oSource, THashtable item) { // Load original values var sourceName = STR(oSource["s_SourceName"]); var sourceId = INT(oSource["i_SourceId"]); var boItem = new BOItem(sourceName, item); var pubDate = STR(item["pubDate"]); if (BLANK(pubDate) && !BLANK(item["dc"])) //TODO implement [dc][time] { var temp = (THashtable)item["dc"]; if (!BLANK(temp["date"])) { pubDate = STR(temp["date"]); item["pubDate"] = pubDate; } } boItem.ProcessMappings(this.dsMappings); boItem.ProcessDescription(); //boItem.ProcessCustomFields(); // Uncomment for processing custom fields boItem.ProcessCategory(); boItem.ProcessCreator(); // Process rules AFTER processing description (as some info can be extracted from it) boItem.ProcessRules(this.dsRules); if (BLANK(boItem.link)) //TODO - what we can do else? { return(0); } // Get date here as it can be extracted in rules processing if (boItem.date != null) { pubDate = boItem.date; } if (!BLANK(pubDate)) { pubDate = pubDate.Trim(); } var date = DateTimes.GmtFormat(DateTimes.SQL_DTS, DateTimes.FromRss(pubDate)); // Check whether item with the same link exists already var doItem = new DOItem(this.context.Connection); var dsItems = doItem.FindItemByLink(boItem.link, sourceId); if (dsItems.GetSize() > 0) { return(0); } // Try to add/embed standard categories from description var countCategories = boItem.AddStandardCategories(this.dsCategories, this.context.Lang); boItem.NormalizeCategories(); // Check the link once again after processing rules if (dsItems == null && !BLANK(boItem.link)) { doItem.FindItemByLink(boItem.link, sourceId); if (dsItems.GetSize() > 0) { return(0); } } var url = boItem.GetUrlTitle(true); //TODO -- Need to pass true if transliteration is required var fields = new THashtable(); fields["s_Link"] = boItem.link; fields["s_Title"] = boItem.title; fields["s_FullTitle"] = boItem.fullTitle; fields["s_Url"] = url; fields["i_Categories"] = countCategories; if (boItem.description != null) { fields["t_Description"] = boItem.description; } if (boItem.fullDescription != null) { fields["t_FullDescription"] = boItem.fullDescription; } fields["d_Date"] = date; fields["i_SourceLink"] = INT(oSource["i_SourceId"]); if (!BLANK(boItem.category)) { fields["s_Category"] = boItem.category; } if (!BLANK(boItem.creator)) { fields["s_Creator"] = boItem.creator; } if (!BLANK(boItem.custom1)) { fields["s_Custom1"] = boItem.custom1; } if (!BLANK(boItem.custom2)) { fields["s_Custom2"] = boItem.custom2; } var result = doItem.Insert(fields); return(result); }