public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
 {
     try
     {
         LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1));
         if (loc == null)
         {
             queue.HandleError(entry, "Invalid location!");
             return;
         }
         EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0));
         if (entity == null)
         {
             queue.HandleError(entry, "Invalid entity!");
             return;
         }
         PlayerTag player;
         if (entity.TryGetPlayer(out player))
         {
             player.Internal.player.gameObject.AddComponent <LaunchComponent>().LaunchPlayer(loc.ToVector3());
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully launched player " + TagParser.Escape(player.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!");
             }
             return;
         }
         ZombieTag zombie;
         if (entity.TryGetZombie(out zombie))
         {
             zombie.Internal.gameObject.AddComponent <LaunchComponent>().Launch(loc.ToVector3());
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully launched zombie " + TagParser.Escape(zombie.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!");
             }
             return;
         }
         AnimalTag animal;
         if (entity.TryGetAnimal(out animal))
         {
             animal.Internal.gameObject.AddComponent <LaunchComponent>().Launch(loc.ToVector3());
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully launched animal " + TagParser.Escape(animal.ToString()) + " to " + TagParser.Escape(loc.ToString()) + "!");
             }
             return;
         }
         ItemEntityTag item;
         if (entity.TryGetItem(out item))
         {
             // TODO: Find some way to teleport items, barricades, etc without voiding the InstanceID?
         }
         queue.HandleError(entry, "That entity can't be launched!");
     }
     catch (Exception ex) // TODO: Necessity?
     {
         queue.HandleError(entry, "Failed to launch entity: " + ex.ToString());
     }
 }
Exemplo n.º 2
0
 public void RemoveTag(LocationTag tag)
 {
     foreach (LocationTag t in tags)
     {
         if (t == tag)
         {
             tags.Remove(tag);
         }
     }
 }
        public override TemplateObject Handle(TagData data)
        {
            string      lname = data.GetModifier(0);
            LocationTag ltag  = LocationTag.For(lname);

            if (ltag == null)
            {
                return(new TextTag("&{NULL}").Handle(data.Shrink()));
            }
            return(ltag.Handle(data.Shrink()));
        }
Exemplo n.º 4
0
 public void AddTag(LocationTag tag)
 {
     foreach (LocationTag t in tags)
     {
         if (t == tag)
         {
             return;
         }
     }
     tags.Add(tag);
 }
Exemplo n.º 5
0
        public override TemplateObject Handle(TagData data)
        {
            string      lname = data.GetModifier(0);
            LocationTag ltag  = LocationTag.For(TheServer, data, lname);

            if (ltag == null)
            {
                data.Error("Invalid location '" + TagParser.Escape(lname) + "'!");
                return(new NullTag());
            }
            return(ltag.Handle(data.Shrink()));
        }
Exemplo n.º 6
0
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1));

            if (loc == null)
            {
                queue.HandleError(entry, "Invalid location!");
                return;
            }
            EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0));

            if (entity == null)
            {
                queue.HandleError(entry, "Invalid entity!");
                return;
            }
            ZombieTag zombie;

            if (entity.TryGetZombie(out zombie))
            {
                zombie.Internal.target.position  = loc.ToVector3();
                zombie.Internal.seeker.canMove   = true;
                zombie.Internal.seeker.canSearch = true;
                zombie.Internal.path             = EZombiePath.RUSH; // TODO: Option for this?
                if (!zombie.Internal.isTicking)
                {
                    zombie.Internal.isTicking = true;
                    ZombieManager.tickingZombies.Add(zombie.Internal);
                }
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully started a zombie walking to " + TagParser.Escape(loc.ToString()) + "!");
                }
                return;
            }
            AnimalTag animal;

            if (entity.TryGetAnimal(out animal))
            {
                animal.Internal.target = loc.ToVector3();
                if (!animal.Internal.isTicking)
                {
                    animal.Internal.isTicking = true;
                    AnimalManager.tickingAnimals.Add(animal.Internal);
                }
                if (entry.ShouldShowGood(queue))
                {
                    entry.Good(queue, "Successfully started an animal walking to " + TagParser.Escape(loc.ToString()) + "!");
                }
                return;
            }
            queue.HandleError(entry, "That entity can't be made to walk!");
        }
