Exemplo n.º 1
0
        public DataAgent <long> Add(ProductDto input)
        {
            var result = new DataAgent <long>();

            try
            {
                result.Data = DbConnection.Query <long>(
                    StoredProcedures.ProductCreate,
                    new
                {
                    input.Name, input.Price, input.Manufacturer, input.ManufacturingYear,
                    input.Depth, input.Width, input.Height, input.Weight, input.Wattage, input.Voltage,
                    input.RemovableBasket, input.EspressoType, input.SteamNozzle, input.IntegratedTimer, input.BarsOfPressure,
                    input.DetachableBlades, input.PivotingHead,
                    input.ProtectiveBumpers, input.AppControlled, input.RoomByRoomNavigation, input.CombinationNozzle,
                    input.DustCupCapacity, input.AdjustableSuction, input.WetCleaning, input.RetractableCord,
                    input.NonStickSoleplate, input.AntiDripSystem, input.SpeedSetting, input.CoolShotButton,
                    input.RemovableEndCap, input.DiffuserNozzle, input.BleachDispenser, input.Defrost, input.Grill,
                    input.ThirdRack, input.CupClips, input.SilverwareBasket, input.StemwareHolders, input.UtensilSeparator,
                    input.VibrationReduction, input.QuickWashCycle, input.CylinderCapacity,
                    input.IceMaker, input.TemperatureAlarm, input.Freezer,
                    input.RemovableTeaInfuser, input.WaterLevelWindow, input.FullCircleConnectorOnThePowerbase,
                    input.TravelBag, input.Programmable
                },
                    commandType: CommandType.StoredProcedure
                    ).SingleOrDefault();
            }
            catch (Exception ex)
            {
                result.ResponseMessage = ex.Message;
            }
            return(result);
        }
        private DataAgent <List <ProductStoreDto> > CheckProductAvailabilityForOrder(List <ProductInOrderInputModel> products, int storeid)
        {
            var availavilityCheck = new DataAgent <List <ProductStoreDto> >();

            foreach (var product in products)
            {
                availavilityCheck = _productRepo.GetAvailabilityOfProductInStore(
                    new ProductStoreDto()
                {
                    ProductId = product.ProductId, StoreId = storeid
                });
                if (availavilityCheck.ContainsData)
                {
                    if (availavilityCheck.Data[0].Quantity < product.Quantity)
                    {
                        return(new DataAgent <List <ProductStoreDto> >
                        {
                            ResponseMessage
                                = $"{nameof(product.ProductId)}" + $"{ResponseMessages.NotEnoughAmountInStorageOrderError}"
                        });
                    }
                }
            }
            return(availavilityCheck);
        }
Exemplo n.º 3
0
        public void PlayerPicksUpPieceFromTaskField()
        {
            InitGameMaster();
            var Player = GetPlayer("testGUID-0004", 10, TeamColour.blue, ActionType.PickUpPiece);

            Player.SetLocation(2, 5);

            RegisterPlayer(Player, Player.GUID);

            var piece = new Piece(PieceType.unknown, 15)
            {
                playerIdSpecified = true,
                timestamp         = DateTime.Now,
                playerId          = Player.ID,
            };

            DataAgent data = new DataAgent(Player.ID)
            {
                PlayerGUID     = Player.GUID,
                GameFinished   = false,
                PlayerLocation = Player.Location,
                Pieces         = new GameArea.GameObjects.Piece[] { new GameArea.GameObjects.Piece(piece) }
            };

            Player.GetBoard.GetTaskField(Player.Location).Piece = new GameArea.GameObjects.Piece(piece);

            // action: Player places a piece
            data.Process(Player.Controller);

            Assert.IsNotNull(Player.GetPiece);
            Assert.IsNull(Player.GetBoard.GetTaskField(Player.Location).Piece);
            Assert.AreEqual(PieceType.unknown, Player.GetPiece.Type);
        }
