private PackageOwnerInfo GetPackageOwnerInfo(int ownerId, bool openForCollab, int contentId) { var owner = MembershipHelper.GetById(ownerId); var ownerInfo = new PackageOwnerInfo { Karma = owner.Karma(), Owner = owner.Name, OwnerAvatar = Utils.GetMemberAvatar(owner, 200, true) }; if (openForCollab) { var service = new ContributionService(DatabaseContext); var contributors = service.GetContributors(contentId).ToList(); if (contributors != null && contributors.Any()) { var names = new List <string>(); foreach (var contributor in contributors) { var member = MembershipHelper.GetById(contributor.MemberId); if (member != null) { names.Add(member.Name); } } ownerInfo.Contributors = names.ToArray(); } } return(ownerInfo); }
public static IEnumerable <IPartier> GetAllPartiers(this MembershipHelper members) { List <IPartier> partiers = new List <IPartier>(); partiers.AddRange( ApplicationContext .Current .Services .MemberService .GetMembersByMemberType(PartyHost.Alias) .Select(x => (IPartier)members.GetById(x.Id)) ); partiers.AddRange( ApplicationContext .Current .Services .MemberService .GetMembersByMemberType(PartyGuest.Alias) .Select(x => (IPartier)members.GetById(x.Id)) ); //DatabaseContext databaseContext = ApplicationContext.Current.DatabaseContext; //foreach(MemberPartyRow memberPartyRow in databaseContext.Database.Fetch<MemberPartyRow>(@"SELECT MemberId, PartyGuid, Timestamp FROM wonderlandMemberParty")) //{ // partiers.Add((IPartier)members.GetById(memberPartyRow.MemberId)); //} return(partiers); }
private static MvpMember PopulateMemberData(IMember member, string category) { var membershipHelper = new MembershipHelper(UmbracoContext.Current); var m = membershipHelper.GetById(member.Id); var company = member.GetValue <string>("company"); var twitter = (member.GetValue <string>("twitter") ?? "").Trim().TrimStart('@'); var github = (member.GetValue <string>("github") ?? "").Trim().TrimStart('@'); var avatarService = new AvatarService(); var avatarHtml = avatarService.GetImgWithSrcSet(m, m.Name, 48); var isMvpRenewal = false; if (category.Contains("Renewal")) { isMvpRenewal = true; category = category.Replace("Renewal", string.Empty); } var mvpMember = new MvpMember { Id = member.Id, Name = member.Name, Avatar = avatarHtml, Company = company, Twitter = twitter, GitHub = github, Category = category, IsMvpRenewal = isMvpRenewal }; return(mvpMember); }
private static MvpMember PopulateMemberData(IMember member, string category) { var membershipHelper = new MembershipHelper(UmbracoContext.Current); var m = membershipHelper.GetById(member.Id); var company = member.GetValue <string>("company"); var twitter = (member.GetValue <string>("twitter") ?? "").Trim().TrimStart('@'); var github = (member.GetValue <string>("github") ?? "").Trim().TrimStart('@'); var avatarService = new AvatarService(); var avatarHtml = avatarService.GetImgWithSrcSet(m, m.Name, 48); var mvpMember = new MvpMember { Id = member.Id, Name = member.Name, Avatar = avatarHtml, Company = company, Twitter = twitter, GitHub = github, Category = category }; return(mvpMember); }
void CommentService_Created(object sender, CommentEventArgs e) { var ts = new TopicService(ApplicationContext.Current.DatabaseContext); //Subscribe to topic var ns = new NotificationService(ApplicationContext.Current.DatabaseContext); ns.SubscribeToForumTopic(e.Comment.TopicId, e.Comment.MemberId); //data for notification: var membershipHelper = new MembershipHelper(Umbraco.Web.UmbracoContext.Current); var member = membershipHelper.GetById(e.Comment.MemberId); var memberName = string.Empty; if (member != null) { memberName = member.Name; } var topic = ts.GetById(e.Comment.TopicId); //send notifications InstantNotification not = new InstantNotification(); not.Invoke(Config.ConfigurationFile, Config.AssemblyDir, "NewComment", e.Comment, topic, topic.GetUrl(), memberName); }
public void SendNotification(Topic topic, string memberName, string url) { var db = ApplicationContext.Current.DatabaseContext.Database; var sql = new Sql().Select("memberId") .From("forumSubscribers") .Where("forumId = @forumId", new { forumId = topic.ParentId }); var results = db.Query <int>(sql).ToList(); using (ContextHelper.EnsureHttpContext()) { var memberShipHelper = new MembershipHelper(UmbracoContext.Current); { foreach (var memberId in results.Where(memberId => memberId != topic.MemberId)) { try { var member = memberShipHelper.GetById(memberId); if (member.GetPropertyValue <bool>("bugMeNot")) { continue; } var from = new MailAddress(_details.SelectSingleNode("//from/email").InnerText, _details.SelectSingleNode("//from/name").InnerText); var contentService = ApplicationContext.Current.Services.ContentService; var forum = contentService.GetById(topic.ParentId); var subject = _details.SelectSingleNode("//subject").InnerText; subject = string.Format(subject, forum.Name); var domain = _details.SelectSingleNode("//domain").InnerText; var body = _details.SelectSingleNode("//body").InnerText; body = string.Format(body, forum.Name, "https://" + domain + url, memberName, topic.Title, HttpUtility.HtmlDecode(umbraco.library.StripHtml(topic.Body))); var mailMessage = new MailMessage { Subject = subject, Body = body }; mailMessage.To.Add(member.GetPropertyValue <string>("Email")); mailMessage.From = from; using (var smtpClient = new SmtpClient()) { smtpClient.Send(mailMessage); } } catch (Exception exception) { LogHelper.Error <NewForumTopic>( string.Format("Error sending mail to member id {0}", memberId), exception); } } } } }
/// <summary> /// queries the Lucene index to get all members with the supplied partyGuid /// </summary> /// <param name="members">the Umbraco MembershipHelper</param> /// <param name="partyGuid">Guid identifying a specific party</param> /// <returns>a collection of PartyHost / PartyGuest associated with a specific party</returns> public static IEnumerable <IPartier> GetPartiers(this MembershipHelper members, Guid partyGuid) { BaseSearchProvider searchProvider = ExamineManager.Instance.SearchProviderCollection["InternalMemberSearcher"]; ISearchCriteria searchCriteria = searchProvider.CreateSearchCriteria(IndexTypes.Member).Field("partyGuid", partyGuid.ToString()).Compile(); ISearchResults searchResults = searchProvider.Search(searchCriteria); return(searchResults.Select(x => (IPartier)members.GetById(x.Id))); }
public void SendNotification(int topicId, int memberId, NotificationMail notificationMail) { try { var topicService = new TopicService(ApplicationContext.Current.DatabaseContext); var topic = topicService.GetById(topicId); using (ContextHelper.EnsureHttpContext()) { var memberShipHelper = new MembershipHelper(UmbracoContext.Current); var member = memberShipHelper.GetById(memberId); using (var smtpClient = new SmtpClient()) { var fromMailAddress = new MailAddress(notificationMail.FromMail, notificationMail.FromName); var subject = string.Format("{0} - '{1}'", notificationMail.Subject, topic.Title); var domain = notificationMail.Domain; var body = notificationMail.Body; body = string.Format(body, topic.Title, "https://" + domain + topic.GetUrl()); if (member.GetPropertyValue <bool>("bugMeNot") == false) { const string notificationTestFolder = "~/App_Data/NotificationTest"; if (Directory.Exists(HostingEnvironment.MapPath(notificationTestFolder)) == false) { Directory.CreateDirectory(HostingEnvironment.MapPath(notificationTestFolder)); } File.AppendAllText(string.Format("{0}/{1}.txt", HostingEnvironment.MapPath(notificationTestFolder), topic.Id), string.Format("To: {0}{3}Subject: {1}{3}Body: {3}{2}", member.GetPropertyValue <string>("Email"), subject, body, Environment.NewLine)); using (var mailMessage = new MailMessage()) { mailMessage.Subject = subject; mailMessage.Body = body; mailMessage.To.Add(member.GetPropertyValue <string>("Email")); mailMessage.From = fromMailAddress; smtpClient.Send(mailMessage); } } } } using (var db = ApplicationContext.Current.DatabaseContext.Database) { var sql = new Sql("UPDATE forumTopics SET markAsSolutionReminderSent = 1 WHERE id = @topicId", new { topicId = topic.Id }); var result = db.Execute(sql); } } catch (Exception ex) { LogHelper.Error <MarkAsSolutionReminder>("Error processing notification", ex); throw; } }
public void SendNotification(Topic topic, string memberName, string url) { var db = ApplicationContext.Current.DatabaseContext.Database; var sql = new Sql().Select("memberId") .From("forumSubscribers") .Where("forumId = @forumId", new { forumId = topic.ParentId }); var results = db.Query<int>(sql).ToList(); using (ContextHelper.EnsureHttpContext()) { var memberShipHelper = new MembershipHelper(UmbracoContext.Current); { foreach (var memberId in results.Where(memberId => memberId != topic.MemberId)) { try { var member = memberShipHelper.GetById(memberId); if (member.GetPropertyValue<bool>("bugMeNot")) continue; var from = new MailAddress(_details.SelectSingleNode("//from/email").InnerText, _details.SelectSingleNode("//from/name").InnerText); var contentService = ApplicationContext.Current.Services.ContentService; var forum = contentService.GetById(topic.ParentId); var subject = _details.SelectSingleNode("//subject").InnerText; subject = string.Format(subject, forum.Name); var domain = _details.SelectSingleNode("//domain").InnerText; var body = _details.SelectSingleNode("//body").InnerText; body = string.Format(body, forum.Name, "https://" + domain + url, memberName, topic.Title, HttpUtility.HtmlDecode(umbraco.library.StripHtml(topic.Body))); var mailMessage = new MailMessage { Subject = subject, Body = body }; mailMessage.To.Add(member.GetPropertyValue<string>("Email")); mailMessage.From = from; using (var smtpClient = new SmtpClient()) { smtpClient.Send(mailMessage); } } catch (Exception exception) { LogHelper.Error<NewForumTopic>( string.Format("Error sending mail to member id {0}", memberId), exception); } } } } }
private PackageOwnerInfo GetPackageOwnerInfo(int ownerId, bool openForCollab, int contentId) { var owner = MembershipHelper.GetById(ownerId); var avatarService = new AvatarService(); var avatarPath = avatarService.GetMemberAvatar(owner); var avatar = $"{avatarPath}?width=200&height=200&mode=crop&upscale=true"; var ownerInfo = new PackageOwnerInfo { Karma = owner?.Karma() ?? 0, Owner = owner?.Name ?? "", OwnerAvatar = avatar }; if (openForCollab) { var service = new ContributionService(DatabaseContext); var contributors = service.GetContributors(contentId).ToList(); if (contributors != null && contributors.Any()) { var names = new List <string>(); foreach (var contributor in contributors) { var member = MembershipHelper.GetById(contributor.MemberId); if (member != null) { names.Add(member.Name); } } ownerInfo.Contributors = names.ToArray(); } } return(ownerInfo); }
void TopicService_Created(object sender, TopicEventArgs e) { var ns = new NotificationService(ApplicationContext.Current.DatabaseContext); ns.SubscribeToForumTopic(e.Topic.Id, e.Topic.MemberId); //send notification InstantNotification not = new InstantNotification(); //data for notification: var membershipHelper = new MembershipHelper(Umbraco.Web.UmbracoContext.Current); var member = membershipHelper.GetById(e.Topic.MemberId); var memberName = string.Empty; if (member != null) memberName = member.Name; not.Invoke(Config.ConfigurationFile, Config.AssemblyDir, "NewTopic", e.Topic, e.Topic.GetUrl(), memberName); }
string GetAuthorEmail(IPublishedContent post, MembershipHelper mbrHelper) { if (post == null) return string.Empty; var authorId = post.GetPropertyValue<int>("postAuthor", 0); if ( authorId > 0) { var author = mbrHelper.GetById(authorId); if ( author != null) { // pre 7.2.2 - you can't do get propertyvalue to get // system values like Email return author.AsDynamic().Email; } } return string.Empty; }
private static BadgeMember PopulateBadgeMemberData(IMember member) { var membershipHelper = new MembershipHelper(UmbracoContext.Current); var m = membershipHelper.GetById(member.Id); var company = member.GetValue <string>("company"); var twitter = (member.GetValue <string>("twitter") ?? "").Trim().TrimStart('@'); var github = (member.GetValue <string>("github") ?? "").Trim().TrimStart('@'); var badgeMember = new BadgeMember { Id = member.Id, Name = member.Name, Avatar = Utils.GetMemberAvatar(m, 48), Company = company, Twitter = twitter, GitHub = github }; return(badgeMember); }
string GetAuthorEmail(IPublishedContent post, MembershipHelper mbrHelper) { if (post == null) { return(string.Empty); } var authorId = post.GetPropertyValue <int>("postAuthor", 0); if (authorId > 0) { var author = mbrHelper.GetById(authorId); if (author != null) { // pre 7.2.2 - you can't do get propertyvalue to get // system values like Email return(author.AsDynamic().Email); } } return(string.Empty); }
public static IPartier GetPartier(this MembershipHelper members, Guid forgottenPasswordGuid) { //BaseSearchProvider searchProvider = ExamineManager.Instance.SearchProviderCollection["InternalMemberSearcher"]; //ISearchCriteria searchCriteria = searchProvider.CreateSearchCriteria(IndexTypes.Member).Field("forgottenPasswordGuid", forgottenPasswordGuid.ToString()).Compile(); //ISearchResults searchResults = searchProvider.Search(searchCriteria); //return searchResults.Select(x => (IPartier)members.GetById(x.Id)).SingleOrDefault(); //// WARNING: hits db IMember member = ApplicationContext .Current .Services .MemberService .GetMembersByPropertyValue("forgottenPasswordGuid", forgottenPasswordGuid.ToString()) .SingleOrDefault(); if (member != null) { return(members.GetById(member.Id) as IPartier); } return(null); }
public static PartyHost GetPartyHost(this MembershipHelper members, string partyUrlIdentifier) { BaseSearchProvider searchProvider = ExamineManager.Instance.SearchProviderCollection["InternalMemberSearcher"]; ISearchCriteria searchCriteria = searchProvider.CreateSearchCriteria(IndexTypes.Member).Field("partyUrlIdentifier", partyUrlIdentifier).Compile(); ISearchResults searchResults = searchProvider.Search(searchCriteria); return(searchResults.Select(x => (PartyHost)members.GetById(x.Id)).SingleOrDefault()); //// WARNING: hits db //IMember partyHost = ApplicationContext // .Current // .Services // .MemberService // .GetMembersByMemberType(PartyHost.Alias) // .SingleOrDefault(x => x.GetValue<string>(PartyHost.PartyUrlIdentifierAlias).ToLower() == partyUrlIdentifier.ToLower()); //if (partyHost != null) //{ // return new PartyHost(members.GetByUsername(partyHost.Username)); //} //return null; }
public Member Get(int id, bool populateFull = false) { return(MemberMapper.MapMember(_membershipHelper.GetById(id), populateFull)); }
public IPublishedContent Member(int id) { return(MembershipHelper.GetById(id)); }
public IPublishedContent Member(string id) { var asInt = id.TryConvertTo <int>(); return(asInt ? MembershipHelper.GetById(asInt.Result) : MembershipHelper.GetByProviderKey(id)); }