예제 #1
0
 private void OnTriggerEnter(Collider other)
 {
     if (this.name.Contains("Blue") && other.name.Contains("Blue"))
     {
         Destroy(other.gameObject);
         other.gameObject.GetComponent <PacketScript>().Collider.HasPacketOnTrackingEntity = false;
         GameObject.Find("PacketFloor").GetComponent <PacketFactoryScript>().IncreasePoints();
     }
     else if (this.name.Contains("Green") && other.name.Contains("Green"))
     {
         Destroy(other.gameObject);
         other.gameObject.GetComponent <PacketScript>().Collider.HasPacketOnTrackingEntity = false;
         GameObject.Find("PacketFloor").GetComponent <PacketFactoryScript>().IncreasePoints();
     }
     else if (this.name.Contains("Red") && other.name.Contains("Red"))
     {
         Destroy(other.gameObject);
         other.gameObject.GetComponent <PacketScript>().Collider.HasPacketOnTrackingEntity = false;
         GameObject.Find("PacketFloor").GetComponent <PacketFactoryScript>().IncreasePoints();
     }
     else if (other.name.Contains("PharusTrack_"))
     {
         TrackingEntity te = GameObject.Find(other.name).GetComponent <TrackingEntity>();
         te.HasPacketOnTrackingEntity = false;
     }
 }
예제 #2
0
        public JsonResultEntity Create([FromBody] TrackingEntity trackingEntity)
        {
            TrackingBL       trackingBL = new TrackingBL();
            JsonResultEntity response   = new JsonResultEntity();

            try
            {
                var result = trackingBL.Create(trackingEntity);

                if (result.HasWarning())
                {
                    response.Message = String.Join(",", result.Warning);
                    return(response);
                }

                response.Success = true;
                response.Data    = result.Value;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                LoggerHelper.Error(ex);
            }

            return(response);
        }
예제 #3
0
        public void TestGetModifiedAttributesOnNewEntityNoAttributesSetReturnsEmptyCollection()
        {
            TrackingEntity entity = new TrackingEntity();

            var modifiesAttributes = entity.GetModifiedAttributes();

            Assert.Empty(modifiesAttributes);
        }
        public void TestGetModifiedAttributesOnNewEntityNoAttributesSetReturnsEmptyCollection()
        {
            TrackingEntity entity = new TrackingEntity();

            var modifiesAttributes = entity.GetModifiedAttributes();

            Assert.Empty(modifiesAttributes);
        }
예제 #5
0
        public TrackingEntity Create(TrackingEntity trackingEntity)
        {
            var query = @"INSERT INTO ""Tracking""(""TrackingID"",""CreatedDate"",""UserID"",""DeviceModel"",""DeviceBrand"",""DeviceID"",""UserFullname"",""UserEmail"",""Channel"",""ClientID"",""TrackingChannel"",""Params"") VALUES(@TrackingID,@CreatedDate,@UserID,@DeviceModel,@DeviceBrand,@DeviceID,@UserFullname,@UserEmail,@Channel,@ClientID,@TrackingChannel,@Params) RETURNING ""ID"";";

            int id = DbConnection.Query <int>(query, trackingEntity).Single();

            trackingEntity.ID = id;
            return(trackingEntity);
        }
예제 #6
0
        public void TestGetModifiedAttributesSetOneAttributeReturnsOneElement()
        {
            TrackingEntity entity    = new TrackingEntity();
            string         attribute = "money";

            entity[attribute] = 2.0m;
            var modifiedAttributes = entity.GetModifiedAttributes();

            Assert.Single(modifiedAttributes);
            Assert.Equal(attribute, modifiedAttributes.First());
        }
예제 #7
0
        public ResultEntity <TrackingEntity> Create(TrackingEntity trackingEntity)
        {
            var validationResult = new ResultEntity <TrackingEntity>();

            using (var trackingDA = new TrackingDA())
            {
                validationResult.Value = trackingDA.Create(trackingEntity);
            }

            return(validationResult);
        }
        public void TestGetModifiedAttributesSetOneAttributeReturnsOneElement()
        {
            TrackingEntity entity = new TrackingEntity();
            string attribute = "money";

            entity[attribute] = 2.0m;
            var modifiedAttributes = entity.GetModifiedAttributes();

            Assert.Single(modifiedAttributes);
            Assert.Equal(attribute, modifiedAttributes.First());
        }
