public static PageInfoDTO Map(LocalBusiness localBusiness, UserDTO user, string appPath, string locale) { var pageDTO = LocalBusinessDTOFactory.Map<PageInfoDTO>( localBusiness, appPath, locale); pageDTO.User = user; pageDTO.DisplayLocale = Thread.CurrentThread.CurrentUICulture.Name; pageDTO.IsRightToLeft = Thread.CurrentThread.CurrentUICulture.TextInfo.IsRightToLeft; return pageDTO; }
//http://aabs.wordpress.com/2008/01/18/c-by-contract-using-expression-trees/ static void Main(string[] args) { Console.WriteLine("Creating Tables..."); var sessionFactory = new SessionFactory(); Console.WriteLine("Finished Creating Tables!"); Console.WriteLine("inserting new data..."); IRepository repository = new NHibernateRepository(sessionFactory); foreach (var str in ConfigurationManager.ConnectionStrings) { if (!str.ToString().Contains("server=localhost") && !str.ToString().Contains(".\\SQLEXPRESS") && !str.ToString().Equals(String.Empty)) { Console.WriteLine("WTF? Don't run this on a remote server!"); Console.ReadKey(); return; } } try { repository.BeginTransaction(); //stas 664118894 var fbUser1 = new FbUser { Id = 585701767, JoinDate = DateTime.Now, Name = "anna", Status = UserStatus.Joined }; var fbUser2 = new FbUser { Id = 806905557, JoinDate = DateTime.Now, Name = "stas", Status = UserStatus.Joined }; var fbUser3 = new FbUser { Id = 716712905, JoinDate = DateTime.Now, Name = "dror", Status = UserStatus.Joined }; //var fbUser3 = new FbUser { Id = 806905557, JoinDate = DateTime.Now, Name = "ran", Status = UserStatus.Joined }; var fbUser4 = new FbUser { Id = 100000431166374, JoinDate = DateTime.Now, Name = "yadid", Status = UserStatus.Joined }; repository.Save(fbUser1); repository.Save(fbUser2); repository.Save(fbUser3); repository.Save(fbUser4); var localBusiness1 = new LocalBusiness { AddressCity = "Yehud", AddressStreet = "Levi Eschol 1", Category = "Music", CreatedDate = DateTime.Now, FacebookUrl = "http://www.facebook.com/pages/%D7%A7%D7%95%D7%9C%D7%95%D7%9C%D7%95/178456328876503", FanPageId = 186841648018387, //FanPageId = 258829897475960, LastModified = DateTime.Now, Name = "קולולו", PublishUserContentToWall = false, PublishAdminContentToWall = true, Owners = new List<FbUser> { fbUser1, fbUser2, fbUser3, fbUser4 } }; var uriBusiness = new LocalBusiness { AddressCity = "Faraway city", AddressStreet = "Back alley", Category = "Music", CreatedDate = DateTime.Now, FacebookUrl = "https://www.facebook.com/pages/%D7%96%D7%9E%D7%A8-test/245866165438909", FanPageId = 245866165438909, FBFanPageAccessToken = "157721837628308|afd07c5be8ae8e01047a1156.1-662326561|juC8P9wsNLP5XirWXPCzEMF7qPU", ImageUrl = "https://fbcdn-profile-a.akamaihd.net/static-ak/rsrc.php/v1/yA/r/gPCjrIGykBe.gif", LastModified = DateTime.Now, Name = "זמר טסט", PublishUserContentToWall = true, PublishAdminContentToWall = true, Owners = new List<FbUser> {fbUser1, fbUser2, fbUser3, fbUser4} }; var uriRadio = new Playlist { Name = "Radio Uri", Description = "", Image = "", CreationDate = DateTime.Now, LastModifiedDate = DateTime.Now, NextPlayDate = DateTime.Parse("23/07/2013 08:55:00"), IsUserModifyable = true, NumOfSongsLimit = 5 }; uriBusiness.AddPlaylist(uriRadio); uriBusiness.ImportPlaylist = uriRadio; repository.Save(uriBusiness); var radio1 = new Playlist { Name = "Kululu-FM", Description = "", Image = "", CreationDate = DateTime.Now, LastModifiedDate = DateTime.Now, NextPlayDate = DateTime.Parse("23/07/2012 08:55:00"), IsUserModifyable = true, NumOfSongsLimit = 5 }; localBusiness1.AddPlaylist(radio1); localBusiness1.ImportPlaylist = radio1; repository.Save(localBusiness1); var localBusiness2 = new LocalBusiness() { Owners = new List<FbUser> { fbUser1 }, AddressCity = "Haifa", AddressStreet = "Rauel Wallenberg", Category = "Music", CreatedDate = DateTime.Now, FacebookUrl = "http://www.facebook.com/pages/%D7%A7%D7%95%D7%9C%D7%95%D7%9C%D7%95/178456328876503", FanPageId = 1, ImageUrl = "http://profile.ak.fbcdn.net/hprofile-ak-snc4/195725_178456328876503_4279627_n.jpg", LastModified = DateTime.Now, PublishAdminContentToWall = true, PublishUserContentToWall = false, Name = "Kululu Test" }; var radio2 = new Playlist { Description = "", Image = "", CreationDate = DateTime.Now, LastModifiedDate = DateTime.Now, Name = "Radius-100FM", NextPlayDate = DateTime.Parse("25/07/2011"), IsUserModifyable = true, NumOfSongsLimit = 10 }; localBusiness2.AddPlaylist(radio2); repository.Save(localBusiness2); var playlistSongRating = SaveSong(repository, radio1, fbUser1, "Cee Lo Green", "Bright Lights Bigger City", 231, "UBhdIcb84Hw", 1, "http://userserve-ak.last.fm/serve/126s/62075863.png"); //radio1.AddRating(song, fbUser3, -1); radio1.RateSong(playlistSongRating, fbUser4, 1); radio1.RateSong(playlistSongRating, fbUser2, 1); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); uriRadio.RateSong(playlistSongRating, fbUser4, 1); playlistSongRating = SaveSong(repository, radio1, fbUser1, "מוש בן ארי", "סתכל לי בעיניים", 249, "HwgVLsnaAoU", 1, "http://userserve-ak.last.fm/serve/126s/20443621.jpg"); //radio1.AddRating(song, fbUser3, 1); radio1.RateSong(playlistSongRating, fbUser4, 1); radio1.RateSong(playlistSongRating, fbUser2, 1); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); uriRadio.RateSong(playlistSongRating, fbUser4, 1); uriRadio.RateSong(playlistSongRating, fbUser2, 1); playlistSongRating = SaveSong(repository, radio1, fbUser1, "J.LO FT. Pitbull", "On The Floor", 267, "t4H_Zoh7G5A", 1, null); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "גלעד שגב", "חנה'לה התבלבלה", 214, "vAlFB4Z7P2Y", 1, "http://userserve-ak.last.fm/serve/126s/163895.jpg"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Adele", "Someone Like You", 306, "7AW9C3-qWug", 1, "http://userserve-ak.last.fm/serve/126s/58297847.png"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); SaveSong(repository, radio1, fbUser1, "Britney Spears", "Till The World Ends", 236, "qzU9OrZlKb8", 1, "http://userserve-ak.last.fm/serve/126s/59558187.png"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); SaveSong(repository, radio1, fbUser1, "Enrique Iglesias", "Tonight", 299, "Jx2yQejrrUE", 1, "http://userserve-ak.last.fm/serve/126s/65262750.png"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Pitbull", "Give Me Everything", 267, "EPo5wWmKEaI", 1, "http://userserve-ak.last.fm/serve/126s/64990460.png"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); //radio1.AddRating(song, fbUser3, -1); radio1.RateSong(playlistSongRating, fbUser4, 1); radio1.RateSong(playlistSongRating, fbUser2, -1); uriRadio.RateSong(playlistSongRating, fbUser4, 1); uriRadio.RateSong(playlistSongRating, fbUser2, -1); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Lady Gaga", "Born This Way", 440, "wV1FrqwZyKw", 1, "http://userserve-ak.last.fm/serve/126s/63387017.png"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "ברי סחרוף", "זמן של מספרים", 303, "PCwDDGYely0", 1, "http://userserve-ak.last.fm/serve/126s/784256.jpg"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Depeche Mode", "Personal Jesus (The Stargate Mix)", 252, "3xLvArgSp3k", 1, "http://userserve-ak.last.fm/serve/126s/2126897.jpg"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Diddy Dirty Money ft. Skylar Grey", "Coming Home", 251, "k-ImCpNqbJw", 1, null); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "The Black Eyed Peas", "Just Can't Get Enough", 236, "OrTyD7rjBpw", 1, "http://userserve-ak.last.fm/serve/126s/65970878.png"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Bob Sinclar & Raffaella Carrà", "Far l'Amore", 220, "rSmdeqxxLLk", 1, "http://userserve-ak.last.fm/serve/126s/26932877.jpg"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Jessie J ft. B.o.B.", "Price Tag", 247, "qMxX-QOV9tI", 1, null); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); //radio1.AddRating(song, fbUser3, -1); radio1.RateSong(playlistSongRating, fbUser4, -1); radio1.RateSong(playlistSongRating, fbUser2, -1); uriRadio.RateSong(playlistSongRating, fbUser4, -1); uriRadio.RateSong(playlistSongRating, fbUser2, -1); //radio2.AddRating(song, fbUser3, 1); playlistSongRating = SaveSong(repository, radio1, fbUser1, "Lady Gaga", "The Edge Of Glory", 328, "QeWBS0JBNzQ", 1, "http://userserve-ak.last.fm/serve/126s/63387017.png"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); //SaveSong(repository, radio1, fbUser1, "הפרוייקט של עידן רייכל - אִמָּא, אַבָּא וכל הַשְּׁאָר", "D98E89oUo6o", 1); playlistSongRating = SaveSong(repository, radio1, fbUser1, "אדיר גץ", "איך היא רוקדת", 236, "Pu2s7bboV9M", 1, "http://userserve-ak.last.fm/serve/126s/51539323.jpg"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "שלומי סרנגה", "זה רק נדמה לך", 218, "MaZIYKtIfnM", 1, "http://userserve-ak.last.fm/serve/126s/83144.jpg"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); playlistSongRating = SaveSong(repository, radio1, fbUser1, "מאור כהן", "ישראל", 183, "svjdhfKJbUc", 1, "http://userserve-ak.last.fm/serve/126s/311813.jpg"); uriRadio.AddSong(playlistSongRating.Song, fbUser1, true); //radio2.RateSong(song, fbUser2, 1); //radio2.AddRating(song, fbUser3, 1); repository.CommitTransaction(); } catch (Exception e) { repository.RollbackTransaction(); repository.CloseSession(); Console.WriteLine("*** Failure ({0}): {1}", e.GetType(), e.Message); } Console.WriteLine("Finished!"); Console.ReadKey(); }
/// <summary> /// Send email to administrator of the page about posting to wall /// </summary> /// /// <param name="localBusiness"> /// local business for which the email should be sent /// </param> /// /// <param name="songName"> /// name of the song posted to the wall /// </param> private void SendEmail(LocalBusiness localBusiness, string songName) { var body = String.Format( App_GlobalResources.Strings.adminEmailSentBody, songName); var eml = new Email( localBusiness.EmailOnAdminPost, localBusiness.Owners[0].FullName, App_GlobalResources.Strings.adminEmailSentFromAddress, App_GlobalResources.Strings.adminEmailSentFromName, App_GlobalResources.Strings.adminEmailSentSubject, body); if (eml.Send()) { Logger.InfoFormat("Sent email to administrator"); } else { Logger.WarnFormat( "Failed to send email to administrator of {0} ({1})", localBusiness.Name, localBusiness.FanPageId); } }
/// <summary> /// build playlist DTO for specified local business /// </summary> /// /// <param name="lb"> /// local business to convert to DTO /// </param> /// /// <param name="nvstr"> /// translation strings /// </param> protected PageInfoDTO BuildPageInfoDto(LocalBusiness lb, IDictionary<string, string> nvstr) { var cust = Repository .Query<Customizations>() .FirstOrDefault(c => c.LocalBusiness == lb); var lbLocale = (cust != null) ? cust.Locale : null; /* assuming here that playlist owner is also localbusiness owner */ var rv = PageInfoDTOFactory.Map( lb, BuildUserDTO(lb.DefaultPlaylist), HttpContext.Request.ApplicationPath, lbLocale); rv.IsCanvas = CurrentUserFBInfo.IsCanvas; rv.Strings = nvstr; return rv; }
private LocalBusiness SaveLocalBusiness(long pageId) { var fbQueryUrl = string.Format("/{0}", pageId); dynamic fanPageInfo = FacebookApp.Get(fbQueryUrl); var localBusiness = new LocalBusiness { FanPageId = pageId, Name = fanPageInfo.name, FacebookUrl = fanPageInfo.link, Category = fanPageInfo.category, CreatedDate = DateTime.Now, LastModified = DateTime.Now, PublishAdminContentToWall = true, PublishUserContentToWall = true }; if (fanPageInfo.location != null) { localBusiness.AddressCity = fanPageInfo.location.city; localBusiness.AddressStreet = fanPageInfo.location.street; } Repository.Save(localBusiness); return localBusiness; }
/// <summary> /// process wall messages of a single fan page /// </summary> /// /// <param name="fp"> /// fan page to process /// </param> /// /// <param name="graphQuery"> /// graph API query to use when processing this fan page /// </param> private List<PlaylistSongRatingAndLikes> ProcessFanPage( LocalBusiness fp, string graphQuery, HarvestType type) { Logger.InfoFormat("Processing fan page {0}: {1}... ", fp.FanPageId, fp.Name); /* build the initial URL of the page */ var feedUrl = string.Format(graphQuery, fp.FanPageId); var defaultUser = GetDefaultUser(fp, graphQuery); var postsInfo = new List<PlaylistSongRatingAndLikes>(); var isReadComplete = false; dynamic parameters = new ExpandoObject(); parameters.limit = FB_FETCH_LIMIT; parameters.offset = 0; var data = FbApp.Get(feedUrl, parameters); do { Logger.Info("fetching posts"); if (!data.ContainsKey("data")) { return postsInfo; } foreach (var dat in data["data"]) { try { var postLink = GetVideoLink(dat); var postType = dat.ContainsKey("type") ? (string)dat["type"] : string.Empty; /* in order to simplify conditions, continue is used * otherwise, "if's" are too comples */ if (postType == null || postLink == null) { continue; } /* filter allowed content */ if (!postType.Equals("video") && !postType.Equals("swf") && !postType.Equals("link")) { continue; } /* process only YouTube links */ if (!postLink.Contains("youtube.com")) { continue; } var postInfo = ProcessLink(fp, dat, defaultUser); /* wasn't previously added, handling cases of duplicate * posts */ if (postInfo != null && !postsInfo.Contains(postInfo)) { postsInfo.Add(postInfo); } } catch (Exception ex) { FbStreamUpdated(StreamUpdateStatus.Error, ex); Logger.Error("This should not have happened", ex); return null; } if (type == HarvestType.TopTen && postsInfo.Count >= 10) break; } if (type == HarvestType.TopTen && postsInfo.Count >= 10) break; Logger.InfoFormat("finished fetching {0} posts", postsInfo.Count); if (!data.ContainsKey("paging") || !data["paging"].ContainsKey("next")) { isReadComplete = true; } else { var serializer = new JavaScriptSerializer(); string nextPage = data["paging"]["next"]; if (graphQuery.ToLower().Contains("since")) { nextPage = string.Format("{0}&since=yesterday", nextPage); } var request = new MyWebRequest(nextPage); data = serializer.Deserialize<dynamic>( request.GetResponse()); } } while (!isReadComplete); Logger.InfoFormat("Done processing fan page {0}: {1}", fp.FanPageId, fp.Name); return postsInfo; }
/// <summary> /// process single wall post with link /// </summary> /// /// <param name="fp"> /// fan page this post belongs to /// </param> /// /// <param name="post"> /// facebook post as recevied from facebook API /// </param> /// /// <param name="user"> /// user posting this link /// </param> /// ///<returns></returns> private PlaylistSongRatingAndLikes ProcessLink( LocalBusiness fp, dynamic post, FbUser user = null) { var name = post.ContainsKey("name") ? (string)post["name"] : string.Empty; var caption = post.ContainsKey("caption") ? (string)post["caption"] : string.Empty; var id = post.ContainsKey("id") ? (string)post["id"] : string.Empty; // TODO: move this to some method var link = GetVideoLink(post); var addedDate = Convert.ToDateTime(post["created_time"]); var from = post["from"]; var fromId = from.ContainsKey("id") ? from["id"] : 0; var numOfComments = (int)post["comments"]["count"]; var numOfLikes = post.ContainsKey("likes") ? (int)post["likes"]["count"] : 0; var message = post.ContainsKey("message") ? post["message"] : null; var description = post.ContainsKey("description") ? post["description"] : null; /* if not record was found and localbusiness doesn't allow import * of new content, exit */ if (!ShouldImport(fp)) { return null; } /* try to find this song in the database or create one */ if (user == null) { user = FindOrCreateUser(fromId); } var song = FindOrCreateSong(link, name, caption) as Song; if (song == null) { return null; } // song doesn't exist in DB yet if (song.Id == 0) { Repository.Save(song); } var rating = Repository.Query<PlaylistSongRating>() .Where(r => r.Playlist == fp.ImportPlaylist) .Where(r => r.FBPostId == id) .FirstOrDefault(); /* if this rating is already stored in the database, do nothing */ if (rating == null) { rating = fp.ImportPlaylist.AddSong(song, user, true, 0); rating.FBMessage = message; rating.FBDescription = description; rating.Origin = Origin.Facebook; rating.FBPostId = id; rating.FacebookAddedDate = addedDate; } else { Logger.InfoFormat( "The song with the {0} FBPostId already exists under this FbPostId {1}", id, rating.FBPostId); } rating.NumOfComments = numOfComments; Repository.SaveOrUpdate(rating); Repository.SaveOrUpdate(fp.ImportPlaylist); return new PlaylistSongRatingAndLikes { PlaylistSongRating = rating, NumOfLikes = numOfLikes }; }
/// <summary> /// should the data of this local business be imported? /// </summary> private static bool ShouldImport(LocalBusiness lb) { return (lb.ImportPlaylist != null); }
/// <summary> /// /// </summary> /// /// <param name="fbLikeData"> /// </param> /// /// <remarks> /// This method is Synchronized, not two calls can be made at the same /// time. /// Calls will be stacked. /// </remarks> private string CreateSqlInsertInto(dynamic fbLikeData, LocalBusiness lb) { var fanPageId = lb.FanPageId.ToString(); var numOfLikes = 0; var insertIntoBuilder = new StringBuilder(3145728); insertIntoBuilder.Append(" INSERT INTO {0} (isAdmin ,postId , userId , objectId ) values"); foreach (var queryRslt in fbLikeData) { foreach (var rsltDetails in queryRslt.fql_result_set) { // appending is admin value insertIntoBuilder.AppendFormat( " ({0}, '{1}', {2}, {3}), ", rsltDetails.user_id == fanPageId ? 1 : 0, rsltDetails.post_id, rsltDetails.user_id, rsltDetails.object_id ); numOfLikes++; } } insertIntoBuilder.Length -= 2; insertIntoBuilder.Append(";"); AddNumOfLikesAdded(numOfLikes); return insertIntoBuilder.ToString(); }
/// <summary> /// When querying posts we find that the default user who added the /// songs is the page itself. Since we don't want to save the page as a /// user, we specify another default user to attach the songs to /// </summary> private static FbUser GetDefaultUser(LocalBusiness lb, string graphRequest) { return graphRequest.ToLower().Contains("posts") ? lb.Owners.FirstOrDefault() : null; }
private void Synchronize(List<PlaylistSongRatingAndLikes> postsInfo, LocalBusiness lb) { if (postsInfo.Count == 0) { return; } FbStreamUpdated(StreamUpdateStatus.RetrievingAggregatedInfo); Logger.InfoFormat("entering GetAggregatedInfoFqlRequests"); var requestsQuery = GetAggregatedInfoFqlRequests(postsInfo); Logger.InfoFormat("exiting GetAggregatedInfoFqlRequests"); Logger.InfoFormat("about to request {0} queries from facebook", requestsQuery.Count); var tasks = new List<Task>(); var taskFactory = new TaskFactory( TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness, TaskContinuationOptions.LongRunning | TaskContinuationOptions.PreferFairness); for (var index = 0; index < requestsQuery.Count; index++) { dynamic response = null; try { Logger.InfoFormat("requesting {0} / {1}", index + 1, requestsQuery.Count); response = FbApp.Query(requestsQuery[index]); Logger.InfoFormat("recieved aggregated info from facebook"); } catch (Exception ex) { Logger.Fatal("The following error has occured", ex); } var task = taskFactory.StartNew(() => { Logger.InfoFormat("entering SaveAggregatedData of reqest number {0}", index); SaveAggregatedData(postsInfo, response); Logger.InfoFormat("left SaveAggregatedData of reqest number {0}", index); }); tasks.Add(task); } // waiting for last thread to compelte execution before exiting if (tasks.Count > 0) { Logger.Info("Waiting for all likes to be retrieived"); Task.WaitAll(tasks.ToArray()); } Logger.Info("commiting aggregated info"); Repository.CommitTransaction(); Logger.Info("complete commit of aggregated info"); //Thread.Sleep(WAIT_BETWEEN_OPERATIONS); SaveLikesInfo(postsInfo, lb); }
/// <summary> /// Converting from PlaylistSongRating to PlaylistSongRatingAndLikes /// and continuing synchronization /// </summary> private void Synchronize(IEnumerable<PlaylistSongRating> fbPosts, LocalBusiness lb) { var postInfoWithLikes = new List<PlaylistSongRatingAndLikes>(); foreach (var postInfo in fbPosts) { postInfoWithLikes.Add(new PlaylistSongRatingAndLikes { PlaylistSongRating = postInfo, NumOfLikes = 0 //setting default values }); } Synchronize(postInfoWithLikes, lb); }
private void SaveLikesInfo( IEnumerable<PlaylistSongRatingAndLikes> postsInfo, LocalBusiness lb) { FbStreamUpdated(StreamUpdateStatus.RetrievingLikes); Logger.InfoFormat("entering GetLikesFqlRequests"); var requestsQuery = GetLikesFqlRequests(postsInfo); Logger.InfoFormat("exiting GetLikesFqlRequests"); Logger.InfoFormat("Complete num of likes to synchronize is {0}", NumOfLikes); var increment = 0; Logger.InfoFormat("requesting {0} queries", requestsQuery.Count); var myProcess = Process.GetCurrentProcess(); while (increment < requestsQuery.Count) { try { Logger.InfoFormat("memory footprint : {0} bytes", myProcess.WorkingSet64); var queries = requestsQuery .Skip(increment) .Take(FB_MULTIQUERY_LIMIT) .ToArray(); increment += FB_MULTIQUERY_LIMIT; Logger.InfoFormat("requesting facebook like batch number {0}", increment); dynamic response = FbApp.Query(queries); Logger.Info("retrieved likes info"); string sqlInsertInto = CreateSqlInsertInto(response, lb); PersistToDB(sqlInsertInto); } catch (Exception ex) { var errMsg = string.Format( "Couldn't retrieve all info from facebook. batch number {0} / {1}", increment, requestsQuery.Count); Logger.Error(errMsg, ex); } finally { Logger.InfoFormat( "batch number {0} / {1}", increment, requestsQuery.Count); } } FbStreamUpdated(StreamUpdateStatus.RetrievingLikesComplete); }
/// <summary> /// parse the culture specified for local business /// </summary> /// /// <param name="lb"> /// local business for saving the data /// </param> /// /// <param name="prop"> /// property to process /// </param> /// /// <returns> /// true if the property was processed by this method, false otherwise /// </returns> private bool ParseCulture(LocalBusiness lb, KeyValuePair<string, object> prop) { if (!prop.Key.Equals("Locale")) { return false; } /* find customization for general local business (without looking * at playlist */ var cust = Repository .Query<Customizations>() .Where(c => c.LocalBusiness == lb) .Where(c => c.Playlist == null) .FirstOrDefault(); /* try to parse the locale, if failed return "true" marking * completion of property processing */ var locs = Enum.GetNames(typeof (MvcApplication.Culture)); if (!locs.Contains(prop.Value.ToString())) { Logger.WarnFormat("Invalid locale specified: {0}", prop.Value); return true; } if (cust == null) { cust = new Customizations { LocalBusiness = lb }; } cust.Locale = prop.Value.ToString(); Repository.SaveOrUpdate(cust); return true; }