public IList <BlockModel> GetListBlockFont(string section) { try { var datas = new List <BlockModel>(); var blockStore = new BlockStore(); var dt = blockStore.GetListBlockFont(section); for (int i = 0; i < dt.Rows.Count; i++) { var model = new BlockModel() { ID = int.Parse(dt.Rows[i]["BLOCK_ID"].ToString()), TITLE = dt.Rows[i]["BLOCK_TITLE"].ToString(), CONTENT = HtmlRemoval.StripTagsRegex(dt.Rows[i]["BLOCK_CONTENT"].ToString()), TAB = dt.Rows[i]["BLOCK_TAB"].ToString(), POSITION = dt.Rows[i]["BLOCK_POSITION"].ToString(), STATUS = dt.Rows[i]["BLOCK_STATUS"].ToString().Trim() == "1", SECTION = dt.Rows[i]["BLOCK_SECTION"].ToString(), IMAGE = dt.Rows[i]["BLOCK_IMAGE"].ToString() // CREATED_DATE = DateTime.Parse(dt.Rows[i]["CREATED_DATE"].ToString()) }; datas.Add(model); } return(datas); } catch (Exception) { return(null); } }
public IList <MenuModel> GetListMenu(string status) { try { var datas = new List <MenuModel>(); var menuStore = new MenuStore(); var dt = menuStore.GetListMenu(status); for (int i = 0; i < dt.Rows.Count; i++) { var model = new MenuModel() { Id = int.Parse(dt.Rows[i]["MENU_ID"].ToString()), Title = HtmlRemoval.StripTagsRegex(dt.Rows[i]["MENU_TITLE"].ToString()), Link = dt.Rows[i]["MENU_LINK"].ToString(), Desc = dt.Rows[i]["MENU_DESC"].ToString(), Status = dt.Rows[i] ["MENU_STATUS"].ToString().Trim() == "1", Link_Home = dt.Rows[i]["MENU_LINK_HOME"].ToString(), Order = int.Parse(dt.Rows[i]["MENU_ORDER"].ToString()) }; datas.Add(model); } return(datas); } catch (Exception) { return(null); } }
private string StripHtmlComment(string source) { string result = HtmlRemoval.StripTagsCharArray(source); result = HtmlRemoval.StripCarriageReturn(result); return(result.Trim()); }
public static SearchResults FromYahooBoss(Yahoo.Boss.BossWebSearchResponse bossResults, string query) { var results = new SearchResults( query, bossResults.Count, bossResults.TotalResults, bossResults.Start ); var batchOrdinal = 0; var queryOrdinal = results.QueryStart; foreach (var bossResult in bossResults.Results) { var result = new SearchResult { BatchOrdinal = batchOrdinal++, QueryOrdinal = queryOrdinal++, Url = bossResult.Url, HtmlUrl = bossResult.DisplayURl, // example: // http://74.6.116.71/search/srpcache?ei=UTF-8&p=c%23+strip+html&vm=r&fr=crmas&u=http://cc.bingj.com/cache.aspx?q=c%23+strip+html&d=4714388897793329&w=iYNpm0Wkcl9f2yCFkMI5wRa72IFiWm_0&icp=1&.intl=us&sig=DHDDZxF3Q1kJw4JCRf2m4w-- // The sig parameter seems to be a checksum of the URL. Perhaps to prevent manufacturing the URL? I don't know the checksum algorithm yet. CacheUrl = string.Empty, // Todo: set CacheUrl. It is mostly the same as Bing. See above. Title = HtmlRemoval.StripTags(bossResult.Title), HtmlTitle = bossResult.Title, Snippet = HtmlRemoval.StripTags(bossResult.Abstract), HtmlSnippet = bossResult.Abstract }; results.Add(result); } return(results); }
public IList <NewModel> GetListNew(string status) { try { var datas = new List <NewModel>(); var newStore = new NewStore(); var dt = newStore.GetListNew(status); for (int i = 0; i < dt.Rows.Count; i++) { var model = new NewModel() { ID = int.Parse(dt.Rows[i]["NEWS_ID"].ToString()), TITLE = dt.Rows[i]["NEWS_TITLE"].ToString(), CONTENT = HtmlRemoval.StripTagsCharArray(dt.Rows[i]["NEWS_CONTENT"].ToString()), IMGPATH = dt.Rows[i]["NEWS_IMGPATH"].ToString(), STATUS = dt.Rows[i]["NEWS_STATUS"].ToString().Trim() == "1", ORDER = int.Parse(dt.Rows[i]["NEWS_ORDER"].ToString()), CATEGORY_ID = int.Parse(dt.Rows[i]["CATEGORY_ID"].ToString()), CATEGORY_TITLE = dt.Rows[i]["CATEGORY_TITLE"].ToString(), CREATED_USER = dt.Rows[i]["CREATED_USER"].ToString() }; datas.Add(model); } return(datas); } catch (Exception ex) { return(null); } }
public async Task <LastArtist> GetDetailArtist(string name) { var resp = await _artistApi.GetArtistInfoAsync(name); ThrowIfError(resp); if (resp.Content != null && resp.Content.Bio != null) { //strip html tags var content = HtmlRemoval.StripTagsRegex(resp.Content.Bio.Content); try { var startIndex = content.IndexOf("\n\n", StringComparison.Ordinal); var endIndex = content.IndexOf("\n \nUser-contributed", StringComparison.Ordinal); var count = endIndex - startIndex; //removing the read more on last.fm content = content.Remove(startIndex, count); } catch { } //html decode resp.Content.Bio.Content = WebUtility.HtmlDecode(content); } return(resp.Content); }
public IList <AnswerModel> GetListAnswer(string status) { try { var datas = new List <AnswerModel>(); var answerStore = new AnswerStore(); var dt = answerStore.GetListAnswer(status); for (int i = 0; i < dt.Rows.Count; i++) { var model = new AnswerModel() { AS_ID = int.Parse(dt.Rows[i]["AS_ID"].ToString()), AS_CONTENT = HtmlRemoval.StripTagsRegex(dt.Rows[i]["AS_CONTENT"].ToString()), QS_CONTENT = HtmlRemoval.StripTagsRegex(dt.Rows[i]["QS_CONTENT"].ToString()), CREATED_USER = dt.Rows[i]["CREATED_USER"].ToString(), AS_STATUS = dt.Rows[i]["AS_STATUS"].ToString().Trim() == "1" // CREATED_DATE = DateTime.Parse(dt.Rows[i]["CREATED_DATE"].ToString()) }; datas.Add(model); } return(datas); } catch (Exception) { return(null); } }
public async Task SendBulkEmailToAllDeacons(AnnouncementViewModel viewModel, string username) { var user = _unitOfWork.AppUserRepository.FindUserByEmail(username); var deacons = _unitOfWork.AppUserRepository.FindUsersByRole(enums.AppUserRole.Deacon); var emailContacts = new List <EmailContact>(); var emailClient = new EmailWrapperClient(); var email = new EmailContact { FromEmailAddress = user.EmailAddress, Subject = viewModel.Title, PlainTextBody = HtmlRemoval.ConvertHtmlToPlainText(viewModel.AnnouncementHtml), HtmlBody = viewModel.AnnouncementHtml }; foreach (var deacon in deacons) { emailContacts.Add(new EmailContact { ToEmailAddress = deacon.EmailAddress, ReceiverName = deacon.FullName }); } var response = await emailClient.SendMultipleEmailsAsync(emailContacts, email); }
protected override void OnSaving() { if (CommunicationType == CommunicationType.Message) { Body = HtmlRemoval.StripTagsRegex(Body); } base.OnSaving(); }
private IEnumerable <Post> LoadPostsFromData(string data) { string _byteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble()); if (data.StartsWith(_byteOrderMarkUtf8)) { data = data.Remove(0, _byteOrderMarkUtf8.Length); } using (XmlReader reader = XmlReader.Create(new StringReader(data))) { reader.MoveToContent(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.Name == "row") { if (String.Equals(reader.GetAttribute("PostTypeId"), "1")) { XElement el = XNode.ReadFrom(reader) as XElement; if (el != null) { Post post = new Post { Id = el.Attribute("Id").Value, Title = el.Attribute("Title") != null?el.Attribute("Title").Value : "", Body = HtmlRemoval.StripTagsRegex(el.Attribute("Body").Value), CreationDate = DateTime.Parse(el.Attribute("CreationDate").Value), Tags = el.Attribute("Tags") != null?el.Attribute("Tags") .Value.Replace("><", "|") .Replace("<", "") .Replace(">", "") .Replace("><", "|") .Replace("<", "") .Replace(">", "") .Split('|') : null }; //foreach (var tag in post.Tags) //{ // if (!allTags.Contains(tag)) // { // noDupTags = // post.Suggest = new CompletionField { Input = new}; // } //} post.Suggest = new CompletionField { Input = post.Tags }; //allTags.Concat(post.Tags); yield return(post); } } } } } }
public List <FeedItem> InsertItemsSqlLucene(RssItemCollection items, Feed feed) { var entiti = new TazehaContext(); List <FeedItem> listReturnBack = new List <FeedItem>(); IRepositorySaver RepositorySql = new SqlRepository(); IRepositorySaver RepositoryLucene = new LuceneRepositoryAsService(); int erroroccur = 0; foreach (RssItem item in items) { if (erroroccur > 2) { return(listReturnBack); } if (!Utility.HasFaWord(item.Title)) { continue; } FeedItem dbitem = new FeedItem(); dbitem.Title = HtmlRemoval.StripTagsRegex(item.Title).Replace("\t", "").Replace("\n", "").Replace("\r", ""); dbitem.Link = item.Link.ToString(); dbitem.Description = HtmlRemoval.StripTagsRegex(item.Description).Replace("\t", "").Replace("\n", "").Replace("\r", ""); //-------------------------Baray DB koochiK!!----------------- dbitem.Description = dbitem.Description.SubstringX(0, _appConfigBiz.MaxDescriptionLength()); dbitem.SiteId = feed.SiteId; dbitem.FeedId = feed.Id; if (item.PubDate.Year > 1350 && item.PubDate < DateTime.Now.AddDays(2)) { dbitem.PubDate = item.PubDate; } else { break; } dbitem.CreateDate = DateTime.Now; //dbitem.Cats = feed.Categories.Select(x => x.Id).ToList(); dbitem.SiteTitle = feed.Site.SiteTitle; dbitem.SiteUrl = feed.Site.SiteUrl; dbitem.SiteId = feed.SiteId; dbitem.IndexedType = dbitem.IndexedType.HasValue ? dbitem.IndexedType + 1 : 1; var feedItem = new FeedItem { Link = dbitem.Link, Title = dbitem.Title, PubDate = dbitem.PubDate, CreateDate = DateTime.Now, FeedId = feed.Id }; if (RepositorySql.AddItem(feedItem)) { RepositoryLucene.AddItem(dbitem); listReturnBack.Add(dbitem); Indexer.Indexer.FirstIndexing(dbitem); } } return(listReturnBack); }
protected override bool Process(Package package) { PXTrace.WriteInformation("Processing email package. "); var account = package.Account; var accountExt = account.GetExtension <PX.SM.EMailAccountExt>(); //Checkin if Incoming Processing is active & SO Processing if (account.IncomingProcessing != true || accountExt.UsrCustomMailer != true) { PXTrace.WriteInformation("IncomingProcessing: " + account.IncomingProcessing + ", SOProcessing: " + accountExt.UsrCustomMailer + ". "); return(false); } var message = package.Message; //Check if not empty email if (!string.IsNullOrEmpty(message.Exception) || message.IsIncome != true || message.RefNoteID != null) { PXTrace.WriteInformation("IsIncome: " + message.IsIncome + ", RefNoteID: " + message.RefNoteID + ". "); return(false); } string mailBody = HtmlRemoval.StripTagsRegexCompiled(package.Message.Body); LuisAPI predictionEngine = PXGraph.CreateInstance <LuisAPI>(); var myTask = predictionEngine.PostPrediction(mailBody); string result; try { result = myTask.Result; } catch (Exception ex) { throw new PXException(ex.Message); } //Create BuildersPO Graph //Get File Attachment UploadFile file = SelectFrom <UploadFile> . InnerJoin <NoteDoc> .On <UploadFile.fileID.IsEqual <NoteDoc.fileID> > .SingleTableOnly. Where <UploadFile.noteID.IsEqual <@P.AsGuid> > .View.Select(package.Graph, message.NoteID); MailerSOGraph soGraph = PXGraph.CreateInstance <MailerSOGraph>(); soGraph.GenerateSalesOrders(result, package.Message.MailFrom, Convert.ToDateTime(package.Message.CreatedDateTime)); return(true); }
public List <FeedItem> DescriptClear(List <FeedItem> Items, string Key) { if (Items == null) { return(Items); } foreach (var item in Items) { item.Description = HtmlRemoval.StripTagsCharArray(item.Description); item.Description = item.Description.SubstringX(0, _appConfigBiz.MaxDescriptionLength()); } return(Items); }
public List <FeedItem> AtomItemsToFeedItems(IEnumerable <SyndicationItem> Items, Feed feed) { var listReturnBack = new List <FeedItem>(); foreach (SyndicationItem item in Items) { if (!string.IsNullOrEmpty(feed.LastUpdatedItemUrl) && feed.LastUpdatedItemUrl.SubstringX(0, 399).Equals(item.Links[0].Uri.AbsoluteUri.SubstringX(0, 399))) { return(listReturnBack); } if (listReturnBack.Any(x => x.Link == item.Links[0].Uri.AbsoluteUri)) { continue; } if (!Utility.HasFaWord(item.Title.Text)) { continue; } var dbitem = new FeedItem(); dbitem.Id = Guid.NewGuid(); dbitem.Title = HtmlRemoval.StripTagsRegex(item.Title.Text).Replace("\t", "").Replace("\n", "").Replace("\r", ""); dbitem.Link = item.Links[0].Uri.AbsoluteUri; dbitem.Description = HtmlRemoval.StripTagsRegex(item.Summary.Text).Replace("\t", "").Replace("\n", "").Replace("\r", ""); //-------------------------Baray DB koochiK!!----------------- dbitem.Description = dbitem.Description.SubstringX(0, MaxDescLength); dbitem.SiteId = feed.SiteId; dbitem.FeedId = feed.Id; if (item.PublishDate.Year > 1350 && item.PublishDate < DateTime.Now.AddDays(2)) { dbitem.PubDate = item.PublishDate.DateTime.AddMinutes(feed.Site.TimeDifference); } else { break; } dbitem.CreateDate = DateTime.Now; //dbitem.Cats = feed.Categories.Select(x => x.Id).ToList(); dbitem.SiteTitle = feed.Site.SiteTitle; dbitem.SiteUrl = feed.Site.SiteUrl; dbitem.SiteId = feed.SiteId; dbitem.ShowContentType = feed.Site.ShowContentType; dbitem.IndexedType = dbitem.IndexedType.HasValue ? dbitem.IndexedType + 1 : 1; var feedItem = new FeedItem { Link = dbitem.Link, Title = dbitem.Title, PubDate = dbitem.PubDate, CreateDate = DateTime.Now, FeedId = feed.Id }; listReturnBack.Add(dbitem); } return(listReturnBack); }
private Vaga GetVagaFromVagaModel(VagaModel vagaModel) { if (vagaModel == null) { return(null); } Vaga vaga = new Vaga(); vagaModel.Titulo = HtmlRemoval.StripTagsRegex(vagaModel.Titulo); vagaModel.DescricaoMarkdown = HtmlRemoval.StripTagsRegex(vagaModel.DescricaoMarkdown); vagaModel.Descricao = HtmlRemoval.StripTagsRegex(vagaModel.Descricao); vagaModel.ThumbnailUrl = HtmlRemoval.StripTagsRegex(vagaModel.ThumbnailUrl); vagaModel.PostItemImageUrl = HtmlRemoval.StripTagsRegex(vagaModel.PostItemImageUrl); vagaModel.HeaderImageUrl = HtmlRemoval.StripTagsRegex(vagaModel.HeaderImageUrl); Uri uriResult; if (!(Uri.TryCreate(vagaModel.ThumbnailUrl, UriKind.Absolute, out uriResult) && uriResult.Scheme == Uri.UriSchemeHttp)) { vagaModel.ThumbnailUrl = null; } if (!(Uri.TryCreate(vagaModel.PostItemImageUrl, UriKind.Absolute, out uriResult) && uriResult.Scheme == Uri.UriSchemeHttp)) { vagaModel.PostItemImageUrl = null; } if (!(Uri.TryCreate(vagaModel.HeaderImageUrl, UriKind.Absolute, out uriResult) && uriResult.Scheme == Uri.UriSchemeHttp)) { vagaModel.HeaderImageUrl = null; } vaga.Titulo = vagaModel.Titulo.Substring(0, vagaModel.Titulo.Length > 29 ? 29 : vagaModel.Titulo.Length); vaga.Descricao = vagaModel.Descricao.Substring(0, vagaModel.Descricao.Length > 79 ? 79 : vagaModel.Descricao.Length); vaga.DescricaoMarkdown = vagaModel.DescricaoMarkdown.Substring(0, vagaModel.DescricaoMarkdown.Length > 3999 ? 3999 : vagaModel.DescricaoMarkdown.Length); vaga.ThumbnailUrl = vagaModel.ThumbnailUrl; vaga.HeaderImageUrl = vagaModel.HeaderImageUrl; vaga.PostItemImageUrl = vagaModel.PostItemImageUrl; vaga.DataCriacao = vagaModel.DataCriacao; vaga.DataExpiracao = vagaModel.DataExpiracao; vaga.TipoVaga = _uow.TiposVaga.GetByID(vagaModel.TipoVagaID); return(vaga); }
public static void CreateStatusLiveTile(Status status) { var content = new TileContent() { Visual = new TileVisual() { TileMedium = CreateMediumTitleBinding(HtmlRemoval.StripTagsCharArray(status.Content), status.Account.AccountName), TileWide = CreateWideTitleBinding(status.Account.AvatarUrl, HtmlRemoval.StripTagsCharArray(status.Content), status.Account.AccountName), TileLarge = CreateLargeTitleBinding(status.Account.AvatarUrl, HtmlRemoval.StripTagsCharArray(status.Content), status.Account.AccountName) } }; var tileXml = content.GetXml(); var tileNotification = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); }
private IEnumerable <Post> LoadPostsFromFile(string inputUrl) { using (XmlReader reader = XmlReader.Create(inputUrl)) { reader.MoveToContent(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.Name == "row") { if (String.Equals(reader.GetAttribute("PostTypeId"), "1")) { XElement el = XNode.ReadFrom(reader) as XElement; if (el != null) { Post post = new Post { Id = el.Attribute("Id").Value, Title = el.Attribute("Title") != null?el.Attribute("Title").Value : "", CreationDate = DateTime.Parse(el.Attribute("CreationDate").Value), Score = int.Parse(el.Attribute("Score").Value), Body = HtmlRemoval.StripTagsRegex(el.Attribute("Body").Value), Tags = el.Attribute("Tags") != null ? el.Attribute("Tags") .Value.Replace("><", "|") .Replace("<", "") .Replace(">", "") .Replace("><", "|") .Replace("<", "") .Replace(">", "") .Split('|') : null, AnswerCount = el.Attribute("AnswerCount") != null ? int.Parse(el.Attribute("AnswerCount").Value) : 0 }; post.Suggest = new CompletionField(); post.Suggest.Input = post.Tags; yield return(post); } } } } } }
private void doData(string JSON) { var random = JsonConvert.DeserializeObject <ZModelHomepage>(JSON).RandomQuotes; if (random != null) { foreach (var item in random) { item.Text = HtmlRemoval.StripTagsRegex(item.Text); RandomQuotes.Add(item); break; } } var birthers = JsonConvert.DeserializeObject <ZModelHomepage>(JSON).Births; if (birthers != null) { foreach (var item in birthers) { item.imageSrc = ZModelAuthor.getImage(item.image); Birthdays.Add(item); } } var diers = JsonConvert.DeserializeObject <ZModelHomepage>(JSON).Deaths; if (diers != null) { foreach (var item in diers) { item.imageSrc = ZModelAuthor.getImage(item.image); Deathdays.Add(item); } } var authors = JsonConvert.DeserializeObject <ZModelHomepage>(JSON).PopularAuthors; if (authors != null) { foreach (var item in authors) { item.imageSrc = ZModelAuthor.getImage(item.image); PopularAuthors.Add(item); } } }
public static String RemoveHtml(String html) { try { string htmlstring = HtmlRemoval.StripTagsCharArray(html); return (htmlstring.Replace("\r\n\r\n\r\n", " ") .Replace("\r\n\r\n", " ") .Replace("\r\n", " ") .Replace("\r", " ") .Replace("\n", " ")); } catch { return(""); } }
public static SearchResults FromSolr(SolrQueryResults <Solr.SearchResult> solrResults, string query, int start) { var results = new SearchResults( query, solrResults.Count, solrResults.NumFound, start); var batchOrdinal = 0; var queryOrdinal = start; foreach (var solrResult in solrResults) { string snippet = string.Empty; foreach (var snippetsPerKeyword in solrResults.Highlights[solrResult.Id].Snippets.Values) { foreach (var snippets in snippetsPerKeyword) { foreach (var snippetPerKeyword in snippets) { snippet += "[" + snippetPerKeyword + "]"; } } } var title = (solrResult.Title == null) ? "No Title" : solrResult.Title[0]; var url = "https://mimeo.<domain>.com/crawled-content.<crawl-job>/" + solrResult.Id; var result = new SearchResult { BatchOrdinal = batchOrdinal++, QueryOrdinal = queryOrdinal++, Url = url, HtmlUrl = solrResult.Url, CacheUrl = string.Empty, Title = title, HtmlTitle = title, Snippet = HtmlRemoval.StripTags(snippet), HtmlSnippet = snippet }; results.Add(result); } return(results); }
public async Task <ActionResult> SendEmail(EmailViewModel emailViewModel) { if (!ModelState.IsValid) { return(View(emailViewModel)); } emailViewModel.UserEmail = User.Identity.Name; // sanitize the html from user emailViewModel.EmailContact.HtmlBody = AntiXssEncoder.HtmlEncode(emailViewModel.EmailContact.HtmlBody, false); emailViewModel.EmailContact.HtmlBody = WebUtility.HtmlDecode(emailViewModel.EmailContact.HtmlBody); if (emailViewModel == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var client = new EmailWrapperClient(); if (emailViewModel.IsTesting && !string.IsNullOrEmpty(emailViewModel.TestToEmail)) { emailViewModel.EmailContact.ToEmailAddress = emailViewModel.TestToEmail; emailViewModel.EmailContact.ReceiverName = "Deacon App Test SendGrid"; } emailViewModel.EmailContact.PlainTextBody = HtmlRemoval.ConvertHtmlToPlainText(emailViewModel.EmailContact.HtmlBody); if (emailViewModel.Bulk) { emailViewModel = await _service.SendBulkEmailsAsync(emailViewModel, client, User.Identity.Name); } else // send email to one member { emailViewModel = await _service.SendSingleEmailAsync(emailViewModel, client, User.Identity.Name); } return(View("EmailComplete", emailViewModel)); }
private void doItemsSearch(string jSONdata) { var json = JsonConvert.DeserializeObject <List <ZModelItem> >(JSONdata); foreach (var item in json) { item.Text = HtmlRemoval.StripTagsRegex(item.Text); Items.Add(item); } if (Items.Count < 1) { Items.Add(new ZModelItem() { Text = "Leider konnten keine Zitate gefunden werden." }); } }
public static void CreateToastNotification(Notification notification) { ToastContent content; switch (notification.Type) { case "mention": content = CreatePostToastContent (notification.Account.AvatarUrl, $"{notification.Account.AccountName} mentioned you", HtmlRemoval.StripTagsCharArray(notification.Status.Content), notification.Status); break; case "reblog": content = CreatePostToastContent (notification.Account.AvatarUrl, $"{notification.Account.AccountName} boosted your status", HtmlRemoval.StripTagsCharArray(notification.Status.Content), notification.Status); break; case "favourite": content = CreatePostToastContent (notification.Account.AvatarUrl, $"{notification.Account.AccountName} favourited your status", HtmlRemoval.StripTagsCharArray(notification.Status.Content), notification.Status); break; case "follow": content = CreateFollowToastContent (notification.Account.AvatarUrl, $"{notification.Account.AccountName} followed you", notification.Account); break; default: throw new Exception("Unknown type"); } XmlDocument doc = content.GetXml(); var toastNotification = new ToastNotification(doc); var nameProperty = toastNotification.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name == "Tag"); nameProperty?.SetValue(toastNotification, notification.Type); ToastNotificationManager.CreateToastNotifier().Show(toastNotification); }
public List <FeedItem> RssItemCollectionToFeedItemsContract(RssItemCollection items, FeedContract feed) { var listReturnBack = new List <FeedItem>(); foreach (RssItem item in items) { if (!string.IsNullOrEmpty(feed.LastFeedItemUrl) && feed.LastFeedItemUrl.SubstringX(0, 399).Equals(item.Link.ToString().SubstringX(0, 399))) { return(listReturnBack); } if (listReturnBack.Any(x => x.Link == item.Link.ToString())) { continue; } if (!Utility.HasFaWord(item.Title)) { continue; } var itemcontract = new FeedItem(); itemcontract.Title = Helper.HtmlRemoval.StripTagsRegex(item.Title).Replace("\t", "").Replace("\n", "").Replace("\r", ""); itemcontract.Link = item.Link.ToString(); itemcontract.Description = HtmlRemoval.StripTagsRegex(item.Description).Replace("\t", "").Replace("\n", "").Replace("\r", ""); //-------------------------Baray DB koochiK!!----------------- itemcontract.Description = itemcontract.Description.SubstringX(0, _appConfigBiz.MaxDescriptionLength()); if (item.PubDate.Year > 1350 && item.PubDate < DateTime.Now.AddDays(2)) { itemcontract.PubDate = item.PubDate; } else { break; } itemcontract.FeedId = feed.Id; itemcontract.SiteId = feed.SiteId; itemcontract.SiteUrl = feed.SiteUrl; itemcontract.SiteTitle = feed.SiteTitle; listReturnBack.Add(itemcontract); } return(listReturnBack); }
public virtual void Render() { if (!this.CanDisplay) { return; } string sDefault = SBSFormField.DefaultValue != null ? $"({SBSFormField.DefaultValue.ToString()})" : ""; sDefault = StringSubstitutor.SubstituteVariablesInExpression(sDefault); string prompt = this.SBSFormField.Prompt; if (prompt != null && prompt.StartsWith("$html:")) { prompt = prompt.Replace("$html:", ""); prompt = HtmlRemoval.StripTagsRegex(prompt); } this.ColoredOutput($"({this.SBSFormField.FieldTypeName}) {prompt}: {sDefault}", ConsoleColor.Cyan); }
public bool RegistrarUsuario(string Nome, string userID, string Email, string senha) { Usuario usuario = _uow.Usuarios.Get(u => u.UserID.ToLower() == userID.ToLower() || u.Email.ToLower() == Email.ToLower()).FirstOrDefault(); if (Nome != HtmlRemoval.StripTagsRegex(Nome) || Email != HtmlRemoval.StripTagsRegex(Email) || userID != HtmlRemoval.StripTagsRegex(userID)) { return(false); } if (usuario != null || userID.Length < 6 || Nome.Length < 2 || Email.Length < 5 || senha.Length < 6) { return(false); } string patternEmail = @"^[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9-]+\.([a-z0-9])+(\.[a-z0-9]+)*"; Regex rgx = new Regex(patternEmail, RegexOptions.IgnoreCase); if (!rgx.IsMatch(Email)) { return(false); } Usuario novoUsuario = new Usuario() { Nome = Nome, Email = Email, UserID = userID, Senha = senha, Roles = "user", DataCriacao = DateTime.Now }; _uow.Usuarios.Insert(novoUsuario); _uow.Save(); return(true); }
public static void CreateNotificationLiveTile(Notification notification) { var notificationString = ""; var notificationSubstring = ""; switch (notification.Type) { case "mention": notificationString = $"âŠī¸ {notification.Account.AccountName}"; notificationSubstring = HtmlRemoval.StripTagsCharArray(notification.Status.Content); break; case "reblog": notificationString = $"đ {notification.Account.AccountName}"; notificationSubstring = HtmlRemoval.StripTagsCharArray(notification.Status.Content); break; case "favourite": notificationString = $"â {notification.Account.AccountName} favourited your status"; notificationSubstring = HtmlRemoval.StripTagsCharArray(notification.Status.Content); break; case "follow": notificationString = $"New Follower:"; notificationSubstring = $"{notification.Account.AccountName}"; break; } var content = new TileContent() { Visual = new TileVisual() { TileMedium = CreateMediumTitleBinding(notificationString, notificationSubstring), TileWide = CreateWideTitleBinding(notification.Account.AvatarUrl, notificationString, notificationSubstring), TileLarge = CreateLargeTitleBinding(notification.Account.AvatarUrl, notificationString, notificationSubstring) } }; var tileXml = content.GetXml(); var tileNotification = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); }
public async void loadData(string search = "0") { IsLoading = true; rootPage.NotifyUser(NotifyType.PrepareMessage); Items = new ObservableCollection <ZModelItem>(); try { ZHelpersREST rest = new ZHelpersREST("author", "quotes", search); JSONdata = await rest.getResponse(); var authorItems = JsonConvert.DeserializeObject <ZModelAuthorItems>(JSONdata).Items; if (Author == null) { Author = JsonConvert.DeserializeObject <ZModelAuthorItems>(JSONdata).Author; } if (authorItems != null) { // authorItems.ForEach(x => Items.Add(x)); foreach (var item in authorItems) { item.username = Author.username; item.Text = HtmlRemoval.SetLineBreaks(item.Text); Items.Add(item); } rootPage.NotifyUser(NotifyType.StatusMessage); } else { rootPage.NotifyUser(NotifyType.StatusMessage, "No items found."); } } catch (Exception ex) { rootPage.NotifyUser(NotifyType.ErrorMessage, ex.Message); } IsLoading = false; }
public static string GetPageDescripton(Item item) { string description = item["Body"]; // Most items have an abstract if (item["Abstract"] != String.Empty) { description = item["Abstract"]; } // Terms do not have an abstract, so just use the Definition if (item["Definition"] != String.Empty) { description = item["Definition"]; } description = HtmlRemoval.StripTagsCharArray(description); if (description.Length > 160) { description = String.Format("{0}...", description.Substring(0, 160)); } return(description.Replace("\"", "'")); }
private Usuario GetUsuarioFromUsuarioModel(UsuarioModel usuarioModel) { if (usuarioModel == null) { return(null); } Usuario usuario = new Usuario(); usuarioModel.Nome = HtmlRemoval.StripTagsRegex(usuarioModel.Nome); usuarioModel.DescricaoMarkdown = HtmlRemoval.StripTagsRegex(usuarioModel.DescricaoMarkdown); usuarioModel.Descricao = HtmlRemoval.StripTagsRegex(usuarioModel.Descricao); usuarioModel.ProfileImageUrl = HtmlRemoval.StripTagsRegex(usuarioModel.ProfileImageUrl); usuarioModel.HeaderImageUrl = HtmlRemoval.StripTagsRegex(usuarioModel.HeaderImageUrl); Uri uriResult; if (!(Uri.TryCreate(usuarioModel.ProfileImageUrl, UriKind.Absolute, out uriResult) && uriResult.Scheme == Uri.UriSchemeHttp)) { usuarioModel.ProfileImageUrl = null; } if (!(Uri.TryCreate(usuarioModel.HeaderImageUrl, UriKind.Absolute, out uriResult) && uriResult.Scheme == Uri.UriSchemeHttp)) { usuarioModel.HeaderImageUrl = null; } usuario.Nome = usuarioModel.Nome.Substring(0, usuarioModel.Nome.Length > 29 ? 29 : usuarioModel.Nome.Length); usuario.Descricao = usuarioModel.Descricao.Substring(0, usuarioModel.Descricao.Length > 79 ? 79 : usuarioModel.Descricao.Length); usuario.DescricaoMarkdown = usuarioModel.DescricaoMarkdown.Substring(0, usuarioModel.DescricaoMarkdown.Length > 3999 ? 3999 : usuarioModel.DescricaoMarkdown.Length); usuario.ProfileImageUrl = usuarioModel.ProfileImageUrl; usuario.HeaderImageUrl = usuarioModel.HeaderImageUrl; return(usuario); }