Exemplo n.º 4
0
        public void PlayerMovesFromTaskFieldToToRightOccupiedGoalField()
        {
            // from (2, 3) to (2, 2)
            InitGameMaster();
            var Player = GetPlayer("testGUID-0004", 10, TeamColour.blue, ActionType.Move);

            Player.SetLocation(2, 3);

            RegisterPlayer(Player, Player.GUID);

            var goalField = new GoalField(2, 2, TeamColour.blue, GoalFieldType.unknown)
            {
                playerIdSpecified = true,
                playerId          = 7,
                timestamp         = DateTime.Now,
            };

            DataAgent data = new DataAgent(Player.ID)
            {
                PlayerGUID     = guid,
                GameFinished   = false,
                PlayerLocation = Player.Location,
                Goals          = new GameArea.GameObjects.GoalField[] { new GameArea.GameObjects.GoalField(goalField) }
            };

            // action: Player moves down to (2,2)
            data.Process(Player.Controller);

            Assert.AreEqual(new GameArea.GameObjects.Location(2, 3), Player.Location);
            Assert.IsNull(Player.GetBoard.GetField(2, 3).Player);
            Assert.IsNotNull(Player.GetBoard.GetField(2, 2).Player);
            Assert.AreEqual(goalField.playerId, Player.GetBoard.GetField(2, 2).Player.ID); // check if Player has stored an encountered stranger in his board view
        }
Exemplo n.º 5
0
        public void PlayerPlacesShamPieceOnOccupiedTaskField()
        {
            InitGameMaster();
            var Player = GetPlayer("testGUID-0003", 10, TeamColour.blue, ActionType.PlacePiece);

            // equip an Player with a sham piece
            var messagePieceKnown = new Piece(PieceType.sham, 100)
            {
                timestamp = DateTime.Now,
            };

            EquipPlayerWithPiece(messagePieceKnown, Player);

            Player.SetLocation(1, 5); // we change a location of an original object

            DataAgent data = new DataAgent(Player.ID)
            {
                PlayerGUID     = guid,
                GameFinished   = false,
                PlayerLocation = Player.Location,
                Tasks          = new GameArea.GameObjects.TaskField[] { null }
            };

            Player.GetBoard.GetTaskField(Player.Location).Piece = new GameArea.GameObjects.Piece(new Piece(PieceType.unknown, 90));

            // action: Player places a piece
            data.Process(Player.Controller);

            // assert
            Assert.IsNotNull(Player.GetPiece);
            Assert.IsNotNull(Player.GetBoard.GetTaskField(Player.Location).Piece);
            Assert.AreNotEqual(Player.GetBoard.GetTaskField(Player.Location).Piece.ID, messagePieceKnown.id);
            Assert.AreEqual(messagePieceKnown.id, Player.GetPiece.ID);
        }
Exemplo n.º 6
0
        public void PlayerPicksUpFromEmptyTaskField()
        {
            InitGameMaster();
            var Player = GetPlayer("testGUID-0004", 10, TeamColour.blue, ActionType.PickUpPiece);

            Player.SetLocation(2, 5);

            RegisterPlayer(Player, Player.GUID);

            DataAgent data = new DataAgent(Player.ID)
            {
                PlayerGUID     = Player.GUID,
                GameFinished   = false,
                PlayerLocation = Player.Location,
                Pieces         = new GameArea.GameObjects.Piece[] { null }
            };

            Player.GetBoard.GetTaskField(Player.Location).Piece = null;

            // action: Player places a piece
            data.Process(Player.Controller);

            Assert.IsNull(Player.GetPiece);
            Assert.IsNull(Player.GetBoard.GetTaskField(Player.Location).Piece);
        }
        private DataAgent <decimal> CountTotalOrderBalance(List <ProductInOrderInputModel> products, long buyerId)
        {
            decimal totalCost = 0;

            var productSearchResult = new DataAgent <List <ProductDto> >();

            foreach (var product in products)
            {
                productSearchResult = _productRepo.FindProducts(new ProductSearchDto {
                    Id = product.ProductId
                });
                if (!productSearchResult.ContainsData)
                {
                    return(new DataAgent <decimal> {
                        ResponseMessage = productSearchResult.ResponseMessage
                    });
                }
                totalCost += (decimal)productSearchResult.Data[0].Price;
            }
            var buyerDto = _buyerRepository.GetBuyer(buyerId);

            if (!buyerDto.ContainsData)
            {
                return(new DataAgent <decimal> {
                    ResponseMessage = buyerDto.ResponseMessage
                });
            }
            totalCost = totalCost - ((totalCost / 100) * (buyerDto.Data.BuyerStatus.Dicscount));

            return(new DataAgent <decimal> {
                Data = totalCost
            });
        }
        public DataAgent <long> Add(OrderDto input)
        {
            var result = new DataAgent <long>();

            try
            {
                result.Data = DbConnection.Query <long>(
                    StoredProcedures.OrderCreate,
                    new
                {
                    input.StoreId, input.BuyerId, input.CreationDate,
                    input.Discount, input.DeliveryCost, input.TotalAmount,
                    input.Details,
                    PaymentTypeId = input.PaymentType.Id,
                    OrderStatusId = input.OrderStatus.Id,
                    DeliveryId    = input.DeliveryType.Id
                },
                    commandType: CommandType.StoredProcedure
                    ).SingleOrDefault();
            }
            catch (Exception ex)
            {
                result.ResponseMessage = ex.Message;
            }
            return(result);
        }
        private void HandleRequest(Socket workerSocket)
        {
            #region Get Request Data Message

            RequestDataMessage requestDataMessage = new RequestInterceptor().GetRequest(workerSocket);

            #endregion


            #region Business Logic

            var dataAgent = new DataAgent();

            // Retransmission (delegation) of data request
            string data = dataAgent.MakeRequest(requestDataMessage, _mavenEndPoint, "SECRET");

            #endregion

            #region Send Back Response Data

            dataAgent.SendResponse(workerSocket, data);

            #endregion

            workerSocket.Close();
        }
