public void ShareToWall(FacebookMessage pMessage, string pUserId) { var args = new Dictionary <string, object>(); args["message"] = pMessage.Message; args["caption"] = pMessage.ArticleCaption; args["description"] = pMessage.Description; args["name"] = pMessage.Title; args["picture"] = pMessage.PhotoLink; args["link"] = pMessage.ArticleLink; string path = "/me/feed"; var fbApp = new FacebookClient(GetAppAccessToken()); fbApp.Post(path, args); dynamic dnm = fbApp.Get(path); }
public FacebookMessage GetTemplate() { var facebookElement = new FacebookElementImage() { Url = _imageUrl, IsReusable = _isReusable }; var facebookMessage = new FacebookMessage() { Attachment = new FacebookAttachment() { Type = "image", Payload = facebookElement } }; return(facebookMessage); }
public FacebookMessage getLastestEntry(string conversationID) { IEnumerator iterator = DataSetManager.Manager.getData(DataSets.Messages, conversationID); if (iterator == null) { return(new FacebookMessage()); } iterator.MoveNext(); FacebookMessage fm = new FacebookMessage(); DataRow row = iterator.Current as DataRow; foreach (string tag in FB_MESSAGE_COLUMNS) { fm[tag] = row[tag]; } return(fm); }
public void getInboxMessages(dynamic data, dynamic profile, Guid userId) { FacebookMessage fbmsg = new FacebookMessage(); FacebookMessageRepository fbmsgrepo = new FacebookMessageRepository(); string profileid = string.Empty; User user = (User)HttpContext.Current.Session["LoggedUser"]; if (data != null) { int lstfbcount = 0; foreach (dynamic result in data["data"]) { try { foreach (dynamic message in result["comments"]["data"]) { //Do want you want with the messages fbmsg.MessageId = message["id"]; fbmsg.FromName = message["from"]["name"]; fbmsg.FromId = message["from"]["id"]; fbmsg.Message = message["message"]; fbmsg.MessageDate = DateTime.Parse(message["created_time"].ToString());; fbmsg.FromProfileUrl = "http://graph.facebook.com/" + message["from"]["id"] + "/picture?type=small"; fbmsg.EntryDate = DateTime.Now; fbmsg.Id = Guid.NewGuid(); fbmsg.ProfileId = profile["id"].ToString(); fbmsg.Type = "inbox_message"; fbmsg.UserId = userId; if (!fbmsgrepo.checkFacebookMessageExists(fbmsg.MessageId)) { fbmsgrepo.addFacebookMessage(fbmsg); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } }
public void parallelAnalyze(FacebookMessage message) { // Add User to user list if not already in it m_newUserSem.WaitOne(); if (!m_users.Contains(message.sender)) { m_users.Add(message.sender); m_numMessages.Add(message.sender, 0); m_earliestMessages.Add(message.sender, message.timeSent); m_latestMessages.Add(message.sender, message.timeSent); // Create new set of semaphores for this particular user m_semTable[message.sender] = new Dictionary <string, Semaphore>(); m_semTable[message.sender][NUM_SEM_TAG] = new Semaphore(1, 1); m_semTable[message.sender][EARLY_MESSAGE_SEM_TAG] = new Semaphore(1, 1); m_semTable[message.sender][TIME_SEM_TAG] = new Semaphore(1, 1); } m_newUserSem.Release(); // Increase message count by 1 for this user m_semTable[message.sender][NUM_SEM_TAG].WaitOne(); m_numMessages[message.sender]++; m_semTable[message.sender][NUM_SEM_TAG].Release(); // Set earliest message time if applicable m_semTable[message.sender][EARLY_MESSAGE_SEM_TAG].WaitOne(); if (m_earliestMessages[message.sender].CompareTo(message.timeSent) > 0) { m_earliestMessages[message.sender] = message.timeSent; } m_semTable[message.sender][EARLY_MESSAGE_SEM_TAG].Release(); // Set latest message time if applicable m_semTable[message.sender][TIME_SEM_TAG].WaitOne(); if (m_latestMessages[message.sender].CompareTo(message.timeSent) < 0) { m_latestMessages[message.sender] = message.timeSent; } m_semTable[message.sender][TIME_SEM_TAG].Release(); }
/// <summary> /// Retrieves the messages associated with a specific conversation /// </summary> /// <param name="conversationID">The conversation tag to get the messages for</param> /// <returns>The list of saved messages which is empty if no data is saved for the specific conversation</returns> public List <FacebookMessage> getMessages(string conversationID) { List <FacebookMessage> messageList = new List <FacebookMessage>(); IEnumerator iterator = DataSetManager.Manager.getData(DataSets.Messages, conversationID); //List<List<dynamic>> table = Database.getTable(DB_CONN_STRING, conversationID, FB_MESSAGE_ROWS); if (iterator != null) { while (iterator.MoveNext()) { System.Data.DataRow row = iterator.Current as System.Data.DataRow; FacebookMessage fm = new FacebookMessage(); foreach (string tag in FB_MESSAGE_COLUMNS) { fm[tag] = row[tag]; } messageList.Add(fm); } } return(messageList); }
public async virtual Task createQuickReplay(IDialogContext context) { // await writeMessageToUser(context, new string[] { title }); var reply = context.MakeMessage(); var channelData = new JObject(); var quickReplies = new JArray(); var qrList = new List <FacebookQuickReply>(); foreach (var s in options) { var r = new FacebookQuickReply("text", s, s); qrList.Add(r); } var message = new FacebookMessage(prompt, qrList); reply.ChannelData = message; await context.PostAsync(reply); updateRequestTime(context); context.Wait(optionsRes); }
public async Task QueryAmenities(IDialogContext context, LuisResult result) { foreach (var entity in result.Entities.Where(Entity => Entity.Type == "Amenity")) { var value = entity.Entity.ToLower(); if (value == "pool" || value == "gym" || value == "wifi" || value == "towels") { //await context.PostAsync("Yes we have that!"); Activity replyMessage = _message.CreateReply(); var facebookMessage = new FacebookMessage(); facebookMessage.notification_type = "NO_PUSH"; facebookMessage.attachment = new FacebookAttachment(); facebookMessage.attachment.type = "template"; facebookMessage.attachment.payload = new FacebookPayload(); facebookMessage.attachment.payload.template_type = "generic"; var amenitiy = new FacebookElement(); amenitiy.subtitle = "Yes we have that!"; amenitiy.title = value; switch (value) { case "pool": amenitiy.image_url = "http://www.girltweetsworld.com/wp-content/uploads/2012/02/P1000180.jpg"; break; case "gym": amenitiy.image_url = "https://s-media-cache-ak0.pinimg.com/originals/cb/c9/4a/cbc94af79da9e334a8555e850da136f4.jpg"; break; case "wifi": amenitiy.image_url = "http://media.idownloadblog.com/wp-content/uploads/2016/02/wifi-icon.png"; break; case "towels": amenitiy.image_url = "http://www.prabhutextile.com/images/bath_towel_1.jpg"; break; default: break; } facebookMessage.attachment.payload.elements = new FacebookElement[] { amenitiy }; replyMessage.ChannelData = facebookMessage; await context.PostAsync(replyMessage); context.Wait(MessageReceived); return; } else { await context.PostAsync("I'm sorry we don't have that."); context.Wait(MessageReceived); return; } } await context.PostAsync("I'm sorry we don't have that."); context.Wait(MessageReceived); return; }
public void parallelAnalyze(FacebookMessage fm) { lock (m_profanityTable) { if (!m_profanityTable.ContainsKey(fm.sender)) { m_profanityTable[fm.sender] = new Dictionary <string, int>(); } } if (fm.message == null) { return; } SortedSet <string> message = new SortedSet <string>(fm.message.ToLower().Split()); foreach (string word in new List <string>(message)) { string[] morewords = word.Split('-'); for (int index = 0; index < morewords.Length; index++) { if (morewords[index] != "") { message.Add(morewords[index]); } } } foreach (string profane_word in m_profaneWords) { List <string> profaneWords = new List <string>(); foreach (string message_word in message) { if (message_word == profane_word || (message_word.Length > profane_word.Length && message_word.Substring(0, profane_word.Length) == profane_word) ) { lock (m_profanityTable[fm.sender]) { if (!m_profanityTable[fm.sender].ContainsKey(profane_word)) { m_profanityTable[fm.sender][profane_word] = 0; } m_profanityTable[fm.sender][profane_word]++; if (!m_flaggedMessages.ContainsKey(fm.sender)) { lock (m_flaggedMessages) { m_flaggedMessages.Add(fm.sender, new Dictionary <FacebookMessage, List <string> >()); } } if (!m_flaggedMessages[fm.sender].ContainsKey(fm)) { m_flaggedMessages[fm.sender].Add(fm, new List <string>()); } m_flaggedMessages[fm.sender][fm].Add(profane_word); } } } } }
public void analyze(FacebookMessage fm) { throw new NotImplementedException("The Parallel Analysis should be called instead"); }
public string GetTeamMembeDetailsForGroupReport(string TeamId, string userid, string days) { string FacebookprofileId = string.Empty; string TwitterprofileId = string.Empty; string FacebookFanPageId = string.Empty; string profid = string.Empty; string FacebookInboxMessagecount = string.Empty; string TwitterInboxMessagecount = string.Empty; Domain.Socioboard.Domain.GroupStatDetails _GroupStatDetails = new Domain.Socioboard.Domain.GroupStatDetails(); Guid UserId = Guid.Parse(userid); try { List<FacebookAccount> _facebookAccount = new List<FacebookAccount>(); List<Domain.Socioboard.Domain.TeamMemberProfile> lstTeamMember = teammemberrepo.getAllTeamMemberProfilesOfTeam(Guid.Parse(TeamId)); foreach (Domain.Socioboard.Domain.TeamMemberProfile TeamMemberProfile in lstTeamMember) { #region MyRegion try { if (TeamMemberProfile.ProfileType == "facebook" || TeamMemberProfile.ProfileType == "twitter") { profid += TeamMemberProfile.ProfileId + ','; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { if (TeamMemberProfile.ProfileType == "facebook") { FacebookprofileId += TeamMemberProfile.ProfileId + ','; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { if (TeamMemberProfile.ProfileType == "twitter") { TwitterprofileId += TeamMemberProfile.ProfileId + ','; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { if (TeamMemberProfile.ProfileType == "facebook_page") { FacebookFanPageId += TeamMemberProfile.ProfileId + ','; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } #endregion } #region MyRegion try { profid = profid.Substring(0, profid.Length - 1); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { FacebookFanPageId = FacebookFanPageId.Substring(0, FacebookFanPageId.Length - 1); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { TwitterprofileId = TwitterprofileId.Substring(0, TwitterprofileId.Length - 1); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { FacebookprofileId = FacebookprofileId.Substring(0, FacebookprofileId.Length - 1); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } #endregion #region Inboxmessagecount if (!string.IsNullOrEmpty(FacebookprofileId)) { try { FacebookMessage _FacebookMessage = new FacebookMessage(); FacebookInboxMessagecount = _FacebookMessage.GetAllInboxMessage(userid, FacebookprofileId, days); } catch (Exception ex) { FacebookInboxMessagecount = (0).ToString(); Console.WriteLine(ex.StackTrace); } } if (!string.IsNullOrEmpty(TwitterprofileId)) { try { TwitterFeed _TwitterFeed = new TwitterFeed(); TwitterInboxMessagecount = _TwitterFeed.TwitterInboxMessagecount(userid, TwitterprofileId, days); } catch (Exception ex) { TwitterInboxMessagecount = (0).ToString(); Console.WriteLine(ex.StackTrace); } } _GroupStatDetails.IncommingMessage = (Convert.ToInt32(FacebookInboxMessagecount) + Convert.ToInt32(TwitterInboxMessagecount)); #endregion #region sentmessage if (!string.IsNullOrEmpty(profid)) { try { ScheduledMessage _ScheduledMessage = new ScheduledMessage(); _GroupStatDetails.SentMessage = _ScheduledMessage.GetAllScheduledMessage(userid, profid, days); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); _GroupStatDetails.SentMessage = 0; } } #endregion #region twitterfolllower try { TwitterAccountFollowers _TwitterAccountFollowers = new TwitterAccountFollowers(); _GroupStatDetails.TwitterFollower = _TwitterAccountFollowers.FollowerCount(userid, TwitterprofileId, days); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); _GroupStatDetails.TwitterFollower = 0; } #endregion #region fancount try { FacebookFanPage _FacebookFanPage = new FacebookFanPage(); _GroupStatDetails.FacebookFan = _FacebookFanPage.FacebookFans(userid, FacebookFanPageId, days); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); _GroupStatDetails.FacebookFan = 0; } #endregion #region MentionRetweetDetails try { TwitterMessage _TwitterMessage = new TwitterMessage(); _GroupStatDetails.MentionGraph = string.Empty; string graphdetails = _TwitterMessage.GetAllRetweetMentionBydays(userid, TwitterprofileId, days); string[] data = graphdetails.Split('@'); foreach (var item in data) { if (item.Contains("usrtwet^")) { _GroupStatDetails.UserTweetGraph = item.Replace("usrtwet^", ""); } else if (item.Contains("mention^")) { _GroupStatDetails.MentionGraph = item.Replace("mention^", ""); } else if (item.Contains("retwet^")) { _GroupStatDetails.RetweetGraph = item.Replace("retwet^", ""); } else if (item.Contains("metion")) { _GroupStatDetails.Mention = Convert.ToInt32(item.Replace("metion", "")); } else if (item.Contains("retwet")) { _GroupStatDetails.Retweet = Convert.ToInt32(item.Replace("retwet", "")); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } #endregion try { ScheduledMessage _ScheduledMessage = new ScheduledMessage(); string details = _ScheduledMessage.GetAllScheduleMsgDetailsForReport(userid, TwitterprofileId, days); string[] data = details.Split('@'); foreach (var item in data) { if (item.Contains("plaintext_")) { _GroupStatDetails.PlainText = Convert.ToInt32(item.Replace("plaintext_","")); } else { _GroupStatDetails.PhotoLink = Convert.ToInt32(item); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return "Something Went Wrong"; } return new JavaScriptSerializer().Serialize(_GroupStatDetails); }
protected virtual async Task OnFacebookEcho(ITurnContext turnContext, FacebookMessage facebookMessage, CancellationToken cancellationToken) { Logger.LogInformation("Echo message received."); // TODO: Your echo event handling logic here... }
public static FacebookMessage Message(long id, JToken json) { FacebookMessage fm; var keyTime = json.TryGetValue <DateTime?>("created_time") ?? json.TryGetValue <DateTime>("updated_time"); if (keyTime == default(DateTime)) { return(null); } if ((fm = Data.FacebookMessages.FirstOrDefault(x => x.Id == id && x.TimeCreated == keyTime)) == null) { fm = new FacebookMessage { Id = id, TimeCreated = keyTime }; Data.FacebookMessages.InsertOnSubmit(fm); } if (!json.Any()) { return(fm); } fm.Message = json.TryGetValue <string>("message"); fm.TimeUpdated = json.TryGetValue <DateTime>("updated_time"); if (fm.TimeUpdated == default(DateTime)) { fm.TimeUpdated = null; } fm.Description = json.TryGetValue <string>("description"); fm.Type = json.TryGetValue <string>("type"); fm.Link = json.TryGetValue <string>("link"); fm.Caption = json.TryGetValue <string>("caption"); fm.Name = json.TryGetValue <string>("name"); try { Data.SubmitChanges(); } catch (Exception ex) { Log.Error(string.Format("There was an error saving the message: {0} {1}", id, fm.Message), ex); return(null); } var fromId = json["from"].TryGetValue <long?>("id"); if (fromId != null) { var contact = Contact(fromId.Value, json["from"]); if (contact != null) { fm.From = contact.Id; } try { Data.SubmitChanges(); } catch (Exception ex) { Log.Error(string.Format("There was an error saving the message: {0} {1}", id, fm.Message), ex); } } var comments = json.TryGetValue <JObject>("comments"); if (comments != null) { var client = new WebClient(); do { foreach (var comment in comments["data"]) { var message = Message(id, comment); try { Data.SubmitChanges(); } catch (Exception ex) { Log.Error( string.Format("There was an error saving the message: {0} {1}", id, message.Message), ex); } } try { string paging; if ((paging = comments["paging"].TryGetValue <string>("next")) == null) { break; } var msgsData = client.DownloadData(paging); var msg = Encoding.UTF8.GetString(msgsData); comments = JObject.Parse(msg); } catch (WebException) { Thread.Sleep(60000); } } while (comments["data"].Any()); } return(fm); }
public async Task QueryAmenities(IDialogContext context, LuisResult result) { foreach (var entity in result.Entities.Where(e => e.Type == "Amenity")) { var entityValue = entity.Entity.ToLower(); if (entityValue == "kitchen" || entityValue == "towels" || entityValue == "wifi" || entityValue == "gym") { //await context.PostAsync("We have that."); Activity replyMessage = _message.CreateReply(); var facebookMessage = new FacebookMessage(); facebookMessage.attachment = new FacebookAttachment(); facebookMessage.attachment.type = "template"; facebookMessage.attachment.payload = new FacebookPayload(); facebookMessage.attachment.payload.template_type = "generic"; var amenity = new FacebookElement(); amenity.subtitle = "Yes, we have that"; amenity.title = entityValue; switch (entityValue) { case "kitchen": amenity.image_url = "http://luxurylaunches.com/wp-content/uploads/2015/10/Mark-hotel-suites-3.jpg"; break; case "gym": amenity.image_url = "https://s-media-cache-ak0.pinimg.com/originals/cb/c9/4a/cbc94af79da9e334a8555e850da136f4.jpg"; break; case "wifi": amenity.image_url = "http://media.idownloadblog.com/wp-content/uploads/2016/02/wifi-icon.png"; break; case "towels": amenity.image_url = "http://www.prabhutextile.com/images/bath_towel_1.jpg"; break; default: break; } facebookMessage.attachment.payload.elements = new FacebookElement[] { amenity }; replyMessage.ChannelData = facebookMessage; await context.PostAsync(replyMessage); context.Wait(MessageReceived); return; } else { await context.PostAsync("I'm sorry. We don't have that."); context.Wait(MessageReceived); return; } } await context.PostAsync("I'm sorry. We don't have that."); context.Wait(MessageReceived); return; }
public void parallelAnalyze(FacebookMessage fm) { throw new NotImplementedException("This should not be called"); }
//Saving FacebookWall of user into database i.e. FacebookMessage table public void getFacebookUserHome(dynamic data, dynamic profile) { FacebookMessage fbmsg = new FacebookMessage(); FacebookMessageRepository fbmsgrepo = new FacebookMessageRepository(); string profileid = string.Empty; User user = (User)HttpContext.Current.Session["LoggedUser"]; if (data != null) { int lstfbcount = 0; foreach (dynamic result in data["data"]) { string message = string.Empty; string imgprof = "http://graph.facebook.com/" + result["from"]["id"] + "/picture?type=small"; fbmsg.EntryDate = DateTime.Now; fbmsg.MessageId = result["id"].ToString(); fbmsg.FromId = result["from"]["id"].ToString(); fbmsg.FromName = result["from"]["name"].ToString(); fbmsg.FromProfileUrl = imgprof; fbmsg.Id = Guid.NewGuid(); fbmsg.MessageDate = DateTime.Parse(result["created_time"].ToString()); fbmsg.UserId = user.Id; try { fbmsg.Picture = result["picture"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); fbmsg.Picture = null; } try { if (result["message_tags"][0] != null) { if (result["to"] != null) { foreach (var item in result["to"]["data"]) { if (result["from"] != null) { if (item["id"] != profile["id"]) { if (result["from"]["id"] == profile["id"]) { fbmsg.Type = "fb_tag"; } else { fbmsg.Type = "fb_home"; } } else { fbmsg.Type = "fb_home"; } } } } else { fbmsg.Type = "fb_home"; } } else { fbmsg.Type = "fb_home"; } } catch (Exception ex) { fbmsg.Type = "fb_home"; Console.WriteLine(ex.StackTrace); } fbmsg.ProfileId = profile["id"].ToString(); fbmsg.FbComment = "http://graph.facebook.com/" + result["id"] + "/comments"; fbmsg.FbLike = "http://graph.facebook.com/" + result["id"] + "/likes"; if (lstfbcount < 25) { try { if (result["message"] != null) { message = result["message"]; lstfbcount++; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); try { if (result["description"] != null) { message = result["description"]; lstfbcount++; } } catch (Exception exx) { try { Console.WriteLine(exx.StackTrace); if (result["story"] != null) { message = result["story"]; lstfbcount++; } } catch (Exception exxx) { Console.WriteLine(exxx.StackTrace); message = string.Empty; } } } } fbmsg.Message = message; if (!fbmsgrepo.checkFacebookMessageExists(fbmsg.MessageId)) { fbmsgrepo.addFacebookMessage(fbmsg); } } } }
public int updateFacebookMessage(FacebookMessage fbaccount) { throw new NotImplementedException(); }
public List <FacebookMessage> getComments(string conversationID) { List <FacebookMessage> messageList = new List <FacebookMessage>(); // TODO: Check values if (m_next == "" || m_next == null) { for (int i = 0; i < m_conversations.data.Count; i++) { if (m_conversations.data[i].id == conversationID) { m_messages = m_conversations.data[i].comments; if (m_conversations.data[i].comments != null) { m_next = m_conversations.data[i].comments.paging.next; } break; } } // May not be neccessary -- check else Post call // TODO: Parse m_next parameter to change limit size } else { m_next = m_next.Replace("limit=25", "limit=10000"); m_messages = m_fbClient.Get(m_next); // m_messages = m_fbClient.Post(m_next, new { method = "GET", limit = 10000 }); if (m_messages.paging != null) { m_next = m_messages.paging.next; } else { Cleanup(); } } if (m_messages != null) { for (int i = 0; i < m_messages.data.Count; i++) { FacebookMessage fm = new FacebookMessage(); string longID = m_messages.data[i].id as string; fm.id = Int32.Parse(longID.Substring(longID.IndexOf('_') + 1)); User sender = new User(); sender.id = m_messages.data[i].from.id; sender.name = m_messages.data[i].from.name; fm.sender = sender; string dtStr = (string)m_messages.data[i].created_time; int year = Int32.Parse(dtStr.Substring(0, 4)); int month = Int32.Parse(dtStr.Substring(5, 2)); int day = Int32.Parse(dtStr.Substring(8, 2)); int hour = Int32.Parse(dtStr.Substring(11, 2)); int minute = Int32.Parse(dtStr.Substring(14, 2)); int second = Int32.Parse(dtStr.Substring(17, 2)); fm.timeSent = new DateTime(year, month, day, hour, minute, second); fm.message = m_messages.data[i].message; messageList.Add(fm); } } return(messageList); }
public TestModule() { m_previousMessage = new FacebookMessage(); m_previousValues = null; }