123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Web;
- using CP.Cache;
- using CP.Common;
- using CP.Model;
- namespace CP.Business
- {
- public class Oauth
- {
- static WMCache cache = WMCache.GetCacheService();
- /// <summary>
- /// 生成第三方登录数据.
- /// </summary>
- /// <param name="info"></param>
- /// <returns></returns>
- public static int CreateOauthInfo(OauthInfo info)
- {
- return OauthData.CreateOauthInfo(info);
- }
- /// <summary>
- /// 删除某个绑定数据
- /// </summary>
- /// <param name="id"></param>
- public static void DeleteUserOauthInfo(int id, long uid)
- {
- OauthData.DeleteUserOauthInfo(id, uid);
- }
- /// <summary>
- /// 某个用户的所有绑定信息
- /// </summary>
- /// <param name="uid"></param>
- /// <returns></returns>
- public static List<OauthInfo> GetUserOauthList(long uid)
- {
- return OauthData.GetUserOauthList(uid);
- }
- /// <summary>
- /// 用户第三方登录..
- /// </summary>
- /// <param name="appuid"></param>
- /// <param name="access_token"></param>
- /// <param name="oauthtype"></param>
- /// <returns></returns>
- public static UserInfo UserOauthLogin(string appuid, string access_token, int oauthtype)
- {
- string ip = Utils.GetRealIP();
- return OauthData.UserOauthLogin(appuid, access_token, ip, oauthtype);
- }
- /// <summary>
- /// 读取QQ互联配置数据
- /// </summary>
- /// <returns></returns>
- public static QzoneConfigInfo GetQzoneConfigInfo()
- {
- string key = CacheKeys.SYSTEM_OAUTH_QQ;
- QzoneConfigInfo info = cache.GetObject<QzoneConfigInfo>(key) as QzoneConfigInfo;
- if (info == null)
- {
- try
- {
- string json = File.ReadAllText(HttpContext.Current.Server.MapPath("~/_data/config/oauth_tencent.conf"));
- info = JSONUtil.ParseFormByJson<QzoneConfigInfo>(json);
- }
- catch (Exception ex)
- {
- HttpContext.Current.Response.Write(ex.Message);
- }
- cache.AddObject(key, info, (int)CacheTime.System);
- }
- return info;
- }
- /// <summary>
- /// 读取Sina互联配置数据
- /// </summary>
- /// <returns></returns>
- public static SinaConfigInfo GetSinaConfigInfo()
- {
- string key = CacheKeys.SYSTEM_OAUTH_SINA;
- SinaConfigInfo info = cache.GetObject<SinaConfigInfo>(key) as SinaConfigInfo;
- if (info == null)
- {
- try
- {
- string json = File.ReadAllText(HttpContext.Current.Server.MapPath("~/_data/config/oauth_sina.conf"));
- info = JSONUtil.ParseFormByJson<SinaConfigInfo>(json);
- }
- catch
- {
- }
- cache.AddObject(key, info, (int)CacheTime.System);
- }
- return info;
- }
- }
- }
|