public string Login(string result) //登录 { string[] answer = result.Split(new char[] { '|' }); string name = answer[1], password = answer[2], longitude = answer[3], latitude = answer[4]; userInformation temp = head; while (temp != null) { if (temp.name == name) { if (temp.password == password) { temp.longitude = longitude; temp.latitude = latitude; UpdateInfo(temp.name); Console.WriteLine("登录成功!"); return(temp.friendList); } else { return("1Password is wrong, please reinput!"); } } temp = temp.next; } return("1User doesn't exist!"); }
/// <summary> /// Returns the favorite rooms of a given user as a string. /// </summary> /// <param name="User">The userInformation object of the user to retrieve the favorite rooms for.</param> public string getFavoriteRooms(userInformation User) { int guestRoomCount = 0; StringBuilder Rooms = new StringBuilder(); Database Database = new Database(false, true); Database.addParameterWithValue("userid", User.ID); Database.Open(); DataTable dTable = Database.getTable("SELECT rooms.*,users.username AS owner FROM rooms LEFT JOIN users ON rooms.ownerid = users.id WHERE rooms.id IN (SELECT roomid FROM rooms_favorites WHERE userid = @userid) ORDER BY rooms.id DESC LIMIT 30"); // User flats first foreach (DataRow dRow in dTable.Rows) { roomInformation Room = roomInformation.Parse(dRow, true); if (Room.isUserFlat) { guestRoomCount++; } Rooms.Append(Room.ToString(User)); } fuseStringBuilder FSB = new fuseStringBuilder(); FSB.appendWired(guestRoomCount); FSB.Append(Rooms.ToString()); return(FSB.ToString()); }
public ActionResult DeleteConfirmed(int id) { userInformation userInformation = db.userInformations.Find(id); db.userInformations.Remove(userInformation); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "id,fullName,age,email,image")] userInformation userInformation) { if (ModelState.IsValid) { db.Entry(userInformation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userInformation)); }
/// <summary> /// Returns the max amount of buddies a given user can have on his buddy list for the messenger. The user's role and club subscription is being checked. /// </summary> /// <param name="User">The userInformation object containing the values to calculate the length with.</param> public int getMaxBuddyListLength(userInformation User) { if (User.hasFuseRight("fuse_extended_buddylist")) { return(this._maxBuddyListLength_Extended); } else { return(this._maxBuddyListLength); } }
// GET: Profile/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } userInformation userInformation = db.userInformations.Find(id); if (userInformation == null) { return(HttpNotFound()); } return(View(userInformation)); }
/// <summary> /// Destroys the session and clears up all used resources. /// </summary> public void Destroy() { if (this.isHoldingUser) { Engine.Game.Users.removeUserSession(this.User.ID); this.leaveRoom(false); this.User = null; this.itemStripHandler.saveHandItems(); this.itemStripHandler.Clear(); this.itemStripHandler = null; } this.gameConnection.Abort(); this.gameConnection = null; }
public string searchFriend(string result) //查找好友 { string[] location = result.Split(new char[] { '|' }); string longitude = location[1], latitude = location[2], range = location[3], searchResult = ""; userInformation temp = head; double x1 = System.Double.Parse(longitude), y1 = System.Double.Parse(latitude), drange = System.Double.Parse(range); while (temp != null) { double x2 = System.Double.Parse(temp.longitude); double y2 = System.Double.Parse(temp.latitude); double a = (x1 - x2) / 2; double aa = Math.Sin(a) * Math.Sin(a); double b = (y1 - y2) / 2; double bb = Math.Cos(x1) * Math.Cos(x2) * Math.Sin(b) * Math.Sin(b); double distance = 2 * Math.Asin(Math.Sqrt(aa + bb)) * 6378.137; if (distance < drange) { searchResult = searchResult + temp.photo + '|' + temp.name + '|' + distance + '|' + temp.longitude + '|' + temp.latitude + '|'; } temp = temp.next; } string[] activity = searchResult.Split(new char[] { '|' }); for (int i = 0; i < activity.Length / 5; i++) { for (int j = i + 1; j < activity.Length / 5; j++) { if (Double.Parse(activity[5 * j + 2]) < Double.Parse(activity[5 * i + 2])) { string strTmp = null; strTmp = activity[5 * j + 0]; activity[5 * j + 0] = activity[5 * i + 0]; activity[5 * i + 0] = strTmp; strTmp = activity[5 * j + 1]; activity[5 * j + 1] = activity[5 * i + 1]; activity[5 * i + 1] = strTmp; strTmp = activity[5 * j + 2]; activity[5 * j + 2] = activity[5 * i + 2]; activity[5 * i + 2] = strTmp; strTmp = activity[5 * j + 3]; activity[5 * j + 3] = activity[5 * i + 3]; activity[5 * i + 3] = strTmp; strTmp = activity[5 * j + 4]; activity[5 * j + 4] = activity[5 * i + 4]; activity[5 * i + 4] = strTmp; } } } result = null; for (int i = 0; i < activity.Length / 5; i++) { result = result + activity[5 * i + 0] + '&' + activity[5 * i + 1] + '&' + activity[5 * i + 2] + '&' + activity[5 * i + 3] + '&' + activity[5 * i + 4] + '/'; } return(result); }
public string Addfriend(string result) //加好友 { string[] answer = result.Split(new char[] { '|' }); string friendName = answer[1], userName = answer[2]; userInformation userTemp = null, friendTemp = null, temp = head; int flag = 0; while (temp != null) { if (temp.name == userName) { userTemp = temp; flag = flag + 1; } if (temp.name == friendName) { friendTemp = temp; flag = flag + 2; } temp = temp.next; } if (flag == 0) { return("输入两个账号都错误!"); } else if (flag == 1) { return("输入好友账号错误!"); } else if (flag == 2) { return("输入自己账号错误!"); } string[] friend = userTemp.friendList.Split(new char[] { '&', '/' }); for (int i = 0; i < friend.Length / 2; i++) { if (friend[i] == friendName) { return("This user has been your friend!"); } } userTemp.friendList = userTemp.friendList + friendTemp.photo + '&' + friendTemp.name + '&' + friendTemp.score + '&' + friendTemp.speed + '&' + friendTemp.distance + '/'; userTemp.friendList = UpdateFriendList(userTemp.friendList); UpdateInfo(userName); return("add friend successful"); }
public void PostEvent(string result) //发起活动,更新我的活动列表 { string[] answer = result.Split(new char[] { '|' }); string activityName = answer[1], userName = answer[3], time = answer[6]; userInformation temp = head; while (temp != null) { if (temp.name == userName) { break; } temp = temp.next; } temp.futureActivityList = temp.futureActivityList + activityName + '&' + time + '&'; UpdateInfo(userName); }
public string findMyActivity(string result) //我的活动 { string[] information = result.Split(new char[] { '|' }); string name = information[1]; userInformation temp = head; while (temp != null) { if (temp.name == name) { break; } temp = temp.next; } temp.futureActivityList = sort(temp.futureActivityList); return(temp.futureActivityList + '|' + temp.finishActivityList); }
public bool requestRoomKick(int userID, int roomID, string Message, string extraInfo) { userInformation Caster = ObjectTree.Game.Users.getUserInfo(userID, false); if (Caster != null) { if (ObjectTree.Game.Rooms.roomInstanceRunning(roomID)) { ObjectTree.Game.Rooms.getRoomInstance(roomID).castRoomKick(Caster.Role, Message); logModerationAction(userID, "roomkick", roomID, Message, extraInfo); return(true); } } return(false); }
/// <summary> /// Parses the generic roomInformation object to a room information string. /// </summary> /// <param name="viewingUser">The userInformation object of the user that requests the flat information string.</param> public string ToString(userInformation viewingUser) { fuseStringBuilder FSB = new fuseStringBuilder(); FSB.appendWired(this.ID); // Room ID if (!this.isUserFlat) // Public space flag { FSB.appendWired(true); } FSB.appendClosedValue(this.Name); // Room name if (this.isUserFlat) // User flat { if (this.showOwner || this.ownerID == viewingUser.ID || viewingUser.hasFuseRight("fuse_see_all_roomowners")) { FSB.appendClosedValue(this.Owner); } else { FSB.Append("-"); } FSB.appendClosedValue(this.accessType.ToString()); } FSB.appendWired(this.currentVisitors); FSB.appendWired(this.maxVisitors); if (!this.isUserFlat) { FSB.appendWired(this.categoryID); } FSB.appendClosedValue(this.Description); if (!this.isUserFlat) { FSB.appendWired(this.ID); FSB.appendWired(false); FSB.appendClosedValue(this.CCTs); FSB.appendWired(false); FSB.appendWired(true); } return(FSB.ToString()); }
/// <summary> /// Writes a buddy request from a given user to another user into the database, and notifies the receiver with the new request if it's online. /// </summary> /// <param name="User">The userInformation object of the user that sends the request.</param> /// <param name="userID2">The database ID of the receiving user.</param> public void requestBuddy(userInformation User, int userID2) { Database Database = new Database(false, true); Database.addParameterWithValue("userid", User.ID); Database.addParameterWithValue("userid2", userID2); Database.Open(); Database.runQuery("INSERT INTO messenger_buddylist(userid,buddyid) VALUES (@userid,@userid2)"); if (ObjectTree.Game.Users.userIsLoggedIn(userID2)) // Receiver is online { serverMessage Message = new serverMessage(132); // "BD" Message.appendWired(User.ID); Message.appendClosedValue(User.Username); ObjectTree.Game.Users.trySendGameMessage(userID2, Message); } }
public ActionResult Create(userInformation userInformation, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file != null && file.ContentLength > 0) { var filename = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Images/"), filename); var picpath = Path.Combine("~/Images", filename); file.SaveAs(path); userInformation.image = picpath.ToString(); } db.userInformations.Add(userInformation); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userInformation)); }
public string findFriend(string result) //好友详情 { string[] fName = result.Split(new char[] { '|' }); string friendName = fName[1]; userInformation temp = head; while (temp != null) { if (temp.name == friendName) { break; } temp = temp.next; } string back = temp.longitude + '|' + temp.latitude + '|' + temp.speed + '|' + temp.distance + '|' + temp.futureActivityList + '|' + temp.finishActivityList; return(back); }
public roomInformation[] getFlatsForUser(userInformation User) { List <roomInformation> Rooms = new List <roomInformation>(); Database Database = new Database(false, true); Database.addParameterWithValue("ownerid", User.ID); Database.Open(); if (Database.Ready) { DataTable dTable = Database.getTable("SELECT rooms.*,users.username AS owner FROM rooms LEFT JOIN users ON (rooms.ownerid = users.id) WHERE ownerid = @ownerid"); foreach (DataRow dRow in dTable.Rows) { Rooms.Add(roomInformation.Parse(dRow, true)); } } return(Rooms.ToArray()); }
public ActionResult Registeration(userInformation user) { if (Session["CurrentUser"] != null) { listOfUsers = (List <userInformation>)Session["CurrentUser"]; return(View()); } else { if (ModelState.IsValid) { listOfUsers.Add(user); Session["CurrentUser"] = listOfUsers; return(RedirectToAction("Login")); } return(View(user)); } }
public string Rigest(string result) //注册 { string[] answer = result.Split(new char[] { '|' }); string name = answer[1], password = answer[2]; //检测是否存在该用户名 userInformation temp = head; while (temp != null) { if (temp.name == name) { return("User existes!"); } temp = temp.next; } Add(name, password, "", "", "", "", "", "", "", "", ""); updateUserList(name); UpdateInfo(name); return("Regist successful!"); }
public bool requestKickFromRoom(int userID, int targetUserID, string Message, string extraInfo) { userInformation Caster = ObjectTree.Game.Users.getUserInfo(userID, false); if (Caster != null) { Session targetSession = ObjectTree.Game.Users.getUserSession(targetUserID); if (targetSession != null && targetSession.inRoom) { if (Caster.Role > targetSession.User.Role) { targetSession.kickFromRoom(Message); logModerationAction(Caster.ID, "kick", targetUserID, Message, extraInfo); return(true); } } } return(false); }
public string JoinActivity(string result) //加入活动,更新我的活动列表 { if (result == "You have joined it!") { return("You have joined it!"); } else if (result == "Join in successful!") { return("Join in successful!"); } string[] answer = result.Split(new char[] { '|' }); string activityName = answer[1], userName = answer[2], time = answer[3]; DateTime dt = DateTime.Now; string ctime = dt.ToString(); string[] date = ctime.Split(new char[] { '/', ' ', ':' }); string year = date[0], month = date[1], day = date[2], hour = date[3]; string[] atime = time.Split(new char[] { '/' }); double ayear = double.Parse(atime[0]), amonth = double.Parse(atime[1]), aday = double.Parse(atime[2]), ahour = double.Parse(atime[3]), nyear = double.Parse(year), nmonth = double.Parse(month), nday = double.Parse(day), nhour = double.Parse(hour); if (ayear < nyear || amonth < nmonth || aday < nday) { return("this activity have finished"); } userInformation temp = head; while (temp != null) { if (temp.name == userName) { break; } temp = temp.next; } temp.futureActivityList = temp.futureActivityList + activityName + '&' + time + '&'; UpdateInfo(userName); return("join successful!"); }
public void UpdateInfo(string userName) //更新用户信息 { userInformation temp = head; while (temp != null) { if (temp.name == userName) { break; } temp = temp.next; } string result = temp.name + '|' + temp.password + '|' + temp.photo + '|' + temp.longitude + '|' + temp.latitude + '|' + temp.speed + '|' + temp.distance + '|' + temp.score + '|' + temp.futureActivityList + '|' + temp.finishActivityList + '|' + temp.friendList; string strname = "data\\" + userName + ".txt"; FileStream myFs1 = new FileStream(strname, FileMode.Create); StreamWriter mySw1 = new StreamWriter(myFs1); mySw1.Write(result); mySw1.Close(); myFs1.Close(); }
private userInformation head; //头指针 public void Add(string name, string password, string photo, string longitude, string latitude, string speed, string distance, string score, string futureActivityList, string finishActivityList, string friendList) { //向链表中加入用户 userInformation newNode = new userInformation(name, password, photo, longitude, latitude, speed, distance, score, futureActivityList, finishActivityList, friendList); if (head == null) { head = newNode; head.next = null; } else { userInformation temp = head; while (temp.next != null) { temp = temp.next; } ; temp.next = newNode; } count++; }
public string finishActivity(string result) //活动结束 { string[] information = result.Split(new char[] { '|' }); string name = information[1], activityName = information[2], speed = information[3], distance = information[4], count = information[5], sponsor = information[6]; double score = double.Parse(speed) * double.Parse(distance) * double.Parse(count) * double.Parse(sponsor); userInformation temp = head; while (temp != null) { if (temp.name == name) { break; } temp = temp.next; } if (temp.speed == "") { temp.speed = speed.ToString(); } double dSpeed = (double.Parse(temp.speed) + double.Parse(speed)) / 2; temp.speed = "" + dSpeed.ToString(); temp.distance = "" + (double.Parse(temp.distance) + double.Parse(distance)).ToString(); temp.score = "" + (double.Parse(temp.score) + score).ToString(); temp.finishActivityList = activityName + '&' + temp.finishActivityList; string[] futureActivity = temp.futureActivityList.Split(new char[] { '&' }); temp.futureActivityList = ""; for (int i = 0; i < futureActivity.Length / 2; i++) { if (futureActivity[i * 2] != activityName) { temp.futureActivityList = temp.futureActivityList + futureActivity[i * 2] + '&' + futureActivity[i * 2 + 1] + '&'; } } UpdateInfo(name); return("Successful!"); }
public ActionResult Registeration() { userInformation userObj = new userInformation(); return(View(userObj)); }
public Manager() { userInformation = new userInformation(); }
public bool requestBan(int userID, int targetUserID, int banHours, bool banIP, bool banMachine, string Message, string extraInfo) { userInformation Caster = ObjectTree.Game.Users.getUserInfo(userID, false); userInformation Target = ObjectTree.Game.Users.getUserInfo(targetUserID, false); if (Caster != null && Target != null) { if (Caster.Role > Target.Role) // Able to ban this user { if (banHours >= 2 && banHours <= 100000 && !(banHours >= 168 && !Caster.hasFuseRight("fuse_superban"))) // Ban condition valid { userAccessInformation lastAccess = null; Session targetSession = ObjectTree.Game.Users.getUserSession(targetUserID); #region Determine last access if (targetSession == null) { lastAccess = ObjectTree.Game.Users.getLastAccess(targetUserID); } else { lastAccess = targetSession.Access; } if ((banIP || banMachine) && lastAccess == null) { return(false); // Can't ban IP and/or machine with no access log } #endregion if (this.requestUnban(userID, targetUserID, lastAccess.IP, lastAccess.machineID)) // Removed old bans succeeded { #region Write ban entry Database dbClient = new Database(false, false); dbClient.addParameterWithValue("userid", targetUserID); dbClient.addParameterWithValue("appliedby", userID); dbClient.addParameterWithValue("expires", DateTime.Now.AddHours(banHours)); dbClient.addParameterWithValue("reason", Message); // Handle access parameters if (banIP) { dbClient.addParameterWithValue("ip", lastAccess.IP); } else { dbClient.addParameterWithValue("ip", DBNull.Value); } if (banMachine) { dbClient.addParameterWithValue("machineid", lastAccess.machineID); } else { dbClient.addParameterWithValue("machineid", DBNull.Value); } dbClient.Open(); if (!dbClient.Ready) { return(false); // Failed to write entry } dbClient.runQuery("INSERT INTO moderation_bans VALUES (@userid,@ip,@machineid,NOW(),@appliedby,@expires,@reason)"); dbClient.Close(); dbClient = null; #endregion #region Notify & disconnect affected users List <Session> toNotify = new List <Session>(); if (targetSession != null) { toNotify.Add(targetSession); } if (banIP) { ObjectTree.Sessions.addSessionsByIpToList(ref toNotify, lastAccess.IP); } serverMessage banCast = genericMessageFactory.createBanCast(Message); foreach (Session lSession in toNotify) { lSession.isValid = false; lSession.leaveRoom(true); lSession.gameConnection.sendMessage(banCast); } #endregion this.logModerationAction(userID, "ban", targetUserID, Message, extraInfo); return(true); } } } } return(false); }