コード例 #1
0
        public void Save(AppReview entity)
        {
            List <AppReview> allAppReviews = (List <AppReview>)FindAll();

            allAppReviews.Add(entity);
            SaveAll(allAppReviews);
        }
コード例 #2
0
        public IEnumerable <AppReview> ParseReviews(string response)
        {
            // Building HTML Map
            HtmlDocument map = new HtmlDocument();

            map.LoadHtml(response);

            // Iterating over Review Nodes
            foreach (HtmlNode reviewNode in map.DocumentNode.SelectNodes("//div[contains(@class,'single-review')]"))
            {
                AppReview reviewInstance = new AppReview();

                try
                {
                    // Parsing Reviewer Url ".//a[contains(href,'/people/details')]"
                    reviewInstance.authorUrl = Consts.ORIGIN + reviewNode.SelectSingleNode("./a").Attributes["href"].Value;

                    // Parsing data out of each review node
                    reviewInstance.authorName = reviewNode.SelectSingleNode(".//span[contains(@class,'author-name')]/a").InnerText;

                    // Assembling Full Permalink for review
                    reviewInstance.permalink = String.Concat
                                               (
                        "https://play.google.com",
                        reviewNode.SelectSingleNode(".//a[contains(@class,'permalink')]").Attributes["href"].Value
                        .Replace("\\", String.Empty)
                        .Replace("\"", String.Empty)
                                               );

                    // Normalizing Review Date
                    reviewInstance.reviewDate = DateTime.Parse(reviewNode.SelectSingleNode(".//span[contains(@class,'review-date')]").InnerText);

                    // Applying Star Ratings Logic (based on Width value)
                    string ratingWidth = reviewNode.SelectSingleNode(".//div[contains(@class,'current-rating')]").Attributes["style"].Value;

                    int ratingWidthInt = Int32.Parse(ratingWidth.Replace("%", String.Empty).Replace("width:", String.Empty));

                    // 20% Width = 1, 40% Width = 2 ... 100% Width = 5 stars
                    reviewInstance.starRatings = ratingWidthInt / 20;

                    // Parsing Review Title
                    HtmlNode reviewParentNode = reviewNode.SelectSingleNode(".//div[contains(@class,'review-body')]");
                    reviewInstance.reviewTitle = reviewParentNode.FirstChild.NextSibling.InnerText.Trim();

                    // Removing Review Title Node out of parent node to be able to fetch the review body correctly
                    reviewParentNode.RemoveChild(reviewParentNode.FirstChild);

                    reviewInstance.reviewBody = reviewParentNode.InnerText.Replace("Full Review", String.Empty).Trim();
                }
                catch (Exception ex)// Do not return app review if some exception was thrown
                {
                    string msg = ex.Message;
                    continue;
                }

                yield return(reviewInstance);
            }
        }
コード例 #3
0
 public void AddAppReview(AppReview appReviewToSave)
 {
     appReviewService.AddAppReview(appReviewToSave);
 }