Exemplo n.º 7
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            // SQLite specific: Default to always using NOCASE collation
            modelBuilder.UseCollation("NOCASE");

            LocationClosure.OnModelCreating(modelBuilder);
            Location.OnModelCreating(modelBuilder);
            Photo.OnModelCreating(modelBuilder);
            ItemTag.OnModelCreating(modelBuilder);
            LocationTag.OnModelCreating(modelBuilder);
            Tag.OnModelCreating(modelBuilder);
            LocationType.OnModelCreating(modelBuilder);
            Item.OnModelCreating(modelBuilder);
        }
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1));

            if (loc == null)
            {
                queue.HandleError(entry, "Invalid location!");
                return;
            }
            string         targetAssetType = entry.GetArgument(queue, 0).ToLower();
            EffectAssetTag effectType      = EffectAssetTag.For(targetAssetType);

            if (effectType == null)
            {
                queue.HandleError(entry, "Invalid effect type!");
                return;
            }
            EffectManager.sendEffect(effectType.Internal.id, EffectManager.INSANE, loc.ToVector3());
            // TODO: radius option instead of always 512 units (INSANE)!
            if (entry.ShouldShowGood(queue))
            {
                entry.Good(queue, "Played effect " + TagParser.Escape(effectType.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!");
            }
        }
Exemplo n.º 9
0
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            try
            {
                TemplateObject spawned = null;
                LocationTag    loc     = LocationTag.For(entry.GetArgument(queue, 1));
                if (loc == null)
                {
                    queue.HandleError(entry, "Invalid location!");
                    return;
                }
                string     targetAssetType = entry.GetArgument(queue, 0).ToLowerFast();
                EntityType etype           = EntityType.ValueOf(targetAssetType);
                if (etype == null)
                {
                    queue.HandleError(entry, "Invalid entity type!");
                    return;
                }
                if (etype.Type == EntityAssetType.ZOMBIE)
                {
                    Vector3 vec3    = loc.ToVector3();
                    byte    reg     = 0; // TODO: Optionally specifiable
                    float   closest = float.MaxValue;
                    for (int r = 0; r < LevelZombies.zombies.Length; r++)
                    {
                        for (int i = 0; i < LevelZombies.zombies[r].Count; i++)
                        {
                            float dist = (LevelZombies.zombies[r][i].point - vec3).sqrMagnitude;
                            if (dist < closest)
                            {
                                closest = dist;
                                reg     = (byte)r;
                            }
                        }
                    }
                    ZombieManager.manager.addZombie(reg, 0, 0, 0, 0, 0, 0, 0, 0, vec3, 0, false);
                    Zombie zombie = ZombieManager.regions[reg].zombies[ZombieManager.regions[reg].zombies.Count - 1];
                    // TODO: Make this actually work! (See complaints file!)

                    /*
                     * foreach (SteamPlayer player in PlayerTool.getSteamPlayers())
                     * {
                     *  ZombieManager.manager.channel.openWrite();
                     *  ZombieManager.manager.channel.write(reg);
                     *  ZombieManager.manager.channel.write((ushort)1);
                     *  ZombieManager.manager.channel.write(new object[]
                     *      {
                     *          zombie.type,
                     *          (byte)zombie.speciality,
                     *          zombie.shirt,
                     *          zombie.pants,
                     *          zombie.hat,
                     *          zombie.gear,
                     *          zombie.move,
                     *          zombie.idle,
                     *          zombie.transform.position,
                     *          MeasurementTool.angleToByte(zombie.transform.rotation.eulerAngles.y),
                     *          zombie.isDead
                     *      });
                     *  ZombieManager.manager.channel.closeWrite("tellZombies", player.playerID.steamID, ESteamPacket.UPDATE_RELIABLE_CHUNK_BUFFER);
                     * }
                     */
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully spawned a zombie at " + TagParser.Escape(loc.ToString()) + "! (WARNING: IT WILL BE INVISIBLE CURRENTLY - SEE THE COMPLAINTS FILE)");
                    }
                    spawned = new ZombieTag(zombie);
                }
                else if (etype.Type == EntityAssetType.ANIMAL)
                {
                    AnimalAssetTag asset = AnimalAssetTag.For(targetAssetType);
                    if (asset == null)
                    {
                        queue.HandleError(entry, "Invalid animal type!");
                        return;
                    }
                    // TODO: Make this bit optional!
                    RaycastHit rch;
                    while (Physics.Raycast(loc.ToVector3(), new Vector3(0, 1, 0), out rch, 5))
                    {
                        loc.Y += 3;
                    }
                    // END TODO
                    AnimalManager.manager.addAnimal(asset.Internal.id, loc.ToVector3(), 0, false);
                    Animal animal = AnimalManager.animals[AnimalManager.animals.Count - 1];
                    foreach (SteamPlayer player in PlayerTool.getSteamPlayers())
                    {
                        AnimalManager.manager.channel.openWrite();
                        AnimalManager.manager.channel.write((ushort)1);
                        AnimalManager.manager.channel.write(new object[]
                        {
                            animal.id,
                            animal.transform.position,
                            MeasurementTool.angleToByte(animal.transform.rotation.eulerAngles.y),
                            animal.isDead
                        });
                        AnimalManager.manager.channel.closeWrite("tellAnimals", player.playerID.steamID, ESteamPacket.UPDATE_RELIABLE_CHUNK_BUFFER);
                    }
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "! (" + animal.gameObject.GetInstanceID() + ")");
                    }
                    spawned = new AnimalTag(animal);
                }
                else if (etype.Type == EntityAssetType.VEHICLE)
                {
                    VehicleAssetTag asset = VehicleAssetTag.For(targetAssetType);
                    if (asset == null)
                    {
                        queue.HandleError(entry, "Invalid vehicle type!");
                        return;
                    }
                    // TODO: Make this bit optional!
                    RaycastHit rch;
                    while (Physics.Raycast(loc.ToVector3(), new Vector3(0, 1, 0), out rch, 5))
                    {
                        loc.Y += 3;
                    }
                    // END TODO
                    VehicleManager.spawnVehicle(asset.Internal.id, loc.ToVector3(), Quaternion.identity);
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!");
                    }
                    // TODO: Get the vehicle entity!
                }
                else if (etype.Type == EntityAssetType.WORLD_OBJECT)
                {
                    WorldObjectAssetTag asset = WorldObjectAssetTag.For(targetAssetType);
                    if (asset == null)
                    {
                        queue.HandleError(entry, "Invalid world object type!");
                        return;
                    }
                    LevelObjects.addObject(loc.ToVector3(), Quaternion.identity, Vector3.one, asset.Internal.id, asset.Internal.name, asset.Internal.GUID, ELevelObjectPlacementOrigin.MANUAL);
                    // TODO: Network!
                    entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "! (WARNING: IT WILL BE INVISIBLE CURRENTLY - SEE THE COMPLAINTS FILE)");
                    // TODO: Get the world entity!
                }
                else if (etype.Type == EntityAssetType.ITEM)
                {
                    ItemAssetTag asset = ItemAssetTag.For(targetAssetType);
                    if (asset == null)
                    {
                        queue.HandleError(entry, "Invalid item type!");
                        return;
                    }
                    byte x;
                    byte y;
                    if (Regions.tryGetCoordinate(loc.ToVector3(), out x, out y))
                    {
                        Item     item = new Item(asset.Internal.id, 1, asset.Internal.quality);
                        ItemData data = new ItemData(item, ++ItemManager.instanceCount, loc.ToVector3(), Dedicator.isDedicated);
                        ItemManager.regions[x, y].items.Add(data);
                        ItemModelTracker.Track(data, loc.ToVector3());
                        ItemManager.manager.channel.send("tellItem", ESteamCall.CLIENTS, x, y, ItemManager.ITEM_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                        {
                            x,
                            y,
                            item.id,
                            item.amount,
                            item.quality,
                            item.state,
                            loc.ToVector3()
                        });
                        if (entry.ShouldShowGood(queue))
                        {
                            entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!");
                        }
                        // TODO: Get the item entity!
                    }
                    else
                    {
                        queue.HandleError(entry, "Trying to spawn item outside any valid item regions!");
                    }
                }
                else if (etype.Type == EntityAssetType.BARRICADE)
                {
                    ItemAssetTag asset = ItemAssetTag.For(targetAssetType.Substring("barricade_".Length));
                    if (asset == null || !(asset.Internal is ItemBarricadeAsset))
                    {
                        queue.HandleError(entry, "Invalid item barricade type!");
                        return;
                    }
                    Barricade barric = new Barricade(asset.Internal.id);
                    BarricadeManager.dropBarricade(barric, null, loc.ToVector3(), 0f, 0f, 0f, CSteamID.Nil.m_SteamID, CSteamID.Nil.m_SteamID);
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!");
                    }
                    // TODO: Get the game object!
                }
                else if (etype.Type == EntityAssetType.STRUCTURE)
                {
                    ItemAssetTag asset = ItemAssetTag.For(targetAssetType.Substring("structure_".Length));
                    if (asset == null || !(asset.Internal is ItemStructureAsset))
                    {
                        queue.HandleError(entry, "Invalid item structure type!");
                        return;
                    }
                    StructureManager.dropStructure(new Structure(asset.Internal.id), loc.ToVector3(), 0f, 0f, 0f, CSteamID.Nil.m_SteamID, CSteamID.Nil.m_SteamID);
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!");
                    }
                    // TODO: Get the game object!
                }
                else
                {
                    queue.HandleError(entry, "Invalid or unspawnable entity type!");
                    return;
                }
                if (spawned != null)
                {
                    queue.SetVariable("spawned", spawned);
                }
            }
            catch (Exception ex) // TODO: Necessity?
            {
                queue.HandleError(entry, "Failed to spawn entity: " + ex.ToString());
            }
        }
        public HttpResponseMessage SaveLocation([FromBody] LocationModel LocationModel)
        {
            int locationId = 0;

            try
            {
                if (LocationModel.CustomerId == 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Customer Id is blank"), Configuration.Formatters.JsonFormatter));
                }
                if (LocationModel.Title == null || LocationModel.Title == "")
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Title is blank"), Configuration.Formatters.JsonFormatter));
                }
                if (LocationModel.Description == null || LocationModel.Description == "")
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Description is blank"), Configuration.Formatters.JsonFormatter));
                }
                //if (LocationModel.ContactInfo == null && LocationModel.ContactInfo == "")
                //{
                //    return Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "ContactInfo is blank"), Configuration.Formatters.JsonFormatter);
                //}
                if (LocationModel.Street == null || LocationModel.Street == "")
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Street is blank"), Configuration.Formatters.JsonFormatter));
                }
                if (LocationModel.City == null || LocationModel.City == "")
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "City is blank"), Configuration.Formatters.JsonFormatter));
                }
                if (LocationModel.State == null || LocationModel.State == "")
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "State is blank"), Configuration.Formatters.JsonFormatter));
                }
                if (LocationModel.Country == null || LocationModel.Country == "")
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Country is blank"), Configuration.Formatters.JsonFormatter));
                }
                if (LocationModel.CategoryIds == null || LocationModel.CategoryIds == "")
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "CategoryIds is blank"), Configuration.Formatters.JsonFormatter));
                }
                if (LocationModel.Ratings == 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Ratings is blank"), Configuration.Formatters.JsonFormatter));
                }

                var customer = _CustomerService.GetCustomers().Where(c => c.CustomerId == LocationModel.CustomerId && c.IsActive == true).FirstOrDefault();
                if (customer != null)
                {
                    var street = _LocationService.GetLocations().Where(l => l.Street.ToLower() == LocationModel.Street.ToLower()).Distinct().ToList();
                    if (street.Count() > 0)
                    {
                        var entity1 = street.Where(l => l.City.ToLower() == LocationModel.City.ToLower()).Distinct().ToList();
                        if (entity1.Count() > 0)
                        {
                            var entity2 = street.Where(l => l.State.ToLower() == LocationModel.State.ToLower()).Distinct().ToList();
                            if (entity2.Count() > 0)
                            {
                                var entity3 = street.Where(l => l.Country.ToLower() == LocationModel.Country.ToLower()).Distinct().ToList();
                                if (entity3.Count() > 0)
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "this location already exists."), Configuration.Formatters.JsonFormatter));
                                }
                            }
                        }
                    }


                    string[] categoryIds = LocationModel.CategoryIds.Split(',');

                    List <int> CatIds = _CategoryService.GetCategories().Select(c => c.CategoryId).ToList();
                    // var CatIds = Categories.Select(c => c.CategoryId);
                    List <string> Ids       = CatIds.ConvertAll <string>(x => x.ToString());
                    bool          isMatched = true;
                    foreach (var item in categoryIds)
                    {
                        if (!Ids.Contains(item))
                        {
                            isMatched = false;
                        }
                    }
                    IEnumerable <string> difference = Ids.Except(categoryIds);
                    if (isMatched)
                    {
                        Mapper.CreateMap <Friendlier.Models.LocationModel, Friendlier.Entity.Location>();
                        Friendlier.Entity.Location location = Mapper.Map <Friendlier.Models.LocationModel, Friendlier.Entity.Location>(LocationModel);
                        //string[] contactDetails = LocationModel.ContactInfo.Split('|');
                        //location.EmailId = contactDetails[1];
                        //location.MobileNo = contactDetails[0];
                        location.EmailId     = LocationModel.EmailId;
                        location.MobileNo    = LocationModel.MobileNo;
                        location.CategoryIds = LocationModel.CategoryIds;
                        location.IsApproved  = false;
                        location.Status      = EnumValue.GetEnumDescription(EnumValue.LocationStatus.New);
                        _LocationService.InsertLocation(location);
                        locationId = location.LocationId;
                        if (LocationModel.Tags != null && LocationModel.Tags != "")
                        {
                            string[] tagList = LocationModel.Tags.Split(',');
                            foreach (var tag in tagList)
                            {
                                LocationTag locationTag = new LocationTag();
                                locationTag.LocationId = locationId;
                                locationTag.Tag        = tag;
                                _LocationTagService.InsertLocationTag(locationTag);
                            }
                        }


                        Mapper.CreateMap <Location, LocationResponseModel>();
                        LocationResponseModel model = Mapper.Map <Location, LocationResponseModel>(location);
                        model.Tags = LocationModel.Tags;
                        SendMailToAdmin(customer.FirstName, model.Title, model.Street + " " + model.City + " " + model.State + " " + model.Country);
                        //model.ContactInfo = location.MobileNo + "|" + location.EmailId;
                        return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("success", model), Configuration.Formatters.JsonFormatter));
                    }

                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Category id is wrong."), Configuration.Formatters.JsonFormatter));
                    }
                }

                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Customer id is wrong."), Configuration.Formatters.JsonFormatter));
                }
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();
                ErrorLogging.LogError(ex);
                return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Please try again."), Configuration.Formatters.JsonFormatter));
            }
        }
        public HttpResponseMessage UpdateLocation([FromBody] LocationModel LocationModel)
        {
            try
            {
                if (LocationModel.CustomerId == 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Customer Id is blank"), Configuration.Formatters.JsonFormatter));
                }
                var customer = _CustomerService.GetCustomers().Where(c => c.CustomerId == LocationModel.CustomerId && c.IsActive == true).FirstOrDefault();
                if (customer == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Customer not found."), Configuration.Formatters.JsonFormatter));
                }
                if (LocationModel.LocationId == 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Location Id is blank"), Configuration.Formatters.JsonFormatter));
                }
                var location = _LocationService.GetLocations().Where(l => l.LocationId == LocationModel.LocationId && l.CustomerId == LocationModel.CustomerId).FirstOrDefault();
                if (location == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Location not found."), Configuration.Formatters.JsonFormatter));
                }
                else
                {
                    location.Title       = ((LocationModel.Title != null && LocationModel.Title != "") ? LocationModel.Title : location.Title);
                    location.Description = ((LocationModel.Description != null && LocationModel.Description != "") ? LocationModel.Description : location.Description);
                    //if (LocationModel.ContactInfo != null && LocationModel.ContactInfo != "")
                    //{
                    //    string[] contactDetails = LocationModel.ContactInfo.Split('|');
                    //    location.EmailId = contactDetails[1];
                    //    location.MobileNo = contactDetails[0];
                    //}
                    location.EmailId  = ((LocationModel.EmailId != null && LocationModel.EmailId != "") ? LocationModel.EmailId : location.EmailId);
                    location.MobileNo = ((LocationModel.MobileNo != null && LocationModel.MobileNo != "") ? LocationModel.MobileNo : location.MobileNo);
                    location.State    = ((LocationModel.State != null && LocationModel.State != "") ? LocationModel.State : location.State);
                    location.City     = ((LocationModel.City != null && LocationModel.City != "") ? LocationModel.City : location.City);
                    location.Country  = ((LocationModel.Country != null && LocationModel.Country != "") ? LocationModel.Country : location.Country);
                    location.Street   = ((LocationModel.Street != null && LocationModel.Street != "") ? LocationModel.Street : location.Street);
                    location.Ratings  = (LocationModel.Ratings != null ? LocationModel.Ratings : location.Ratings);
                    if (LocationModel.CategoryIds != null && LocationModel.CategoryIds != "")
                    {
                        string[] categoryIds = LocationModel.CategoryIds.Split(',');

                        List <int> CatIds = _CategoryService.GetCategories().Select(c => c.CategoryId).ToList();
                        // var CatIds = Categories.Select(c => c.CategoryId);
                        List <string> Ids       = CatIds.ConvertAll <string>(x => x.ToString());
                        bool          isMatched = true;
                        foreach (var item in categoryIds)
                        {
                            if (!Ids.Contains(item))
                            {
                                isMatched = false;
                            }
                        }
                        IEnumerable <string> difference = Ids.Except(categoryIds);
                        if (isMatched)
                        {
                            location.CategoryIds = LocationModel.CategoryIds;
                        }
                        else
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Category id is wrong."), Configuration.Formatters.JsonFormatter));
                        }
                    }
                    //location.CategoryIds = ((LocationModel.CategoryIds != null && LocationModel.CategoryIds != "") ? LocationModel.CategoryIds : location.CategoryIds);

                    _LocationService.UpdateLocation(location);
                    string tags        = "";
                    var    LocationTag = _LocationTagService.GetLocationTags().Where(t => t.LocationId == location.LocationId).ToList();
                    if (LocationModel.Tags != null || LocationModel.Tags != "")
                    {
                        string[] tagList = LocationModel.Tags.Split(',');


                        if (LocationTag.Count() > 0)
                        {
                            foreach (var tag in LocationTag)
                            {
                                _LocationTagService.DeleteLocationTag(tag);
                            }
                        }
                        foreach (var tag in tagList)
                        {
                            LocationTag locationTag = new LocationTag();
                            locationTag.LocationId = location.LocationId;
                            locationTag.Tag        = tag;
                            _LocationTagService.InsertLocationTag(locationTag);
                            tags = tags + "," + tag;
                        }
                    }

                    Mapper.CreateMap <Location, LocationResponseModel>();
                    LocationResponseModel model = Mapper.Map <Location, LocationResponseModel>(location);
                    string[] categoryId         = model.CategoryIds.Split(',');
                    string   categoryNames      = "";
                    foreach (var item in categoryId)
                    {
                        var categoryName = _CategoryService.GetCategories().Where(c => c.CategoryId == Convert.ToInt32(item)).Select(c => c.Name).FirstOrDefault();
                        categoryNames = categoryNames + ',' + categoryName;
                    }
                    model.CategoryNames = categoryNames.TrimStart(',').TrimEnd(',');
                    List <string> LocationImages = new List <string>();
                    var           images         = _LocationImagesService.GetLocationImages().Where(l => l.LocationId == location.LocationId).ToList();
                    if (images.Count() > 0)
                    {
                        foreach (var image in images)
                        {
                            LocationImages.Add(image.ImagePath);
                        }
                    }
                    model.LocationImages = LocationImages;

                    model.Tags = tags.TrimStart(',').TrimEnd(',');
                    // model.ContactInfo = location.MobileNo + "|" + location.EmailId;
                    return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("success", model), Configuration.Formatters.JsonFormatter));
                }
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();
                ErrorLogging.LogError(ex);
                return(Request.CreateResponse(HttpStatusCode.OK, CommonCls.CreateMessage("error", "Please try again."), Configuration.Formatters.JsonFormatter));
            }
        }
