PageRenderTime 47ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/mojoPortal.Business.WebHelpers/Search/IndexItem.cs

#
C# | 493 lines | 404 code | 70 blank | 19 comment | 6 complexity | a2f64e980eedc865d40ba769ed670b0f MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause, CPL-1.0, CC-BY-SA-3.0, GPL-2.0
  1. // Author: Joe Audette
  2. // Created: 2005-06-26
  3. // Last Modified: 2009-06-01
  4. //
  5. // The use and distribution terms for this software are covered by the
  6. // Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
  7. // which can be found in the file CPL.TXT at the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by
  9. // the terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. using System;
  13. using System.Globalization;
  14. using System.Xml;
  15. using System.Xml.Serialization;
  16. namespace mojoPortal.Business.WebHelpers
  17. {
  18. /// <summary>
  19. ///
  20. /// </summary>
  21. [Serializable()]
  22. public class IndexItem
  23. {
  24. #region Constructors
  25. public IndexItem()
  26. {
  27. }
  28. public IndexItem(Lucene.Net.Documents.Document doc, float score)
  29. {
  30. ViewRoles = doc.Get("ViewRoles");
  31. SiteId = Convert.ToInt32(doc.Get("SiteID"), CultureInfo.InvariantCulture);
  32. PageId = Convert.ToInt32(doc.Get("PageID"), CultureInfo.InvariantCulture);
  33. PageName = doc.Get("PageName");
  34. PageIndex = Convert.ToInt32(doc.Get("PageIndex"), CultureInfo.InvariantCulture);
  35. PageNumber = Convert.ToInt32(doc.Get("PageNumber"), CultureInfo.InvariantCulture);
  36. string fid = doc.Get("FeatureId");
  37. if ((fid != null)&&(fid.Length > 0))
  38. {
  39. FeatureId = fid;
  40. }
  41. FeatureName = doc.Get("FeatureName");
  42. ItemId = Convert.ToInt32(doc.Get("ItemID"), CultureInfo.InvariantCulture);
  43. ModuleId = Convert.ToInt32(doc.Get("ModuleID"), CultureInfo.InvariantCulture);
  44. ModuleTitle = doc.Get("ModuleTitle");
  45. Title = doc.Get("Title");
  46. intro = doc.Get("Intro");
  47. ViewPage = doc.Get("ViewPage");
  48. QueryStringAddendum = doc.Get("QueryStringAddendum");
  49. DateTime pubBegin = DateTime.MinValue;
  50. if (DateTime.TryParse(doc.Get("PublishBeginDate"), out pubBegin))
  51. {
  52. this.publishBeginDate = pubBegin;
  53. }
  54. DateTime pubEnd = DateTime.MaxValue;
  55. if (DateTime.TryParse(doc.Get("PublishEndDate"), out pubEnd))
  56. {
  57. this.publishEndDate = pubEnd;
  58. }
  59. bool useQString;
  60. if (bool.TryParse(doc.Get("UseQueryStringParams"), out useQString))
  61. {
  62. this.useQueryStringParams = useQString;
  63. }
  64. boost = doc.GetBoost();
  65. }
  66. #endregion
  67. #region Private Properties
  68. private int siteID = -1;
  69. private int pageID = -1;
  70. private int moduleID = -1;
  71. private int itemID = -1;
  72. private int pageIndex = -1;
  73. private int pageNumber = 1; // for use in pageable modules like forums
  74. private string pageName = string.Empty;
  75. private string featureId = Guid.Empty.ToString();
  76. private string featureName = string.Empty;
  77. private string featureResourceFile = string.Empty;
  78. private string moduleTitle = string.Empty;
  79. private string title = string.Empty;
  80. private string content = string.Empty;
  81. private string otherContent = string.Empty;
  82. private string intro = string.Empty;
  83. private string viewRoles = string.Empty;
  84. private string moduleViewRoles = string.Empty;
  85. private string viewPage = "Default.aspx";
  86. private bool useQueryStringParams = true;
  87. private string queryStringAddendum = string.Empty;
  88. private DateTime publishBeginDate = DateTime.MinValue;
  89. private DateTime publishEndDate = DateTime.MaxValue;
  90. private string indexPath = string.Empty;
  91. private string itemKey = string.Empty;
  92. private string pageMetaDescription = string.Empty;
  93. private string pageMetaKeywords = string.Empty;
  94. private float score = 0;
  95. private float boost = 0;
  96. private bool removeOnly = false;
  97. #endregion
  98. #region Public Properties
  99. public string IndexPath
  100. {
  101. get { return indexPath; }
  102. set { indexPath = value; }
  103. }
  104. public string Key
  105. {
  106. get
  107. {
  108. return this.siteID.ToString(CultureInfo.InvariantCulture) + "~"
  109. + this.pageID.ToString(CultureInfo.InvariantCulture) + "~"
  110. + this.moduleID.ToString(CultureInfo.InvariantCulture) + "~"
  111. + ItemKey
  112. + this.queryStringAddendum;
  113. }
  114. }
  115. public int SiteId
  116. {
  117. get { return siteID; }
  118. set { siteID = value; }
  119. }
  120. public int PageId
  121. {
  122. get { return pageID; }
  123. set { pageID = value; }
  124. }
  125. public int ModuleId
  126. {
  127. get { return moduleID; }
  128. set { moduleID = value; }
  129. }
  130. public int ItemId
  131. {
  132. get { return itemID; }
  133. set { itemID = value; }
  134. }
  135. public string ItemKey
  136. {
  137. get
  138. {
  139. if (ItemId > -1)
  140. {
  141. //return ItemId.ToString(CultureInfo.InvariantCulture) + itemKey;
  142. return ItemId.ToString(CultureInfo.InvariantCulture);
  143. }
  144. return itemKey;
  145. }
  146. set { itemKey = value; }
  147. }
  148. /// <summary>
  149. /// legacy field not needed anymore
  150. /// </summary>
  151. public int PageIndex
  152. {
  153. get { return pageIndex; }
  154. set { pageIndex = value; }
  155. }
  156. public int PageNumber
  157. {
  158. get { return pageNumber; }
  159. set { pageNumber = value; }
  160. }
  161. public bool RemoveOnly
  162. {
  163. get { return removeOnly; }
  164. set { removeOnly = value; }
  165. }
  166. [XmlIgnore]
  167. public string PageName
  168. {
  169. get { return pageName; }
  170. set { pageName = value; }
  171. }
  172. // This is needed to support xml serialization, string with special characterscan cause invalid xml, base 64 encoding them gets around the problem.
  173. [XmlElement(ElementName = "pageName", DataType = "base64Binary")]
  174. public byte[] PageNameSerialization
  175. {
  176. get
  177. {
  178. return System.Text.Encoding.Unicode.GetBytes(PageName);
  179. }
  180. set
  181. {
  182. PageName = System.Text.Encoding.Unicode.GetString(value);
  183. }
  184. }
  185. [XmlIgnore]
  186. public string PageMetaDescription
  187. {
  188. get { return pageMetaDescription; }
  189. set { pageMetaDescription = value; }
  190. }
  191. [XmlElement(ElementName = "pageMetaDescription", DataType = "base64Binary")]
  192. public byte[] PageMetaDescriptionSerialization
  193. {
  194. get
  195. {
  196. return System.Text.Encoding.Unicode.GetBytes(PageMetaDescription);
  197. }
  198. set
  199. {
  200. PageMetaDescription = System.Text.Encoding.Unicode.GetString(value);
  201. }
  202. }
  203. [XmlIgnore]
  204. public string PageMetaKeywords
  205. {
  206. get { return pageMetaKeywords; }
  207. set { pageMetaKeywords = value; }
  208. }
  209. [XmlElement(ElementName = "pageMetaKeywords", DataType = "base64Binary")]
  210. public byte[] PageMetaKeywordsSerialization
  211. {
  212. get
  213. {
  214. return System.Text.Encoding.Unicode.GetBytes(PageMetaKeywords);
  215. }
  216. set
  217. {
  218. PageMetaKeywords = System.Text.Encoding.Unicode.GetString(value);
  219. }
  220. }
  221. public string FeatureId
  222. {
  223. get { return featureId; }
  224. set { featureId = value; }
  225. }
  226. [XmlIgnore]
  227. public string FeatureName
  228. {
  229. get { return featureName; }
  230. set { featureName = value; }
  231. }
  232. [XmlElement(ElementName = "featureName", DataType = "base64Binary")]
  233. public byte[] FeatureNameSerialization
  234. {
  235. get
  236. {
  237. return System.Text.Encoding.Unicode.GetBytes(FeatureName);
  238. }
  239. set
  240. {
  241. FeatureName = System.Text.Encoding.Unicode.GetString(value);
  242. }
  243. }
  244. public string FeatureResourceFile
  245. {
  246. get { return featureResourceFile; }
  247. set { featureResourceFile = value; }
  248. }
  249. [XmlIgnore]
  250. public string ModuleTitle
  251. {
  252. get { return moduleTitle; }
  253. set { moduleTitle = value; }
  254. }
  255. [XmlElement(ElementName = "moduleTitle", DataType = "base64Binary")]
  256. public byte[] ModuleTitleSerialization
  257. {
  258. get
  259. {
  260. return System.Text.Encoding.Unicode.GetBytes(ModuleTitle);
  261. }
  262. set
  263. {
  264. ModuleTitle = System.Text.Encoding.Unicode.GetString(value);
  265. }
  266. }
  267. [XmlIgnore]
  268. public string Title
  269. {
  270. get { return title; }
  271. set { title = value; }
  272. }
  273. [XmlElement(ElementName = "title", DataType = "base64Binary")]
  274. public byte[] TitleSerialization
  275. {
  276. get
  277. {
  278. return System.Text.Encoding.Unicode.GetBytes(Title);
  279. }
  280. set
  281. {
  282. Title = System.Text.Encoding.Unicode.GetString(value);
  283. }
  284. }
  285. [XmlIgnore]
  286. public string Intro
  287. {
  288. get { return intro; }
  289. set { intro = value; }
  290. }
  291. [XmlElement(ElementName = "intro", DataType = "base64Binary")]
  292. public byte[] IntroSerialization
  293. {
  294. get
  295. {
  296. return System.Text.Encoding.Unicode.GetBytes(Intro);
  297. }
  298. set
  299. {
  300. Intro = System.Text.Encoding.Unicode.GetString(value);
  301. }
  302. }
  303. [XmlIgnore]
  304. public string Content
  305. {
  306. get { return content; }
  307. set { content = value; }
  308. }
  309. [XmlElement(ElementName = "content", DataType = "base64Binary")]
  310. public byte[] ContentSerialization
  311. {
  312. get
  313. {
  314. return System.Text.Encoding.Unicode.GetBytes(Content);
  315. }
  316. set
  317. {
  318. Content = System.Text.Encoding.Unicode.GetString(value);
  319. }
  320. }
  321. [XmlIgnore]
  322. public string OtherContent
  323. {
  324. get { return otherContent; }
  325. set { otherContent = value; }
  326. }
  327. [XmlElement(ElementName = "otherContent", DataType = "base64Binary")]
  328. public byte[] OtherContentSerialization
  329. {
  330. get
  331. {
  332. return System.Text.Encoding.Unicode.GetBytes(OtherContent);
  333. }
  334. set
  335. {
  336. OtherContent = System.Text.Encoding.Unicode.GetString(value);
  337. }
  338. }
  339. [XmlIgnore]
  340. public string ViewRoles
  341. {
  342. get { return viewRoles; }
  343. set { viewRoles = value; }
  344. }
  345. [XmlElement(ElementName = "viewRoles", DataType = "base64Binary")]
  346. public byte[] ViewRolesSerialization
  347. {
  348. get
  349. {
  350. return System.Text.Encoding.Unicode.GetBytes(ViewRoles);
  351. }
  352. set
  353. {
  354. ViewRoles = System.Text.Encoding.Unicode.GetString(value);
  355. }
  356. }
  357. [XmlIgnore]
  358. public string ModuleViewRoles
  359. {
  360. get { return moduleViewRoles; }
  361. set { moduleViewRoles = value; }
  362. }
  363. [XmlElement(ElementName = "moduleViewRoles", DataType = "base64Binary")]
  364. public byte[] ModuleViewRolesSerialization
  365. {
  366. get
  367. {
  368. return System.Text.Encoding.Unicode.GetBytes(ModuleViewRoles);
  369. }
  370. set
  371. {
  372. ModuleViewRoles = System.Text.Encoding.Unicode.GetString(value);
  373. }
  374. }
  375. [XmlIgnore]
  376. public string ViewPage
  377. {
  378. get { return viewPage; }
  379. set { viewPage = value; }
  380. }
  381. [XmlElement(ElementName = "viewPage", DataType = "base64Binary")]
  382. public byte[] ViewPageSerialization
  383. {
  384. get
  385. {
  386. return System.Text.Encoding.Unicode.GetBytes(ViewPage);
  387. }
  388. set
  389. {
  390. ViewPage = System.Text.Encoding.Unicode.GetString(value);
  391. }
  392. }
  393. public bool UseQueryStringParams
  394. {
  395. get { return useQueryStringParams; }
  396. set { useQueryStringParams = value; }
  397. }
  398. public string QueryStringAddendum
  399. {
  400. get { return queryStringAddendum; }
  401. set { queryStringAddendum = value; }
  402. }
  403. public DateTime PublishBeginDate
  404. {
  405. get { return publishBeginDate; }
  406. set { publishBeginDate = value; }
  407. }
  408. public DateTime PublishEndDate
  409. {
  410. get { return publishEndDate; }
  411. set { publishEndDate = value; }
  412. }
  413. public float Score
  414. {
  415. get { return score; }
  416. }
  417. public float Boost
  418. {
  419. get { return boost; }
  420. }
  421. #endregion
  422. }
  423. }