public void Publish(EarnedBadgeItemDTO earnedBadge) { //Get the user that earned the badge string userEmail = string.Format("{0}@magenic.com", earnedBadge.EmployeeADName); string userUrl = GetUserUrl(userEmail); string response = MakeGetRequest(userUrl, Token); YammerUser yammerUser = YammerUser.GetInstanceFromJson(response.Substring(1, response.Length - 2)); //let's post a message now to this group bool broadcastToAll = false; string msg = string.Format(YammerMessageText, yammerUser.UserID, earnedBadge.Name, broadcastToAll.ToString(), "http://magenic.com/" + earnedBadge.Name, earnedBadge.ImagePath, earnedBadge.Name, earnedBadge.Tagline); //try adding the message response = MakePostRequest(msg, MessageUrl, Token); if (!string.IsNullOrEmpty(response)) { YammerMessage newMsg = YammerMessage.GetInstanceFromJson(response); } }
public void PublishUpdates(EarnedBadgeItemDTO earnedBadge) { foreach (IPublisher publiser in _publishers) { publiser.Publish(earnedBadge); } }
public EarnedBadgeItemDTO GetEarnedBadge(int badgeAwardId) { using (var ctx = new Entities()) { BadgeAward badgeAward = ctx.BadgeAwards.SingleOrDefault(badges => badges.BadgeAwardId == badgeAwardId); if (badgeAward == null) { throw new NotFoundException(string.Format("Badge award with id {0} was not found", badgeAwardId)); } var earnedBadge = new EarnedBadgeItemDTO { AwardDate = badgeAward.AwardDate, AwardPoints = badgeAward.Badge.BadgeAwardValueAmount, BadgePriority = badgeAward.Badge.BadgePriority, DisplayOnce = badgeAward.Badge.DisplayOnce, EmployeeADName = badgeAward.Employee.ADName, Id = badgeAward.BadgeAwardId, ImagePath = badgeAward.Badge.BadgePath, Name = badgeAward.Badge.BadgeName, PaidOut = badgeAward.PaidOut, Tagline = badgeAward.Badge.BadgeTagLine, Type = (Common.Enums.BadgeType)badgeAward.Badge.BadgeTypeId }; return earnedBadge; } }
public void Publish(EarnedBadgeItemDTO earnedBadge) { //Get the user that earned the badge string userEmail = string.Format("{0}@magenic.com", earnedBadge.EmployeeADName); string userUrl = GetUserUrl(userEmail); try { var response = MakeGetRequest(userUrl, Token); YammerUser yammerUser = YammerUser.GetInstanceFromJson(response.Substring(1, response.Length - 2)); //let's post a message now to this group bool broadcastToAll = false; string msg = string.Format(YammerMessageText, yammerUser.UserID, earnedBadge.Name, broadcastToAll.ToString(), "http://magenic.com/" + earnedBadge.Name, earnedBadge.ImagePath, earnedBadge.Name, earnedBadge.Tagline); //try adding the message response = MakePostRequest(msg, MessageUrl, Token); if (!string.IsNullOrEmpty(response)) { YammerMessage newMsg = YammerMessage.GetInstanceFromJson(response); } } catch (WebException ex) { var httpResponse = ex.Response as HttpWebResponse; if (httpResponse != null && httpResponse.StatusCode == HttpStatusCode.NotFound) { Logger.Warn<YammerPublisher>(string.Format("Problem getting Yammer information for URL: {0}. Most likely cause is the user was not setup in Yammer, continuing to process.", userUrl)); } else { throw; } } }