Exemplo n.º 12
0
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            try
            {
                LocationTag loc = LocationTag.For(entry.GetArgument(queue, 1));
                if (loc == null)
                {
                    queue.HandleError(entry, "Invalid location!");
                    return;
                }
                EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0));
                if (entity == null)
                {
                    queue.HandleError(entry, "Invalid entity!");
                    return;
                }
                PlayerTag player;
                if (entity.TryGetPlayer(out player))
                {
                    player.Internal.player.sendTeleport(loc.ToVector3(), 0);
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully teleported a player to " + TagParser.Escape(loc.ToString()) + "!");
                    }
                    return;
                }
                ZombieTag zombie;
                if (entity.TryGetZombie(out zombie))
                {
                    zombie.Internal.transform.position = loc.ToVector3();
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully teleported a zombie to " + TagParser.Escape(loc.ToString()) + "!");
                    }
                    return;
                }
                AnimalTag animal;
                if (entity.TryGetAnimal(out animal))
                {
                    animal.Internal.transform.position = loc.ToVector3();
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully teleported an animal to " + TagParser.Escape(loc.ToString()) + "!");
                    }
                    return;
                }
                ItemEntityTag item;
                if (entity.TryGetItem(out item))
                {
                    // TODO: Find some way to teleport items, barricades, etc without voiding the InstanceID?

                    /*
                     * Transform transform = item.Internal.transform.parent;
                     * byte x;
                     * byte y;
                     * if (Regions.tryGetCoordinate(transform.position, out x, out y))
                     * {
                     *  ItemRegion region = ItemManager.regions[x, y];
                     *  for (byte i = 0; i < region.models.Count; i+)
                     *  {
                     *      if (region.models[i] == transform)
                     *      {
                     *          ItemManager.regions[x, y].items.RemoveAt(i);
                     *          ItemModelTracker.Untrack(x, y, i);
                     *          ItemManager.manager.channel.send("tellTakeItem", ESteamCall.CLIENTS, x, y, ItemManager.ITEM_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                     *          {
                     *              x,
                     *              y,
                     *              loc.ToVector3()
                     *          });
                     *          // Then respawn item at new location
                     *          break;
                     *      }
                     *  }
                     * }
                     */
                }
                queue.HandleError(entry, "That entity can't be teleported!");
            }
            catch (Exception ex) // TODO: Necessity of this?
            {
                queue.HandleError(entry, "Failed to teleport entity: " + ex.ToString());
            }
        }