コード例 #4
0
        private void LaunchAppViewLoad(string str)
        {
            #region 小板子的HTML内容获取

            try { AppInfo = ReplaceHtml(Regex.Split(Regex.Split(Regex.Split(str, "应用简介</p>")[1], @"<div class=""apk_left_title_info"">")[1], "</div>")[0].Trim()); } catch (Exception) { }
            try { AppVersionMassage = ReplaceHtml(Regex.Split(Regex.Split(str, @"<p class=""apk_left_title_info"">")[2], "</p>")[0].Replace("<br />", "").Replace("<br/>", "").Trim()); } catch (Exception) { }
            try { AppReview = ReplaceHtml(Regex.Split(Regex.Split(str, @"<p class=""apk_left_title_info"">")[1], "</p>")[0].Replace("<br />", "").Replace("<br/>", "").Trim()); } catch (Exception) { }

            id            = Regex.Split(str, @"onclick=""onDownloadApk")[1].Split('(')[1].Split(')')[0].Trim();
            AppVersion    = Regex.Split(str, @"<p class=""detail_app_title"">")[1].Split('>')[1].Split('<')[0].Trim();
            AppMassage    = Regex.Split(str, @"<p class=""apk_topba_message"">")[1].Split('<')[0].Trim().Replace("\n", "").Replace(" ", "");
            AppName       = Regex.Split(str, @"<p class=""detail_app_title"">")[1].Split('<')[0].Trim();
            AppLogo       = Regex.Split(str, @"<div class=""apk_topbar"">")[1].Split('"')[1].Trim();
            AppUpdateTime = Regex.Split(str, "更新时间:")[1].Split('<')[0].Trim();
            AppScore      = Regex.Split(str, @"<p class=""rank_num"">")[1].Split('<')[0].Trim();
            AppCommendNum = Regex.Split(str, @"<p class=""apk_rank_p1"">")[1].Split('<')[0].Trim();

            //UIHelper.ShowMessage(id);

            //Download URI
            //AppDownloadUrl = Regex.Split(Regex.Split(Regex.Split(str, "function onDownloadApk")[1], "window.location.href")[1], @"""")[1];

            AppIconImage.Source = new BitmapImage(new Uri(AppLogo, UriKind.RelativeOrAbsolute));
            titleBar.Title      = AppTitleText.Text = AppName;
            AppVTText.Text      = AppUpdateTime;
            AppV2Text.Text      = AppVersion;
            AppVText.Text       = AppVersion;
            AppMText.Text       = Regex.Split(AppMassage, "/")[2] + " " + Regex.Split(AppMassage, "/")[3] + " " + AppScore + "分";
            AppXText.Text       = Regex.Split(AppMassage, "/")[1] + " · " + Regex.Split(AppMassage, "/")[0];

            if (Regex.Split(str, @"<p class=""apk_left_title_info"">").Length > 3)
            {
                //当应用有点评
                AppVMText.Text    = AppVersionMassage;
                AppDText.Text     = AppReview;
                DPanel.Visibility = Visibility.Visible;
            }
            else
            {
                //当应用无点评的时候(小编要是一个一个全好好点评我就不用加判断了嘛!)
                AppVMText.Text = AppReview;
                AppDText.Text  = "";
            }
            if (AppReview.Contains("更新时间") && AppReview.Contains("ROM") && AppReview.Contains("名称"))
            {
                UPanel.Visibility = Visibility.Collapsed;
            }


            //加载截图!
            string   images     = Regex.Split(Regex.Split(str, @"<div class=""ex-screenshot-thumb-carousel"">")[1], "</div>")[0];
            string[] imagearray = Regex.Split(images, "<img");
            for (int i = 0; i < imagearray.Length - 1; i++)
            {
                string imageUrl = imagearray[i + 1].Split('"')[1];
                if (!imageUrl.Equals(""))
                {
                    Image newImage = new Image
                    {
                        Height = 100,
                        //获得图片
                        Source = new BitmapImage(new Uri(imageUrl, UriKind.RelativeOrAbsolute))
                    };
                    //添加到缩略视图
                    ScreenShotView.Items.Add(newImage);
                }
            }
            images     = Regex.Split(Regex.Split(str, @"<div class=""carousel-inner"">")[1], @"<a class=""left carousel-control""")[0];
            imagearray = Regex.Split(images, "<img");
            for (int i = 0; i < imagearray.Length - 1; i++)
            {
                string imageurl = imagearray[i + 1].Split('"')[1];
                Image  newImage = new Image
                {
                    //获得图片
                    Source = new BitmapImage(new Uri(imageurl, UriKind.RelativeOrAbsolute))
                };
                //添加到视图
                ScreenShotFlipView.Items.Add(newImage);
            }

            //还有简介(丧心病狂啊)
            AppJText.Text = AppInfo;

            //评分。。
            AppRText.Text = AppScore;
            AppRating.PlaceholderValue = double.Parse(AppScore);
            AppPText.Text = AppCommendNum;


            /*
             * //获取开发者
             * string kAppName = Web.ReplaceHtml(Regex.Split(Regex.Split(str, "开发者名称:")[1], "</p>")[0]);
             * try
             * {
             *  AppKNText.Text = kAppName;
             *  AppKImage.Source = new BitmapImage(new Uri(await CoolApkSDK.GetCoolApkUserFaceUri(kAppName), UriKind.RelativeOrAbsolute));
             * }
             * catch (Exception)
             * {
             *  KPanel.Visibility = Visibility.Collapsed;
             * }*/

            #endregion

            _ = GenerateActivityAsync();
            titleBar.HideProgressRing();
        }
コード例 #5
0
 public void Save(AppReview entity)
 {
     throw new NotImplementedException();
 }
コード例 #6
0
        public void AddAppReview(AppReview appReviewToSave)
        {
            AppReviewFileRepository appRepo = new AppReviewFileRepository();

            appRepo.Save(appReviewToSave);
        }