コード例 #1
0
ファイル: TourAPI.cs プロジェクト: kswOok/Tour
 public static string get_channel_article_guidance_detail(int id)
 {
     using (var db = new TouristDBEntities())
     {
         var obj = (from t in db.dt_channel_article_guidance
                    where t.id == id
                    select new
         {
             t.id,
             t.title,
             t.img_url,
             t.zhaiyao,
             t.content,
             t.update_time
         }).FirstOrDefault();
         return(Obj2Json(new
         {
             data = new
             {
                 obj.id,
                 obj.title,
                 obj.img_url,
                 obj.zhaiyao,
                 obj.update_time,
                 content = obj.content.Replace("src=\"/upload", "src=\"http://guomengtech.com/upload")
             },
             result = 1
         }));
     }
 }
コード例 #2
0
ファイル: TourAPI.cs プロジェクト: kswOok/Tour
 public static string get_channel_article_food()
 {
     using (var db = new TouristDBEntities())
     {
         return(Obj2Json(new
         {
             data = (from t in db.dt_channel_article_food orderby t.sort_id
                     select new
             {
                 t.id,
                 t.title,
                 t.img_url,
                 t.fuwu,
                 t.youhui,
                 t.youhuiquan,
                 t.zhaiyao,
                 t.calendar,
                 t.is_hot,
                 t.haoshi,
                 t.sub_title,
                 t.source,
                 t.phone_number,
                 t.longitude,
                 t.latitude
             }).ToList(),
             result = 1
         }));
     }
 }
コード例 #3
0
ファイル: TourAPI.cs プロジェクト: kswOok/Tour
 private static string getAccessToken()
 {
     using (var db = new TouristDBEntities())
     {
         var obj = db.dt_wx_token.SingleOrDefault(s => s.appid == APPID && s.type == "access_token");
         if (obj == null)
         {
             obj = new dt_wx_token
             {
                 appid        = APPID,
                 type         = "access_token",
                 refresh_time = DateTime.Now.Subtract(new TimeSpan(3, 0, 0))
             };
             db.dt_wx_token.Add(obj);
         }
         if (DateTime.Now.Subtract(obj.refresh_time.Value).TotalSeconds > 5400)
         {
             var request = (HttpWebRequest)WebRequest.Create(
                 "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" +
                 APPID + "&secret=" + SECRET);
             var response = (HttpWebResponse)request.GetResponse();
             using (var sr = new StreamReader(response.GetResponseStream()))
             {
                 string responseString = sr.ReadToEnd();
                 var    temp           = JsonConvert.DeserializeObject <dynamic>(responseString);
                 obj.value        = temp.access_token;
                 obj.refresh_time = DateTime.Now;
             }
         }
         db.SaveChanges();
         return(obj.value);
     }
 }
コード例 #4
0
ファイル: TourAPI.cs プロジェクト: kswOok/Tour
 public static string get_channel_article_food_detail(int id)
 {
     using (var db = new TouristDBEntities())
     {
         var obj = (from t in db.dt_channel_article_food orderby t.sort_id
                    where t.id == id
                    select new
         {
             t.id,
             t.title,
             t.img_url,
             t.zhaiyao,
             t.content,
             t.update_time,
             t.youhui,
             t.youhuiquan,
             t.fuwu,
             t.calendar,
             t.is_hot,
             t.haoshi,
             t.sub_title,
             t.source,
             t.phone_number,
             t.longitude,
             t.latitude
         }).FirstOrDefault();
         var images = (from t in db.dt_article_albums
                       where t.article_id == id
                       select new
         {
             img_url = t.original_path.Replace("src=\"/upload", "src=\"http://guomengtech.com/upload")
         }).ToList();
         return(Obj2Json(new
         {
             data = new
             {
                 obj.id,
                 obj.title,
                 obj.img_url,
                 obj.zhaiyao,
                 obj.update_time,
                 obj.youhui,
                 obj.youhuiquan,
                 obj.fuwu,
                 obj.calendar,
                 obj.is_hot,
                 obj.haoshi,
                 obj.sub_title,
                 obj.source,
                 obj.phone_number,
                 obj.longitude,
                 obj.latitude,
                 content = obj.content.Replace("src=\"/upload", "src=\"http://guomengtech.com/upload"),
                 images
             },
             result = 1
         }));
     }
 }
コード例 #5
0
ファイル: TourAPI.cs プロジェクト: kswOok/Tour
 public static string get_channel_article_guidance()
 {
     using (var db = new TouristDBEntities())
     {
         return(Obj2Json(new
         {
             data = (from t in db.dt_channel_article_guidance
                     select new
             {
                 t.id,
                 t.title,
                 t.img_url
             }).ToList(),
             result = 1
         }));
     }
 }