예제 #9
0
        public int Update(TrackingEntity trackingEntity)
        {
            int affectedRows = 0;

            if (IsHaveId <TrackingEntity>(trackingEntity) == false)
            {
                var query = @"UPDATE ""Tracking"" SET ""TrackingID""=@TrackingID,""CreatedDate""=@CreatedDate,""UserID""=@UserID,""DeviceModel""=@DeviceModel,""DeviceBrand""=@DeviceBrand,""DeviceID""=@DeviceID,""UserFullname""=@UserFullname,""UserEmail""=@UserEmail,""Channel""=@Channel,""ClientID""=@ClientID,""TrackingChannel""=@TrackingChannel,""Params""=@Params WHERE ""ID""=@ID";
                affectedRows = DbConnection.Execute(query, trackingEntity);
            }

            return(affectedRows);
        }
예제 #10
0
        public async Task <bool> AddTrackingAsync(TrackingModel trackingModel)
        {
            TrackingEntity trackingEntity = _mapper.Map <TrackingEntity>(trackingModel);
            //TrackingEntity tracking = await _trackingContext.Trackings
            //    .LastOrDefaultAsync(t => t.CardId == trackingEntity.CardId);

            await _trackingContext.Trackings.AddAsync(trackingEntity);

            await _trackingContext.SaveChangesAsync();

            return(true);
        }
예제 #11
0
        public void TestSetAttributeIndexerOneTimeReturnsValue()
        {
            TrackingEntity entity         = new TrackingEntity();
            string         attributeName  = "attribute";
            decimal        attributeValue = 2.5m;

            entity[attributeName] = attributeValue;

            decimal returnedValue = (decimal)entity[attributeName];

            Assert.Equal(attributeValue, returnedValue);
        }
예제 #12
0
        public void TestToFinalEntityNoModifiedAttributesFromExistingReturnsEntityWithEmptyAttributeCollection()
        {
            Entity originalEntity = new Entity();

            originalEntity["attribute1"] = 5.0m;
            originalEntity["attribute2"] = "some string value";
            originalEntity["attribute3"] = false;
            TrackingEntity entity = new TrackingEntity(originalEntity);

            Entity finalEntity = entity.ToFinalEntity();

            Assert.Empty(finalEntity.Attributes);
        }
예제 #13
0
    //private void OnTriggerExit(Collider other)
    //{
    //    if (this._collider != null)
    //    {
    //        this._collider.HasPacketOnTrackingEntity = false;
    //        this._collider = null;
    //    }
    //}

    // Update is called once per frame
    void Update()
    {
        if (this._collider != null)
        {
            if (GameObject.Find(_collider.name).GetComponent <TrackingEntity>() == null)
            {
                _collider = null;
            }
            else
            {
                //Debug.Log(_collider.AbsolutePosition);
                this.transform.position = _collider.transform.position;
                //this.transform.localPosition = new Vector3(_collider.transform.localPosition.x, _collider.transform.localPosition.y, 0);
            }
        }
    }
        public void TestGetModifiedAttributesSetMultipleAttributeReturnsAllAttributes()
        {
            TrackingEntity entity = new TrackingEntity();
            var attributes = Enumerable
                .Range(0, 10)
                .Select(c => Tuple.Create("Attribute" + c, "Value" + c))
                .ToList();

            foreach (var attribute in attributes)
            {
                entity[attribute.Item1] = attribute.Item2;
            }

            var modifiedAttributes = entity.GetModifiedAttributes();

            Assert.Equal(attributes.Select(c => c.Item1).ToList(), modifiedAttributes);
        }
