public string GetDropboxAccountDetailsByUserId(string UserId) { if (string.IsNullOrEmpty(UserId)) { return "User Id is Null"; } Domain.Socioboard.Domain.DropboxAccount _DropboxAccount = new Domain.Socioboard.Domain.DropboxAccount(); DropboxAccountRepository _DropboxAccountRepository = new DropboxAccountRepository(); try { // Convert User if in Guid Guid _Userid = Guid.Parse(UserId); //IF USER NOT EXIST //CHECK AND GET USER DATA IN TABLE _DropboxAccount = _DropboxAccountRepository.getDropboxAccountDetailsbyId(_Userid); if (_DropboxAccount != null) { return new JavaScriptSerializer().Serialize(_DropboxAccount); } else { return new JavaScriptSerializer().Serialize(null); } } catch (Exception) { return new JavaScriptSerializer().Serialize(null); } }
//[WebMethod] //[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)] public bool AddUserInfo(String _UserDetail, string UserId, string _AccessToken, GlobussDropboxLib.Authentication.oAuthToken _oAuthToken) { var _OBJ_User = Newtonsoft.Json.Linq.JObject.Parse(_UserDetail); DropboxAccountRepository _DropboxAccountRepository = new DropboxAccountRepository(); Domain.Socioboard.Domain.DropboxAccount _DropboxAccount = new Domain.Socioboard.Domain.DropboxAccount(); //User user = (User)Session["LoggedUser"]; Guid _UserId = Guid.Parse(UserId); _DropboxAccount.Id = Guid.NewGuid(); _DropboxAccount.UserId = _UserId; _DropboxAccount.DropboxUserName = _OBJ_User["display_name"].ToString(); _DropboxAccount.DropboxUserId = _OBJ_User["uid"].ToString(); _DropboxAccount.DropboxEmail = _OBJ_User["email"].ToString(); _DropboxAccount.AccessToken = _AccessToken; _DropboxAccount.OauthToken = _oAuthToken.Token; _DropboxAccount.OauthTokenSecret = _oAuthToken.TokenSecret; _DropboxAccount.CreateDate = DateTime.Now; _DropboxAccountRepository.Add(_DropboxAccount); return true; }
public string AddDropboxAccount(string code, string UserId) { GlobussDropboxLib.Authentication.oAuthToken _oAuthToken = new GlobussDropboxLib.Authentication.oAuthToken(); _oAuthToken.ConsumerKey = ConfigurationManager.AppSettings["DBX_Appkey"]; _oAuthToken.ConsumerSecret = ConfigurationManager.AppSettings["DBX_Appsecret"]; Guid Userid = Guid.Parse(UserId); //GET RESPONCE CODE BY URL string _code = code; //POST DATA string _PostData = ("code=" + _code + "&client_id=" + ConfigurationManager.AppSettings["DBX_Appkey"] + "&client_secret=" + ConfigurationManager.AppSettings["DBX_Appsecret"] + "&redirect_uri=" + HttpUtility.UrlEncode(ConfigurationManager.AppSettings["DBX_redirect_uri"]) + "&grant_type=authorization_code").Trim(); var _StrAccess_Token = _oAuthToken.WebRequest(GlobussDropboxLib.Authentication.oAuthToken.Method.POST, GlobussDropboxLib.App.Core.Global._APP_TOEKN_URL, _PostData); string _OauthRequestToken = _oAuthToken.GetRequestToken(); var _Jval_AccessToken = Newtonsoft.Json.Linq.JValue.Parse(_StrAccess_Token); var _AccessToken = ((Newtonsoft.Json.Linq.JValue)_Jval_AccessToken["access_token"]).Value.ToString(); //_oAuthToken.AccessTokenGet(AccessToken); //GET USER INFO string _UserDetail = GlobussDropboxLib.Dropbox.Core.User.User.GetUserInfo(ref _oAuthToken, _AccessToken); //AddUserInfo(_UserDetail, _AccessToken, _oAuthToken); var _OBJ_User = Newtonsoft.Json.Linq.JObject.Parse(_UserDetail); DropboxAccountRepository _DropboxAccountRepository = new DropboxAccountRepository(); Domain.Socioboard.Domain.DropboxAccount _DropboxAccount = new Domain.Socioboard.Domain.DropboxAccount(); _DropboxAccount.Id = Guid.NewGuid(); _DropboxAccount.UserId = Userid; _DropboxAccount.DropboxUserName = _OBJ_User["display_name"].ToString(); _DropboxAccount.DropboxUserId = _OBJ_User["uid"].ToString(); _DropboxAccount.DropboxEmail = _OBJ_User["email"].ToString(); _DropboxAccount.AccessToken = _AccessToken; _DropboxAccount.OauthToken = _oAuthToken.Token; _DropboxAccount.OauthTokenSecret = _oAuthToken.TokenSecret; _DropboxAccount.CreateDate = DateTime.Now; _DropboxAccountRepository.Add(_DropboxAccount); return ""; }