private static void Display(ThirdPartyInfo data, int indent) { if (data == null) { return; } if (data.assurableSpecified) { DisplayValue("Assurable", data.assurable, indent); } if (data.nmftaMemberSpecified) { DisplayValue("MNFTA Member", data.nmftaMember, indent); } if (data.ooidaMemberSpecified) { DisplayValue("OOIDA Member", data.ooidaMember, indent); } if (data.rivieraGreenLightSpecified) { DisplayValue("Riviera Green Light", data.rivieraGreenLight, indent); } if (data.rmisGreenLightSpecified) { DisplayValue("RMIS Green Light", data.rmisGreenLight, indent); } }
public async static ETTask LinkByFaceBook(Player player, LinkInfo info, L2C_Link response) { string fbToken = info.Secret; bool isValidToken = await FacebookHelper.ValidateFacebookToken(fbToken); if (!isValidToken) { response.Error = ErrorCode.ERR_LinkFailed; return; } ThirdPartyInfo fbInfo = await FacebookHelper.GetFacebookUserInfo(fbToken); if (fbInfo == null) { response.Error = ErrorCode.ERR_LinkFailed; return; } long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); ThirdPartyUser thirdPartyUser = await UserDataHelper.FindOneThirdPartyUser(fbInfo.id, UserDataHelper.tagFB); if (thirdPartyUser == null) { long uid = player.uid; User user = await UserDataHelper.FindOneUser(uid); if (user == null) { response.Error = ErrorCode.ERR_LinkFailed; return; } //綁定第三方-FB thirdPartyUser = ComponentFactory.CreateWithId <ThirdPartyUser>(IdGenerater.GenerateId()); thirdPartyUser.uid = user.Id; thirdPartyUser.party = UserDataHelper.tagFB; thirdPartyUser.userId = fbInfo.id; thirdPartyUser.gender = fbInfo.gender; thirdPartyUser.location = fbInfo.location; thirdPartyUser.email = fbInfo.email; thirdPartyUser.name = fbInfo.name; thirdPartyUser.birthday = fbInfo.birthday; thirdPartyUser.createAt = now; await UserDataHelper.UpsertThirdPartyUser(thirdPartyUser); //取得新的第三方列表 response.LinkTypes.Clear(); response.LinkTypes.AddRange(await GetAllLinkType(user.Id)); } else { response.Error = ErrorCode.ERR_LinkIsExist; } }
public async static ETTask LinkByAppleId(Player player, LinkInfo info, L2C_Link response) { string appleId = CryptographyHelper.AESDecrypt(info.Secret); ThirdPartyInfo appleInfo = new ThirdPartyInfo { id = appleId, }; long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); ThirdPartyUser thirdPartyUser = await UserDataHelper.FindOneThirdPartyUser(appleInfo.id, UserDataHelper.tagAppleId); if (thirdPartyUser == null) { long uid = player.uid; User user = await UserDataHelper.FindOneUser(uid); if (user == null) { response.Error = ErrorCode.ERR_LinkFailed; return; } // 綁定第三方-Apple thirdPartyUser = ComponentFactory.CreateWithId <ThirdPartyUser>(IdGenerater.GenerateId()); thirdPartyUser.uid = user.Id; thirdPartyUser.party = UserDataHelper.tagAppleId; thirdPartyUser.userId = appleInfo.id; thirdPartyUser.gender = appleInfo.gender; thirdPartyUser.location = appleInfo.location; thirdPartyUser.email = appleInfo.email; thirdPartyUser.name = appleInfo.name; thirdPartyUser.birthday = appleInfo.birthday; thirdPartyUser.createAt = now; await UserDataHelper.UpsertThirdPartyUser(thirdPartyUser); // 取得新的第三方列表 response.LinkTypes.Clear(); response.LinkTypes.AddRange(await GetAllLinkType(user.Id)); } else { response.Error = ErrorCode.ERR_LinkIsExist; } }
public bool ThirdPartyPost([FromBody] ThirdPartyInfo Info) { if (!ModelState.IsValid) { throw new Exception(); } string queryString = "INSERT INTO Third_Party_ (fromMonth, fromDay, fromHour, toMonth, toDay, toHour, lat1, lon1, lat2, lon2, Mode ) VALUES( \'" + Info.fromMonth + "\', \'" + Info.fromDay + "\', \'" + Info.fromHour + "\', \'" + Info.toMonth + "\' " + ", \'" + Info.toDay + "\', \'" + Info.toHour + "\', \'" + Info.lat1 + "\', \'" + Info.lon1 + "\', \'" + Info.lat2 + "\', \'" + Info.lon2 + "\', \'" + Info.Mode + "\')"; if (LOG_TO_DB(queryString)) { return(true); } else { return(false); } }
/// <summary> /// 使用AppleID登入 /// </summary> /// <param name="session"></param> /// <param name="info"></param> /// <param name="response"></param> /// <returns></returns> public async static ETTask AuthenticationByAppleId(Session session, AuthenticationInfo info, R2C_Authentication response) { string appleId = CryptographyHelper.AESDecrypt(info.Secret); ThirdPartyInfo appleInfo = new ThirdPartyInfo { id = appleId, }; long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); ThirdPartyUser thirdPartyUser = await UserDataHelper.FindOneThirdPartyUser(appleInfo.id, UserDataHelper.tagAppleId); User user = null; if (thirdPartyUser == null) { // 用AppleId註冊帳號 user = ComponentFactory.CreateWithId <User>(IdGenerater.GenerateId()); string salt = CryptographyHelper.GenerateRandomId(); string password = CryptographyHelper.GenerateRandomId(16); string hashPassword = CryptographyHelper.MD5Encoding(password, salt); user.salt = salt; user.hashPassword = hashPassword; user.email = appleInfo.email; user.name = user.Id.ToString(); user.gender = appleInfo.genderCode; user.location = appleInfo.locationCode; user.birthday = appleInfo.birthdayCode; user.createAt = now; user.playerCharSetting = new PlayerCharSetting(); user.playerCharSetting.CharacterId = 1L; user.playerRideTotalInfo = new RideTotalInfo(); user.language = info.Language; user.identity = (int)User.Identity.Player; user.userBagCapacity = EquipmentDataHelper.GetDefaultUserBag(); await UserDataHelper.SinUserUp(user); // 註冊第三方-AppleId thirdPartyUser = ComponentFactory.CreateWithId <ThirdPartyUser>(IdGenerater.GenerateId()); thirdPartyUser.uid = user.Id; thirdPartyUser.party = UserDataHelper.tagAppleId; thirdPartyUser.userId = appleInfo.id; thirdPartyUser.gender = appleInfo.gender; thirdPartyUser.location = appleInfo.location; thirdPartyUser.email = appleInfo.email; thirdPartyUser.name = appleInfo.name; thirdPartyUser.birthday = appleInfo.birthday; thirdPartyUser.createAt = now; await UserDataHelper.UpsertThirdPartyUser(thirdPartyUser); // 註冊第三方-Guest thirdPartyUser = ComponentFactory.CreateWithId <ThirdPartyUser>(IdGenerater.GenerateId()); thirdPartyUser.uid = user.Id; thirdPartyUser.party = UserDataHelper.tagGuest; thirdPartyUser.userId = info.DeviceId; thirdPartyUser.name = ""; thirdPartyUser.gender = ""; thirdPartyUser.location = ""; thirdPartyUser.email = ""; thirdPartyUser.birthday = ""; thirdPartyUser.createAt = now; await UserDataHelper.UpsertThirdPartyUser(thirdPartyUser); } else { user = await UserDataHelper.FindOneUser(thirdPartyUser.uid); } await SignInByUid(session, user, response, info.FirebaseDeviceToken, true, UserDataHelper.tagAppleId); }
public async static ETTask AuthenticationByFaceBook(Session session, AuthenticationInfo info, R2C_Authentication response) { string fbToken = info.Secret; bool isValidToken = await FacebookHelper.ValidateFacebookToken(fbToken); if (!isValidToken) { response.Error = ErrorCode.ERR_FBSignInFailed; return; } ThirdPartyInfo fbInfo = await FacebookHelper.GetFacebookUserInfo(fbToken); if (fbInfo == null) { response.Error = ErrorCode.ERR_FBSignInFailed; return; } long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); ThirdPartyUser thirdPartyUser = await UserDataHelper.FindOneThirdPartyUser(fbInfo.id, UserDataHelper.tagFB); User user = null; if (thirdPartyUser == null) { // 用FB註冊帳號 user = ComponentFactory.CreateWithId <User>(IdGenerater.GenerateId()); string salt = CryptographyHelper.GenerateRandomId(); string password = CryptographyHelper.GenerateRandomId(16); string hashPassword = CryptographyHelper.MD5Encoding(password, salt); user.salt = salt; user.hashPassword = hashPassword; user.email = fbInfo.email; user.name = fbInfo.name; user.gender = fbInfo.genderCode; user.location = fbInfo.locationCode; user.birthday = fbInfo.birthdayCode; user.createAt = now; user.playerCharSetting = new PlayerCharSetting(); user.playerCharSetting.CharacterId = 1L; user.playerRideTotalInfo = new RideTotalInfo(); user.language = info.Language; user.identity = (int)User.Identity.Player; user.userBagCapacity = EquipmentDataHelper.GetDefaultUserBag(); await UserDataHelper.SinUserUp(user); //註冊第三方-FB thirdPartyUser = ComponentFactory.CreateWithId <ThirdPartyUser>(IdGenerater.GenerateId()); thirdPartyUser.uid = user.Id; thirdPartyUser.party = UserDataHelper.tagFB; thirdPartyUser.userId = fbInfo.id; thirdPartyUser.gender = fbInfo.gender; thirdPartyUser.location = fbInfo.location; thirdPartyUser.email = fbInfo.email; thirdPartyUser.name = fbInfo.name; thirdPartyUser.birthday = fbInfo.birthday; thirdPartyUser.createAt = now; await UserDataHelper.UpsertThirdPartyUser(thirdPartyUser); //註冊第三方-Guest thirdPartyUser = ComponentFactory.CreateWithId <ThirdPartyUser>(IdGenerater.GenerateId()); thirdPartyUser.uid = user.Id; thirdPartyUser.party = UserDataHelper.tagGuest; thirdPartyUser.userId = info.DeviceId; thirdPartyUser.name = ""; thirdPartyUser.gender = ""; thirdPartyUser.location = ""; thirdPartyUser.email = ""; thirdPartyUser.birthday = ""; thirdPartyUser.createAt = now; await UserDataHelper.UpsertThirdPartyUser(thirdPartyUser); } else { user = await UserDataHelper.FindOneUser(thirdPartyUser.uid); } await SignInByUid(session, user, response, info.FirebaseDeviceToken, true, UserDataHelper.tagFB); }