Exemplo n.º 10
0
        public void PlayerMovesFromTaskFieldOutOfBoard()
        {
            // from (4, 7) to (5, 7)
            InitGameMaster();
            var Player = GetPlayer("testGUID-0004", 10, TeamColour.blue, ActionType.Move);

            Player.SetLocation(4, 7);

            RegisterPlayer(Player, Player.GUID);

            DataAgent data = new DataAgent(Player.ID)
            {
                PlayerGUID     = guid,
                GameFinished   = false,
                PlayerLocation = Player.Location,
                Goals          = new GameArea.GameObjects.GoalField[] { }
            };

            // action: Player moves down to (5, 7)
            data.Process(Player.Controller);

            Assert.AreEqual(new GameArea.GameObjects.Location(4, 7), Player.Location);
            //Assert.IsNull(gameMaster.GetBoard.GetField(4, 7).Player);
            //Assert.IsNull(gameMaster.GetBoard.GetField(5, 7));
        }
Exemplo n.º 11
0
        public void PlayerMovesFromTaskFieldToEmptyTaskField()
        {
            // from (2, 4) to (2, 5)
            InitGameMaster();
            var Player = GetPlayer("testGUID-0004", 10, TeamColour.blue, ActionType.Move);

            Player.SetLocation(2, 4);

            RegisterPlayer(Player, Player.GUID);

            var taskField = new TaskField(2, 5)
            {
                pieceIdSpecified = true,
                pieceId          = 250,
                timestamp        = DateTime.Now,
            };

            DataAgent data = new DataAgent(Player.ID)
            {
                PlayerGUID     = guid,
                GameFinished   = false,
                PlayerLocation = new GameArea.GameObjects.Location(2, 5),
                Tasks          = new GameArea.GameObjects.TaskField[] { new GameArea.GameObjects.TaskField(taskField) }
            };

            // action: Player moves up to (2,5)
            data.Process(Player.Controller);

            // assert
            Assert.AreEqual(new GameArea.GameObjects.Location(2, 5), Player.Location);
            Assert.IsNull(Player.GetBoard.GetField(2, 4).Player);
            Assert.IsNull(Player.GetBoard.GetField(2, 5).Player);
            Assert.AreEqual(taskField.pieceId, Player.GetBoard.GetTaskField(2, 5).Piece.ID);
        }
