Пример #1
0
        internal static void MapDataReaderToContentDto(SQLiteDataReader dataReader, out ContentDto contentDto)
        {
            contentDto = new ContentDto();

            contentDto.ContentId = dataReader.GetInt64((int) ContentDao.ContentsField.ContentId);
            contentDto.UrlId = dataReader.GetInt64((int) ContentDao.ContentsField.UrlId);
            contentDto.ContentType = (ContentTypesEnum) dataReader.GetInt64((int) ContentDao.ContentsField.ContentType);
            contentDto.Element = dataReader.GetString((int) ContentDao.ContentsField.Element);
            contentDto.Element = HttpUtility.UrlDecode(contentDto.Element);
            contentDto.Line = dataReader.GetInt64((int) ContentDao.ContentsField.Line);
            contentDto.LinePosition = dataReader.GetInt64((int) ContentDao.ContentsField.LinePosition);
        }
Пример #2
0
        private static ContentDto[] GetContent(WebPageParsing webPageParsing)
        {
            var content = new List <ContentDto>();
            var webPageContent = webPageParsing.GetTitle();

            var contentDto = new ContentDto
                {
                    Element = webPageContent.Element,
                    Line = webPageContent.Line,
                    LinePosition = webPageContent.LinePosition
                };
            content.Add(contentDto);
            return content.ToArray();
        }
Пример #3
0
        internal void InsertOrUpdateContent(ContentDto contentDto)
        {
            string sqlStatement;

            if (contentDto.ContentId.HasValue)
            {
                sqlStatement = String.Format("INSERT OR REPLACE INTO Contents (content_id, url_id, content_type, element, line, line_position) " +
                    "VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')",
                    contentDto.ContentId, contentDto.UrlId, contentDto.ContentTypeRawInt, HttpUtility.UrlEncode(contentDto.Element),
                    contentDto.Line, contentDto.LinePosition);

                ExecuteSqlCommand(sqlStatement);
            }
            else
            {
                sqlStatement = String.Format("INSERT OR REPLACE INTO Contents (url_id, content_type, element, line, line_position) " +
                    "VALUES ('{0}', '{1}', '{2}', '{3}', '{4}')",
                    contentDto.UrlId, contentDto.ContentTypeRawInt, HttpUtility.UrlEncode(contentDto.Element), contentDto.Line,
                    contentDto.LinePosition);

                ExecuteSqlCommand(sqlStatement);
                contentDto.ContentId = GetLastInsertedRowId();
            }
        }