예제 #15
0
        public void TestToFinalEntityOneModifiedAttributeFromExistingReturnsEntityWithOneAttribute()
        {
            Entity originalEntity = new Entity();

            originalEntity["attribute1"] = 2.0m;
            originalEntity["attribute2"] = "some string value";
            originalEntity["attribute3"] = true;
            TrackingEntity entity = new TrackingEntity(originalEntity);

            entity["attribute1"] = 3.0m;

            Entity finalEntity = entity.ToFinalEntity();

            Assert.Single(finalEntity.Attributes);
            Assert.Equal("attribute1", finalEntity.Attributes.First().Key);
            Assert.Equal(3.0m, finalEntity.Attributes.First().Value);
        }
예제 #16
0
        public void TestGetModifiedAttributesSetMultipleAttributeReturnsAllAttributes()
        {
            TrackingEntity entity     = new TrackingEntity();
            var            attributes = Enumerable
                                        .Range(0, 10)
                                        .Select(c => Tuple.Create("Attribute" + c, "Value" + c))
                                        .ToList();

            foreach (var attribute in attributes)
            {
                entity[attribute.Item1] = attribute.Item2;
            }

            var modifiedAttributes = entity.GetModifiedAttributes();

            Assert.Equal(attributes.Select(c => c.Item1).ToList(), modifiedAttributes);
        }
        public void TestSetAttributeIndexerMultipleTimesReturnsLastValue()
        {
            TrackingEntity entity = new TrackingEntity();
            string attributeName = "attribute";
            var decimalValues = Enumerable
                .Range(0, 10)
                .Select(c => new decimal(c))
                .ToList();

            foreach (var decimalValue in decimalValues)
            {
                entity[attributeName] = decimalValue;
            }

            decimal returnedValue = (decimal)entity[attributeName];

            Assert.Equal(decimalValues.Last(), returnedValue);
        }
예제 #18
0
        public void TestSetAttributeIndexerMultipleTimesReturnsLastValue()
        {
            TrackingEntity entity        = new TrackingEntity();
            string         attributeName = "attribute";
            var            decimalValues = Enumerable
                                           .Range(0, 10)
                                           .Select(c => new decimal(c))
                                           .ToList();

            foreach (var decimalValue in decimalValues)
            {
                entity[attributeName] = decimalValue;
            }

            decimal returnedValue = (decimal)entity[attributeName];

            Assert.Equal(decimalValues.Last(), returnedValue);
        }
예제 #19
0
    private void OnTriggerEnter(Collider other)
    {
        try
        {
            TrackingEntity trackingEntity = GameObject.Find(other.gameObject.name).GetComponent <TrackingEntity>();

            if (_collider == null)
            {
                if (other.gameObject.name.Contains("PharusTrack_") && !trackingEntity.HasPacketOnTrackingEntity)
                {
                    this._collider = trackingEntity;
                    trackingEntity.HasPacketOnTrackingEntity = true;
                }
            }
        } catch (Exception ex)
        {
            Debug.LogError(ex.Message);
        }
    }
예제 #20
0
        public ResultEntity <TrackingEntity> Update(TrackingEntity trackingEntity)
        {
            var validationResult = new ResultEntity <TrackingEntity>();

            using (var trackingDA = new TrackingDA())
            {
                var resultUpdate = trackingDA.Update(trackingEntity);

                if (resultUpdate <= 0)
                {
                    validationResult.Warning.Add("Failed Updating Tracking!");
                    return(validationResult);
                }

                validationResult.Value = trackingEntity;
            }

            return(validationResult);
        }
예제 #21
0
        public void TestToFinalEntityMultipleModifiedAttributesFromExistingReturnsEntityWithSameAttributeCollection()
        {
            Entity originalEntity = new Entity();

            originalEntity["attribute1"] = 5.0m;
            originalEntity["attribute2"] = "some string value";
            originalEntity["attribute3"] = false;
            TrackingEntity entity = new TrackingEntity(originalEntity);

            var attributeUpdateValues = new List <KeyValuePair <string, object> >();

            attributeUpdateValues.Add(new KeyValuePair <string, object>("attribute1", 10.0m));
            attributeUpdateValues.Add(new KeyValuePair <string, object>("attribute3", false));

            foreach (var attributeUpdateValue in attributeUpdateValues)
            {
                entity[attributeUpdateValue.Key] = attributeUpdateValue.Value;
            }

            Entity finalEntity = entity.ToFinalEntity();

            Assert.Equal(attributeUpdateValues, finalEntity.Attributes);
        }
