public string updateUserPosition(UserPosition model) { try { using (var client = new WebClient()) { var values = new NameValueCollection(); values["api_method"] = "setGPSLocation"; values["api_data"] = JsonConvert.SerializeObject(new { mobile = model.Mobile, lat = model.Latitude, lon = model.Longitude, date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); var response = client.UploadValues(model.ip, values); var responseString = Encoding.Default.GetString(response); dynamic result = JsonConvert.DeserializeObject(responseString); if (!(bool)result.IsError) { this.isError = false; this.errorMessage = result.Message; } else { this.isError = true; this.errorMessage = result.Message; } } } catch (Exception e) { this.isError = true; this.errorMessage = e.Message; } return(JsonConvert.SerializeObject(new { isError = this.isError, errorMessage = this.errorMessage })); }
public async Task UserPosition_Create_PositionName() { //setup var position = new UserPosition() { Id = 3, PositionName = "Postion Name 3", Description = "Description 33" }; _userPositionRepository.Setup(x => x.Create(It.IsAny <UserPosition>())).Callback(() => { _userPositions.Add(position); }).Returns(() => Task <UserPosition> .Factory.StartNew(() => new UserPosition() { Id = 3, PositionName = "Postion Name 3", Description = "Description 33" })); //Act var result = await _controller.Create(_mapper.Map <UserPositionRequest>(position)); //Assert var okObjectResult = result as OkObjectResult; Assert.NotNull(okObjectResult); var pos = okObjectResult.Value as UserPositionResponse; Assert.NotNull(pos); Assert.NotNull(_userPositions.FirstOrDefault(x => x.Id == position.Id)); }
public void CreateTest3() { UserPosition up = createPosition(10, 90, OrderType.开仓, TradeDirectType.卖); var ps = new PositionSummary(up, 90m); var up1 = createPosition(20, 120, OrderType.开仓, TradeDirectType.卖); ps.Update(up1, true, 120); var up2 = createPosition(5, 200, OrderType.平仓, TradeDirectType.买); ps.Update(up2, false, 200); Assert.AreEqual(25, ps.Count); // Assert.AreEqual(25, ps.ClosableCount); Assert.AreEqual(110, ps.BuyPrice); Assert.AreEqual(2750, ps.BuyTotal); Assert.AreEqual(-2250, ps.FloatProfit); Assert.AreEqual(-450, ps.CloseProfit); Assert.AreEqual(-5000, ps.TotalValue); }
public UserPosition GetUserPosition(string userId) { var result = this._dbContext.Results .FirstOrDefault(x => x.UserId == userId); var userPosition = new UserPosition(); if (result == null) { return(userPosition); } if (result.FinalPlace > 0) { userPosition.FinalPlace = result.FinalPlace.Value; } if (result.Week3Place > 0) { userPosition.Week3Place = result.Week3Place.Value; } if (result.Week2Place > 0) { userPosition.Week2Place = result.Week2Place.Value; } if (result.Week1Place > 0) { userPosition.Week1Place = result.Week1Place.Value; } return(userPosition); }
public async Task <IActionResult> Edit(int id, [Bind("PositionId,PositionName")] UserPosition userPosition) { if (id != userPosition.PositionId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userPosition); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserPositionExists(userPosition.PositionId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(PartialView("~/Areas/AppIdentity/Views/UserPosition/CreateEdit.cshtml", userPosition)); }
private void btnOk_Click(object sender, System.EventArgs e) { if (comboBoxSysPositions.SelectedItem == null) { //MessageBox.Show("System position is not selected."); MetroSetMessageBox.Show(this, "请选择坐标点位."); return; } UserPosition up = comboBoxSysPositions.SelectedItem as UserPosition; moveToLocationCmdLine.PositionName = up.Name; moveToLocationCmdLine.MoveType = up.MoveType; if (isCreating) { MsgCenter.Broadcast(Constants.MSG_FINISH_ADDING_CMD_LINE, this, moveToLocationCmdLine); } else { MsgCenter.Broadcast(Constants.MSG_FINISH_EDITING_CMD_LINE, this, moveToLocationCmdLine); } if (!this.isCreating) { if (this.moveToLocationCmdLine != null && this.moveToLocationCmdLineBackUp != null) { CompareObj.CompareField(this.moveToLocationCmdLine, this.moveToLocationCmdLineBackUp, null, this.GetType().Name, true); } } }
public int GetPositionIndex(UserPosition position) { if (PhotonNetwork.room == null) { return(0); } //Iterate through players ignoring the local player and any who aren't in the location we are moving to. Find the first available spot. bool[] takenIndexes = new bool[MultiplayerController.MAX_PLAYERS]; foreach (PhotonPlayer photonPlayer in PhotonNetwork.playerList) { if (!photonPlayer.IsLocal && photonPlayer.CustomProperties.ContainsKey("EnvironmentLocation") && (int)photonPlayer.CustomProperties["EnvironmentLocation"] == (int)position) { if (photonPlayer.CustomProperties.ContainsKey("EnvironmentPositionIndex")) { takenIndexes[(int)photonPlayer.customProperties["EnvironmentPositionIndex"]] = true; } } } for (int i = 0; i < takenIndexes.Length; i++) { if (!takenIndexes[i]) { return(i); } } return(0); }
internal static UserPosition GetUserPosition(int id) { var up = new UserPosition(); string commandText = @"select * from userposition where id = ?id"; List <MySqlParameter> parameters = new List <MySqlParameter>(); parameters.Add(new MySqlParameter("?id", id)); try { using (var conn = Utility.ObtainConn(Utility._gameDbConn)) { //MySqlDataReader reader = MySqlHelper.ExecuteReader(GlobalConfig.DbConn, CommandType.Text, commandText, parameters.ToArray()); MySqlDataReader reader = MySqlHelper.ExecuteReader(conn, CommandType.Text, commandText, parameters.ToArray()); while (reader.Read()) { up.Id = reader.GetInt32(0); up.PositionId = (int)reader["PositionId"]; up.NickName = reader["NickName"].ToString(); up.Message = reader["Message"].ToString(); up.UserId = (int)reader["UserId"]; up.SellerId = (int)reader["SellerId"]; up.Phone = reader["Phone"].ToString(); up.CreateTime = (DateTime)reader["CreateTime"]; up.PayId = (int)reader["PayId"]; up.Status = (int)reader["Status"]; } } } catch (System.Exception ex) { throw; } return(up); }
private void btnAdd_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbName.Text)) { //MessageBox.Show("Please input name."); MetroSetMessageBox.Show(this, "请输入点名称."); return; } string name = tbName.Text.Trim(); if (this.program.UserPositions.Find(x => x.Name == name) != null) { //MessageBox.Show("Name " + name + " has already existed!"); MetroSetMessageBox.Show(this, "名称 " + name + " 已经存在!"); return; } if (!tbX.IsValid || !tbY.IsValid) { //MessageBox.Show("Please input valid values."); MetroSetMessageBox.Show(this, "请输入正确的参数."); return; } PointD pos = new PointD(tbX.Value, tbY.Value); UserPosition up = new UserPosition(name, pos); up.MoveType = this.getMoveType(); this.program.UserPositions.Add(up); listBoxDefs.Items.Add(up); changed = true; string msg = string.Format("Add userPosition {0}:[{1},{2}]", name, pos.X, pos.Y); Logger.DEFAULT.Info(LogCategory.MANUAL | LogCategory.SETTING, this.GetType().Name, msg); }
UserPosition createPosition(int count, decimal price, OrderType type, TradeDirectType dir) { UserPosition up = new UserPosition { Order = new Order { Contract = new Contract { Code = "1", Name = "1", Coin = new Coin { Id = 1 } }, OrderType = type, Direction = dir, Count = count, DonePrice = price, DoneCount = count, }, Count = count, Trader = new Trader { } }; return(up); }
public void CreateTest5() { UserPosition up = createPosition(10, 90, OrderType.开仓, TradeDirectType.卖); var ps = new PositionSummary(up, 90m); var up1 = createPosition(20, 120, OrderType.开仓, TradeDirectType.卖); ps.Update(up1, true, 120); var up2 = createPosition(5, 200, OrderType.平仓, TradeDirectType.买); ps.Update(up2, false, 200); var up3 = createPosition(10, 200, OrderType.开仓, TradeDirectType.卖); ps.Update(up3, true, 200); var up4 = createPosition(15, 140, OrderType.平仓, TradeDirectType.买); ps.Update(up4, false, 140); Assert.AreEqual(20, ps.Count); // Assert.AreEqual(20, ps.ClosableCount); Assert.IsTrue(135.714m - ps.BuyPrice < 0.001m); Assert.IsTrue(2714.28m - ps.BuyTotal < 0.01m); Assert.IsTrue(-85.72m - ps.FloatProfit < 0.01m); Assert.IsTrue(-514.29m - ps.CloseProfit < 0.01m); Assert.AreEqual(-2800, ps.TotalValue); }
private void AdjacentNodes(LinkedList <Node> duplicatedMap, Node parent, UserPosition target, LinkedList <Node> queue, UserPosition start) { foreach (Point p in this.Room.RoomData.WalkDiagonal ? DiagonalMovement : NoDiagonalMovement) { if (duplicatedMap.Where(node => node.X == parent.X + p.X && node.Y == parent.Y + p.Y).Count() > 0) { Node n = duplicatedMap.Where(node => node.X == parent.X + p.X && node.Y == parent.Y + p.Y).First(); if (n.Closed) { continue; } int newCostsToStart = parent.CostsToStartPoint + 1; int newCostsToTarget = newCostsToStart + Heuristic(new Point(n.X, n.Y), new Point(target.X, target.Y)); if (queue.Contains(n) && newCostsToTarget >= n.FullCosts) { continue; } n.ParentNode = parent; n.CostsToStartPoint = newCostsToStart; n.FullCosts = newCostsToTarget; if (!queue.Contains(n)) { queue.AddLast(n); } } } }
internal static void UpdateUserPosition(UserPosition order) { string commandText = @"UPDATE userposition SET UserId = ?UserId, PositionId = ?PositionId, NickName = ?NickName, Message = ?Message, Phone = ?Phone, SellerId = ?SellerId, PayId = ?PayId, CreateTime = ?CreateTime, Status = ?Status WHERE Id = ?Id"; List <MySqlParameter> parameters = new List <MySqlParameter>(); parameters.Add(new MySqlParameter("?Id", order.Id)); parameters.Add(new MySqlParameter("?UserId", order.UserId)); parameters.Add(new MySqlParameter("?PositionId", order.PositionId)); parameters.Add(new MySqlParameter("?NickName", order.NickName)); parameters.Add(new MySqlParameter("?Message", order.Message)); parameters.Add(new MySqlParameter("?SellerId", order.SellerId)); parameters.Add(new MySqlParameter("?Phone", order.Phone)); parameters.Add(new MySqlParameter("?PayId", order.PayId)); parameters.Add(new MySqlParameter("?CreateTime", order.CreateTime)); parameters.Add(new MySqlParameter("?Status", order.Status)); MySqlHelper.ExecuteNonQuery(GlobalConfig.DbConn, CommandType.Text, commandText, parameters.ToArray()); }
public IHttpActionResult PutUserPosition(int id, UserPosition userPosition) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != userPosition.ID) { return(BadRequest()); } db.Entry(userPosition).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserPositionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <LocationSuccessResponse> AddAsync(UserLocationRequest request) { try { var position = new UserPosition { Id = Guid.NewGuid().ToString(), Latitude = request.Latitude, Longitude = request.Longitude, Date = DateTime.Now, UserId = request.UserId }; await _context.UserPositions.AddAsync(position); await _context.SaveChangesAsync(); } catch (Exception ex) { return(new LocationSuccessResponse { Success = false, Errors = new string[] { ex.Message.ToString() } }); } return(new LocationSuccessResponse { Success = true }); }
public void ShowMinorTeleportationMarkerAtTransform(UserPosition position, Transform potentialLocationsContainer) { m_MinorTeleportationContainer.SetActive(true); m_MinorTeleportationContainer.transform.position = potentialLocationsContainer.transform.position; m_MinorTeleportationContainer.transform.rotation = potentialLocationsContainer.transform.rotation; }
public int SetUserPosition(UserPosition position, Action callback = null) { if ((position == UserPosition.ThirdPartyTable || position == UserPosition.ThirdPartyRoom) && AlcoveThirdPartyExperienceController.CurrentThirdPartyExperience == null) { if (m_ThirdPartyExperienceSelectionCanvas) { m_ThirdPartyExperienceSelectionCanvas.SetActive(true); } CameraController.getInstance().PositionObjectInFrontOfCamera(m_ThirdPartyExperienceSelectionCanvas.gameObject, 1.25f); return(-1); } else { if (m_ThirdPartyExperienceSelectionCanvas) { m_ThirdPartyExperienceSelectionCanvas.SetActive(false); } } int availablePositionIndex = GetPositionIndex(position); SetUserPosition(position, availablePositionIndex, callback); if (OVRPlugin.GetSystemHeadsetType().ToString().Contains("Quest") || OVRPlugin.GetSystemHeadsetType().ToString().Contains("Rift")) { CameraController.CameraContainer.transform.position = new Vector3(CameraController.CameraContainer.transform.position.x, m_FloorHeight, CameraController.CameraContainer.transform.position.z); } return(availablePositionIndex); }
void Update() { if (changePos >= 0) { userObject = (changePos == 0) ? GameObject.Find("ExpoCyber"):GameObject.Find("user" + changePos); moveNeck = userObject.transform.Find("Armature").gameObject.transform.Find("Hips").gameObject; moveNeck = moveNeck.transform.Find("Spine").gameObject.transform.Find("Chest").gameObject; moveNeck = moveNeck.transform.Find("Neck").gameObject.transform.Find("Head").gameObject; moveNeck.transform.rotation = Quaternion.Euler(headAngle); } if (!init && act) { userPos = (UserPosition)FindObjectOfType(typeof(UserPosition)); head = (HeadMovement)FindObjectOfType(typeof(HeadMovement)); neck = head.neck; api = (ApiPdf)FindObjectOfType(typeof(ApiPdf)); init = true; SetImgUri(); } else if (act) { SetImgUri(); } if (delAct) { delAct = false; userPos.DeleteUser(delPos); } if (newAct) { Debug.Log("yonderuuu"); newAct = false; userPos.CreateUser(newPos); } string data = "{ \"topic\":\"rooms:vr_presentation\", \"ref\":1, \"payload\":{ \"token\":\"" + _token + "\", \"seat_position\": " + _seat + ", \"head_position\": { \"x\": 0, \"y\": 0, \"z\"" + ": 0 }, \"angle\": { \"x\": " + neck.transform.localEulerAngles.x + ", \"y\": " + neck.transform.localEulerAngles.y + ", \"z\": " + neck.transform.localEulerAngles.z + " },\"name\":\"" + guiContoller.username + "\"},\"event\":\"presenter:motion\"}"; if (send) { ws.Send(data); } if (Input.GetKeyUp("s") && send) { string stream = "{\"topic\":\"rooms:vr_presentation\", \"ref\":1, \"payload\":{\"user\":\"" + guiContoller.username + "\",\"body\":\"chat - message\"}, \"event\":\"new:message\"}"; ws.Send(stream); } }
/// <summary> /// 转换为用户岗位数据传输对象 /// </summary> /// <param name="entity">用户岗位实体</param> public static UserPositionDto ToDto(this UserPosition entity) { if (entity == null) { return(new UserPositionDto()); } return(entity.MapTo <UserPositionDto>()); }
public UserPosition DeleteUserPosition(UserPosition userPosition) { if (userPosition.Position.SystemPosition && userPosition.User.SystemUser) userPosition.AddInvalidValue(new InvalidValue("Cannot delete a system user's, system position", typeof(UserPosition), "", null, null, null)); else Repository.Delete(userPosition); return userPosition; }
public static OutAssignedPositionDTO Map(UserPosition userPosition) { return(new OutAssignedPositionDTO { Id = userPosition.Position.Id, Name = userPosition.Position.Name, DateOfAssignment = userPosition.DateOfAssignment }); }
public bool CreateUserCoordinate(double x, double y, int userId) { UserPosition userPosition = new UserPosition(); userPosition.X = x.ToString(); userPosition.Y = y.ToString(); userPosition.UserId = userId; _objectSearchContext.Add(userPosition); return(true); }
public static ICollection <Account> FindByPosition(UserPosition @enum) { IQueryable <Account> query = from account in DBInstance.DataContext.Accounts where account.Position.position_enum.Equals(@enum) select account; return(query.Count() > 0 ? query.ToList() : null); }
public void ShowTeleportationMarkerForPosition(UserPosition position) { Transform objectPosTransform = SetObjectPosition(m_TeleportationContainer, position, GetPositionIndex(position)); Vector3 floorPos = m_TeleportationContainer.transform.position; floorPos.y = m_FloorHeight; m_TeleportationGlow.transform.position = floorPos; m_TeleportationContainer.SetActive(true); m_TeleportationContainer.transform.rotation = objectPosTransform.transform.rotation; }
public async Task <UserMapInfo> UpdateUserPosition(User user, UserPosition userPosition) { user.Latitude = userPosition.Latitude; user.Longitude = userPosition.Longitude; var result = await userRepository.Update(user); var userMapInfo = mapper.Map <UserMapInfo>(result); return(userMapInfo); }
public void Update(UserPosition userPosition) { var result = dbTable.FirstOrDefault(x => x.Id == userPosition.Id); if (result != null) { Delete(result.Id); Create(userPosition); } }
public static List <UserPosition> GetGroupPeople() { MySql.Data.MySqlClient.MySqlConnection mySqlConnection = new MySql.Data.MySqlClient.MySqlConnection(); mySqlConnection.ConnectionString = "Server=localhost;Database=locationshare;Uid=root;Pwd=root;"; List <UserPosition> tUserPosition = new List <UserPosition>(); try { mySqlConnection.Open(); switch (mySqlConnection.State) { case System.Data.ConnectionState.Open: MySqlCommand cmd = new MySqlCommand("GetGroupPeople", mySqlConnection); cmd.CommandType = CommandType.StoredProcedure; MySqlDataReader reader = null; reader = cmd.ExecuteReader(); while (reader.Read()) { if (Convert.ToInt32(reader["RemainingTime"]) > 0 && (string)reader["UserName"] != HttpContext.Current.Session["UserName"].ToString()) { UserPosition user = new UserPosition(); user.UserName = (string)reader["UserName"]; user.Lat = (float)reader["Lat"]; user.Lon = (float)reader["Lon"]; user.RemainingTime = Convert.ToInt32(reader["RemainingTime"]); tUserPosition.Add(user); } } break; case System.Data.ConnectionState.Closed: // Connection could not be made, throw an error break; default: // Connection is actively doing something else break; } } catch (MySql.Data.MySqlClient.MySqlException mySqlException) { } catch (Exception exception) { } finally { if (mySqlConnection.State != System.Data.ConnectionState.Closed) { mySqlConnection.Close(); } } return(tUserPosition); }
public void AddOrUpdateUserPositionAjax(UserPosition userposition) { if (userposition.Id == 0) { _userpositionService.AddUserPosition(userposition); } else { _userpositionService.UpdateUserPosition(userposition); } }
public async Task <IActionResult> Create([Bind("PositionId,PositionName")] UserPosition userPosition) { if (ModelState.IsValid) { _context.Add(userPosition); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(PartialView("~/Areas/AppIdentity/Views/UserPosition/CreateEdit.cshtml", userPosition)); }
public IHttpActionResult GetUserPosition(int id) { UserPosition userPosition = db.UserPositions.Find(id); if (userPosition == null) { return(NotFound()); } return(Ok(userPosition)); }
public ActionResult UserPosition(UserPosition position) { if (new UserService().UserPosition(position.UserId, position.Longitude, position.Latitude, position.Creatime) > 0) { return(Json(new { success = "操作成功" })); } else { return(Json(new { error = "操作失败" })); } }
public void ShouldNotDeleteSystemUserPosition() { SetupDeleteUserPosition(); var userPosition = new UserPosition { User = new User { SystemUser = true }, Position = new Position { SystemPosition = true } }; Assert.IsTrue(_positionService.DeleteUserPosition(userPosition).InvalidValues.Any(), "Should not of deleted system user position"); }
public void ShouldDeleteNonSystemUserPosition() { SetupDeleteUserPosition(); var userPosition = new UserPosition { User = new User { SystemUser = false }, Position = new Position { SystemPosition = false } }; _positionService.DeleteUserPosition(userPosition); Assert.IsFalse(_positionService.DeleteUserPosition(userPosition).InvalidValues.Any(), "Should of deleted non system user position"); }
public UserPosition SaveUserPosition(UserPosition userPosition) { return ValidateAndSave(userPosition); }