public UserFieldSaveHandler(string SocialConnId, SocialConnectionType SocialType, string Field, string Value) { this.SocialConnId = SocialConnId; this.SocialType = SocialType; this.Field = Field; this.Value = Value; }
public static object GetUser(string ID, SocialConnectionType TypeID) { GamervineDataContext dContext = new GamervineDataContext(); var userInfo = from usc in dContext.UserSocialConnections join u in dContext.Users on usc.UserId equals u.UserId join gt in dContext.Gamertags on u.UserId equals gt.UserId join xd in dContext.XboxData on gt.TagId equals xd.TagId where usc.ConnectionUserId == ID && usc.Type == TypeID.GetHashCode() orderby xd.RetrieveDate descending select new { xd.TileUrl, xd.Gamerscore, xd.Gamertag, xd.ReputationImageUrl }; if (userInfo.Count() > 0) { return(userInfo.First()); } else { return(new Exception("Invalid social user ID \"" + ID + "\" for type \"" + TypeID + "\".")); } }
public static object GetUserGameConnectionData(string ID, SocialConnectionType SocConnType, DataConnectionType DataConnType) { GamervineDataContext dContext = new GamervineDataContext(); var gvUserId = from usc in dContext.UserSocialConnections where usc.ConnectionUserId == ID && usc.Type == SocConnType.GetHashCode() select usc.UserId; if (gvUserId.Count() > 0) { var gamertag = from gt in dContext.Gamertags where gt.Type == DataConnType.GetHashCode() && gt.UserId == gvUserId.First() select new { gt.TagId, gt.Tag }; if (gamertag.Count() > 0) { var jobs = from j in dContext.Jobs where j.TagId == gamertag.First().TagId select new { j.JobId, j.Type, j.Frequency, j.FrequencyUnits }; var gtSocialConns = from gtsc in dContext.GamertagSocialConnections join usc in dContext.UserSocialConnections on gtsc.UserSocialConnectionId equals usc.UserSocialConnectionId where gtsc.TagId == gamertag.First().TagId select new { usc.Type }; return(new { TagId = gamertag.First().TagId, Tag = gamertag.First().Tag, Jobs = jobs, GamertagSocialConnections = gtSocialConns }); } else { return new { TagId = string.Empty } }; } else { return new { Error = "Social connection ID \"" + ID + "\" does not exist." } }; }
public string ValidateUser(string ID, string SocialConnTypeID, string Token) { Hashtable ht = new Hashtable(); SocialConnectionType typeID = (SocialConnectionType)Enum.Parse(typeof(SocialConnectionType), SocialConnTypeID); bcUser.ValidateUser(ID, typeID, Token); ht.Add("Result", "Success"); return(JSON.JsonEncode(ht)); }
public static object GetUserGameConnectionData(string ID, SocialConnectionType SocConnType, DataConnectionType DataConnType) { GamervineDataContext dContext = new GamervineDataContext(); var gvUserId = from usc in dContext.UserSocialConnections where usc.ConnectionUserId == ID && usc.Type == SocConnType.GetHashCode() select usc.UserId; if (gvUserId.Count() > 0) { var gamertag = from gt in dContext.Gamertags where gt.Type == DataConnType.GetHashCode() && gt.UserId == gvUserId.First() select new { gt.TagId, gt.Tag }; if (gamertag.Count() > 0) { var jobs = from j in dContext.Jobs where j.TagId == gamertag.First().TagId select new { j.JobId, j.Type, j.Frequency, j.FrequencyUnits }; var gtSocialConns = from gtsc in dContext.GamertagSocialConnections join usc in dContext.UserSocialConnections on gtsc.UserSocialConnectionId equals usc.UserSocialConnectionId where gtsc.TagId == gamertag.First().TagId select new { usc.Type }; return new { TagId = gamertag.First().TagId, Tag = gamertag.First().Tag, Jobs = jobs, GamertagSocialConnections = gtSocialConns }; } else return new { TagId = string.Empty }; } else return new { Error = "Social connection ID \"" + ID + "\" does not exist."}; }
public static ISocialConnector GetSocialConnectorForType(int Type) { SocialConnectionType scType = (SocialConnectionType)Enum.Parse(typeof(SocialConnectionType), Type.ToString()); switch (scType) { case SocialConnectionType.Facebook: return(new FacebookSocialConnector()); default: throw new Exception("SocialConnector doesn't exist for type \"" + Type + "\"."); } }
public string GetUser(string ID, string SocialConnTypeID) { SocialConnectionType typeID = (SocialConnectionType)Enum.Parse(typeof(SocialConnectionType), SocialConnTypeID); object o = bcUser.GetUser(ID, typeID); Hashtable ht = new Hashtable(); foreach (PropertyInfo pi in o.GetType().GetProperties()) { ht.Add(pi.Name, pi.GetValue(o, null)); } return(JSON.JsonEncode(ht)); }
public string SaveField(string Object, string SocialConnID, string SocialConnTypeID, string Field, string Value) { SocialConnectionType socialConnType = (SocialConnectionType)Enum.Parse(typeof(DataConnectionType), SocialConnTypeID); switch (Object) { case "User": UserFieldSaveHandler ufsh = new UserFieldSaveHandler(SocialConnID, socialConnType, Field, Value); ufsh.Save(); break; } return(string.Empty); }
public string GetUserGameConnectionData(string SocialConnectionID, string SocialConnTypeID, string DataConnTypeID) { Hashtable ht = new Hashtable(); DataConnectionType dataConnType = (DataConnectionType)Enum.Parse(typeof(DataConnectionType), DataConnTypeID); SocialConnectionType socialConnType = (SocialConnectionType)Enum.Parse(typeof(DataConnectionType), SocialConnTypeID); object o = bcGamertag.GetUserGameConnectionData(SocialConnectionID, socialConnType, dataConnType); foreach (PropertyInfo pi in o.GetType().GetProperties()) { object propVal = pi.GetValue(o, null); if (propVal is IQueryable) { IQueryable iqPropVal = (IQueryable)propVal; Hashtable htPropVal = new Hashtable(); int count = 0; foreach (var item in iqPropVal) { Hashtable htObject = new Hashtable(); foreach (PropertyInfo piPropVal in item.GetType().GetProperties()) { htObject.Add(piPropVal.Name, piPropVal.GetValue(item, null)); } htPropVal.Add(count, htObject); count++; } htPropVal.Add("Count", count); ht.Add(pi.Name, htPropVal); } else { ht.Add(pi.Name, pi.GetValue(o, null)); } } return(JSON.JsonEncode(ht)); }
public static object GetUser(string ID, SocialConnectionType TypeID) { GamervineDataContext dContext = new GamervineDataContext(); var userInfo = from usc in dContext.UserSocialConnections join u in dContext.Users on usc.UserId equals u.UserId join gt in dContext.Gamertags on u.UserId equals gt.UserId join xd in dContext.XboxData on gt.TagId equals xd.TagId where usc.ConnectionUserId == ID && usc.Type == TypeID.GetHashCode() orderby xd.RetrieveDate descending select new { xd.TileUrl, xd.Gamerscore, xd.Gamertag, xd.ReputationImageUrl }; if (userInfo.Count() > 0) return userInfo.First(); else return new Exception("Invalid social user ID \"" + ID + "\" for type \"" + TypeID + "\"."); }
public static void ValidateUser(string ID, SocialConnectionType TypeID, string Token) { try { GamervineDataContext dContext = new GamervineDataContext(); var gvUserId = from usc in dContext.UserSocialConnections where usc.ConnectionUserId == ID && usc.Type == TypeID.GetHashCode() select usc.UserId; if (gvUserId.Count() == 0) { //User doesn't exist in the system, create new user records User u = new User(); u.Email = string.Empty; u.UserId = Guid.NewGuid().ToString(); u.State = State.Active.GetHashCode(); u.CreatedDate = DateTime.UtcNow; UserSocialConnection usc = new UserSocialConnection(); usc.ConnectionUserId = ID; usc.Token = Token; usc.Type = TypeID.GetHashCode(); usc.UserId = u.UserId; usc.UserSocialConnectionId = Guid.NewGuid().ToString(); dContext.Users.InsertOnSubmit(u); dContext.UserSocialConnections.InsertOnSubmit(usc); dContext.SubmitChanges(); } } catch (Exception ex) { Debug.WriteLine("Exception occurred in bcUser.ValidateUser -> " + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace); } }
public static object GetUserProfile(string ID, SocialConnectionType TypeID) { GamervineDataContext dContext = new GamervineDataContext(); var gvUserId = from usc in dContext.UserSocialConnections join u in dContext.Users on usc.UserId equals u.UserId where usc.ConnectionUserId == ID && usc.Type == TypeID.GetHashCode() select new { usc.UserId, u.State, u.IncludeDetailedStatus, u.IncludeGamertag, u.PostUniqueGames }; if (gvUserId.Count() > 0) { string strGVUserId = gvUserId.First().UserId; var tags = from u in dContext.Users join gt in dContext.Gamertags on u.UserId equals gt.UserId where u.UserId == strGVUserId select new { gt.Type, gt.State }; var socialConnections = from usc in dContext.UserSocialConnections where usc.UserId == strGVUserId select new { usc.ConnectionUserId, usc.Type }; var gamertagSocialConns = from gtsc in dContext.GamertagSocialConnections join usc in dContext.UserSocialConnections on gtsc.UserSocialConnectionId equals usc.UserSocialConnectionId join gt in dContext.Gamertags on gtsc.TagId equals gt.TagId where usc.UserId == strGVUserId select new { usc.Type, GCType = gt.Type }; var userProfile = new { State = gvUserId.First().State, IncludeDetailedStatus = gvUserId.First().IncludeDetailedStatus, IncludeGamertag = gvUserId.First().IncludeGamertag, PostUniqueGames = gvUserId.First().PostUniqueGames, Tags = tags, SocialConnections = socialConnections, GamertagSocialConnections = gamertagSocialConns }; return(userProfile); } else { return(new Exception("Invalid social user ID \"" + ID + "\" for type \"" + TypeID + "\".")); } }
public static object GetUserProfile(string ID, SocialConnectionType TypeID) { GamervineDataContext dContext = new GamervineDataContext(); var gvUserId = from usc in dContext.UserSocialConnections join u in dContext.Users on usc.UserId equals u.UserId where usc.ConnectionUserId == ID && usc.Type == TypeID.GetHashCode() select new { usc.UserId, u.State, u.IncludeDetailedStatus, u.IncludeGamertag, u.PostUniqueGames }; if (gvUserId.Count() > 0) { string strGVUserId = gvUserId.First().UserId; var tags = from u in dContext.Users join gt in dContext.Gamertags on u.UserId equals gt.UserId where u.UserId == strGVUserId select new { gt.Type, gt.State }; var socialConnections = from usc in dContext.UserSocialConnections where usc.UserId == strGVUserId select new { usc.ConnectionUserId, usc.Type }; var gamertagSocialConns = from gtsc in dContext.GamertagSocialConnections join usc in dContext.UserSocialConnections on gtsc.UserSocialConnectionId equals usc.UserSocialConnectionId join gt in dContext.Gamertags on gtsc.TagId equals gt.TagId where usc.UserId == strGVUserId select new { usc.Type, GCType = gt.Type }; var userProfile = new { State = gvUserId.First().State, IncludeDetailedStatus = gvUserId.First().IncludeDetailedStatus, IncludeGamertag = gvUserId.First().IncludeGamertag, PostUniqueGames = gvUserId.First().PostUniqueGames, Tags = tags, SocialConnections = socialConnections, GamertagSocialConnections = gamertagSocialConns }; return userProfile; } else return new Exception("Invalid social user ID \"" + ID + "\" for type \"" + TypeID + "\"."); }