예제 #1
0
 private static void AddReview(Review r)
 {
     int uId = UpdateUser(r.Username);
     int rId = GetReviewId(r);
     if (rId > 0)
     {
         string update = string.Format(
             @"UPDATE Review
                 SET StarLvl = {1},
                 Content = '{2}',
                 DateTime = '{3}'
             WHERE Id = {0};", rId,
                         r.StarLevel,
                         r.Content,
                         r.PostTime);
         SQLiteAccess.Execute(update);
     }
     else
     {
         string insert = string.Format(
             @"INSERT INTO Review(
                 UserId,
                 MerchantId,
                 StarLvl,
                 Content,
                 DateTime,
                 Remark)
             VALUES(
                 {0},
                 {1},
                 {2},
                 '{3}',
                 '{4}',
                 '{5}');",
                         uId.ToString(),
                         r.MerchantId.ToString(),
                         r.StarLevel,
                         r.Content,
                         r.PostTime,
                         string.Empty);
         SQLiteAccess.Execute(insert);
     }
 }
예제 #2
0
 private Review GetReview(HtmlNode node)
 {
     Review r = new Review();
     r.Username = GetText(GetSingleDescendantNode(node, "dt/cite/a"));
     r.Content = GetText(GetSingleDescendantNode(node, "dd/div"));
     r.StarLevel = GetSingleDescendantNode(node, "dd/ul/li/span[@class]").Attributes["class"].Value;
     r.StarLevel = GetStarLever(r.StarLevel);
     r.PostTime = GetText(GetSingleDescendantNode(node, "dd/ul[2]/li/span[@class='review-date']"));
     r.PostTime = GetTimeString(r.PostTime);
     Console.WriteLine(r.Username);
     Console.WriteLine(r.PostTime);
     Console.WriteLine(r.StarLevel);
     Console.WriteLine(r.Content);
     return r;
 }
예제 #3
0
 private static int GetReviewId(Review r)
 {
     string selectId = string.Format("SELECT Id FROM Review WHERE UserId = {0} AND MerchantId = {1};", GetUserId(r.Username), r.MerchantId);
     object obj = SQLiteAccess.ExecuteScalar(selectId);
     if (obj == null)
     {
         return 0;
     }
     return Convert.ToInt32(obj);
 }