Exemplo n.º 12
0
        static async Task RunAsync()
        {
            var dataAgent = new DataAgent();

            await dataAgent.InitializeAsync();

            var expand = NavigationHelper <Film> .Get()
                         .Include((it) => it.FilmActors.Select().Actor)
                         .Include((it) => it.FilmCategories).All();

            var queryObject = new QueryObject()
            {
                Filter = string.Format("ReleaseYear='{0}'", 2006),
                Expand = expand,
                Top    = 20,
            };

            var films = await dataAgent.DataService.From.Remote.Films.GetItemsAsync(queryObject);

            foreach (var film in films.Rows)
            {
                Console.WriteLine(film.Title);
                Console.WriteLine("=============================");
                foreach (var actor in film.FilmActors)
                {
                    Console.WriteLine(string.Format(" - {0}, {1}", actor.Actor.FirstName, actor.Actor.LastName));
                }
                Console.WriteLine();
            }

            dataAgent.DataService.ClearDataContext();

            Console.WriteLine("Done.");
        }
Exemplo n.º 13
0
        public void PlayerMovesFromTaskFieldToRightEmptyGoalField()
        {
            // from (2, 3) to (2, 2)
            InitGameMaster();
            var Player = GetPlayer("testGUID-0004", 10, TeamColour.blue, ActionType.Move);

            Player.SetLocation(2, 3);

            RegisterPlayer(Player, Player.GUID);

            var goalField = new GoalField(2, 2, TeamColour.blue, GoalFieldType.unknown)
            {
                timestamp = DateTime.Now,
            };

            DataAgent data = new DataAgent(Player.ID)
            {
                PlayerGUID     = guid,
                GameFinished   = false,
                PlayerLocation = new GameArea.GameObjects.Location(2, 2),
                Goals          = new GameArea.GameObjects.GoalField[] { new GameArea.GameObjects.GoalField(goalField) }
            };

            // action: Player moves down to (2,2)
            data.Process(Player.Controller);

            Assert.AreEqual(new GameArea.GameObjects.Location(2, 2), Player.Location);
            Assert.IsNull(Player.GetBoard.GetField(2, 3).Player);
            Assert.IsNull(Player.GetBoard.GetField(2, 2).Player);
        }
Exemplo n.º 14
0
        public void PlayerWithNormalPieceTestsPiece()
        {
            InitGameMaster();
            var Player = GetPlayer("testGUID-0002", 10, TeamColour.blue, ActionType.TestPiece);

            // equip an Player with a normal piece
            var messagePieceKnown = new Piece(PieceType.normal, 100)
            {
                timestamp = DateTime.Now,
            };

            EquipPlayerWithPiece(messagePieceKnown, Player);

            DataAgent data = new DataAgent(Player.ID)
            {
                PlayerGUID     = guid,
                GameFinished   = false,
                PlayerLocation = Player.Location,
                Pieces         = new GameArea.GameObjects.Piece[] { new GameArea.GameObjects.Piece(messagePieceKnown) }
            };

            // action
            data.Process(Player.Controller);

            // assert
            Assert.AreEqual(PieceType.normal, Player.GetPiece.Type);
        }
Exemplo n.º 15
0
        public void PlayerDiscoverySeesPlayerInGoalArea()
        {
            InitGameMaster();
            var Player = GetPlayer("testGUID-0004", 10, TeamColour.blue, ActionType.Discover);

            Player.SetLocation(1, 3);

            RegisterPlayer(Player, Player.GUID);

            List <GameArea.GameObjects.TaskField> listTask = new List <GameArea.GameObjects.TaskField>();
            List <GameArea.GameObjects.GoalField> listGoal = new List <GameArea.GameObjects.GoalField>();

            for (int i = 0; i < 6; ++i)
            {
                int xIdx = i % 3;
                int yIdx = i / 3 + 3;
                if (xIdx == 1 && yIdx == 4)
                {
                    continue;
                }
                listTask.Add(new GameArea.GameObjects.TaskField(new TaskField((uint)xIdx, (uint)yIdx)
                {
                    timestamp       = DateTime.Now,
                    distanceToPiece = i + 1, // przykladowe dystanse - tylko dla testu czy Player sobie zapisuje u siebie
                }));
            }
            for (int i = 0; i < 3; ++i)
            {
                int xIdx = i;
                int yIdx = 2;
                listGoal.Add(new GameArea.GameObjects.GoalField(new GoalField((uint)xIdx, (uint)yIdx, TeamColour.blue)
                {
                    playerIdSpecified = false,
                    timestamp         = DateTime.Now,
                }));
            }
            listGoal[1] = new GameArea.GameObjects.GoalField(new GoalField((uint)1, (uint)2, TeamColour.blue)
            {
                playerIdSpecified = true,
                playerId          = 4,
                timestamp         = DateTime.Now,
            });

            DataAgent data = new DataAgent(Player.ID)
            {
                PlayerGUID     = guid,
                GameFinished   = false,
                PlayerLocation = Player.Location,
                Tasks          = listTask.ToArray(),
                Goals          = listGoal.ToArray(),
            };

            // action: Player discovers area
            data.Process(Player.Controller);

            Assert.AreEqual(new GameArea.GameObjects.Location(1, 3), Player.Location);
            Assert.IsNotNull(Player.GetBoard.GetGoalField(1, 2).Player);
            Assert.AreEqual(4ul, Player.GetBoard.GetGoalField(1, 2).Player.ID);
        }
        public string MakeRequest(RequestDataMessage requestMessage, int discoveryTimeout)
        {
            var dataAgent = new DataAgent();

            string data = dataAgent.MakeRequest(requestMessage, ProxyEndPoint, "SECRET");

            return(data);
        }
