/// <summary> /// Wrong name. Does in fact check if the user may be added, then ALSO adds the user to the node /// </summary> /// <param name="user"></param> /// <param name="ship"></param> /// <param name="node"></param> /// <returns></returns> public static string checkShipAtCommNode(Core.User user, Core.Ship ship, Core.CommunicationNode node) { string ret = ""; //List<SpacegameServer.Core.DiplomaticRelation> newContacts = new List<SpacegameServer.Core.DiplomaticRelation>(); if (!node.checkAndAddUser(user, ship)) { return(ret); } SpacegameServer.BC.XMLGroups.CommNodeData nodeData = new SpacegameServer.BC.XMLGroups.CommNodeData(); //nodeData.xmlKnownUsers = SpacegameServer.BC.XMLGroups.UserContacts.createContacts(user, newContacts); nodeData.commNodes = new XMLGroups.CommNodes(); nodeData.commNodes.commNode = new List <XMLGroups.CommNode>(); nodeData.commNodes.commNode.Add(XMLGroups.CommNode.createCommNode(node, user)); //Todo: only transfer "new" alliance contact data //nodeData.allianceDiplomacy = XMLGroups.KnownAlliances.createAllianceContacts(user); //nodeData.allianceRelations = XMLGroups.AllianceUserRelations.createAllianceUserRelations(user); BusinessConnector.Serialize <SpacegameServer.BC.XMLGroups.CommNodeData>(nodeData, ref ret, true); return(ret); }
public string getReceivedMessages( int userId, int fromNr, // fromNr the earliest already received message int toNr, // toNr 50 means 50 messages more to read (towards the past) -> from . to counts backwards (current messages are already loaded, so fetch older ones with this call) int lastMessageId, // The highest ID that the user already got (if he is currently fetching oler messages, unreceived newer ones should also be transferred int messageType) // Filter for message type { string xml = ""; if (!Core.Core.Instance.users.ContainsKey(userId)) { return(xml); } Core.User user = Core.Core.Instance.users[userId]; try { xml = (new BC.Message(user)).getReceivedMessages(userId, fromNr, toNr, lastMessageId, messageType); } catch (Exception ex) { SpacegameServer.Core.Core.Instance.writeExceptionToLog(ex); } return(xml); }
public string getCommNodeMessage(int userId, int commNodeId, int from, int to) { string xml = ""; if (!Core.Core.Instance.users.ContainsKey(userId)) { return(xml); } if (!Core.Core.Instance.commNodes.ContainsKey(commNodeId)) { return(xml); } Core.User user = Core.Core.Instance.users[userId]; Core.CommunicationNode node = Core.Core.Instance.commNodes[commNodeId]; try { xml = (new BC.CommNode(node, user)).getCommNodeMessages(from, to); } catch (Exception ex) { SpacegameServer.Core.Core.Instance.writeExceptionToLog(ex); } return(xml); }
public string leaveAlliance(int userId, int userToRemoveId, int allianceId) { string xml = ""; if (!Core.Core.Instance.users.ContainsKey(userId)) { return(xml); } Core.User user = Core.Core.Instance.users[userId]; if (!Core.Core.Instance.users.ContainsKey(userToRemoveId)) { return(xml); } Core.User userToRemove = Core.Core.Instance.users[userToRemoveId]; try { xml = BC.Alliance.leaveAlliance(user, userToRemove, allianceId); } catch (Exception ex) { SpacegameServer.Core.Core.Instance.writeExceptionToLog(ex); } return(xml); }
public string getMessagesText(int userId, int messageId) { string xml = ""; if (!Core.Core.Instance.users.ContainsKey(userId)) { return(xml); } if (!Core.Core.Instance.messages.ContainsKey(messageId)) { return(xml); } Core.User user = Core.Core.Instance.users[userId]; try { xml = (new BC.Message(user)).getMessagesText(userId, messageId); } catch (Exception ex) { SpacegameServer.Core.Core.Instance.writeExceptionToLog(ex); } return(xml); }
/// <summary> /// creates all contact Informations /// </summary> /// <param name="player"></param> /// <returns></returns> public static UserContacts createAllContacts(Core.User player) { UserContacts knownUsers = new UserContacts(); knownUsers.knownUser = new List <UserContact>(); foreach (var targetRelation in Core.Core.Instance.userRelations.getAllDiplomatics(player, 1)) { Core.User targetUser = (Core.User)targetRelation.target; knownUsers.knownUser.Add( new UserContact(targetUser.id, targetUser.username, targetRelation.relation, targetRelation.relationSenderProposal, targetRelation.relationTargetProposal, //Math.Min(relations.Key, relations.Value), relations.Key, relations.Value, targetUser.popVicPoints, targetUser.researchVicPoints, targetUser.goodsVicPoints, targetUser.shipVicPoints, targetUser.overallVicPoints, targetUser.overallRank, targetUser.allianceId, targetUser.AiId, targetUser.AiRelation, targetUser.ProfileUrl) ); } return(knownUsers); }
/// <summary> /// creates a single contact information /// </summary> /// <param name="player">player</param> /// <param name="target">targetUser</param> /// <returns></returns> public static UserContacts createContact(Core.User player, Core.User targetUser) { UserContacts knownUsers = new UserContacts(); knownUsers.knownUser = new List <UserContact>(); SpacegameServer.Core.FullDiplomaticRelationProposals targetRelation = Core.Core.Instance.userRelations.getDiplomaticsToUser(player, targetUser); knownUsers.knownUser.Add( new UserContact(targetUser.id, targetUser.username, targetRelation.relation, targetRelation.relationSenderProposal, targetRelation.relationTargetProposal, //Math.Min(relations.Key, relations.Value), relations.Key, relations.Value, targetUser.popVicPoints, targetUser.researchVicPoints, targetUser.goodsVicPoints, targetUser.shipVicPoints, targetUser.overallVicPoints, targetUser.overallRank, targetUser.allianceId, targetUser.AiId, targetUser.AiRelation, targetUser.ProfileUrl) ); return(knownUsers); }
public static AllianceInvites createAllianceInvites(Core.User player) { AllianceInvites invites = new AllianceInvites(); invites.allianceInvite = new List <AllianceInvite>(); if (player.allianceId != 0) { if (Core.Core.Instance.invitesPerAlliance.ContainsKey(player.allianceId)) { foreach (var invite in Core.Core.Instance.invitesPerAlliance[player.allianceId]) { invites.allianceInvite.Add(new AllianceInvite(invite, player.allianceId)); } } } if (Core.Core.Instance.invitesPerUser.ContainsKey(player.id)) { foreach (var invite in Core.Core.Instance.invitesPerUser[player.id]) { invites.allianceInvite.Add(new AllianceInvite(player.id, invite)); } } return(invites); }
public void removeInviteToAlliance(int senderId, int receiverId) { if (!Core.Core.Instance.users.ContainsKey(senderId)) { return; } if (!Core.Core.Instance.users.ContainsKey(receiverId)) { return; } Core.User sender = Core.Core.Instance.users[senderId]; Core.User receiver = Core.Core.Instance.users[receiverId]; try { SpacegameServer.Core.Alliance.removeInvitation(sender, receiver); } catch (Exception ex) { SpacegameServer.Core.Core.Instance.writeExceptionToLog(ex); } return; }
public ActionResult Register(RegistrationRequest registrationRequest) { try { Core.User user = accessController.Register(registrationRequest); if (user != null) { ViewBag.IsRegistered = true; Util.SetCredentials(user); string userData = JsonConvert.SerializeObject(user); FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket( 1, user.Id.ToString(), //user id DateTime.Now, DateTime.Now.AddMinutes(30), // expiry false, //do not remember userData, "/"); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(authTicket)); Response.Cookies.Add(cookie); } } catch (Exception excp) { ViewBag.Error = excp.Message; } return(View()); }
public void saveFogString(int userId, string fogString, int fogVersion) { if (!Core.Core.Instance.users.ContainsKey(userId)) { return; } Core.User user = Core.Core.Instance.users[userId]; if (user.fogVersion >= fogVersion) { return; } user.fogVersion = fogVersion; user.fogString = fogString; Core.Core.Instance.dataConnection.userSaveFog(user); /* * if (!Core.Core.Instance.users.ContainsKey(senderId)) return; * Core.User sender = Core.Core.Instance.users[senderId]; * * try * { * SpacegameServer.Core.Alliance.changeDescription(sender, newName); * } * catch (Exception ex) * { * SpacegameServer.Core.Core.Instance.writeExceptionToLogFile(ex); * } */ return; }
public string getUserDetails(int targetUserId) { BC.XMLGroups.UserDetails relations = new BC.XMLGroups.UserDetails(); if (!Core.Core.Instance.users.ContainsKey(this.userId)) { return("<relations></relations>"); } if (!Core.Core.Instance.users.ContainsKey(targetUserId)) { return("<relations></relations>"); } Core.User user = Core.Core.Instance.users[this.userId]; Core.User targetUser = Core.Core.Instance.users[targetUserId]; relations.description = targetUser.Description; relations.userId = targetUser.id; relations.relation = Core.Core.Instance.userRelations.getUserDiplomatics(user, targetUser); string x = ""; //BusinessConnector.Serialize<BC.XMLGroups.UserDetails>(relations, ref x, true); x = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(relations); return(x); }
public User GetRecruiterInfo(string userName) { User recruiter = new Core.User(); recruiter.UserName = dataTable.Rows[0]["user_name"].ToString(); recruiter.UserId = Convert.ToInt32(dataTable.Rows[0]["user_id"]); recruiter.UserType = Convert.ToByte(dataTable.Rows[0]["user_type"]); recruiter.FirstName = dataTable.Rows[0]["first_name"].ToString(); recruiter.LastName = dataTable.Rows[0]["last_name"].ToString(); recruiter.Email = dataTable.Rows[0]["email"].ToString(); recruiter.PhoneNumber = dataTable.Rows[0]["phone"].ToString(); using (MemoryStream ms = new MemoryStream((byte[])dataTable.Rows[0]["photo"])) { var photo = new BitmapImage(); photo.BeginInit(); photo.CacheOption = BitmapCacheOption.OnLoad; photo.StreamSource = ms; photo.EndInit(); recruiter.Photo = photo; } recruiter.JobPosition = dataTable.Rows[0]["job_position"].ToString(); recruiter.CompanyName = query.getCompanyName(Convert.ToUInt32(dataTable.Rows[0]["company_id"])); return(recruiter); }
private bool CanSeeUnpublishedContents() { var context = System.Web.HttpContext.Current; if (context == null) { return(false); } string token = context.Request.QueryString["previewToken"]; if (String.IsNullOrEmpty(token)) { return(false); } Core.Services.SecurityService security = new Core.Services.SecurityService(); var admCMS = new Groups.ADM_CMS(); var admSEC = new Core.Groups.ADM_SEC(); Core.User u = security.GetUserByAuthToken(token); if (u == null) { return(false); } string[] roles = security.GetUserRoles(u); return(roles.Contains(admCMS.UserGroupUId) || roles.Contains(admSEC.UserGroupUId)); }
private void _kinect_UserCreated(object sender, KinectUserEventArgs e) { Core.User kinect_user = _kinect.GetUser(e.User.Id); var xnaUser = new User.User(kinect_user, Content, new Size(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight)); _users.Add(xnaUser); }
public ActionResult Add(AddUserViewModel userViewModel) { if (userManager.HasUserName(userViewModel.UserName)) { ModelState.AddModelError("UserName", "用户名已存在"); } if (userManager.HasEmail(userViewModel.Email)) { ModelState.AddModelError("Email", "Email已存在"); } if (ModelState.IsValid) { User _user = new Core.User() { RoleID = userViewModel.RoleID, UserName = userViewModel.UserName, Name = userViewModel.Name, Sex = userViewModel.Sex, Password = Core.General.Security.Sha256(userViewModel.Password), Email = userViewModel.Email, RegTime = DateTime.Now }; var _response = userManager.Add(_user); if (_response.Code == 1) { return(View("Prompt", new Prompt() { Title = "添加用户成功", Message = "您已成功添加了用户【" + _response.Data.UserName + "(" + _response.Data.Name + ")】", Buttons = new List <string> { "<a href=\"" + Url.Action("Index", "User") + "\" class=\"btn btn-default\">用户管理</a>", "<a href=\"" + Url.Action("Details", "User", new { id = _response.Data.UserID }) + "\" class=\"btn btn-default\">查看用户</a>", "<a href=\"" + Url.Action("Add", "User") + "\" class=\"btn btn-default\">继续添加</a>" } })); } else { ModelState.AddModelError("", _response.Message); } } //角色列表 var _roles = new RoleManager().FindList(); List <SelectListItem> _listItems = new List <SelectListItem>(_roles.Count()); foreach (var _role in _roles) { _listItems.Add(new SelectListItem() { Text = _role.Name, Value = _role.RoleID.ToString() }); } ViewBag.Roles = _listItems; //角色列表结束 return(View(userViewModel)); }
public User(Core.User user, ContentManager content, Size windowSize) { // TODO: Complete member initialization _user = user; _content = content; WindowSize = windowSize; AddBodyParts(); _user.Updated += Kinect_User_Updated; }
/// <summary> /// Fetches all research for the owner of the call, or only completed specialization research if the owner asks informations about another player(userId ) /// </summary> /// <param name="userId"></param> /// <param name="owner"></param> /// <returns></returns> public List <Core.UserResearch> getUserResearch(int userId, bool owner) { if (!Core.Core.Instance.users.ContainsKey(userId)) { return(new List <Core.UserResearch>()); } Core.User user = Core.Core.Instance.users[userId]; return(user.PlayerResearch.Where(e => owner || (e.isCompleted == 1 && e.research.researchType == 10)).ToList()); }
public UserDeep(Guid?id, Core.User core) : base() { ID = Calc.ID(id, core); Name = core.Name; Hide = core.Groupings?.Where(item => item.Action == Skelbimai.Core.SkelbimasAction.Hide) .Select(item => item.SkelbimasID); Show = core.Groupings?.Where(item => item.Action == Skelbimai.Core.SkelbimasAction.Show) .Select(item => item.SkelbimasID); }
public string getFogString(int userId) { if (!Core.Core.Instance.users.ContainsKey(userId)) { return(""); } Core.User user = Core.Core.Instance.users[userId]; return(user.fogString); }
private ClaimsIdentity GetIdentityFromUser(Models.APIContext db, Core.User user, string authenticationType) { var identity = new ClaimsIdentity(authenticationType); identity.AddClaim(new System.Security.Claims.Claim(ClaimTypes.Name, string.Format("{0} {1}", user.FirstName, user.LastName))); identity.AddClaim(new System.Security.Claims.Claim(ClaimTypes.Email, user.EmailAddress)); identity.AddClaim(new System.Security.Claims.Claim(ClaimTypes.NameIdentifier, user.Id.ToString())); return(identity); }
public static AllianceFullData createFullData(Core.User user) { AllianceFullData fullData = new AllianceFullData(); fullData.allianceDiplomacy = XMLGroups.KnownAlliances.createAllianceContacts(user); fullData.allianceRelations = XMLGroups.AllianceUserRelations.createAllianceUserRelations(user); fullData.allianceInvites = XMLGroups.AllianceInvites.createAllianceInvites(user); return(fullData); }
public void SetLatestGalacticEvents(int userId, int LatestEventSoFar) { if (!Core.Core.Instance.users.ContainsKey(userId)) { return; } Core.User user = Core.Core.Instance.users[userId]; user.LastReadGalactivEvent = LatestEventSoFar; Core.Core.Instance.dataConnection.saveUser(user); }
public static string leaveAlliance(Core.User user, Core.User userToRemove, int allianceId) { string xml = ""; Core.Alliance.leaveCheck(user, userToRemove, allianceId); SpacegameServer.BC.XMLGroups.AllianceFullData allianceInfo = SpacegameServer.BC.XMLGroups.AllianceFullData.createFullData(user); BusinessConnector.Serialize <SpacegameServer.BC.XMLGroups.AllianceFullData>(allianceInfo, ref xml, true); return(xml); }
public void SetShowCombatFast(int userId, bool value) { if (!Core.Core.Instance.users.ContainsKey(userId)) { return; } Core.User user = Core.Core.Instance.users[userId]; user.showCombatFast = value; Core.Core.Instance.dataConnection.saveUser(user); }
/// <summary> /// creates a single contact information /// </summary> /// <param name="player"></param> /// <param name="target"></param> /// <returns></returns> public static UserContacts createContacts(Core.User player, int target) { UserContacts knownUsers = new UserContacts(); knownUsers.knownUser = new List <UserContact>(); foreach (var targetRelation in Core.Core.Instance.userRelations.getDiplomatics(player, 1)) { Core.User targetUser = (Core.User)targetRelation.target; knownUsers.knownUser.Add( new UserContact(targetUser.id, targetUser.username, targetRelation.relation, targetRelation.relationSenderProposal, targetRelation.relationTargetProposal, //Math.Min(relations.Key, relations.Value), relations.Key, relations.Value, targetUser.popVicPoints, targetUser.researchVicPoints, targetUser.goodsVicPoints, targetUser.shipVicPoints, targetUser.overallVicPoints, targetUser.overallRank, targetUser.allianceId, targetUser.AiId, targetUser.AiRelation, targetUser.ProfileUrl) ); } /* * foreach(var targetRelation in Core.Core.Instance.userRelations.getUserRelationsForUser(player)) * { * //skip others if single player data is requested * if (target != 0 && targetRelation.Key != target) continue; * Core.User targetUser = Core.Core.Instance.users[targetRelation.Key]; * * var relations = Core.Core.Instance.userRelations.getProposals(player, targetUser); * * knownUsers.knownUser.Add( * new UserContact(targetUser.id, targetUser.username, * Math.Min(relations.Key, relations.Value), relations.Key, relations.Value, * targetUser.popVicPoints, * targetUser.researchPoints, * targetUser.goodsVicPoints, * targetUser.shipVicPoints, * targetUser.overallVicPoints, * targetUser.overallRank, * targetUser.allianceId) * ); * * } */ return(knownUsers); }
public static List <AllowedShipHulls> createAllowedShipHulls(Core.User player) { List <AllowedShipHulls> allowedShipHulls = new List <AllowedShipHulls>(); foreach (var hull in Core.Core.Instance.ShipHulls.Where(e => e != null)) { if (player.hasGameObjectEnabled(5, hull.id)) { allowedShipHulls.Add(new AllowedShipHulls(hull.id)); } } return(allowedShipHulls); }
public static List <AllowedBuilding> createAllowedBuildings(Core.User player) { List <AllowedBuilding> allowedBuildings = new List <AllowedBuilding>(); foreach (var building in Core.Core.Instance.Buildings.Where(e => e != null)) { if (player.hasGameObjectEnabled(3, building.id)) { allowedBuildings.Add(new AllowedBuilding(building.id)); } } return(allowedBuildings); }
public void LoginTests(Core.User user) { try { new BasicAuthorization(user).Login().Wait(); } catch (Exception e) { Assert.Fail($"Authorization not success. User information: {user}.\n\nException: {e.Message}"); } Assert.Pass(); }
public static List <AllowedModule> createAllowedModules(Core.User player) { List <AllowedModule> allowedModules = new List <AllowedModule>(); foreach (var module in Core.Core.Instance.Modules.Where(e => e != null)) { if (player.hasGameObjectEnabled(4, module.id)) { allowedModules.Add(new AllowedModule(module.id)); } } return(allowedModules); }
public ActionResult SocialLoginback(string code, string error, string error_reason) { var fb = new FacebookConnector(); var wowBiz = new WoWBiz(); var accessToken = fb.GetAccessToken(code, RedirectUri.AbsoluteUri); // Store the access token in the session for farther use Session["AccessToken"] = accessToken; // Get user profile from facebook dynamic userProfile = fb.GetUserProfile(accessToken); #region User Process var clientId = userProfile.id; var userProfileImage = string.Format("https://graph.facebook.com/{0}/picture", userProfile.id); //Create user for first times login var existingUser = wowBiz.GetUserByClientId((string)clientId); if (existingUser == null) { var user = new Core.User { ImageUrl = userProfileImage, Name = string.Format("{0} {1}", userProfile.first_name, userProfile.last_name), Socials = new List<Core.Social>{ new Core.Social{ ClientId_ = clientId, Email = userProfile.email, Name = string.Format("{0} {1}", userProfile.first_name, userProfile.last_name), Token = accessToken, Type = (int)Core.Enum.SocialType.Facebook, } } }; var success = wowBiz.CreateNewUser(user); existingUser = user; } else { //Update wowBiz.UpdateSocialToken(existingUser.Socials.First().Id, accessToken); } Session["User"] = existingUser; #endregion // Set the auth cookie FormsAuthentication.SetAuthCookie(userProfile.email, false); return RedirectToAction("Index", "Home"); }
public static void Main(string[] args) { IServerConfiguration config = Db4oClientServer.NewServerConfiguration(); using (IObjectServer server = Db4oClientServer.OpenServer(config, YapFileName, 0)) { using (IObjectContainer client = server.OpenClient()) { var pass = "******"; var user = new Core.User() { CreatedOn = DateTime.Now, Email = "*****@*****.**", Name = "Teste 1", Password = Encoding.Unicode.GetString(new MD5CryptoServiceProvider().ComputeHash(Encoding.Unicode.GetBytes(pass))) }; client.Store(user); } } //AccessRemoteServer(); //using (IObjectServer server = Db4oClientServer.OpenServer(Db4oClientServer.NewServerConfiguration(), // YapFileName, ServerPort)) //{ // server.GrantAccess(ServerUser, ServerPassword); // QueryRemoteServer(ServerPort, ServerUser, ServerPassword); // DemonstrateRemoteReadCommitted(ServerPort, ServerUser, ServerPassword); // DemonstrateRemoteRollback(ServerPort, ServerUser, ServerPassword); //} }