コード例 #6
0
ファイル: TourAPI.cs プロジェクト: kswOok/Tour
 public static string get_brand_list()
 {
     using (var db = new TouristDBEntities())
     {
         return(Obj2Json(new
         {
             data = (from t in db.dt_article_category
                     where t.channel_id == 2
                     select new
             {
                 t.id,
                 t.title,
                 t.img_url
             }).ToList(),
             result = 1
         }).Replace("/upload/", "https://guomengtech.com/upload/"));
     }
 }
コード例 #7
0
ファイル: TourAPI.cs プロジェクト: kswOok/Tour
 public static string get_brand_detail(int id)
 {
     using (var db = new TouristDBEntities())
     {
         return(Obj2Json(new
         {
             data = (from t in db.dt_article_category
                     where t.id == id
                     select new
             {
                 t.id,
                 t.title,
                 t.img_url,
                 t.content
             }).FirstOrDefault(),
             result = 1
         }).Replace("/upload/", "https://guomengtech.com/upload/"));
     }
 }
コード例 #8
0
ファイル: TourAPI.cs プロジェクト: kswOok/Tour
 public static string get_channel_article_content()
 {
     using (var db = new TouristDBEntities())
     {
         return(Obj2Json(new
         {
             data = (from t in db.dt_channel_article_content
                     orderby t.sort_id
                     select new
             {
                 t.id,
                 t.title,
                 t.img_url,
                 t.zhaiyao,
                 t.is_hot,
                 t.content
             }).ToList(),
             result = 1
         }));
     }
 }
コード例 #9
0
ファイル: TourAPI.cs プロジェクト: kswOok/Tour
 public static string get_channel_article_content_detail(int id)
 {
     using (var db = new TouristDBEntities())
     {
         var obj = (from t in db.dt_channel_article_content
                    orderby t.sort_id
                    where t.id == id
                    select new
         {
             t.id,
             t.title,
             t.img_url,
             t.zhaiyao,
             t.content,
             t.update_time
         }).FirstOrDefault();
         var images = (from t in db.dt_article_albums
                       where t.article_id == id
                       select new
         {
             img_url = t.original_path.Replace("src=\"/upload", "src=\"http://guomengtech.com/upload")
         }).ToList();
         return(Obj2Json(new
         {
             data = new
             {
                 obj.id,
                 obj.title,
                 obj.img_url,
                 obj.zhaiyao,
                 obj.update_time,
                 content = obj.content.Replace("src=\"/upload", "src=\"http://guomengtech.com/upload"),
                 images
             },
             result = 1
         }));
     }
 }
コード例 #10
0
ファイル: TourAPI.cs プロジェクト: kswOok/Tour
        public static string add_or_update_user(string openid, string unionid, string photo, int sex, string nickname,
                                                int age, string phone, string interest, float latitude, float longitude, float accuracy)
        {
            using (var db = new TouristDBEntities())
            {
                dt_users user = null;
                if (openid != null && openid != "")
                {
                    user = db.dt_users.FirstOrDefault(s => s.openid == openid);
                    if (user == null)
                    {
                        user           = new dt_users();
                        user.openid    = openid;
                        user.unionid   = unionid;
                        user.user_name = nickname;
                        user.password  = "******";
                        user.avatar    = photo;
                        user.sex       = sex.ToString();
                        user.age       = age;
                        user.mobile    = phone;
                        user.interest  = interest;
                        user.latitude  = latitude;
                        user.longitude = longitude;
                        user.accuracy  = accuracy;
                        user.GetAddress();
                        db.dt_users.Add(user);
                    }
                    else
                    {
                        if (unionid != null && unionid != "")
                        {
                            user.unionid = unionid;
                        }
                        if (photo != null && photo != "")
                        {
                            user.avatar = photo;
                        }
                        if (sex != -1)
                        {
                            user.sex = sex.ToString();
                        }
                        if (nickname != null && nickname != "")
                        {
                            user.user_name = nickname;
                        }
                        if (age != -1)
                        {
                            user.age = age;
                        }
                        if (phone != null && phone != "")
                        {
                            user.mobile = phone;
                        }
                        if (interest != null && interest != "")
                        {
                            user.interest = interest;
                        }
                        if (latitude != -1)
                        {
                            user.latitude = latitude;
                        }
                        if (longitude != -1)
                        {
                            user.longitude = longitude;
                        }
                        if (accuracy != -1)
                        {
                            user.accuracy = accuracy;
                        }
                        user.GetAddress();
                    }
                    db.SaveChanges();
                }

                return(Obj2Json(new
                {
                    user,
                    result = 1
                }));
            }
        }