Exemplo n.º 17
0
        public DataTable GetMobliePh(string tjbh)
        {
            string sql     = "SELECT tjbh,ph,MOBILE FROM v_tj_dh_ph where  tjbh='" + tjbh + "'";
            string strConn = System.Configuration.ConfigurationManager.AppSettings["Constr"].ToString();

            strConn = strConn + ";App=XXTJXT";
            DataAgent da1 = new DataAgent(strConn);

            return(da1.GetDataTable(sql));
        }
Exemplo n.º 18
0
 void Awake()
 {
     if (_instance == null) {
         _instance = this;
         DontDestroyOnLoad (this);
     }
     else{
         if (this != _instance)
             Destroy (this.gameObject);
     }
 }
 private ActionResult <K> MakeResponse <T, K>(DataAgent <T> result)
 {
     if (result.ContainsData)
     {
         if (result.Data == null)
         {
             return(NotFound(ResponseMessages.ValueNotFound));
         }
         return(Ok(result.Data));
     }
     return(Problem(detail: result.ResponseMessage, statusCode: 520));
 }
Exemplo n.º 20
0
        public string MakeRequest(RequestDataMessage requestMessage, int discoveryTimeout)
        {
            // Why not in constructor? Because preferred IP address can be changed be SO before MakeRequest() is called.
            _clientLocalIpAddress = Dns.GetHostAddresses(Dns.GetHostName()).FirstOrDefault();

            IPEndPoint mavenEndPoint = GetMavenEndPoint(discoveryTimeout);

            // Retrieve data from the maven node
            string data = new DataAgent().MakeRequest(requestMessage, mavenEndPoint, "SECRET");

            return(data);
        }
Exemplo n.º 21
0
        public DataTable GetZybRyxx(string tjbh, string tjcs)
        {
            StringBuilder sql = new StringBuilder("select gz,hyzk,tjbh,tjcs,xm,sfzh,csnyr,dw,dwdh,gh,bh,convert(varchar(10),tbrq,120) tbrq,lx,jws,bm,zdrq,zddw,sfqy,ccnl,jq,zq,tjnl,xyzn,lccs,zccs,sccs,yctc,sfxy,xyns,sfyj,yjsl,yjsj,qt,jtbs,dwdz,gz,ygzdwjgz,zybwhjcs,mingcheng,mzmc,hy,zyjcs,lcbx,xysjcjg,zdbz,zdjl,clyj,wjh,zgl,jsgl,xysl,dhqk,picture,zgqj,sgq,lgs,whcd,xb from v_tj_zyb_ryxx ");

            sql.Append(" where tjbh='" + tjbh + "' and tjcs='" + tjcs + "'");

            string strConn = System.Configuration.ConfigurationManager.AppSettings["Constr"].ToString();

            strConn = strConn + ";App=XXTJXT";
            DataAgent da = new DataAgent(strConn);

            return(da.GetDataTable(sql.ToString()));
        }