Exemplo n.º 13
0
        protected EntityMapperBase()
        {
            var warehouse = new Warehouse
            {
                Id          = 16473,
                Name        = "Test Warehouse 16473",
                Description = "The test warehouse"
            };

            var tagForWarehouse = new Tag
            {
                Id = 46437
            };

            var warehouseTag = new WarehouseTag
            {
                WarehouseId = warehouse.Id,
                Warehouse   = warehouse,
                TagId       = tagForWarehouse.Id,
                Tag         = tagForWarehouse
            };

            var branch = new Branch
            {
                Id          = 27362,
                Name        = "Test Branch 27362",
                Description = "The test branch"
            };

            var tagForBranch = new Tag
            {
                Id = 57832
            };

            var branchTag = new BranchTag
            {
                BranchId = branch.Id,
                Branch   = branch,
                TagId    = tagForBranch.Id,
                Tag      = tagForBranch
            };

            var warehouseLocation = new Location
            {
                Id          = 63672,
                Name        = "Warehouse Location",
                Description = "Warehouse Street, Warehouse Land"
            };

            var tagForWarehouseLocation = new Tag
            {
                Id = 53627
            };

            var warehouseLocationTag = new LocationTag
            {
                LocationId = warehouseLocation.Id,
                Location   = warehouseLocation,
                TagId      = tagForWarehouseLocation.Id,
                Tag        = tagForWarehouseLocation
            };

            var branchLocation = new Location
            {
                Id          = 73726,
                Name        = "Branch Location",
                Description = "Branch Street, Branch Land"
            };

            var tagForBranchLocation = new Tag
            {
                Id = 53272
            };

            var branchLocationTag = new LocationTag
            {
                LocationId = branchLocation.Id,
                Location   = branchLocation,
                TagId      = tagForBranchLocation.Id,
                Tag        = tagForBranchLocation
            };

            var product = new Product
            {
                Id          = 37638,
                Name        = "Test Product",
                Description = "The test product"
            };

            var tagForProduct = new Tag
            {
                Id = 58276
            };

            var productTag = new ProductTag
            {
                ProductId = product.Id,
                Product   = product,
                TagId     = tagForProduct.Id,
                Tag       = tagForProduct
            };

            var warehouseProduct = new WarehouseProduct
            {
                Id          = 38376,
                WarehouseId = warehouse.Id,
                Warehouse   = warehouse,
                ProductId   = product.Id,
                Product     = product
            };

            var tagForWarehouseProduct = new Tag
            {
                Id = 63463
            };

            var warehouseProductTag = new WarehouseProductTag
            {
                WarehouseProductId = warehouseProduct.Id,
                WarehouseProduct   = warehouseProduct,
                TagId = tagForWarehouseProduct.Id,
                Tag   = tagForWarehouseProduct
            };

            warehouse.BranchId   = branch.Id;
            warehouse.Branch     = branch;
            warehouse.LocationId = warehouseLocation.Id;
            warehouse.Location   = warehouseLocation;
            warehouse.Tags.Add(warehouseTag);
            tagForWarehouse.Warehouses.Add(warehouseTag);
            tagForWarehouseLocation.Locations.Add(warehouseLocationTag);
            warehouseLocation.Tags.Add(warehouseLocationTag);

            branch.Location = branchLocation;
            branch.Warehouses.Add(warehouse);
            branch.Tags.Add(branchTag);
            tagForBranch.Branches.Add(branchTag);
            tagForBranchLocation.Locations.Add(branchLocationTag);
            branchLocation.Tags.Add(branchLocationTag);

            product.Tags.Add(productTag);
            tagForProduct.Products.Add(productTag);

            warehouse.Products.Add(warehouseProduct);
            product.Warehouses.Add(warehouseProduct);
            warehouseProduct.Tags.Add(warehouseProductTag);
            tagForWarehouseProduct.WarehouseProducts.Add(warehouseProductTag);

            _warehouse = warehouse;
        }