/// <summary> /// This function is used to delete an TemplateChunksEntity. /// </summary> /// <param name="chunkid">Chunk ID</param> /// <param name="templateguid">Template GUID</param> /// <param name="ispreparsed">Is Preparsed Flag</param> /// <returns>True on success, false on fail.</returns> public static bool Delete(int chunkid, Guid templateguid, bool ispreparsed) { TemplateChunksEntity templates = new TemplateChunksEntity(templateguid, ispreparsed, chunkid); DataAccessAdapter ds = new DataAccessAdapter(); return(ds.DeleteEntity(templates)); }
//public static int Count(Guid templateGuid) //{ // DataAccessAdapter ds = new DataAccessAdapter(); // PredicateExpression pred = new PredicateExpression(); // pred.Add(TemplateChunksFields.TemplateGUID == templateguid); // RelationPredicateBucket bucket = new RelationPredicateBucket(pred); // return ds. // return ds.DeleteEntitiesDirectly("TemplateChunksEntity", bucket); //} /// <summary> /// This method is used to retreive a single TemplateChunksEntity by it Primary Key /// </summary> /// <param name="chunkID">Chunk ID</param> /// <param name="templateGUID">Template Global Unique ID</param> /// <param name="isPreParsed">Is Pre Parsed Flag</param> /// <returns>An entity if found, null if nothing found.</returns> public static TemplateChunksEntity SelectSingle(int chunkID, Guid templateGUID, bool isPreParsed) { TemplateChunksEntity tce = new TemplateChunksEntity(templateGUID, isPreParsed, chunkID); DataAccessAdapter ds = new DataAccessAdapter(); if (ds.FetchEntity(tce) == true) { return(tce); } else { return(null); } }
/// <summary> /// This function is used to insert a TemplateChunksEntity in the storage area. /// </summary> /// <param name="chunkid">Chunk ID</param> /// <param name="templateguid">Template GUID</param> /// <param name="ispreparsed">Is Preparsed Flag</param> /// <param name="htmltext">HTML Text</param> /// <param name="chunktype">Chunk Type</param> /// <param name="prefix">Prefix</param> /// <param name="tagname">TagName</param> /// <param name="attributes">Attributes</param> /// <returns>True on success, False on fail</returns> public static bool Insert(int chunkid, Guid templateguid, bool ispreparsed, string htmltext, byte chunktype, string prefix, string tagname, string attributes) { TemplateChunksEntity templates = new TemplateChunksEntity(); templates.ChunkID = chunkid; templates.TemplateGUID = templateguid; templates.IsPreParsed = ispreparsed; templates.HTMLText = htmltext; templates.ChunkType = chunktype; templates.Prefix = prefix; templates.TagName = tagname; templates.Attributes = attributes; DataAccessAdapter ds = new DataAccessAdapter(); return(ds.SaveEntity(templates)); }
public static int SaveChunksFromSource(Guid templateGUID, string source) { //Chekc if guid exists with oarsed = true if (SelectCount(templateGUID, true) > 0) { Delete(templateGUID, true); } //Pass to parser. //get chunks //save chunks with incrementing chunk id; int currentChunk = 1; HtmlParser parser = new HtmlParser(); EntityCollection <TemplateChunksEntity> chunkcoll = new EntityCollection <TemplateChunksEntity>(); List <HtmlChunk> chunks = parser.ParseToChunks(source); foreach (HtmlChunk chunk in chunks) { TemplateChunksEntity chunkEntity = new TemplateChunksEntity(templateGUID, true, currentChunk); currentChunk++; chunkEntity.HTMLText = chunk.Value; chunkEntity.ChunkType = (byte)chunk.ChunkType; if (chunk.ChunkType == HtmlChunkType.Tag || chunk.ChunkType == HtmlChunkType.Region) { HtmlTag chunkTag = (HtmlTag)chunk; chunkEntity.Prefix = chunkTag.Prefix; chunkEntity.TagName = chunkTag.TagName; chunkEntity.Attributes = chunkTag.AttributesAsString; } chunkcoll.Add(chunkEntity); } DataAccessAdapter da = new DataAccessAdapter(); return(da.SaveEntityCollection(chunkcoll)); }