Exemplo n.º 22
0
        public void PlayerDiscoverySeesPiece()
        {
            InitGameMaster();
            var Player = GetPlayer("testGUID-0004", 10, TeamColour.blue, ActionType.Discover);

            Player.SetLocation(1, 5);

            RegisterPlayer(Player, Player.GUID);

            List <GameArea.GameObjects.TaskField> list = new List <GameArea.GameObjects.TaskField>();

            for (int i = 0; i < 9; ++i)
            {
                int xIdx = i % 3;
                int yIdx = i / 3 + 4;
                if (xIdx == 1 && yIdx == 5)
                {
                    continue;
                }
                list.Add(new GameArea.GameObjects.TaskField(new TaskField((uint)xIdx, (uint)yIdx)
                {
                    timestamp       = DateTime.Now,
                    distanceToPiece = i + 1, // przykladowe dystanse - tylko dla testu czy Player sobie zapisuje u siebie
                }));
            }

            list[1] = new GameArea.GameObjects.TaskField(new TaskField((uint)0, (uint)5)
            {
                pieceIdSpecified = true,
                pieceId          = 15,
                timestamp        = DateTime.Now,
                distanceToPiece  = 0,
            });

            DataAgent data = new DataAgent(Player.ID)
            {
                PlayerGUID     = guid,
                GameFinished   = false,
                PlayerLocation = Player.Location,
                Tasks          = list.ToArray(),
            };

            // action: Player discovers area
            data.Process(Player.Controller);

            Assert.AreEqual(new GameArea.GameObjects.Location(1, 5), Player.Location);
            Assert.IsNull(Player.GetBoard.GetTaskField(0, 5).Player);
            Assert.IsNotNull(Player.GetBoard.GetTaskField(0, 5).Piece);
            Assert.AreEqual(0, Player.GetBoard.GetTaskField(0, 5).DistanceToPiece);
            Assert.AreEqual(15ul, Player.GetBoard.GetTaskField(0, 5).Piece.ID);
        }
Exemplo n.º 23
0
 void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         if (this != _instance)
         {
             Destroy(this.gameObject);
         }
     }
 }
