private void SendUserRecentScore() { new Thread(async() => { var users = LatestUpdate.Keys.ToArray(); foreach (string username in users) { try { Score[] UserRecentScores = await OsuApi.GetUserRecent.WithUser(username).Results(); foreach (var recentScore in UserRecentScores.OrderBy(score => score.Date)) { if (!(IsNewScore(recentScore) && recentScore.Rank != Rank.F)) { continue; } UpdateUser(recentScore.Username, recentScore.Date); Beatmap beatmap = (await OsuApi.GetSpecificBeatmap.WithId(recentScore.BeatmapId).Results()).FirstOrDefault(); User user = await OsuApi.GetUser.WithUser(username).Result(); using (var temporaryStream = new MemoryStream()) { ScoreImage.CreateScorePanel(user, recentScore, beatmap).Save(temporaryStream, System.Drawing.Imaging.ImageFormat.Png); temporaryStream.Position = 0; await OsuChannel.SendFileAsync(temporaryStream, "osuScoreImage.png"); } } } catch { } } }).Start(); }
public void generateThumbnail(ScoreImage img) { Uri blobUri = new Uri(img.ImageURL); // get image url string blobName = blobUri.Segments[blobUri.Segments.Length - 1]; // ??? get blobname using image url // use blobname to get thumbnial name, also get input blob and output blob CloudBlockBlob inputBlob = this.imagesBlobContainer.GetBlockBlobReference(blobName); string thumbnailName = Path.GetFileNameWithoutExtension(inputBlob.Name) + "thumb.jpg"; CloudBlockBlob outputBlob = this.imagesBlobContainer.GetBlockBlobReference(thumbnailName); int[] size; using (Stream input = inputBlob.OpenRead()) // transform input/output blobs to streams using (Stream output = outputBlob.OpenWrite()) { size = ConvertImageToThumbnailJPG(input, output); // call a function to get blob containing thumbnail outputBlob.Properties.ContentType = "image/jpeg"; } Trace.TraceInformation("Generated thumbnail in blob {0}", thumbnailName); img.ImageWidth = size[0]; img.ImageHeight = size[1]; img.ThumbnailWidth = size[2]; img.ThumbnailHeight = size[3]; img.ThumbnailURL = outputBlob.Uri.ToString(); // add a item "ThumbnailURL" to advertisement, containing the url of thembnail //db.SaveChanges(); // database do saving }
public async Task <HttpResponseMessage> PostImageTest() { var response = Request.CreateResponse(); string message = "successful."; bool isWrong = false; // Client-provided attributes string wechatid = HttpContext.Current.Request["WechatId"]; string label = HttpContext.Current.Request["Label"]; string score = HttpContext.Current.Request["Score"]; string imageHash; var imageFile = HttpContext.Current.Request.Files.Count > 0 ? HttpContext.Current.Request.Files[0] : null; isWrong = checkInput(wechatid, label, score, imageFile, out message, out imageHash); if (isWrong) { response.StatusCode = HttpStatusCode.Forbidden; response.Content = new StringContent(message); return(response); } ScoreImage img = new ScoreImage(); img.WechatId = wechatid; img.Score = double.Parse(score); img.Label = (Label)int.Parse(label); img.imageHash = imageHash; CloudBlockBlob imageBlob = null; if (ModelState.IsValid) { imageBlob = await UploadAndSaveBlobAsync(imageFile); img.ImageURL = imageBlob.Uri.ToString(); img.PostedDate = DateTime.Now; // generate thumbnail generateThumbnail(img); db.Images.Add(img); await db.SaveChangesAsync(); Trace.TraceInformation("Created ImageId {0} in database", img.ImageId); response.StatusCode = HttpStatusCode.OK; message = "successful."; } else { response.StatusCode = HttpStatusCode.InternalServerError; message = "fail: server error."; } response.Content = new StringContent(message); return(response); }
void ReleaseDesignerOutlets() { if (AddPointsText != null) { AddPointsText.Dispose(); AddPointsText = null; } if (AreaCollection != null) { AreaCollection.Dispose(); AreaCollection = null; } if (AreaCollectionHeight != null) { AreaCollectionHeight.Dispose(); AreaCollectionHeight = null; } if (BkgdImage != null) { BkgdImage.Dispose(); BkgdImage = null; } if (BtnPendingRequest != null) { BtnPendingRequest.Dispose(); BtnPendingRequest = null; } if (CityLabel != null) { CityLabel.Dispose(); CityLabel = null; } if (cnsAreaCollectionTop != null) { cnsAreaCollectionTop.Dispose(); cnsAreaCollectionTop = null; } if (cnsMenuContainerHeight != null) { cnsMenuContainerHeight.Dispose(); cnsMenuContainerHeight = null; } if (ConnectedNetworkText != null) { ConnectedNetworkText.Dispose(); ConnectedNetworkText = null; } if (FacebookConnectedImage != null) { FacebookConnectedImage.Dispose(); FacebookConnectedImage = null; } if (FacebookLabel != null) { FacebookLabel.Dispose(); FacebookLabel = null; } if (FacebookLoginButton != null) { FacebookLoginButton.Dispose(); FacebookLoginButton = null; } if (FriendsCountText != null) { FriendsCountText.Dispose(); FriendsCountText = null; } if (InfoLabel != null) { InfoLabel.Dispose(); InfoLabel = null; } if (InstagramConnectedImage != null) { InstagramConnectedImage.Dispose(); InstagramConnectedImage = null; } if (InstagramLabel != null) { InstagramLabel.Dispose(); InstagramLabel = null; } if (InstaLoginButton != null) { InstaLoginButton.Dispose(); InstaLoginButton = null; } if (MainView != null) { MainView.Dispose(); MainView = null; } if (NameLabel != null) { NameLabel.Dispose(); NameLabel = null; } if (NetworksContainer != null) { NetworksContainer.Dispose(); NetworksContainer = null; } if (PositionLabel != null) { PositionLabel.Dispose(); PositionLabel = null; } if (ProfileImage != null) { ProfileImage.Dispose(); ProfileImage = null; } if (Score != null) { Score.Dispose(); Score = null; } if (ScoreImage != null) { ScoreImage.Dispose(); ScoreImage = null; } if (scrlMainContent != null) { scrlMainContent.Dispose(); scrlMainContent = null; } if (TableView != null) { TableView.Dispose(); TableView = null; } if (TableViewHeight != null) { TableViewHeight.Dispose(); TableViewHeight = null; } if (TwitterConnectedImage != null) { TwitterConnectedImage.Dispose(); TwitterConnectedImage = null; } if (TwitterLabel != null) { TwitterLabel.Dispose(); TwitterLabel = null; } if (TwitterLoginButton != null) { TwitterLoginButton.Dispose(); TwitterLoginButton = null; } if (vMenuTableContainer != null) { vMenuTableContainer.Dispose(); vMenuTableContainer = null; } if (vMenuTableInset != null) { vMenuTableInset.Dispose(); vMenuTableInset = null; } if (vProfileInfoContainer != null) { vProfileInfoContainer.Dispose(); vProfileInfoContainer = null; } }
void ReleaseDesignerOutlets() { if (btnBack != null) { btnBack.Dispose(); btnBack = null; } if (btnDone != null) { btnDone.Dispose(); btnDone = null; } if (cnsVActionBarAlignmentBasisHeight != null) { cnsVActionBarAlignmentBasisHeight.Dispose(); cnsVActionBarAlignmentBasisHeight = null; } if (HandleImage != null) { HandleImage.Dispose(); HandleImage = null; } if (Image != null) { Image.Dispose(); Image = null; } if (NotificationButton != null) { NotificationButton.Dispose(); NotificationButton = null; } if (NotificationButtonImage != null) { NotificationButtonImage.Dispose(); NotificationButtonImage = null; } if (Score != null) { Score.Dispose(); Score = null; } if (ScoreImage != null) { ScoreImage.Dispose(); ScoreImage = null; } if (Title != null) { Title.Dispose(); Title = null; } if (vActionBarAlignmentBasis != null) { vActionBarAlignmentBasis.Dispose(); vActionBarAlignmentBasis = null; } if (vHandleImageLeftBottomBasis != null) { vHandleImageLeftBottomBasis.Dispose(); vHandleImageLeftBottomBasis = null; } if (vLeftBottomBasis != null) { vLeftBottomBasis.Dispose(); vLeftBottomBasis = null; } }
public string PostInstance(ScoreImage img) { return(img.Label.ToString()); }
public async Task <HttpResponseMessage> PostLike() { var response = Request.CreateResponse(); string message = "successful."; response.Content = new StringContent(message); response.StatusCode = HttpStatusCode.OK; string imageIdStr = HttpContext.Current.Request["imageId"]; string visitorWechatId = HttpContext.Current.Request["VisitorWechatId"]; string isToCancelLikeStr = HttpContext.Current.Request["IsToCancelLike"]; if (null == visitorWechatId || "" == visitorWechatId) { message = "visitorWechatId not found or set as null."; response.Content = new StringContent(message); response.StatusCode = HttpStatusCode.Forbidden; return(response); } bool isToCancelLike; int imageId; try { imageId = int.Parse(imageIdStr); isToCancelLike = bool.Parse(isToCancelLikeStr); } catch { message = "IsToCancelLike or imageId has wrong format."; response.Content = new StringContent(message); response.StatusCode = HttpStatusCode.Forbidden; return(response); } var query = await(from like in db.Likes where (like.imageId == imageId && like.wechatId == visitorWechatId) select like).ToListAsync(); if (isToCancelLike) // to cancel like { if (query.Count == 0) { message = "fail: this image is not liked by this user."; response.Content = new StringContent(message); response.StatusCode = HttpStatusCode.Forbidden; return(response); } ScoreImage img = await db.Images.FindAsync(imageId); // like num -- img.LikeNum -= 1; Like toDeleteLike = query[0]; db.Likes.Remove(toDeleteLike); await db.SaveChangesAsync(); } else // to add like { if (query.Count > 0) { message = "fail: this image is already liked by this user."; response.Content = new StringContent(message); response.StatusCode = HttpStatusCode.Forbidden; return(response); } ScoreImage img = await db.Images.FindAsync(imageId); // like num ++ img.LikeNum += 1; Like newLikeItem = new Like(); newLikeItem.imageId = imageId; // insert a item of like newLikeItem.wechatId = visitorWechatId; db.Likes.Add(newLikeItem); await db.SaveChangesAsync(); } return(response); }
void ReleaseDesignerOutlets() { if (BtnPrivacyPolicy != null) { BtnPrivacyPolicy.Dispose(); BtnPrivacyPolicy = null; } if (BtnTermsService != null) { BtnTermsService.Dispose(); BtnTermsService = null; } if (DoneButton != null) { DoneButton.Dispose(); DoneButton = null; } if (DoneButtonStackView != null) { DoneButtonStackView.Dispose(); DoneButtonStackView = null; } if (DoneButtonView != null) { DoneButtonView.Dispose(); DoneButtonView = null; } if (FacebookConnectedImage != null) { FacebookConnectedImage.Dispose(); FacebookConnectedImage = null; } if (FacebookLoginButton != null) { FacebookLoginButton.Dispose(); FacebookLoginButton = null; } if (InstagramConnectedImage != null) { InstagramConnectedImage.Dispose(); InstagramConnectedImage = null; } if (InstagramLoginButton != null) { InstagramLoginButton.Dispose(); InstagramLoginButton = null; } if (LogoutButton != null) { LogoutButton.Dispose(); LogoutButton = null; } if (NextButton != null) { NextButton.Dispose(); NextButton = null; } if (prb_Value != null) { prb_Value.Dispose(); prb_Value = null; } if (ProgressBar != null) { ProgressBar.Dispose(); ProgressBar = null; } if (ProgressBarandNextButtonView != null) { ProgressBarandNextButtonView.Dispose(); ProgressBarandNextButtonView = null; } if (ProgressBarNextButtonStackView != null) { ProgressBarNextButtonStackView.Dispose(); ProgressBarNextButtonStackView = null; } if (ScoreFill != null) { ScoreFill.Dispose(); ScoreFill = null; } if (ScoreImage != null) { ScoreImage.Dispose(); ScoreImage = null; } if (TwitterConnectedImage != null) { TwitterConnectedImage.Dispose(); TwitterConnectedImage = null; } if (TwitterLoginButton != null) { TwitterLoginButton.Dispose(); TwitterLoginButton = null; } }
void ReleaseDesignerOutlets() { if (AreaCollection != null) { AreaCollection.Dispose(); AreaCollection = null; } if (AreaCollectionHeight != null) { AreaCollectionHeight.Dispose(); AreaCollectionHeight = null; } if (BottomTabView != null) { BottomTabView.Dispose(); BottomTabView = null; } if (btnInfo != null) { btnInfo.Dispose(); btnInfo = null; } if (cnBgCenterX != null) { cnBgCenterX.Dispose(); cnBgCenterX = null; } if (cnsAreaCollectionTop != null) { cnsAreaCollectionTop.Dispose(); cnsAreaCollectionTop = null; } if (cnsTableViewHeight != null) { cnsTableViewHeight.Dispose(); cnsTableViewHeight = null; } if (ivBackground != null) { ivBackground.Dispose(); ivBackground = null; } if (ivProfileImage != null) { ivProfileImage.Dispose(); ivProfileImage = null; } if (ivTriangle != null) { ivTriangle.Dispose(); ivTriangle = null; } if (lblScoreGroup != null) { lblScoreGroup.Dispose(); lblScoreGroup = null; } if (LeaderboardButton != null) { LeaderboardButton.Dispose(); LeaderboardButton = null; } if (PointsAndStatsButton != null) { PointsAndStatsButton.Dispose(); PointsAndStatsButton = null; } if (Score != null) { Score.Dispose(); Score = null; } if (ScoreImage != null) { ScoreImage.Dispose(); ScoreImage = null; } if (ScoreView != null) { ScoreView.Dispose(); ScoreView = null; } if (ScrollView != null) { ScrollView.Dispose(); ScrollView = null; } if (TableView != null) { TableView.Dispose(); TableView = null; } if (TransactionsButton != null) { TransactionsButton.Dispose(); TransactionsButton = null; } if (vBgImgOverlay != null) { vBgImgOverlay.Dispose(); vBgImgOverlay = null; } if (vContent != null) { vContent.Dispose(); vContent = null; } if (vContentBackground != null) { vContentBackground.Dispose(); vContentBackground = null; } if (vScoreimageInset != null) { vScoreimageInset.Dispose(); vScoreimageInset = null; } if (vScoreLabelInset != null) { vScoreLabelInset.Dispose(); vScoreLabelInset = null; } if (vScoreViewAlignment != null) { vScoreViewAlignment.Dispose(); vScoreViewAlignment = null; } if (vScoreViewFooterAlignment != null) { vScoreViewFooterAlignment.Dispose(); vScoreViewFooterAlignment = null; } if (vScoreViewSplitter != null) { vScoreViewSplitter.Dispose(); vScoreViewSplitter = null; } if (vTriangleBorder != null) { vTriangleBorder.Dispose(); vTriangleBorder = null; } if (vTriangleBottomAlign != null) { vTriangleBottomAlign.Dispose(); vTriangleBottomAlign = null; } }