public ActionResult Home(string message, HttpPostedFileBase file) { if (string.IsNullOrWhiteSpace(message) && file == null) { return RedirectToAction("Home"); } message = message.Trim(); mu = Membership.GetUser(); ua = new UserAccount(Convert.ToInt32(mu.ProviderUserKey)); //StatusUpdates sus = null; ViewBag.CurrentUser = ua.ToUnorderdListItem; StatusUpdate su = new StatusUpdate(); su.GetMostRecentUserStatus(ua.UserAccountID); DateTime startTime = Utilities.GetDataBaseTime(); TimeSpan span = startTime.Subtract(su.CreateDate); //su = new StatusUpdate(); // TODO: this is not working properly, preventing posts if (su.Message == message && file == null) { // double post return RedirectToAction("Home"); } else { su = new StatusUpdate(); } if (file != null && Utilities.IsImageFile(file.FileName)) { Bitmap b = new Bitmap(file.InputStream); var acl = CannedAcl.PublicRead; S3Service s3 = new S3Service(); s3.AccessKeyID = AmazonCloudConfigs.AmazonAccessKey; s3.SecretAccessKey = AmazonCloudConfigs.AmazonSecretKey; PhotoItem pitem = new PhotoItem(); pitem.CreatedByUserID = ua.UserAccountID; pitem.Title = message; // full System.Drawing.Image fullPhoto = (System.Drawing.Image)b; string fileNameFull = Utilities.CreateUniqueContentFilename(file); Stream maker = fullPhoto.ToAStream(ImageFormat.Jpeg); s3.AddObject( maker, maker.Length, AmazonCloudConfigs.AmazonBucketName, fileNameFull, file.ContentType, acl); pitem.FilePathRaw = fileNameFull; // resized System.Drawing.Image photoResized = (System.Drawing.Image)b; string fileNameResize = Utilities.CreateUniqueContentFilename(file); photoResized = ImageResize.FixedSize(photoResized, 500, 375, System.Drawing.Color.Black); maker = photoResized.ToAStream(ImageFormat.Jpeg); s3.AddObject( maker, maker.Length, AmazonCloudConfigs.AmazonBucketName, fileNameResize, file.ContentType, acl); pitem.FilePathStandard = fileNameResize; // thumb System.Drawing.Image thumbPhoto = (System.Drawing.Image)b; thumbPhoto = ImageResize.Crop(thumbPhoto, 150, 150, ImageResize.AnchorPosition.Center); string fileNameThumb = Utilities.CreateUniqueContentFilename(file); maker = thumbPhoto.ToAStream(ImageFormat.Jpeg); s3.AddObject( maker, maker.Length, AmazonCloudConfigs.AmazonBucketName, fileNameThumb, file.ContentType, acl); pitem.FilePathThumb = fileNameThumb; pitem.Create(); su.PhotoItemID = pitem.PhotoItemID; } su.UserAccountID = ua.UserAccountID; su.Message = message; su.CreatedByUserID = ua.UserAccountID; su.IsMobile = Request.Browser.IsMobileDevice; su.Create(); if (Request.Browser.IsMobileDevice) { // this will bring them to the post return new RedirectResult(Url.Action("Home") + "#most_recent"); } else { // the menu prevents brining to post correctly return RedirectToAction("Home"); } }
public ActionResult ProfileDetail(string userName) { ViewBag.VideoHeight = (Request.Browser.IsMobileDevice) ? 100 : 277; ViewBag.VideoWidth = (Request.Browser.IsMobileDevice) ? 225 : 400; _ua = new UserAccount(userName); var uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(_ua.UserAccountID); uad.BandsSeen = ContentLinker.InsertBandLinks(uad.BandsSeen, false); uad.BandsToSee = ContentLinker.InsertBandLinks(uad.BandsToSee, false); var model = new ProfileModel(); model.ProfilePhotoMainRaw = uad.RawProfilePicUrl; if (_ua.UserAccountID > 0) { model.UserAccountID = _ua.UserAccountID; model.PhotoCount = PhotoItems.GetPhotoItemCountForUser(_ua.UserAccountID); model.CreateDate = _ua.CreateDate; } if (_mu != null) { ViewBag.IsBlocked = BlockedUser.IsBlockedUser(_ua.UserAccountID, Convert.ToInt32(_mu.ProviderUserKey)); ViewBag.IsBlocking = BlockedUser.IsBlockedUser(Convert.ToInt32(_mu.ProviderUserKey), _ua.UserAccountID); if (_ua.UserAccountID == Convert.ToInt32(_mu.ProviderUserKey)) { model.IsViewingSelf = true; } else { var ucon = new UserConnection(); ucon.GetUserToUserConnection(Convert.ToInt32(_mu.ProviderUserKey), _ua.UserAccountID); model.UserConnectionID = ucon.UserConnectionID; if (BlockedUser.IsBlockedUser(Convert.ToInt32(_mu.ProviderUserKey), _ua.UserAccountID)) { return RedirectToAction("index", "home"); } } } else { if (uad.MembersOnlyProfile) { return RedirectToAction("LogOn", "Account"); } } ViewBag.ThumbIcon = uad.FullProfilePicURL; SetModelForUserAccount(model, uad); // var su = new StatusUpdate(); su.GetMostRecentUserStatus(_ua.UserAccountID); if (su.StatusUpdateID > 0) { model.LastStatusUpdate = su.CreateDate; model.MostRecentStatusUpdate = su.Message; } model.ProfileVisitorCount = ProfileLog.GetUniqueProfileVisitorCount(_ua.UserAccountID); GetUserPhotos(model); GetUserNews(model); model.MetaDescription = _ua.UserName + " " + Messages.Profile + " " + FromDate.DateToYYYY_MM_DD(_ua.LastActivityDate); GetUserPlaylist(); ForumThreads(_ua.UserAccountID, model); if (uad.UserAccountID > 0) { model.Birthday = uad.BirthDate; if (uad.ShowOnMapLegal) { // because of the foreign cultures, numbers need to stay in the English version unless a javascript encoding could be added string currentLang = Utilities.GetCurrentLanguageCode(); Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString()); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString()); model.DisplayOnMap = uad.ShowOnMapLegal; var rnd = new Random(); int offset = rnd.Next(10, 100); SiteStructs.LatLong latlong = GeoData.GetLatLongForCountryPostal(uad.Country, uad.PostalCode); if (latlong.latitude != 0 && latlong.longitude != 0) { model.Latitude = Convert.ToDecimal(latlong.latitude + Convert.ToDouble("0.00" + offset)) .ToString(CultureInfo.InvariantCulture); model.Longitude = Convert.ToDecimal(latlong.longitude + Convert.ToDouble("0.00" + offset)) .ToString(CultureInfo.InvariantCulture); } else { model.DisplayOnMap = false; } Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(currentLang); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(currentLang); } ViewBag.ThumbIcon = uad.FullProfilePicThumbURL; LoadCurrentImagesViewBag(uad.UserAccountID); } ViewBag.UserAccountDetail = uad; ViewBag.UserAccount = _ua; GetUserContacts(model); UserAccountDetail uadLooker = null; if (_mu != null) { uadLooker = new UserAccountDetail(); uadLooker.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey)); } if (uadLooker != null && (_mu != null && _ua.UserAccountID > 0 && uadLooker.EnableProfileLogging && uad.EnableProfileLogging)) { var pl = new ProfileLog { LookedAtUserAccountID = _ua.UserAccountID, LookingUserAccountID = Convert.ToInt32(_mu.ProviderUserKey) }; if (pl.LookingUserAccountID != pl.LookedAtUserAccountID) pl.Create(); ArrayList al = ProfileLog.GetRecentProfileViews(_ua.UserAccountID); if (al != null && al.Count > 0) { var uas = new UserAccounts(); foreach (UserAccount viewwer in al.Cast<int>().Select(id => new UserAccount(id)) .Where(viewwer => !viewwer.IsLockedOut && viewwer.IsApproved) .TakeWhile(viewwer => uas.Count < Maxcountusers)) { uas.Add(viewwer); } } } GetUserAccountVideos(); // this is either a youtube user or this is a band var art = new Artist(); art.GetArtistByAltname(userName); if (art.ArtistID > 0) { // try this way for dashers model.UserName = art.Name; } var vids = new Videos(); var sngrs = new SongRecords(); if (art.ArtistID == 0) { vids.GetAllVideosByUser(userName); var uavs = new UserAccountVideos(); uavs.GetRecentUserAccountVideos(_ua.UserAccountID, 'U'); foreach (Video f2 in uavs.Select(uav1 => new Video(uav1.VideoID)).Where(f2 => !vids.Contains(f2))) { vids.Add(f2); } vids.Sort((x, y) => (y.PublishDate.CompareTo(x.PublishDate))); model.UserName = _ua != null ? _ua.UserName : userName; } else { GetArtistProfile(art, vids); } vids.Sort((p1, p2) => p2.PublishDate.CompareTo(p1.PublishDate)); sngrs.AddRange(vids.Select(v1 => new SongRecord(v1))); if (_mu != null && _ua.UserAccountID != Convert.ToInt32(_mu.ProviderUserKey)) { var uc1 = new UserConnection(); uc1.GetUserToUserConnection(_ua.UserAccountID, Convert.ToInt32(_mu.ProviderUserKey)); if (uc1.UserConnectionID > 0) { switch (uc1.StatusType) { case 'C': if (uc1.IsConfirmed) { model.IsCyberFriend = true; } else { model.IsWatingToBeCyberFriend = true; } break; case 'R': if (uc1.IsConfirmed) { model.IsRealFriend = true; } else { model.IsWatingToBeRealFriend = true; } break; default: model.IsDeniedCyberFriend = true; model.IsDeniedRealFriend = true; break; } } } if (sngrs.Count == 0 && art.ArtistID == 0 && _ua.UserAccountID == 0) { // no longer exists Response.RedirectPermanent("/"); return new EmptyResult(); } var sngDisplay = new SongRecords(); sngDisplay.AddRange(from sr1 in sngrs let vidToShow = new Video(sr1.VideoID) where vidToShow.IsEnabled select sr1); model.SongRecords = sngDisplay.VideosList(); return View(model); }
public ActionResult Home(string message, HttpPostedFileBase file) { if (string.IsNullOrWhiteSpace(message) && file == null) { return RedirectToAction("Home"); } if (message != null) message = message.Trim(); if (_mu != null) _ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey)); if (_ua.UserAccountID == 18136) { // check if over posting user can take a hint to stop var lastUpdate = new StatusUpdate(); lastUpdate.GetMostRecentUserStatus(_ua.UserAccountID); if (lastUpdate.CreateDate > DateTime.UtcNow.AddHours(-24)) { TempData["user_error"] = "Please STOP posting so much, you are only allowed to post once ever 24 hours! Thank you for keeping the wall clean."; return RedirectToAction("Home"); } } ViewBag.CurrentUser = _ua.ToUnorderdListItem; var su = new StatusUpdate(); su.GetMostRecentUserStatus(_ua.UserAccountID); DateTime startTime = DateTime.UtcNow; TimeSpan span = startTime.Subtract(su.CreateDate); // TODO: this is not working properly, preventing posts if (su.Message == message && file == null) { // double post return RedirectToAction("Home"); } su = new StatusUpdate(); if (file != null && Utilities.IsImageFile(file.FileName)) { var b = new Bitmap(file.InputStream); const CannedAcl acl = CannedAcl.PublicRead; var s3 = new S3Service { AccessKeyID = AmazonCloudConfigs.AmazonAccessKey, SecretAccessKey = AmazonCloudConfigs.AmazonSecretKey }; var pitem = new PhotoItem {CreatedByUserID = _ua.UserAccountID, Title = message}; Image fullPhoto = b; string fileNameFull = Utilities.CreateUniqueContentFilename(file); Stream maker = fullPhoto.ToAStream(ImageFormat.Jpeg); s3.AddObject( maker, maker.Length, AmazonCloudConfigs.AmazonBucketName, fileNameFull, file.ContentType, acl); pitem.FilePathRaw = fileNameFull; // resized Image photoResized = b; string fileNameResize = Utilities.CreateUniqueContentFilename(file); photoResized = ImageResize.FixedSize(photoResized, 500, 375, Color.Black); maker = photoResized.ToAStream(ImageFormat.Jpeg); s3.AddObject( maker, maker.Length, AmazonCloudConfigs.AmazonBucketName, fileNameResize, file.ContentType, acl); pitem.FilePathStandard = fileNameResize; // thumb Image thumbPhoto = b; thumbPhoto = ImageResize.Crop(thumbPhoto, 150, 150, ImageResize.AnchorPosition.Center); string fileNameThumb = Utilities.CreateUniqueContentFilename(file); maker = thumbPhoto.ToAStream(ImageFormat.Jpeg); s3.AddObject( maker, maker.Length, AmazonCloudConfigs.AmazonBucketName, fileNameThumb, file.ContentType, acl); pitem.FilePathThumb = fileNameThumb; pitem.Create(); su.PhotoItemID = pitem.PhotoItemID; } su.UserAccountID = _ua.UserAccountID; su.Message = message; su.CreatedByUserID = _ua.UserAccountID; su.IsMobile = Request.Browser.IsMobileDevice; su.Create(); if (Request.Browser.IsMobileDevice) { return new RedirectResult(Url.Action("Home") + "#most_recent"); } return RedirectToAction("Home"); }
public void ProcessRequest(HttpContext context) { if (string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.param_type.ToString()])) return; var ptyc = (SiteEnums.QueryStringNames) Enum.Parse(typeof (SiteEnums.QueryStringNames), context.Request.QueryString[SiteEnums.QueryStringNames.param_type.ToString()]); MembershipUser mu; switch (ptyc) { case SiteEnums.QueryStringNames.status_update: #region status_update string key = context.Request.QueryString[SiteEnums.QueryStringNames.status_update_id.ToString()]; if (string.IsNullOrEmpty(key)) { key = context.Request.QueryString[ SiteEnums.QueryStringNames.most_applauded_status_update_id.ToString()]; } int statusUpdateID = Convert.ToInt32(key); StatusUpdate statup; if ( !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_rsp.ToString()])) { mu = MembershipWrapper.GetUser(); if (mu == null) return; var ack = new Acknowledgement { CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey), UserAccountID = Convert.ToInt32(mu.ProviderUserKey), AcknowledgementType = Convert.ToChar( context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_rsp.ToString()]), StatusUpdateID = statusUpdateID }; statup = new StatusUpdate(statusUpdateID); if (!Acknowledgement.IsUserAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey))) { ack.Create(); var sun = new StatusUpdateNotification(); if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString())) { sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.A); } if (Convert.ToInt32(mu.ProviderUserKey) != statup.UserAccountID) { sun.UserAccountID = statup.UserAccountID; SiteEnums.ResponseType rspType; if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString())) { rspType = SiteEnums.ResponseType.A; sun.ResponseType = Convert.ToChar(rspType.ToString()); } else { rspType = SiteEnums.ResponseType.B; sun.ResponseType = Convert.ToChar(rspType.ToString()); } sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); if (sun.StatusUpdateNotificationID == 0) { sun.IsRead = false; sun.Create(); } else { sun.IsRead = false; sun.Update(); } SendNotificationEmail(statup.UserAccountID, Convert.ToInt32(mu.ProviderUserKey), rspType, sun.StatusUpdateID); } context.Response.Write(string.Format(@"{{""StatusAcks"": ""{0}""}}", HttpUtility.HtmlEncode(statup.StatusAcknowledgements))); } else { // reverse ack.GetAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey)); ack.Delete(); // TODO: DELETE NOTIFICATION context.Response.Write(string.Format(@"{{""StatusAcks"": ""{0}""}}", HttpUtility.HtmlEncode(statup.StatusAcknowledgements))); } } else if ( !string.IsNullOrEmpty( context.Request.QueryString[ SiteEnums.QueryStringNames.stat_update_comment_rsp.ToString()])) { mu = MembershipWrapper.GetUser(); if (mu == null) return; var ack = new StatusCommentAcknowledgement { CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey), UserAccountID = Convert.ToInt32(mu.ProviderUserKey), AcknowledgementType = Convert.ToChar( context.Request.QueryString[ SiteEnums.QueryStringNames.stat_update_comment_rsp.ToString()]), StatusCommentID = statusUpdateID }; var statcomup = new StatusComment(statusUpdateID); statup = new StatusUpdate(statcomup.StatusUpdateID); if (!StatusCommentAcknowledgement.IsUserCommentAcknowledgement(statcomup.StatusCommentID, Convert.ToInt32( mu.ProviderUserKey))) { ack.Create(); var sun = new StatusUpdateNotification(); sun.GetStatusUpdateNotificationForUserStatus(statcomup.UserAccountID, statcomup.StatusUpdateID, ack.AcknowledgementType == Convert.ToChar( SiteEnums.ResponseType.A.ToString()) ? SiteEnums.ResponseType.A : SiteEnums.ResponseType.B); if (Convert.ToInt32(mu.ProviderUserKey) != statcomup.UserAccountID) { sun.UserAccountID = statcomup.UserAccountID; SiteEnums.ResponseType rspType; if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString())) { rspType = SiteEnums.ResponseType.A; sun.ResponseType = Convert.ToChar(rspType.ToString()); } else { rspType = SiteEnums.ResponseType.B; sun.ResponseType = Convert.ToChar(rspType.ToString()); } if (sun.StatusUpdateNotificationID == 0) { sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.IsRead = false; sun.Create(); } else { sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.IsRead = false; sun.Update(); } SendNotificationEmail(statup.UserAccountID, Convert.ToInt32(mu.ProviderUserKey), rspType, sun.StatusUpdateID); } context.Response.Write(string.Format(@"{{""StatusAcks"": ""{0}""}}", HttpUtility.HtmlEncode( statcomup.StatusCommentAcknowledgementsOptions))); } else { // reverse ack.GetCommentAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey)); ack.Delete(); // TODO: DELETE NOTIFICATION context.Response.Write(string.Format(@"{{""StatusAcks"": ""{0}""}}", HttpUtility.HtmlEncode( statcomup.StatusCommentAcknowledgementsOptions))); } } else if ( !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]) && !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]) ) { mu = MembershipWrapper.GetUser(); if (mu == null) return; var statCom = new StatusComment { CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey), Message = HttpUtility.HtmlEncode( context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]), StatusUpdateID = statusUpdateID, UserAccountID = Convert.ToInt32(mu.ProviderUserKey) }; // TODO: CHECK IF THERE IS A RECENT MESSAGE THAT IS THE SAME if (statCom.StatusCommentID != 0) return; //BUG: THERE IS AN EVENT HANDLER THAT HAS QUEUED UP TOO MANY var suLast = new StatusUpdate(); suLast.GetMostRecentUserStatus(Convert.ToInt32(mu.ProviderUserKey)); if (suLast.Message.Trim() != statCom.Message.Trim() || (suLast.Message.Trim() == statCom.Message.Trim() && suLast.StatusUpdateID != statCom.StatusUpdateID)) { statCom.Create(); } statup = new StatusUpdate(statusUpdateID); // create a status update notification for the post maker and all commenters StatusUpdateNotification sun; if (Convert.ToInt32(mu.ProviderUserKey) != statup.UserAccountID) { sun = new StatusUpdateNotification(); sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.C); if (sun.StatusUpdateNotificationID == 0) { sun.ResponseType = Convert.ToChar(SiteEnums.ResponseType.C.ToString()); sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.IsRead = false; sun.StatusUpdateID = statup.StatusUpdateID; sun.UserAccountID = statup.UserAccountID; sun.Create(); } else { sun.IsRead = false; sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.Update(); } SendNotificationEmail(statup.UserAccountID, Convert.ToInt32(mu.ProviderUserKey), SiteEnums.ResponseType.C, sun.StatusUpdateID); } var statComs = new StatusComments(); statComs.GetAllStatusCommentsForUpdate(statusUpdateID); foreach (StatusComment sc1 in statComs) { sun = new StatusUpdateNotification(); sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.C); if (Convert.ToInt32(mu.ProviderUserKey) == sc1.UserAccountID || Convert.ToInt32(mu.ProviderUserKey) == statup.UserAccountID) continue; if (sun.StatusUpdateNotificationID == 0) { sun.IsRead = false; sun.StatusUpdateID = statusUpdateID; sun.UserAccountID = sc1.UserAccountID; sun.Create(); } else { sun.IsRead = false; sun.Update(); } } context.Response.Write(@"{""StatusAcks"": """ + @"""}"); } else if ( !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()]) && context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()] == "P" ) { // delete post statup = new StatusUpdate(statusUpdateID); StatusUpdateNotifications.DeleteNotificationsForStatusUpdate(statup.StatusUpdateID); Acknowledgements.DeleteStatusAcknowledgements(statup.StatusUpdateID); var statComs = new StatusComments(); statComs.GetAllStatusCommentsForUpdate(statup.StatusUpdateID); foreach (StatusComment sc1 in statComs) { StatusCommentAcknowledgements.DeleteStatusCommentAcknowledgements( sc1.StatusCommentID); } StatusComments.DeleteStatusComments(statup.StatusUpdateID); statup.Delete(); if (statup.PhotoItemID != null) { var pitm = new PhotoItem(Convert.ToInt32(statup.PhotoItemID)); var s3 = new S3Service { AccessKeyID = AmazonCloudConfigs.AmazonAccessKey, SecretAccessKey = AmazonCloudConfigs.AmazonSecretKey }; if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathRaw)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathRaw); } if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathStandard)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathStandard); } if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathThumb)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathThumb); } pitm.Delete(); } context.Response.Write(@"{""StatusAcks"": """ + @"""}"); } else if ( !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()]) && context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()] == "C" ) { // delete comment var statCom = new StatusComment( Convert.ToInt32( context.Request.QueryString[ SiteEnums.QueryStringNames.status_com_id.ToString()])); StatusCommentAcknowledgements.DeleteStatusCommentAcknowledgements( statCom.StatusCommentID); statCom.Delete(); context.Response.Write(string.Format(@"{{""StatusUpdateID"": ""{0}""}}", statCom.StatusUpdateID)); } else if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.all_comments.ToString()])) { mu = MembershipWrapper.GetUser(); if (mu == null) return; var preFilter = new StatusComments(); preFilter.GetAllStatusCommentsForUpdate(statusUpdateID); var statComs = new StatusComments(); statComs.AddRange( preFilter.Where( su1 => !BlockedUser.IsBlockingUser(Convert.ToInt32(mu.ProviderUserKey), su1.UserAccountID))); statComs.IncludeStartAndEndTags = true; var sb = new StringBuilder(100); sb.Append(statComs.ToUnorderdList); context.Response.Write(string.Format(@"{{""StatusComs"": ""{0}""}}", HttpUtility.HtmlEncode(sb.ToString()))); } else if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.comment_page.ToString()])) { int pcount = Convert.ToInt32( context.Request.QueryString[ SiteEnums.QueryStringNames.comment_page.ToString()]); var statups = new StatusUpdates(); pcount = pcount + 10; var preFilter = new StatusUpdates(); preFilter.GetStatusUpdatesPageWise(pcount, 1); mu = MembershipWrapper.GetUser(); statups.AddRange( preFilter.Where( su1 => mu != null && !BlockedUser.IsBlockingUser(Convert.ToInt32(mu.ProviderUserKey), su1.UserAccountID))); statups.IncludeStartAndEndTags = false; context.Response.Write(string.Format(@"{{""StatusUpdates"": ""{0}""}}", HttpUtility.HtmlEncode(statups.ToUnorderdList))); } #endregion break; case SiteEnums.QueryStringNames.begin_playlist: #region begin_playlist context.Response.Write( PlaylistVideo.GetFirstVideo(Convert.ToInt32(context.Request.QueryString[ SiteEnums.QueryStringNames.playlist.ToString()]))); #endregion break; case SiteEnums.QueryStringNames.menu: #region menu mu = MembershipWrapper.GetUser(); int userCountChat = 0; int userMessages = 0; int unconfirmedUsers = 0; int notifications = 0; if (mu != null) { // log off users who are offline var uasOffline = new UserAccounts(); uasOffline.GetWhoIsOffline(true); foreach (UserAccount uaoff1 in uasOffline) { var cru = new ChatRoomUser(); cru.GetChatRoomUserByUserAccountID(uaoff1.UserAccountID); if (cru.ChatRoomUserID > 0) { cru.DeleteChatRoomUser(); } var offlineUser = new UserAccount(uaoff1.UserAccountID); offlineUser.RemoveCache(); } userCountChat = ChatRoomUsers.GetChattingUserCount(); userMessages = DirectMessages.GetDirectMessagesToUserCount(mu); unconfirmedUsers = UserConnections.GetCountUnconfirmedConnections(Convert.ToInt32(mu.ProviderUserKey)); } // get users online int onlineUsers = UserAccounts.GetOnlineUserCount(); if (mu != null) { notifications = StatusUpdateNotifications.GetStatusUpdateNotificationCountForUser( Convert.ToInt32(mu.ProviderUserKey)); } string timedMessge = string.Format( @"{{""UserCountChat"": ""{0}"", ""UserMessages"": ""{1}"", ""OnlineUsers"": ""{2}"", ""Notifications"": ""{3}"", ""UnconfirmedUsers"": ""{4}""}}", userCountChat, userMessages, onlineUsers, notifications, unconfirmedUsers); context.Response.Write(timedMessge); #endregion break; case SiteEnums.QueryStringNames.random: #region random if ( !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])) { context.Response.Write(Video.GetRandomJSON( context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])); } else { context.Response.Write(Video.GetRandomJSON()); } #endregion break; case SiteEnums.QueryStringNames.video_playlist: #region video_playlist if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])) { context.Response.Write( PlaylistVideo.GetNextVideo( Convert.ToInt32( context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]), context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])); } else if ( !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.begin_playlist.ToString()])) { context.Response.Write( PlaylistVideo.GetFirstVideo( Convert.ToInt32( context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]))); } else { context.Response.Write( PlaylistVideo.CurrentVideoInPlaylist( Convert.ToInt32( context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]) )); } #endregion break; case SiteEnums.QueryStringNames.video: #region video var vid = new Video("YT", context.Request.QueryString[SiteEnums.QueryStringNames.vid.ToString()]); VideoLog.AddVideoLog(vid.VideoID, context.Request.UserHostAddress); context.Response.Write( Video.GetVideoJSON(context.Request.QueryString[SiteEnums.QueryStringNames.vid.ToString()])); #endregion break; case SiteEnums.QueryStringNames.playlist: #region playlist if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])) { context.Response.Write( PlaylistVideo.GetNextVideo( Convert.ToInt32( context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]), context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])); } else if ( !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.begin_playlist.ToString()])) { context.Response.Write( PlaylistVideo.GetFirstVideo( Convert.ToInt32( context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]))); } else { context.Response.Write( PlaylistVideo.CurrentVideoInPlaylist( Convert.ToInt32( context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]) )); } #endregion break; } }
public void ProcessRequest(HttpContext context) { // context.Response.ContentType = "text/plain"; // context.Response.CacheControl = "no-cache"; // context.Response.AddHeader("Pragma", "no-cache"); // //context.Response.AddHeader("Pragma", "no-store"); // //context.Response.AddHeader("cache-control", "no-cache"); //context.Response.Cache.SetCacheability(HttpCacheability.NoCache); // context.Response.Cache.SetNoServerCaching(); if (string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.param_type.ToString()])) return; SiteEnums.QueryStringNames ptyc = (SiteEnums.QueryStringNames)Enum.Parse(typeof(SiteEnums.QueryStringNames), context.Request.QueryString[SiteEnums.QueryStringNames.param_type.ToString()]); // Dictionary<string, Subgurim.Chat.Usuario> usrrs = null; StringBuilder sb = null; MembershipUser mu = null; switch (ptyc) { case SiteEnums.QueryStringNames.status_update: #region status_update string key = context.Request.QueryString[SiteEnums.QueryStringNames.status_update_id.ToString()]; if (string.IsNullOrEmpty(key)) { key = context.Request.QueryString[SiteEnums.QueryStringNames.most_applauded_status_update_id.ToString()]; } int statusUpdateID = Convert.ToInt32(key); StatusUpdate statup = null; if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_rsp.ToString()])) { mu = Membership.GetUser(); Acknowledgement ack = new Acknowledgement(); ack.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); ack.UserAccountID = Convert.ToInt32(mu.ProviderUserKey); ack.AcknowledgementType = Convert.ToChar(context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_rsp.ToString()]); ack.StatusUpdateID = statusUpdateID; statup = new StatusUpdate(statusUpdateID); if (!Acknowledgement.IsUserAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey))) { ack.Create(); StatusUpdateNotification sun = new StatusUpdateNotification(); if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString())) { // sun.GetStatusUpdateNotificationForUserStatus(Convert.ToInt32(mu.ProviderUserKey), statusUpdateID, SiteEnums.ResponseType.A); sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.A); } else if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.B.ToString())) { //sun.GetStatusUpdateNotificationForUserStatus(Convert.ToInt32(mu.ProviderUserKey), statusUpdateID, SiteEnums.ResponseType.B); sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.B); } if (Convert.ToInt32(mu.ProviderUserKey) != statup.UserAccountID) { sun.UserAccountID = statup.UserAccountID; SiteEnums.ResponseType rspType = SiteEnums.ResponseType.U; if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString())) { rspType = SiteEnums.ResponseType.A; sun.ResponseType = Convert.ToChar(rspType.ToString()); } else { rspType = SiteEnums.ResponseType.B; sun.ResponseType = Convert.ToChar(rspType.ToString()); } sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); if (sun.StatusUpdateNotificationID == 0) { sun.IsRead = false; sun.Create(); } else { sun.IsRead = false; sun.Update(); } SendNotificationEmail(statup.UserAccountID, rspType, sun.StatusUpdateID); } context.Response.Write(@"{""StatusAcks"": """ + HttpUtility.HtmlEncode(statup.StatusAcknowledgements) + @"""}"); } else { // reverse ack.GetAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey)); ack.Delete(); // TODO: DELETE NOTIFICATION context.Response.Write(@"{""StatusAcks"": """ + HttpUtility.HtmlEncode(statup.StatusAcknowledgements) + @"""}"); } } else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_comment_rsp.ToString()])) { mu = Membership.GetUser(); StatusCommentAcknowledgement ack = new StatusCommentAcknowledgement(); ack.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); ack.UserAccountID = Convert.ToInt32(mu.ProviderUserKey); ack.AcknowledgementType = Convert.ToChar(context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_comment_rsp.ToString()]); ack.StatusCommentID = statusUpdateID; // this is really the commentID (or should be) StatusComment statcomup = new StatusComment(statusUpdateID); statup = new StatusUpdate(statcomup.StatusUpdateID); if (!StatusCommentAcknowledgement.IsUserCommentAcknowledgement(statcomup.StatusCommentID, Convert.ToInt32(mu.ProviderUserKey))) { ack.Create(); StatusUpdateNotification sun = new StatusUpdateNotification(); if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString())) { sun.GetStatusUpdateNotificationForUserStatus(statcomup.UserAccountID, statcomup.StatusUpdateID, SiteEnums.ResponseType.A); } else { sun.GetStatusUpdateNotificationForUserStatus(statcomup.UserAccountID, statcomup.StatusUpdateID, SiteEnums.ResponseType.B); } if (Convert.ToInt32(mu.ProviderUserKey) != statcomup.UserAccountID) { sun.UserAccountID = statcomup.UserAccountID; SiteEnums.ResponseType rspType = SiteEnums.ResponseType.U; if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString())) { rspType = SiteEnums.ResponseType.A; sun.ResponseType = Convert.ToChar(rspType.ToString()); } else { rspType = SiteEnums.ResponseType.B; sun.ResponseType = Convert.ToChar(rspType.ToString()); } if (sun.StatusUpdateNotificationID == 0) { sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.IsRead = false; sun.Create(); } else { sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.IsRead = false; sun.Update(); } SendNotificationEmail(statup.UserAccountID, rspType, sun.StatusUpdateID); } context.Response.Write(@"{""StatusAcks"": """ + HttpUtility.HtmlEncode(statcomup.StatusCommentAcknowledgementsOptions) + @"""}"); } else { // reverse ack.GetCommentAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey)); ack.Delete(); // TODO: DELETE NOTIFICATION context.Response.Write(@"{""StatusAcks"": """ + HttpUtility.HtmlEncode(statcomup.StatusCommentAcknowledgementsOptions) + @"""}"); } } else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]) && !string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]) ) { mu = Membership.GetUser(); if (mu == null) return; StatusComment statCom = new StatusComment(); statCom.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); statCom.Message = HttpUtility.HtmlEncode(context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]); statCom.StatusUpdateID = statusUpdateID; statCom.UserAccountID = Convert.ToInt32(mu.ProviderUserKey); //statCom.GetStatusCommentMessage(); // ? ignore this duplicate now // TODO: CHECK IF THERE IS A RECENT MESSAGE THAT IS THE SAME if (statCom.StatusCommentID == 0) { //BUG: THERE IS AN EVENT HANDLER THAT HAS QUEUED UP TOO MANY StatusUpdate suLast = new StatusUpdate(); suLast.GetMostRecentUserStatus(Convert.ToInt32(mu.ProviderUserKey)); if (suLast.Message.Trim() != statCom.Message.Trim() || (suLast.Message.Trim() == statCom.Message.Trim() && suLast.StatusUpdateID != statCom.StatusUpdateID)) { statCom.Create(); } statup = new StatusUpdate(statusUpdateID); // create a status update notification for the post maker and all commenters StatusUpdateNotification sun = null; if (Convert.ToInt32(mu.ProviderUserKey) != statup.UserAccountID) { sun = new StatusUpdateNotification(); sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.C); if (sun.StatusUpdateNotificationID == 0) { sun.ResponseType = Convert.ToChar(SiteEnums.ResponseType.C.ToString()); sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.IsRead = false; sun.StatusUpdateID = statup.StatusUpdateID; sun.UserAccountID = statup.UserAccountID; sun.Create(); } else { sun.IsRead = false; sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.Update(); } SendNotificationEmail(statup.UserAccountID, SiteEnums.ResponseType.C, sun.StatusUpdateID); } StatusComments statComs = new StatusComments(); statComs.GetAllStatusCommentsForUpdate(statusUpdateID); foreach (StatusComment sc1 in statComs) { sun = new StatusUpdateNotification(); sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.C); if (Convert.ToInt32(mu.ProviderUserKey) == sc1.UserAccountID || Convert.ToInt32(mu.ProviderUserKey) == statup.UserAccountID) continue; if (sun.StatusUpdateNotificationID == 0) { sun.IsRead = false; sun.StatusUpdateID = statusUpdateID; sun.UserAccountID = sc1.UserAccountID; sun.Create(); } else { sun.IsRead = false; sun.Update(); } } context.Response.Write(@"{""StatusAcks"": """ + @"""}"); } } else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()]) && context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()] == "P" ) { // delete post statup = new StatusUpdate(statusUpdateID); StatusUpdateNotifications.DeleteNotificationsForStatusUpdate(statup.StatusUpdateID); Acknowledgements.DeleteStatusAcknowledgements(statup.StatusUpdateID); StatusComments statComs = new StatusComments(); statComs.GetAllStatusCommentsForUpdate(statup.StatusUpdateID); foreach (StatusComment sc1 in statComs) { StatusCommentAcknowledgements.DeleteStatusCommentAcknowledgements(sc1.StatusCommentID); } StatusComments.DeleteStatusComments(statup.StatusUpdateID); statup.Delete(); if (statup.PhotoItemID != null) { PhotoItem pitm = new PhotoItem(Convert.ToInt32(statup.PhotoItemID)); S3Service s3 = new S3Service(); s3.AccessKeyID = AmazonCloudConfigs.AmazonAccessKey; s3.SecretAccessKey = AmazonCloudConfigs.AmazonSecretKey; if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathRaw)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathRaw); } if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathStandard)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathStandard); } if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathThumb)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathThumb); } pitm.Delete(); } context.Response.Write(@"{""StatusAcks"": """ + @"""}"); } else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()]) && context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()] == "C" ) { // delete comment StatusComment statCom = new StatusComment( Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.status_com_id.ToString()])); StatusCommentAcknowledgements.DeleteStatusCommentAcknowledgements(statCom.StatusCommentID); statCom.Delete(); context.Response.Write(@"{""StatusUpdateID"": """ + statCom.StatusUpdateID.ToString() + @"""}"); } else if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.all_comments.ToString()])) { mu = Membership.GetUser(); if (mu == null) return; StatusComments preFilter = new StatusComments(); preFilter.GetAllStatusCommentsForUpdate(statusUpdateID); StatusComments statComs = new StatusComments(); foreach (BootBaronLib.AppSpec.DasKlub.BOL.StatusComment su1 in preFilter) { if (!BootBaronLib.AppSpec.DasKlub.BOL.BlockedUser.IsBlockingUser(Convert.ToInt32(mu.ProviderUserKey), su1.UserAccountID)) { statComs.Add(su1); } } statComs.IncludeStartAndEndTags = true; sb = new StringBuilder(100); sb.Append(statComs.ToUnorderdList); context.Response.Write(@"{""StatusComs"": """ + HttpUtility.HtmlEncode(sb.ToString()) + @"""}"); } else if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.comment_page.ToString()])) { int pcount = Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.comment_page.ToString()]); StatusUpdates statups = new StatusUpdates(); pcount = pcount + 10; StatusUpdates preFilter = new StatusUpdates(); preFilter.GetStatusUpdatesPageWise(pcount, 1); StatusUpdates sus = new StatusUpdates(); mu = Membership.GetUser(); foreach (BootBaronLib.AppSpec.DasKlub.BOL.StatusUpdate su1 in preFilter) { if (!BootBaronLib.AppSpec.DasKlub.BOL.BlockedUser.IsBlockingUser(Convert.ToInt32(mu.ProviderUserKey), su1.UserAccountID)) { statups.Add(su1); } } statups.IncludeStartAndEndTags = false; context.Response.Write(@"{""StatusUpdates"": """ + HttpUtility.HtmlEncode(statups.ToUnorderdList) + @"""}"); } #endregion break; case SiteEnums.QueryStringNames.begin_playlist: #region begin_playlist context.Response.Write( PlaylistVideo.GetFirstVideo(Convert.ToInt32(context.Request.QueryString[ SiteEnums.QueryStringNames.playlist.ToString()]))); #endregion break; case SiteEnums.QueryStringNames.menu: #region menu mu = Membership.GetUser(); // menu updates // get count in video room int userCountChat = 0; // get new mail int userMessages = 0; // get new users int unconfirmedUsers = 0; // status notifications int notifications = 0; if (mu != null) { // log off users who are offline UserAccounts uasOffline = new UserAccounts(); uasOffline.GetWhoIsOffline(true); UserAccount offlineUser = null; foreach (UserAccount uaoff1 in uasOffline) { ChatRoomUser cru = new ChatRoomUser(); cru.GetChatRoomUserByUserAccountID(uaoff1.UserAccountID); if (cru.ChatRoomUserID > 0) { cru.DeleteChatRoomUser(); } offlineUser = new UserAccount(uaoff1.UserAccountID); offlineUser.RemoveCache(); } userCountChat = ChatRoomUsers.GetChattingUserCount(); userMessages = BootBaronLib.AppSpec.DasKlub.BOL.DirectMessages.GetDirectMessagesToUserCount(mu); unconfirmedUsers = BootBaronLib.AppSpec.DasKlub.BOL.UserConnections.GetCountUnconfirmedConnections(Convert.ToInt32(mu.ProviderUserKey)); } // get users online int onlineUsers = UserAccounts.GetOnlineUserCount(); if (mu != null) { notifications = StatusUpdateNotifications.GetStatusUpdateNotificationCountForUser(Convert.ToInt32(mu.ProviderUserKey)); } string timedMessge = string.Format( @"{{""UserCountChat"": ""{0}"", ""UserMessages"": ""{1}"", ""OnlineUsers"": ""{2}"", ""Notifications"": ""{3}"", ""UnconfirmedUsers"": ""{4}""}}",userCountChat,userMessages,onlineUsers,notifications,unconfirmedUsers); context.Response.Write(timedMessge); #endregion break; case SiteEnums.QueryStringNames.random: #region random if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])) { context.Response.Write(Video.GetRandomJSON( context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])); } else { context.Response.Write(Video.GetRandomJSON()); } #endregion break; case SiteEnums.QueryStringNames.video_playlist: #region video_playlist if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])) { context.Response.Write( PlaylistVideo.GetNextVideo(Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]), context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])); } else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.begin_playlist.ToString()])) { context.Response.Write( PlaylistVideo.GetFirstVideo(Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]))); } else { context.Response.Write( PlaylistVideo.CurrentVideoInPlaylist( Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]) )); } #endregion break; case SiteEnums.QueryStringNames.video: #region video Video vid = new Video("YT", context.Request.QueryString[SiteEnums.QueryStringNames.vid.ToString()]); VideoLog.AddVideoLog(vid.VideoID, context.Request.UserHostAddress); context.Response.Write(Video.GetVideoJSON(context.Request.QueryString[SiteEnums.QueryStringNames.vid.ToString()])); #endregion break; case SiteEnums.QueryStringNames.begindate: #region begindate //string[] dates = HttpUtility.UrlDecode( // context.Request.QueryString[SiteEnums.QueryStringNames.begindate.ToString()] // ).Split('G'); DateTime dtBegin = Convert.ToDateTime(context.Request.QueryString[SiteEnums.QueryStringNames.begindate.ToString()]); dtBegin = new DateTime(dtBegin.Year, dtBegin.Month, 1); DateTime dtEnd = dtBegin.AddMonths(1).AddDays(-1); Events tds = new Events(); tds.GetEventsForLocation( dtBegin, dtEnd, context.Request.QueryString[SiteEnums.QueryStringNames.country_iso.ToString()], context.Request.QueryString[SiteEnums.QueryStringNames.region.ToString()], context.Request.QueryString[SiteEnums.QueryStringNames.city.ToString()]); CalendarItems citms = GetCitms(tds, dtBegin, dtEnd, true); //[ 100, 500, 300, 200, 400 ] sb = new StringBuilder(); sb.Append("["); int processed = 1; foreach (CalendarItem ci1 in citms) { if (processed == citms.Count) { sb.Append(ci1.StartDate.Day); } else { sb.Append(ci1.StartDate.Day); sb.Append(", "); } processed++; } sb.Append("]"); context.Response.Write(sb.ToString()); #endregion break; case SiteEnums.QueryStringNames.playlist: #region playlist if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])) { context.Response.Write( PlaylistVideo.GetNextVideo(Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]), context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])); } else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.begin_playlist.ToString()])) { context.Response.Write( PlaylistVideo.GetFirstVideo(Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]))); } else { context.Response.Write( PlaylistVideo.CurrentVideoInPlaylist( Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]) )); } #endregion break; default: // ? break; } }
public ActionResult ProfileDetail(string userName) { ViewBag.VideoHeight = (Request.Browser.IsMobileDevice) ? 100 : 277; ViewBag.VideoWidth = (Request.Browser.IsMobileDevice) ? 225 : 400; ua = new UserAccount(userName); UserAccountDetail uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(ua.UserAccountID); uad.BandsSeen = ContentLinker.InsertBandLinks(uad.BandsSeen, false); uad.BandsToSee = ContentLinker.InsertBandLinks(uad.BandsToSee, false); MembershipUser mu = Membership.GetUser(); ProfileModel model = new ProfileModel(); if (ua.UserAccountID > 0) { model.UserAccountID = ua.UserAccountID; model.PhotoCount = PhotoItems.GetPhotoItemCountForUser(ua.UserAccountID); model.CreateDate = ua.CreateDate; } if (mu != null) { ViewBag.IsBlocked = BlockedUser.IsBlockedUser(ua.UserAccountID, Convert.ToInt32(mu.ProviderUserKey)); ViewBag.IsBlocking = BlockedUser.IsBlockedUser(Convert.ToInt32(mu.ProviderUserKey), ua.UserAccountID); if (ua.UserAccountID == Convert.ToInt32(mu.ProviderUserKey)) { model.IsViewingSelf = true; } else { UserConnection ucon = new UserConnection(); ucon.GetUserToUserConnection(Convert.ToInt32(mu.ProviderUserKey), ua.UserAccountID); model.UserConnectionID = ucon.UserConnectionID; if (BlockedUser.IsBlockedUser(Convert.ToInt32(mu.ProviderUserKey), ua.UserAccountID)) { return RedirectToAction("index", "home"); } } } else { if (uad.MembersOnlyProfile) { return RedirectToAction("Account", "LogOn"); } } // model.UserName = ua.UserName; model.CreateDate = ua.CreateDate; model.LastActivityDate = ua.LastActivityDate; // model.DisplayAge = uad.DisplayAge; model.Age = uad.YearsOld; model.BandsSeen = uad.BandsSeen; model.BandsToSee = uad.BandsToSee; model.HardwareAndSoftwareSkills = uad.HardwareSoftware; model.MessageToTheWorld = uad.AboutDescription; model.YouAreFull = uad.Sex; model.InterestedInFull = uad.InterestedFull; model.RelationshipStatusFull = uad.RelationshipStatusFull ; model.RelationshipStatus = uad.RelationshipStatus; model.InterestedIn = uad.InterestedIn; model.YouAre = uad.YouAre; model.Website = uad.ExternalURL; model.CountryCode = uad.Country; model.CountryName = uad.CountryName; model.IsBirthday = uad.IsBirthdayToday; model.ProfilePhotoMain = uad.FullProfilePicURL; model.ProfilePhotoMainThumb = uad.FullProfilePicThumbURL; model.DefaultLanguage = uad.DefaultLanguage; model.EnableProfileLogging = uad.EnableProfileLogging; model.Handed = uad.HandedFull; model.RoleIcon = uad.SiteBages; // StatusUpdate su = new StatusUpdate(); su.GetMostRecentUserStatus(ua.UserAccountID); if (su.StatusUpdateID > 0) { model.LastStatusUpdate = su.CreateDate; model.MostRecentStatusUpdate = su.Message; } model.ProfileVisitorCount = ProfileLog.GetUniqueProfileVisitorCount(ua.UserAccountID); PhotoItems ptiems = new PhotoItems(); ptiems.GetUserPhotos(ua.UserAccountID); if (ptiems.Count > 0) { ptiems.Sort((PhotoItem x, PhotoItem y) => (y.CreateDate.CompareTo(x.CreateDate))); PhotoItems ptiemsDisplay = new PhotoItems(); int maxPhotos = 8; foreach (PhotoItem pitm1 in ptiems) { pitm1.UseThumb = true; if (ptiemsDisplay.Count < maxPhotos) { ptiemsDisplay.Add(pitm1); } else break; } ptiemsDisplay.UseThumb = true; ptiemsDisplay.ShowTitle = false; model.HasMoreThanMaxPhotos = (ptiems.Count > maxPhotos); ptiemsDisplay.IsUserPhoto = true; model.PhotoItems = ptiemsDisplay.ToUnorderdList; } Contents conts = new Contents(); conts.GetContentForUser(ua.UserAccountID); model.NewsCount = conts.Count; if (conts.Count > 0) { conts.Sort((Content x, Content y) => (y.ReleaseDate.CompareTo(x.ReleaseDate))); Contents displayContents = new Contents(); int maxCont = 1; int currentCount = 0; foreach (Content ccn1 in conts) { currentCount++; if (maxCont >= currentCount) { displayContents.Add(ccn1); } else break; } displayContents.IncludeStartAndEndTags = false; model.NewsArticles = displayContents.ToUnorderdList; } model.MetaDescription = ua.UserName + " " + BootBaronLib.Resources.Messages.Profile + " " + FromDate.DateToYYYY_MM_DD(ua.LastActivityDate); // playlist BootBaronLib.AppSpec.DasKlub.BOL.Playlist plyst = new Playlist(); plyst.GetUserPlaylist(ua.UserAccountID); if (plyst.PlaylistID > 0 && PlaylistVideos.GetCountOfVideosInPlaylist(plyst.PlaylistID) > 0) { ViewBag.AutoPlay = plyst.AutoPlay; ViewBag.AutoPlayNumber = (plyst.AutoPlay) ? 1 : 0; ViewBag.UserPlaylistID = plyst.PlaylistID; } if (uad.UserAccountID > 0) { model.Birthday = uad.BirthDate; if (uad.ShowOnMapLegal) { byte[] myarray2 = Encoding.Unicode.GetBytes(string.Empty); // because of the foreign cultures, numbers need to stay in the English version unless a javascript encoding could be added string currentLang = Utilities.GetCurrentLanguageCode(); Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString()); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString()); Encoding iso = Encoding.GetEncoding("ISO-8859-1"); Encoding utf8 = Encoding.UTF8; model.DisplayOnMap = uad.ShowOnMapLegal; Random rnd = new Random(); int offset = rnd.Next(10, 100); SiteStructs.LatLong latlong = GeoData.GetLatLongForCountryPostal(uad.Country, uad.PostalCode); if (latlong.latitude != 0 && latlong.longitude != 0) { model.Latitude = Convert.ToDecimal(latlong.latitude + Convert.ToDouble("0.00" + offset)).ToString(); model.Longitude = Convert.ToDecimal(latlong.longitude + Convert.ToDouble("0.00" + offset)).ToString(); } else { model.DisplayOnMap = false; } Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(currentLang); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(currentLang); } ViewBag.ThumbIcon = uad.FullProfilePicThumbURL; LoadCurrentImagesViewBag(uad.UserAccountID); } ViewBag.UserAccountDetail = uad; ViewBag.UserAccount = ua; UserConnections ucons = new UserConnections(); ucons.GetUserConnections(ua.UserAccountID); ucons.Shuffle(); UserAccounts irlContacts = new UserAccounts(); UserAccounts CyberAssociates = new UserAccounts(); UserAccount userCon = null; foreach (UserConnection uc1 in ucons) { if (!uc1.IsConfirmed) continue; switch (uc1.StatusType) { case 'C': if (CyberAssociates.Count >= maxcountusers) continue; if (uc1.ToUserAccountID != ua.UserAccountID) { userCon = new UserAccount(uc1.ToUserAccountID); } else { userCon = new UserAccount(uc1.FromUserAccountID); } CyberAssociates.Add(userCon); break; case 'R': if (irlContacts.Count >= maxcountusers) continue; if (uc1.ToUserAccountID != ua.UserAccountID) { userCon = new UserAccount(uc1.ToUserAccountID); } else { userCon = new UserAccount(uc1.FromUserAccountID); } irlContacts.Add(userCon); break; default: break; } } if (irlContacts.Count > 0) { model.IRLFriendCount = irlContacts.Count; } if (CyberAssociates.Count > 0) { // ViewBag.CyberAssociatesCount = Convert.ToString( CyberAssociates.Count ); model.CyberFriendCount = CyberAssociates.Count; } mu = Membership.GetUser(); UserAccountDetail uadLooker = null; if (mu != null) { uadLooker = new UserAccountDetail(); uadLooker.GetUserAccountDeailForUser(Convert.ToInt32(mu.ProviderUserKey)); } if (mu != null && ua.UserAccountID > 0 && uadLooker.EnableProfileLogging && uad.EnableProfileLogging) { ProfileLog pl = new ProfileLog(); pl.LookedAtUserAccountID = ua.UserAccountID; pl.LookingUserAccountID = Convert.ToInt32(mu.ProviderUserKey); if (pl.LookingUserAccountID != pl.LookedAtUserAccountID) pl.Create(); ArrayList al = ProfileLog.GetRecentProfileViews(ua.UserAccountID); if (al != null && al.Count > 0) { UserAccounts uas = new UserAccounts(); UserAccount viewwer = null; foreach (int ID in al) { viewwer = new UserAccount(ID); if (!viewwer.IsLockedOut && viewwer.IsApproved) { if (uas.Count >= maxcountusers) break; uas.Add(viewwer); } } // model.ViewingUsers = uas.ToUnorderdList; } } UserAccountVideos uavs = null; if (ua.UserAccountID > 0) { uavs = new UserAccountVideos(); uavs.GetRecentUserAccountVideos(ua.UserAccountID, 'F'); if (uavs.Count > 0) { Videos favvids = new Videos(); Video f1 = new Video(); foreach (UserAccountVideo uav1 in uavs) { f1 = new Video(uav1.VideoID); if (f1.IsEnabled) favvids.Add(f1); } SongRecord sng1 = null; SongRecords sngrcds2 = new SongRecords(); foreach (Video v1 in favvids) { sng1 = new SongRecord(v1); sngrcds2.Add(sng1); } sngrcds2.IsUserSelected = true; ViewBag.UserFavorites = sngrcds2.VideosList();//.ListOfVideos(); } } // this is either a youtube user or this is a band Artist art = new Artist( ); art.GetArtistByAltname(userName); if (art.ArtistID > 0) { // try this way for dashers model.UserName = art.Name; } Videos vids = new Videos(); SongRecords sngrs = new SongRecords(); if (art.ArtistID == 0) { vids.GetAllVideosByUser(userName); uavs = new UserAccountVideos(); uavs.GetRecentUserAccountVideos(ua.UserAccountID, 'U'); Video f2 = null; foreach (UserAccountVideo uav1 in uavs) { f2 = new Video(uav1.VideoID); if (!vids.Contains(f2)) vids.Add(f2); } vids.Sort((Video x, Video y) => (y.PublishDate.CompareTo(x.PublishDate))); model.UserName = userName; } else { // photo ArtistProperty aprop = new ArtistProperty(); aprop.GetArtistPropertyForTypeArtist(art.ArtistID, SiteEnums.ArtistPropertyType.PH.ToString()); if (!string.IsNullOrEmpty(aprop.PropertyContent)) { ViewBag.ArtistPhoto = System.Web.VirtualPathUtility.ToAbsolute(aprop.PropertyContent); ViewBag.ThumbIcon = System.Web.VirtualPathUtility.ToAbsolute(aprop.PropertyContent); } // meta descriptione aprop = new ArtistProperty(); aprop.GetArtistPropertyForTypeArtist(art.ArtistID, SiteEnums.ArtistPropertyType.MD.ToString()); if (!string.IsNullOrEmpty(aprop.PropertyContent)) ViewBag.MetaDescription = aprop.PropertyContent; // description aprop = new ArtistProperty(); aprop.GetArtistPropertyForTypeArtist(art.ArtistID, SiteEnums.ArtistPropertyType.LD.ToString()); if (!string.IsNullOrEmpty(aprop.PropertyContent)) ViewBag.ArtistDescription = ContentLinker.InsertBandLinks(aprop.PropertyContent, false); #region rss ///// rss //RssResources rssrs = new RssResources(); //rssrs.GetArtistRssResource(art.ArtistID); //if (rssrs.Count > 0) //{ // RssItems ritems = new RssItems(); // RssItems ritemsOUT = new RssItems(); // foreach (RssResource rssre in rssrs) // { // ritems.GetTopRssItemsForResource(rssre.RssResourceID); // //ritm = new RssItem(rssre..ArtistID); // } // ritems.Sort((RssItem x, RssItem y) => (y.PubDate.CompareTo(x.PubDate))); // foreach (RssItem ritm in ritems) // { // if (ritemsOUT.Count < 10) // { // ritemsOUT.Add(ritm); // } // } // ViewBag.ArtistNews = ritemsOUT.ToUnorderdList; //} //else //{ // ViewBag.ArtistNews = null; //} //ViewBag.DisplayName = art.DisplayName; #endregion Songs sngss = new Songs(); sngss.GetSongsForArtist(art.ArtistID); SongRecord snrcd = new SongRecord(); foreach (Song sn1 in sngss) { vids.GetVideosForSong(sn1.SongID); } } vids.Sort(delegate(Video p1, Video p2) { return p2.PublishDate.CompareTo(p1.PublishDate); }); foreach (BootBaronLib.AppSpec.DasKlub.BOL.Video v1 in vids) { sngrs.Add(new SongRecord(v1)); } if (mu != null && ua.UserAccountID != Convert.ToInt32(mu.ProviderUserKey)) { UserConnection uc1 = new UserConnection(); uc1.GetUserToUserConnection(ua.UserAccountID, Convert.ToInt32(mu.ProviderUserKey)); if (uc1.UserConnectionID > 0) { switch (uc1.StatusType) { case 'C': if (uc1.IsConfirmed) { model.IsCyberFriend = true; } else { model.IsWatingToBeCyberFriend = true; } break; case 'R': if (uc1.IsConfirmed) { model.IsRealFriend = true; } else { model.IsWatingToBeRealFriend = true; } break; default: model.IsDeniedCyberFriend = true; model.IsDeniedRealFriend = true; break; } } } if (sngrs == null || sngrs.Count == 0 && art.ArtistID == 0 && ua.UserAccountID == 0) { // no longer exists Response.RedirectPermanent("/"); return new EmptyResult(); } //sngrs.Sort((SongRecord x, SongRecord y) => (y.cre.CompareTo(x.CreateDate))); SongRecords sngDisplay = new SongRecords(); Video vidToShow = null; foreach (SongRecord sr1 in sngrs) { vidToShow = new Video(sr1.VideoID); if (vidToShow.IsEnabled) { sngDisplay.Add(sr1); } } model.SongRecords = sngDisplay.VideosList(); return View(model); }