Exemplo n.º 24
0
        private void YESBtn_Click(object sender, EventArgs e)
        {
            DataAgent dataAgent = DataAgentFactory.GetDataAgent();
            DataTable dt        = dataAgent.GetExistUser(userIdTextBox.Text);

            if (dt.Rows.Count > 0)
            {
                int A = dataAgent.AddExistUser(OMWorkBench.AgentId, OMWorkBench.MangerId, userIdTextBox.Text);
                this.DialogResult = DialogResult.Yes;
            }
            else
            {
                userExistLabel.Text      = "此用户不存在!";
                userExistLabel.ForeColor = Color.Red;
            }
        }
        public void ProductIdtValidationIsCorrect(long product, DataAgent <List <ProductOutputModel> > model, string expected)
        {
            // Given

            _manager.Setup(m => m.FindProducts(new ProductSearchInputModel {
                Id = product
            })).Returns(model);
            // _manager.SetReturnsDefault(model);
            // When

            string actual = _validator.ValidateProductId(product);

            // Then
            Assert.IsTrue(model.ContainsData);
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 26
0
        public override void DeleteCmd()
        {
            DataTable       reasonTable = OMWorkBench.DataAgent.GetStateChangeReason(currentAgentId, 0);
            FrozedAgentForm frozedAgent = new FrozedAgentForm(reasonTable);

            frozedAgent.Text = "删除";
            if (frozedAgent.ShowDialog() == DialogResult.OK)
            {
                DataAgent dataAgent = DataAgentFactory.GetDataAgent();
                dataAgent.ChangeAgentSatate(OMWorkBench.AgentId, Convert.ToInt32(AgentDGV.CurrentRow.Cells["id"].Value), frozedAgent.FrozedResonStr, 2);
                _childDS.Tables["organization"].Select("id=" + currentAgentId)[0]["current_state"] = 2;
                agentBDS.Filter    += " and current_state<2";
                AgentDGV.DataSource = agentBDS;
            }
            base.DeleteCmd();
        }
Exemplo n.º 27
0
        private void CheckBtn_Click(object sender, EventArgs e)
        {
            DataAgent dataAgent = DataAgentFactory.GetDataAgent();
            DataTable dt        = dataAgent.GetExistUser(userIdTextBox.Text);

            if (dt.Rows.Count > 0)
            {
                userNameTextBox.Text     = dt.Rows[0]["nickname"].ToString();
                userExistLabel.Text      = "可以添加此用户!";
                userExistLabel.ForeColor = Color.Green;
            }
            else
            {
                userExistLabel.Text      = "此用户不存在!";
                userExistLabel.ForeColor = Color.Red;
            }
        }
Exemplo n.º 28
0
        public DataAgent <int> DeleteProductFromStore(long productId)
        {
            var result = new DataAgent <int>();

            try
            {
                result.Data = DbConnection.Query <int>(
                    StoredProcedures.ProductDeleteFromStore,
                    new { productId },
                    commandType: CommandType.StoredProcedure).
                              SingleOrDefault();
            }
            catch (Exception ex)
            {
                result.ResponseMessage = ex.Message;
            }
            return(result);
        }
Exemplo n.º 29
0
        public void PlayerWithoutPieceTestsPiece()
        {
            InitGameMaster();
            var Player = GetPlayer("testGUID-0001", 10, TeamColour.red, ActionType.TestPiece);

            RegisterPlayer(Player, Player.GUID);

            DataAgent data = new DataAgent(Player.ID)
            {
                PlayerGUID     = guid,
                GameFinished   = false,
                PlayerLocation = Player.Location
            };

            // action
            data.Process(Player.Controller);

            // assert
            Assert.IsNull(Player.GetPiece);
        }
Exemplo n.º 30
0
        public void PlayerPlacesNormalPieceOnNotOccupiedTaskField()
        {
            InitGameMaster();
            var Player = GetPlayer("testGUID-0004", 10, TeamColour.blue, ActionType.PlacePiece);

            // equip an Player with a sham piece
            var messagePieceKnown = new Piece(PieceType.normal, 100)
            {
                timestamp = DateTime.Now,
            };

            EquipPlayerWithPiece(messagePieceKnown, Player);

            Player.SetLocation(1, 5); // we change a location of an original object

            var taskField = new TaskField(1, 5)
            {
                pieceIdSpecified  = true,
                pieceId           = messagePieceKnown.id,
                playerIdSpecified = true,
                playerId          = Player.ID,
                timestamp         = DateTime.Now,
            };

            DataAgent data = new DataAgent(Player.ID)
            {
                PlayerGUID     = guid,
                GameFinished   = false,
                PlayerLocation = Player.Location,
                Tasks          = new GameArea.GameObjects.TaskField[] { new GameArea.GameObjects.TaskField(taskField) }
            };

            // action: Player places a piece
            data.Process(Player.Controller);

            // assert
            Assert.IsNull(Player.GetPiece);
            Assert.IsNotNull(Player.GetBoard.GetTaskField(Player.Location).Piece);
            Assert.AreEqual(messagePieceKnown.id, Player.GetBoard.GetTaskField(Player.Location).Piece.ID);
            //Assert.AreEqual(PieceType.normal, Player.GetBoard.GetTaskField(Player.Location).Piece.Type);
        }
Exemplo n.º 31
0
 public override void FrozedCmd()
 {
     if (mainToolStrip.Items["FrozedTSButton"].Text == "解冻")
     {
         OMWorkBench.DataAgent.ChangeAgentSatate(OMWorkBench.AgentId, currentAgentId, "解冻", 0);
         _childDS.Tables["organization"].Select("id=" + currentAgentId)[0]["current_state"] = 0;
         MessageBox.Show("已解冻!");
         SetForFrozed(true);
     }
     else
     {
         DataTable       reasonTable = OMWorkBench.DataAgent.GetStateChangeReason(currentAgentId, 0);
         FrozedAgentForm frozedAgent = new FrozedAgentForm(reasonTable);
         if (frozedAgent.ShowDialog() == DialogResult.OK)
         {
             DataAgent dataAgent = DataAgentFactory.GetDataAgent();
             dataAgent.ChangeAgentSatate(OMWorkBench.AgentId, Convert.ToInt32(AgentDGV.CurrentRow.Cells["id"].Value), frozedAgent.FrozedResonStr, 1);
             _childDS.Tables["organization"].Select("id=" + currentAgentId)[0]["current_state"] = 1;
             SetForFrozed(false);
         }
     }
 }