protected virtual string GenerateItemHash(XmlDocument item) { var builder = new StringBuilder(1000); builder.Append(item.Id); builder.Append("|"); builder.Append(item.Title); SHA1CryptoServiceProvider hasher = new SHA1CryptoServiceProvider(); byte[] originalBytes = Encoding.UTF8.GetBytes(builder.ToString()); byte[] encodedBytes = hasher.ComputeHash(originalBytes); return Convert.ToBase64String(encodedBytes); }
public virtual WrapperObject ConvertToWraperObject(XmlDocument item) { WrapperObject obj = new WrapperObject(null); obj.MappingSettings = this.PipeSettings.Mappings; obj.Language = this.PipeSettings.LanguageIds.FirstOrDefault(); obj.AddProperty(PublishingConstants.FieldTitle, item.Title); obj.AddProperty(PublishingConstants.FieldContent, item.Content); obj.AddProperty(PublishingConstants.FieldItemHash, GenerateItemHash(item)); obj.AddProperty(PublishingConstants.FieldLink, item.Image); obj.AddProperty(PublishingConstants.FieldPublicationDate, item.Date); obj.AddProperty(PublishingConstants.FieldIdentifier, item.Id); obj.AddProperty(PublishingConstants.FieldCategories, item.Categories); //list of categories (Category.Name) separated by comma //obj.AddProperty(PublishingConstants.FieldCategories, "News"); return obj; }