public User(Core core, string userName, UserLoadOptions loadOptions) : base(core) { ItemLoad += new ItemLoadHandler(User_ItemLoad); bool containsInfoData = false; bool containsProfileData = false; bool containsIconData = false; if (loadOptions == UserLoadOptions.Key) { try { LoadItem("user_name_lower", userName.ToLower(), true); } catch (InvalidItemException) { throw new InvalidUserException(); } } else { SelectQuery query = new SelectQuery(User.GetTable(typeof(User))); query.AddFields(User.GetFieldsPrefixed(core, typeof(User))); query.AddCondition(new DataField("user_keys", "user_name_lower"), userName.ToLower()); if ((loadOptions & UserLoadOptions.Info) == UserLoadOptions.Info) { containsInfoData = true; query.AddJoin(JoinTypes.Inner, UserInfo.GetTable(typeof(UserInfo)), "user_id", "user_id"); query.AddFields(UserInfo.GetFieldsPrefixed(core, typeof(UserInfo))); /*if ((loadOptions & UserLoadOptions.Icon) == UserLoadOptions.Icon) { containsIconData = true; query.AddJoin(JoinTypes.Left, new DataField("user_info", "user_icon"), new DataField("gallery_items", "gallery_item_id")); query.AddField(new DataField("gallery_items", "gallery_item_uri")); query.AddField(new DataField("gallery_items", "gallery_item_parent_path")); }*/ } if ((loadOptions & UserLoadOptions.Profile) == UserLoadOptions.Profile) { containsProfileData = true; query.AddJoin(JoinTypes.Inner, UserProfile.GetTable(typeof(UserProfile)), "user_id", "user_id"); query.AddFields(UserProfile.GetFieldsPrefixed(core, typeof(UserProfile))); if ((loadOptions & UserLoadOptions.Country) == UserLoadOptions.Country) { query.AddJoin(JoinTypes.Left, new DataField("user_profile", "profile_country"), new DataField("countries", "country_iso")); } if ((loadOptions & UserLoadOptions.Religion) == UserLoadOptions.Religion) { query.AddJoin(JoinTypes.Left, new DataField("user_profile", "profile_religion"), new DataField("religions", "religion_id")); } } DataTable memberTable = db.Query(query); if (memberTable.Rows.Count > 0) { loadItemInfo(typeof(User), memberTable.Rows[0]); if (containsInfoData) { userInfo = new UserInfo(core, memberTable.Rows[0]); } if (containsProfileData) { userProfile = new UserProfile(core, this, memberTable.Rows[0], loadOptions); } if (containsIconData) { loadUserIcon(memberTable.Rows[0]); } } else { throw new InvalidUserException(); } } }
public ForumMember(Core core, Primitive owner, long userId, UserLoadOptions loadOptions) : base(core) { ItemLoad += new ItemLoadHandler(ForumMember_ItemLoad); SelectQuery query = GetSelectQueryStub(core, UserLoadOptions.All); query.AddCondition("user_keys.user_id", userId); query.AddCondition("item_id", owner.Id); query.AddCondition("item_type_id", owner.TypeId); DataTable memberTable = db.Query(query); if (memberTable.Rows.Count == 1) { DataRow userRow = memberTable.Rows[0]; loadItemInfo(userRow); loadItemInfo(typeof(User), userRow); if ((loadOptions & UserLoadOptions.Info) == UserLoadOptions.Info) { userInfo = new UserInfo(core, userRow); } if ((loadOptions & UserLoadOptions.Profile) == UserLoadOptions.Profile) { userProfile = new UserProfile(core, this, userRow, loadOptions); } /*if ((loadOptions & UserLoadOptions.Icon) == UserLoadOptions.Icon) { loadUserIcon(userRow); }*/ } else { throw new InvalidUserException(); } }
public static SelectQuery GetSelectQueryStub(Core core, UserLoadOptions loadOptions) { long typeId = ItemType.GetTypeId(core, typeof(User)); /*if (loadOptions == UserLoadOptions.All && QueryCache.HasQuery(typeId)) { return (SelectQuery)QueryCache.GetQuery(typeof(User), typeId); } else*/ { #if DEBUG Stopwatch httpTimer = new Stopwatch(); httpTimer.Start(); #endif SelectQuery query = new SelectQuery(GetTable(typeof(User))); query.AddFields(User.GetFieldsPrefixed(core, typeof(User))); query.AddFields(ItemInfo.GetFieldsPrefixed(core, typeof(ItemInfo))); TableJoin join = query.AddJoin(JoinTypes.Left, new DataField(typeof(User), "user_id"), new DataField(typeof(ItemInfo), "info_item_id")); join.AddCondition(new DataField(typeof(ItemInfo), "info_item_type_id"), ItemKey.GetTypeId(core, typeof(User))); if ((loadOptions & UserLoadOptions.Info) == UserLoadOptions.Info) { query.AddJoin(JoinTypes.Inner, UserInfo.GetTable(typeof(UserInfo)), "user_id", "user_id"); query.AddFields(UserInfo.GetFieldsPrefixed(core, typeof(UserInfo))); /*if ((loadOptions & UserLoadOptions.Icon) == UserLoadOptions.Icon) { query.AddJoin(JoinTypes.Left, new DataField("user_info", "user_icon"), new DataField("gallery_items", "gallery_item_id")); query.AddField(new DataField("gallery_items", "gallery_item_uri")); query.AddField(new DataField("gallery_items", "gallery_item_parent_path")); }*/ } if ((loadOptions & UserLoadOptions.Profile) == UserLoadOptions.Profile) { query.AddJoin(JoinTypes.Inner, UserProfile.GetTable(typeof(UserProfile)), "user_id", "user_id"); query.AddFields(UserProfile.GetFieldsPrefixed(core, typeof(UserProfile))); // Countries are cached separately as they do not change /*if ((loadOptions & UserLoadOptions.Country) == UserLoadOptions.Country) { query.AddJoin(JoinTypes.Left, new DataField("user_profile", "profile_country"), new DataField("countries", "country_iso")); }*/ if ((loadOptions & UserLoadOptions.Religion) == UserLoadOptions.Religion) { query.AddJoin(JoinTypes.Left, new DataField("user_profile", "profile_religion"), new DataField("religions", "religion_id")); } } #if DEBUG httpTimer.Stop(); if (HttpContext.Current != null && core.Session != null && core.Session.SessionMethod != SessionMethods.OAuth) { HttpContext.Current.Response.Write(string.Format("<!-- Build user query stub in {0} -->\r\n", httpTimer.ElapsedTicks / 10000000.0)); } #endif /*if (loadOptions == UserLoadOptions.All) { QueryCache.AddQueryToCache(typeId, query); }*/ return query; } }
public ApplicationDeveloper(Core core, DataRow memberRow, UserLoadOptions loadOptions) : base(core, memberRow, loadOptions) { loadItemInfo(typeof(ApplicationDeveloper), memberRow); }
public ForumMember(Core core, System.Data.Common.DbDataReader memberRow, UserLoadOptions loadOptions) : base(core, memberRow, loadOptions) { ItemLoad += new ItemLoadHandler(ForumMember_ItemLoad); loadItemInfo(memberRow); }
public MusicianMember(Core core, Musician owner, string username, UserLoadOptions loadOptions) : base(core) { SelectQuery query = GetSelectQueryStub(core, UserLoadOptions.All); query.AddCondition("user_keys.username", username); query.AddCondition("musician_id", owner.Id); DataTable memberTable = db.Query(query); if (memberTable.Rows.Count == 1) { loadItemInfo(typeof(User), memberTable.Rows[0]); loadItemInfo(typeof(UserInfo), memberTable.Rows[0]); loadItemInfo(typeof(UserProfile), memberTable.Rows[0]); loadItemInfo(typeof(MusicianMember), memberTable.Rows[0]); } else { throw new InvalidUserException(); } }
public UserRelation(Core core, DataRow userRow, UserLoadOptions loadOptions) : base(core, userRow, loadOptions) { loadItemInfo(userRow); }
public UserProfile(Core core, User user, System.Data.Common.DbDataReader memberRow, UserLoadOptions loadOptions) : this(core, user, memberRow) { }
public static new SelectQuery GetSelectQueryStub(Core core, UserLoadOptions loadOptions) { SelectQuery query = GetSelectQueryStub(core, typeof(NetworkMember)); query.AddFields(User.GetFieldsPrefixed(core, typeof(User))); query.AddJoin(JoinTypes.Inner, User.GetTable(typeof(User)), "user_id", "user_id"); if ((loadOptions & UserLoadOptions.Info) == UserLoadOptions.Info) { query.AddFields(UserInfo.GetFieldsPrefixed(core, typeof(UserInfo))); query.AddJoin(JoinTypes.Inner, UserInfo.GetTable(typeof(UserInfo)), "user_id", "user_id"); } if ((loadOptions & UserLoadOptions.Profile) == UserLoadOptions.Profile) { query.AddFields(UserProfile.GetFieldsPrefixed(core, typeof(UserProfile))); query.AddJoin(JoinTypes.Inner, UserProfile.GetTable(typeof(UserProfile)), "user_id", "user_id"); query.AddJoin(JoinTypes.Left, new DataField("user_profile", "profile_country"), new DataField("countries", "country_iso")); query.AddJoin(JoinTypes.Left, new DataField("user_profile", "profile_religion"), new DataField("religions", "religion_id")); } /*if ((loadOptions & UserLoadOptions.Icon) == UserLoadOptions.Icon) { query.AddField(new DataField("gallery_items", "gallery_item_uri")); query.AddField(new DataField("gallery_items", "gallery_item_parent_path")); query.AddJoin(JoinTypes.Left, new DataField("user_info", "user_icon"), new DataField("gallery_items", "gallery_item_id")); }*/ return query; }
public GroupMember(Core core, System.Data.Common.DbDataReader memberRow, UserLoadOptions loadOptions) : base(core, memberRow, loadOptions) { loadItemInfo(memberRow); }
public UserProfile(Core core, User user, DataRow memberRow, UserLoadOptions loadOptions) : this(core, user, memberRow) { }
public GroupMember(Core core, DataRow memberRow, UserLoadOptions loadOptions) : base(core, memberRow, loadOptions) { loadItemInfo(memberRow); /*try {*/ if (memberRow != null && memberRow.Table.Columns.Contains("user_id_go")) { if (!(memberRow["user_id_go"] is DBNull)) { isOperator = true; } } /*} catch { // TODO: is there a better way? //isOperator = false; }*/ }
public SubGroupMember(Core core, DataRow memberRow, UserLoadOptions loadOptions) : base(core, memberRow, loadOptions) { loadItemInfo(typeof(SubGroupMember), memberRow); }
public Kin(Core core, DataRow userRow, UserLoadOptions loadOptions) : base(core, userRow, loadOptions) { }
public User(Core core, System.Data.Common.DbDataReader userRow, UserLoadOptions loadOptions) : base(core) { ItemLoad += new ItemLoadHandler(User_ItemLoad); if (userRow != null) { loadItemInfo(typeof(User), userRow); if ((loadOptions & UserLoadOptions.Info) == UserLoadOptions.Info) { userInfo = new UserInfo(core, userRow); } if ((loadOptions & UserLoadOptions.Profile) == UserLoadOptions.Profile) { userProfile = new UserProfile(core, this, userRow, loadOptions); } } else { throw new InvalidUserException(); } }
public NetworkMember(Core core, DataRow memberRow, UserLoadOptions loadOptions) : base(core, memberRow, loadOptions) { loadItemInfo(memberRow); }
public MusicianMember(Core core, DataRow memberRow, UserLoadOptions loadOptions) : base(core, memberRow, loadOptions) { loadItemInfo(typeof(MusicianMember), memberRow); }
public Fan(Core core, DataRow memberRow, UserLoadOptions loadOptions) : base(core, memberRow, loadOptions) { loadItemInfo(typeof(Fan), memberRow); }
public static new SelectQuery GetSelectQueryStub(Core core, UserLoadOptions loadOptions) { SelectQuery query = new SelectQuery("user_relations"); query.AddFields(UserRelation.GetFieldsPrefixed(core, typeof(UserRelation))); query.AddFields(User.GetFieldsPrefixed(core, typeof(User))); query.AddFields(ItemInfo.GetFieldsPrefixed(core, typeof(ItemInfo))); query.AddJoin(JoinTypes.Inner, User.GetTable(typeof(User)), "relation_you", "user_id"); TableJoin join = query.AddJoin(JoinTypes.Left, new DataField(typeof(UserRelation), "relation_you"), new DataField(typeof(ItemInfo), "info_item_id")); join.AddCondition(new DataField(typeof(ItemInfo), "info_item_type_id"), ItemKey.GetTypeId(core, typeof(User))); if ((loadOptions & UserLoadOptions.Info) == UserLoadOptions.Info) { query.AddFields(UserInfo.GetFieldsPrefixed(core, typeof(UserInfo))); query.AddJoin(JoinTypes.Inner, UserInfo.GetTable(typeof(UserInfo)), "relation_you", "user_id"); } if ((loadOptions & UserLoadOptions.Profile) == UserLoadOptions.Profile) { query.AddFields(UserProfile.GetFieldsPrefixed(core, typeof(UserProfile))); query.AddJoin(JoinTypes.Inner, UserProfile.GetTable(typeof(UserProfile)), "relation_you", "user_id"); query.AddJoin(JoinTypes.Left, new DataField("user_profile", "profile_country"), new DataField("countries", "country_iso")); query.AddJoin(JoinTypes.Left, new DataField("user_profile", "profile_religion"), new DataField("religions", "religion_id")); } /*if ((loadOptions & UserLoadOptions.Icon) == UserLoadOptions.Icon) { query.AddField(new DataField("gallery_items", "gallery_item_uri")); query.AddField(new DataField("gallery_items", "gallery_item_parent_path")); query.AddJoin(JoinTypes.Left, new DataField("user_info", "user_icon"), new DataField("gallery_items", "gallery_item_id")); }*/ return query; }
public ForumMember(Core core, DataRow memberRow, UserLoadOptions loadOptions) : base(core, memberRow, loadOptions) { ItemLoad += new ItemLoadHandler(ForumMember_ItemLoad); loadItemInfo(memberRow); }
public UserRelation(Core core, System.Data.Common.DbDataReader userRow, UserLoadOptions loadOptions) : base(core, userRow, loadOptions) { loadItemInfo(userRow); }
public ApplicationDeveloper(Core core, ApplicationEntry owner, long userId, UserLoadOptions loadOptions) : base(core) { SelectQuery query = GetSelectQueryStub(core, UserLoadOptions.All); query.AddCondition("user_keys.user_id", userId); query.AddCondition("application_id", owner.Id); DataTable memberTable = db.Query(query); if (memberTable.Rows.Count == 1) { loadItemInfo(typeof(User), memberTable.Rows[0]); loadItemInfo(typeof(UserInfo), memberTable.Rows[0]); loadItemInfo(typeof(UserProfile), memberTable.Rows[0]); loadItemInfo(typeof(ApplicationDeveloper), memberTable.Rows[0]); /*loadUserInfo(memberTable.Rows[0]); loadUserIcon(memberTable.Rows[0]);*/ } else { throw new InvalidUserException(); } }