예제 #22
0
 /// <summary>
 /// 要更新的实体
 /// </summary>
 /// <param name="snapshot">实体快照</param>
 /// <returns>更新构建器</returns>
 public SetBuilder <T> Set(TrackingEntity <T> snapshot)
 {
     return(Set(snapshot.GetChanges()));
 }
        public void TestToFinalEntityMultipleModifiedAttributesFromExistingReturnsEntityWithSameAttributeCollection()
        {
            Entity originalEntity = new Entity();
            originalEntity["attribute1"] = 5.0m;
            originalEntity["attribute2"] = "some string value";
            originalEntity["attribute3"] = false;
            TrackingEntity entity = new TrackingEntity(originalEntity);

            var attributeUpdateValues = new List<KeyValuePair<string, object>>();
            attributeUpdateValues.Add(new KeyValuePair<string, object>("attribute1", 10.0m));
            attributeUpdateValues.Add(new KeyValuePair<string, object>("attribute3", false));

            foreach (var attributeUpdateValue in attributeUpdateValues)
            {
                entity[attributeUpdateValue.Key] = attributeUpdateValue.Value;
            }

            Entity finalEntity = entity.ToFinalEntity();

            Assert.Equal(attributeUpdateValues, finalEntity.Attributes);
        }
        public void TestSetAttributeIndexerOneTimeReturnsValue()
        {
            TrackingEntity entity = new TrackingEntity();
            string attributeName = "attribute";
            decimal attributeValue = 2.5m;

            entity[attributeName] = attributeValue;

            decimal returnedValue = (decimal) entity[attributeName];

            Assert.Equal(attributeValue, returnedValue);
        }
예제 #25
0
        public void TestGetAttributeIndexerNoAttributeValueThrowsException()
        {
            TrackingEntity entity = new TrackingEntity();

            Assert.Throws <KeyNotFoundException>(() => entity["someattribute"]);
        }
예제 #26
0
 public PacketScript(int packetId, Vector3 pos)
 {
     this._packetId         = packetId;
     this._absolutePosition = pos;
     this._collider         = null;
 }
예제 #27
0
 /// <summary>
 /// 要更新的实体
 /// </summary>
 /// <param name="entity">要更新的实体</param>
 /// <param name="refer">用于参照的实体</param>
 /// <returns>更新构建器</returns>
 public SetBuilder <T> Set(T entity, T refer)
 {
     return(Set(TrackingEntity <T> .GetChanges(entity, refer)));
 }
        public void TestGetAttributeIndexerNoAttributeValueThrowsException()
        {
            TrackingEntity entity = new TrackingEntity();

            Assert.Throws<KeyNotFoundException>(() => entity["someattribute"]);
        }
        public void TestToFinalEntityOneModifiedAttributeFromExistingReturnsEntityWithOneAttribute()
        {
            Entity originalEntity = new Entity();
            originalEntity["attribute1"] = 2.0m;
            originalEntity["attribute2"] = "some string value";
            originalEntity["attribute3"] = true;
            TrackingEntity entity = new TrackingEntity(originalEntity);
            entity["attribute1"] = 3.0m;

            Entity finalEntity = entity.ToFinalEntity();

            Assert.Single(finalEntity.Attributes);
            Assert.Equal("attribute1", finalEntity.Attributes.First().Key);
            Assert.Equal(3.0m, finalEntity.Attributes.First().Value);
        }
        public void TestToFinalEntityNoModifiedAttributesFromExistingReturnsEntityWithEmptyAttributeCollection()
        {
            Entity originalEntity = new Entity();
            originalEntity["attribute1"] = 5.0m;
            originalEntity["attribute2"] = "some string value";
            originalEntity["attribute3"] = false;
            TrackingEntity entity = new TrackingEntity(originalEntity);

            Entity finalEntity = entity.ToFinalEntity();

            Assert.Empty(finalEntity.Attributes);
        }