public void OnVkGetUser(string str) { var mas = str.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var socData = new SocialData { ViewerId = mas[0], FirstName = mas[1], LastName = mas[2], Photo = mas[3] }; if (SocialData.ContainsKey(socData.ViewerId)) { SocialData[socData.ViewerId] = socData; } else { SocialData.Add(socData.ViewerId, socData); } LogWrite("OnVkGetUser OK"); LogWrite(" resultStr: " + str); LogWrite(" uid: " + socData.ViewerId); LogWrite(" FName: " + socData.FirstName); LogWrite(" LName: " + socData.LastName); LogWrite(" Photo: " + socData.Photo); }
protected abstract void DoParticleSocialInteraction(ref Particle particle, ref SpeciesData speciesData, ref SocialData socialData, ref Particle other, ref SpeciesData otherSpeciesData, ref Vector3 totalSocialforce, ref int totalSocialInteractions);
void LoginHandler(LoginManagerLoginResult loginResult, NSError error) { if (loginResult.IsCancelled) { _facebookTask.TrySetResult(TryResult.Create(false, new SocialData { LoginState = SocialLoginStateEnum.Canceled })); } else if (error != null) { _facebookTask.TrySetResult(TryResult.Create(false, new SocialData { LoginState = SocialLoginStateEnum.Failed, ErrorString = error.LocalizedDescription })); } else { _socialData = new SocialData { Token = loginResult.Token.TokenString, UserId = loginResult.Token.UserId, ExpireAt = loginResult.Token.ExpirationDate.ToDateTimeUtc() }; _facebookTask.TrySetResult(TryResult.Create(true, _socialData)); } }
/// <summary> /// “关注”指定的目标用户(异步) /// </summary> /// <param name="userId">用户编号</param> /// <param name="targetUserId">被关注的目标用户编号</param> public static async void FollowedTargetUser(int userId, int targetUserId) { await Task.Run(() => { UserFollowed uFollowed = new UserFollowed { UserId = userId, FollowedUserId = targetUserId, CreateDate = DateTime.Now }; bool result = SocialData.ChangedFollowedWithTargetUser(uFollowed, 1); if (result) { SocialConfig config = SocialConfigs.GetSocialConfigCache(); if (config.BeFollowedExpChanged != 0) { UserBiz.UpdateUserExp(targetUserId, config.BeFollowedExpChanged, "被关注"); } if (config.BeFollowedCoinChanged != 0) { UserBiz.UpdateUserCoin(targetUserId, config.BeFollowedCoinChanged, "被关注"); } UserBiz.SetUserCacheInfo(userId); UserBiz.SetUserCacheInfo(targetUserId); //发送系统消息给被关注对象,提醒该用户被“关注” //Todo.... } }); }
async Task LoginTask(SocialData data) { if (data == null) { Mvx.Trace("Received empty data for login"); return; } var success = false; var result = default(Profile); var _serverApiService = Mvx.Resolve <IServerApiService>(); switch (data.Source) { case AuthorizationType.Email: if (Validate()) { result = await _serverApiService.SignIn(LoginString, PasswordString); success = result != null; } break; case AuthorizationType.Facebook: result = await _serverApiService.FacebookSignIn(data.Id, data.Source.ToString().ToLower()); if (result != null) { userName = data.FullName; _storedSettingsService.Profile = GetProfileFromResponse(result, data); SettingsService.SocialRegistartionSource = true; success = CheckHttpStatuseCode(result.StatusCode); } break; case AuthorizationType.GPlus: result = await _serverApiService.GooglePlusSignIn(data.Email, data.Source.ToString().ToLower()); if (result != null) { userName = data.FullName; _storedSettingsService.Profile = GetProfileFromResponse(result, data); success = CheckHttpStatuseCode(result.StatusCode); SettingsService.SocialRegistartionSource = true; } break; } if (success) { //_dataBaseService.SetUser(result); _storedSettingsService.Profile = result; _storedSettingsService.IsAuthorized = true; _storedSettingsService.ProfileId = result.Id; _storedSettingsService.AuthToken = result.Token; Close(this); ShowViewModel <HomeViewModel>(new { name = result.FirstName, message = "Welcome back, " }); } }
public static SocialData LuaCreateSocial(string name) { var newSocial = new SocialData(_dbManager.GenerateNewId <SocialData>(), name); _luaManager.Proxy.CreateTable("social"); AddLastObject(newSocial); _dbManager.AddToRepository(newSocial); _logManager.Boot("Social {0} created", name); return(newSocial); }
/// <summary> /// 查找群组列表 /// </summary> /// <param name="keyword"></param> /// <param name="interest"></param> /// <param name="onlyLess"></param> /// <param name="userId"></param> /// <param name="site"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public static PageResult <int> GroupFind(string keyword, string interest, bool onlyLess, int userId, int site, int pageIndex, int pageSize) { PageResult <int> pageData = new PageResult <int> { RecordCount = SocialData.GroupFindCount(keyword, interest, onlyLess, userId, site), PageIndex = pageIndex, PageSize = pageSize }; pageData.Data = SocialData.GroupFindList(keyword, interest, onlyLess, userId, site, pageData.PageIndex, pageData.PageSize); return(pageData); }
private Profile GetProfileFromResponse(Profile profileFromResponse, SocialData data) { if (profileFromResponse.StatusCode == System.Net.HttpStatusCode.NotFound) { profileFromResponse.FirstName = data.FirstName; profileFromResponse.LastName = data.LastName; profileFromResponse.Email = data.Email; profileFromResponse.FacebookId = data.Id; profileFromResponse.Source = data.Source.ToString().ToLower(); } return(profileFromResponse); }
/// <summary> /// 获取指定用户所参与群组列表 /// </summary> /// <param name="userId"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public static PageResult <int> GetGroupsByUser(int userId, int pageIndex, int pageSize) { IEnumerable <int> groupIds = SocialData.GetGroupsByUser(userId); PageResult <int> resultData = new PageResult <int> { RecordCount = groupIds.Count(), PageIndex = pageIndex, PageSize = pageSize }; resultData.Data = groupIds.SkipTake <int>(resultData.PageSize, resultData.PageIndex); return(resultData); }
/// <summary> /// 获取用户之间单向“关注”关系数据列表 /// </summary> /// <param name="userId">指定的用户</param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="followedType">关注类型:0-用户关注的,1-关注用户的</param> /// <returns></returns> private static PageResult <UserFollowed> GetUsersFollowedPageData(int userId, int pageIndex, int pageSize, byte followedType) { List <UserFollowed> userFollowedList = SocialData.GetUsersFollowedList(userId, followedType).ToList(); PageResult <UserFollowed> pageData = new PageResult <UserFollowed> { RecordCount = userFollowedList.Count, PageIndex = pageIndex, PageSize = pageSize }; pageData.Data = userFollowedList.SkipTake <UserFollowed>(pageData.PageSize, pageData.PageIndex); return(pageData); }
/// <summary> /// 取消“关注”指定的目标用户(异步) /// </summary> /// <param name="userId">用户编号</param> /// <param name="targetUserId">被关注的目标用户编号</param> public static async void RemoveFollowedByTargetUser(int userId, int targetUserId) { await Task.Run(() => { UserFollowed uFollowed = new UserFollowed { UserId = userId, FollowedUserId = targetUserId, CreateDate = DateTime.Now }; bool result = SocialData.ChangedFollowedWithTargetUser(uFollowed, 0); if (result) { UserBiz.SetUserCacheInfo(userId); UserBiz.SetUserCacheInfo(targetUserId); } }); }
public TestController(string userTag, string loginSessionId, IViewModelFactory viewModelFactory, ICompanyInfo routingGroupInfo) : base(viewModelFactory, routingGroupInfo) { RoomService.CreateClient(); LocalUserVm.UserTag = userTag; LocalUserVm.LoginSession = new LoginSession() { UserId = LocalUserVm.UserId, LoginSessionId = loginSessionId }; RoomVm = viewModelFactory.GetViewModel <RoomViewModel>(); ContactController = new ContactController(RoomService); ContactData = ContactData.GetContactData(ContactController, LocalUserVm.UserId, LocalUserVm.LoginSession); SocialData = new SocialData(RoomService, LocalUserVm.Model); ContactAccessors = new ObservableCollection <ContactAccessUi>(); }
/// <summary> /// 创建群组 /// </summary> /// <param name="userId"></param> /// <param name="groupName"></param> /// <param name="interest"></param> /// <param name="iconData"></param> /// <param name="iconExtName"></param> /// <returns></returns> public static GroupInfo CreateGroup(int userId, string groupName, string interest, byte[] iconData, string iconExtName) { SocialConfig config = SocialConfigs.GetSocialConfigCache(); GroupInfo groupInfo = new GroupInfo { GroupName = groupName, GroupIcon = config.DefaultGroupIcon, Comment = string.Empty, CreatorId = userId, GroupType = 0, InterestCode = interest, QuickJoinCode = string.Empty, MaxMemberCount = config.GroupMaxMemberCount < 1 ? 20 : config.GroupMaxMemberCount, MemberCount = 0, CreateDate = DateTime.Now }; UserCacheInfo userCache = UserBiz.ReadUserCacheInfo(userId); SocialData.CreateGroup(groupInfo, userCache.UserSite); if (groupInfo.GroupId > 0) { //更新快速加入码和图标 groupInfo.QuickJoinCode = Convert.ToBase64String(groupInfo.GroupId.GetIntOffsetBytes()).TrimEnd('=').ToUpper(); string iconUrl = iconData.SaveMediaFile(FileTarget.Group, groupInfo.GroupId, MediaType.Image, iconExtName); if (!string.IsNullOrEmpty(iconUrl)) { groupInfo.GroupIcon = iconUrl; } SocialData.UpdateGroupInfo(groupInfo); //缓存群信息和成员列表信息 groupInfo.MemberCount++; SetGroupCacheInfo(groupInfo.GroupId, groupInfo); List <UserCacheInfo> memberList = new List <UserCacheInfo>(1) { UserBiz.ReadUserCacheInfo(userId) }; SetGroupMembersCacheInfo(groupInfo.GroupId, memberList); return(groupInfo); } return(null); }
/// <summary> /// 用户从群组中退出 /// </summary> /// <param name="userId"></param> /// <param name="groupId"></param> public static void QuitFromGroup(int userId, int groupId) { GroupInfo groupInfo = ReadGroupCacheInfo(groupId); if (null != groupInfo) { int resultCode = SocialData.UserQuitFromGroup(userId, groupId); //仅当前用户退出群 if (1 == resultCode) { groupInfo.MemberCount--; SetGroupCacheInfo(groupId, groupInfo); Func <UserCacheInfo, bool> func = m => m.UserId == userId; List <UserCacheInfo> groupMemberList = GetGroupMembersList(groupId); if (groupMemberList.Count(func) > 0) { var removeUser = groupMemberList.Single(func); groupMemberList.Remove(removeUser); SetGroupMembersCacheInfo(groupInfo.GroupId, groupMemberList); } //通知该群组剩余成员 (groupMemberList),更新群组成员列表 //Todo } //当前用户为群组创建者,退出成功导致群组解散 if (0 == resultCode) { RemoveGroupInfoCache(groupId); Func <UserCacheInfo, bool> func = m => m.UserId == userId; List <UserCacheInfo> groupMemberList = GetGroupMembersList(groupId); if (groupMemberList.Count(func) > 0) { var removeUser = groupMemberList.Single(func); groupMemberList.Remove(removeUser); RemoveGroupMembersCache(groupId); } //通知该群组剩余成员 (groupMemberList),群组被解散 //Todo } } }
/// <summary> /// Use this method to define how one particle would interact with another. You should /// not modify either this particle or the other particle. If you want to create a social /// force, add it to totalSocialForce and increment totalSocialInteractions. At the end /// of the particle step all social forces will be averaged. /// </summary> protected override void DoParticleSocialInteraction(ref Particle particle, ref SpeciesData speciesData, ref SocialData socialData, ref Particle other, ref SpeciesData otherSpeciesData, ref Vector3 totalSocialforce, ref int totalSocialInteractions) { Vector3 vectorToOther = other.position - particle.position; float distanceSquared = vectorToOther.sqrMagnitude; if (distanceSquared < socialData.socialRangeSquared) { float distance = Mathf.Sqrt(distanceSquared); Vector3 directionToOther = vectorToOther / distance; //If we are close enough for a social force, add the new force to the total force sum //and increment the number of total social interactions. totalSocialforce += socialData.socialForce * directionToOther; totalSocialInteractions++; } }
/// <summary> /// 用户加入群组 /// </summary> /// <param name="userId"></param> /// <param name="groupId"></param> /// <param name="quickJoinCode"></param> /// <returns></returns> public static int UserJoinToGroup(int userId, int groupId, string quickJoinCode = "") { GroupInfo groupInfo = GetGroupInfoFromDb(groupId, quickJoinCode); if (null == groupInfo) { return(-2); } if (groupInfo.MemberCount >= groupInfo.MaxMemberCount) { return(-1); } GroupMember gMember = new GroupMember { GroupId = groupInfo.GroupId, UserId = userId, IsCreator = groupInfo.CreatorId == userId, CreateDate = DateTime.Now }; int code = SocialData.UserJoinToGroup(gMember); if (1 == code) { groupInfo.MemberCount++; SetGroupCacheInfo(groupInfo.GroupId, groupInfo); List <UserCacheInfo> groupMemberList = GetGroupMembersList(groupInfo.GroupId); if (groupMemberList.Count > 0) { //通知该群组之前的成员(groupMemberList),更新群组成员列表 //Todo } groupMemberList.Add(UserBiz.ReadUserCacheInfo(userId)); SetGroupMembersCacheInfo(groupInfo.GroupId, groupMemberList); } return(code); }
public LeaderboardEntryPlayerData(SocialData socialData) { this.userId = socialData.FacebookId; this.name = socialData.Name; this.metadata = string.Empty; }
/// <summary> /// 根据群编号或者快速加入码获取群组信息 /// </summary> /// <param name="groupId">群组编号</param> /// <param name="quickJoinCode">快速加入码</param> /// <returns>群组信息</returns> public static GroupInfo GetGroupInfoFromDb(int groupId, string quickJoinCode = "") { return(SocialData.GetGroupInfo(groupId, quickJoinCode)); }
/// <summary> /// 是否已经存在“关注”关系 /// </summary> /// <param name="userId">用户编号</param> /// <param name="targetUserId">被关注的目标用户编号</param> /// <returns>是否已经存在“关注”关系</returns> public static bool AlreadyBeFollowed(int userId, int targetUserId) { return(SocialData.BeFollowedWithTargetUser(new UserFollowed { UserId = userId, FollowedUserId = targetUserId })); }