示例#1
0
        private void loadTables()
        {
            //Solo en modo Debug
            var filePath =
                System.IO.Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName, "Mesas.csv");

            CsvReader reader = new CsvReader(filePath);

            var tablesDeserialize =
                (List <ResturantTable>)serializationService.Deserialize(TablesDirectory, TablesFileName);

            if (tablesDeserialize == null)
            {
                Repository.Instancia.resurantTables = reader.ReadingTables();
                serializationService.Serialize(Repository.Instancia.resurantTables, TablesDirectory, TablesFileName);
            }
            else
            {
                Repository.Instancia.resurantTables = tablesDeserialize ?? new List <ResturantTable>();
            }


            lbboxTables.BeginUpdate();

            lbboxTables.Items.Clear();

            var tables = Repository.Instancia.resurantTables;

            foreach (var table in tables)
            {
                lbboxTables.Items.Add(table.Datos);
            }
            lbboxTables.EndUpdate();
        }
示例#2
0
        public void SerializeDeserializeTest()
        {
            //Arrange

            var bufferLength = 2500;
            var buffer       = new byte[bufferLength];
            var random       = new Random();

            for (int i = 0; i < bufferLength; i++)
            {
                buffer[i] = (byte)random.Next(255);
            }
            var path = $"{Environment.CurrentDirectory}\\TempSerialization.ser";
            var serializationService = new SerializationService();

            //Act

            serializationService.Serialize(buffer, path);
            var deserializedBuffer = serializationService.Deserialize(path);

            //Assert

            CollectionAssert.AreEqual(buffer, deserializedBuffer);
            File.Delete(path);
        }
        /*
         *  Navigate<T> allows developers to navigate using a
         *  page key instead of the view type. This is accomplished by
         *  creating a custom Enum and setting up the PageKeys dict
         *  with the Key/Type pairs for your views. The dict is
         *  shared by all NavigationServices and is stored in
         *  the BootStrapper (or Application) of the app.
         *
         *  Implementation example:
         *
         *  // define your Enum
         *  public Enum Pages { MainPage, DetailPage }
         *
         *  // setup the keys dict
         *  var keys = BootStrapper.PageKeys<Views>();
         *  keys.Add(Pages.MainPage, typeof(Views.MainPage));
         *  keys.Add(Pages.DetailPage, typeof(Views.DetailPage));
         *
         *  // use Navigate<T>()
         *  NavigationService.Navigate(Pages.MainPage);
         */

        // T must be the same custom Enum used with BootStrapper.PageKeys()
        public bool Navigate <T>(T key, object parameter = null, NavigationTransitionInfo infoOverride = null)
            where T : struct, IConvertible
        {
            DebugWrite($"Key: {key}, Parameter: {parameter}, NavigationTransitionInfo: {infoOverride}");

            var keys = BootStrapper.Current.PageKeys <T>();

            if (!keys.ContainsKey(key))
            {
                throw new KeyNotFoundException(key.ToString());
            }

            var page = keys[key];

            if (page.FullName.Equals(LastNavigationType))
            {
                if (parameter == LastNavigationParameter)
                {
                    return(false);
                }

                if (parameter != null && parameter.Equals(LastNavigationParameter))
                {
                    return(false);
                }
            }

            parameter = SerializationService.Serialize(parameter);
            return(FrameFacadeInternal.Navigate(page, parameter, infoOverride));
        }
示例#4
0
        public async Task <bool> NavigateAsync(Type page, object parameter = null, NavigationTransitionInfo infoOverride = null)
        {
            DebugWrite($"Page: {page}, Parameter: {parameter}, NavigationTransitionInfo: {infoOverride}");

            // serialize parameter
            var serializedParameter = default(string);

            try
            {
                serializedParameter = SerializationService.Serialize(parameter);
            }
            catch
            {
                throw new Exception("Parameter cannot be serialized. See https://github.com/Windows-XAML/Template10/wiki/Page-Parameters");
            }

            return(await NavigationOrchestratorAsync(page, parameter, NavigationMode.New, () =>
            {
                try
                {
                    return FrameFacade.Navigate(page, serializedParameter, infoOverride);
                }
                catch (Exception ex)
                {
                    // Catch and ignore exceptions
                    DebugWrite(ex.Message, Severities.Error);
                    return false;
                }
            }));
        }
示例#5
0
        public async Task <bool> NavigateAsync(Type page, object parameter = null, NavigationTransitionInfo infoOverride = null)
        {
            DebugWrite($"Page: {page}, Parameter: {parameter}, NavigationTransitionInfo: {infoOverride}");

            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }

            if ((page.FullName == LastNavigationType) && (parameter == LastNavigationParameter))
            {
                return(false);
            }

            if ((page.FullName == LastNavigationType) && (parameter?.Equals(LastNavigationParameter) ?? false))
            {
                return(false);
            }

            parameter = SerializationService.Serialize(parameter);

            await Task.CompletedTask;

            return(FrameFacadeInternal.Navigate(page, parameter, infoOverride));
        }
示例#6
0
        public async Task <bool> NavigateAsync(Type page, object parameter = null, NavigationTransitionInfo infoOverride = null)
        {
            DebugWrite($"Page: {page}, Parameter: {parameter}, NavigationTransitionInfo: {infoOverride}");

            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }

            // use CurrentPageType/Param instead of LastNavigationType/Parameter to avoid new navigation to the current
            // page in some race conditions.
            if ((page.FullName == CurrentPageType?.FullName) && (parameter == CurrentPageParam))
            {
                return(false);
            }

            if ((page.FullName == CurrentPageType?.FullName) && (parameter?.Equals(CurrentPageParam) ?? false))
            {
                return(false);
            }


            parameter = SerializationService.Serialize(parameter);

            await Task.CompletedTask;

            return(FrameFacadeInternal.Navigate(page, parameter, infoOverride));
        }
示例#7
0
        public async Task SaveAllManga(List <Manga> mangaList)
        {
            var serviceFolder = await GetServiceFolder();

            SerializationService serializer = new SerializationService();
            await serializer.Serialize(serviceFolder, _allMangaFileName, mangaList, typeof(List <Manga>));
        }
        private string SerializeClientObject(IAsyncUploadResult fileInfo, MetaData metaData)
        {
            string str  = SerializationService.Serialize(fileInfo);
            string str2 = SerializationService.Serialize(metaData, true);

            fileInfo.FileName = Path.GetFileName(fileInfo.FileName);
            return(string.Format("{{\"fileInfo\":{0}, \"metaData\":\"{1}\" }}", str, str2));
        }
示例#9
0
        public override void ExecuteResult(ControllerContext context)
        {
            HttpResponseBase response = context.HttpContext.Response;

            response.ContentEncoding = Encoding.UTF8;
            response.ContentType     = GetResponseContentType(context);

            response.Write(SerializationService.Serialize(Model, response.ContentType, Formatting));
        }
示例#10
0
        protected internal NavigationService(Frame frame)
        {
            SerializationService            = Services.SerializationService.SerializationService.Json;
            IsInMainView                    = CoreApplication.MainView == CoreApplication.GetCurrentView();
            FrameFacadeInternal             = new FrameFacade(this, frame);
            FrameFacadeInternal.Navigating += async(s, e) =>
            {
                if (e.Suspending)
                {
                    return;
                }

                var page = FrameFacadeInternal.Content as Page;
                if (page != null)
                {
                    // force (x:bind) page bindings to update
                    XamlUtils.UpdateBindings(page);

                    // call navagable override (navigating)
                    var dataContext = ResolveForPage(page);
                    if (dataContext != null)
                    {
                        // allow the viewmodel to cancel navigation
                        e.Cancel = !(await NavigatingFromAsync(page, dataContext, false, e.NavigationMode));
                        if (!e.Cancel)
                        {
                            await NavigateFromAsync(page, dataContext, false);
                        }
                    }
                }
            };
            FrameFacadeInternal.Navigated += async(s, e) =>
            {
                var parameter      = SerializationService.Deserialize(e.Parameter?.ToString());
                var currentContent = FrameFacadeInternal.Frame.Content;
                if (Equals(e.Parameter?.ToString(), SerializationService.Serialize(LastNavigationParameter)))
                {
                    parameter = LastNavigationParameter;
                }
                await this.GetDispatcherWrapper().DispatchAsync(async() =>
                {
                    try
                    {
                        if (currentContent == FrameFacadeInternal.Frame.Content)
                        {
                            await NavigateToAsync(e.NavigationMode, parameter, FrameFacadeInternal.Frame.Content);
                        }
                    }
                    catch (Exception ex)
                    {
                        DebugWrite($"DispatchAsync/NavigateToAsync {ex.Message}");
                        throw;
                    }
                }, 1);
            };
        }
示例#11
0
        private void btnDeleteOrders_Click(object sender, EventArgs e)
        {
            var sendOrdersDeserialize = (List <Orders>)serializationService.Deserialize(SendOrdersDirectory, SendOrdersFileName);
            var sendOrdersTable       = new List <Orders>();

            sendOrdersTable = sendOrdersDeserialize ?? new List <Orders>();



            lblOrders.BeginUpdate();
            lblOrders.Items.Clear();


            if (sendOrdersTable != null)
            {
                for (int i = sendOrdersTable.Count() - 1; i >= 0; i--)
                {
                    if (sendOrdersTable[i].indexTable == indexMesa.Value)
                    {
                        if (sendOrdersTable[i].indexTable == indexMesa)
                        {
                            sendOrdersTable.RemoveAt(i);
                            serializationService.Serialize(sendOrdersDeserialize, SendOrdersDirectory, SendOrdersFileName);
                            Repository.Instancia.resurantTables[indexMesa.Value].People = 0;
                            Repository.Instancia.resurantTables[indexMesa.Value].State  = tablesStates((int)States.AVAILABLE);
                            serializationService.Serialize(Repository.Instancia.resurantTables, TablesDirectory, TablesFileName);

                            btnDeleteOrders.Enabled = false;
                        }
                    }
                }
                lblOrders.EndUpdate();
                DialogResult respuest = MessageBox.Show("Sus ordenes fueron finalizadas Satisfactoriamente, Desea volver al menu principal?", "Notificacion", MessageBoxButtons.OKCancel);

                if (respuest == DialogResult.OK)
                {
                    Tables tables = new Tables();
                    this.Hide();
                    tables.Show();
                }
            }
        }
示例#12
0
 private static void CloseApp(object sender, EventArgs e)
 {
     for (int i = 0; i < Repository.Instancia.resurantTables.Count; i++)
     {
         if (Repository.Instancia.resurantTables[i].State.Contains(tablesStates((int)States.INPROCESS)))
         {
             Repository.Instancia.resurantTables[i].State = tablesStates((int)States.RESUME_PROCESS);
             serializationService.Serialize(Repository.Instancia.resurantTables, TablesDirectory, TablesFileName);
         }
     }
 }
示例#13
0
        private void HandleAddItem()
        {
            NWPlayer    player = _.GetLastDisturbed();
            NWItem      item   = _.GetInventoryDisturbItem();
            NWPlaceable device = Object.OBJECT_SELF;
            var         model  = MarketService.GetPlayerMarketData(player);

            // Serializing containers can be tricky so for the time being we'll leave them disabled.
            if (_.GetHasInventory(item) == TRUE)
            {
                ItemService.ReturnItem(player, item);
                player.SendMessage(ColorTokenService.Red("Containers cannot be sold on the market."));
                return;
            }

            // If selling an item, serialize it and store its information in the player's temporary data.
            if (model.IsSellingItem)
            {
                // Check the item's category. If one cannot be determined, the player cannot put it on the market.
                int marketCategoryID = MarketService.DetermineMarketCategory(item);
                if (marketCategoryID <= 0)
                {
                    ItemService.ReturnItem(player, item);
                    player.FloatingText("This item cannot be placed on the market.");
                    return;
                }

                model.ItemID               = item.GlobalID;
                model.ItemName             = item.Name;
                model.ItemRecommendedLevel = item.RecommendedLevel;
                model.ItemStackSize        = item.StackSize;
                model.ItemTag              = item.Tag;
                model.ItemResref           = item.Resref;
                model.ItemMarketCategoryID = marketCategoryID;
                model.ItemObject           = SerializationService.Serialize(item);
                model.SellPrice            = 0;
                model.LengthDays           = 7;

                item.Destroy();

                device.DestroyAllInventoryItems();
                device.IsLocked = false;
                model.IsReturningFromItemPicking = true;
                model.IsAccessingInventory       = false;
                DialogService.StartConversation(player, device, "MarketTerminal");
            }
            else
            {
                ItemService.ReturnItem(player, item);
            }
        }
示例#14
0
        public async Task <bool> NavigateAsync(Type page, object parameter = null, IDictionary <string, object> state = null, NavigationTransitionInfo infoOverride = null)
        {
            DebugWrite($"Page: {page}, Parameter: {parameter}, NavigationTransitionInfo: {infoOverride}");

            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }

            // use CurrentPageType/Param instead of LastNavigationType/Parameter to avoid new navigation to the current
            // page in some race conditions.
            if ((page.FullName == CurrentPageType?.FullName) && (parameter == CurrentPageParam))
            {
                return(false);
            }

            if ((page.FullName == CurrentPageType?.FullName) && (parameter?.Equals(CurrentPageParam) ?? false))
            {
                return(false);
            }

            if (state != null)
            {
                var pageState = FrameFacadeInternal.PageStateSettingsService(page, 1, parameter).Values;
                foreach (var item in state)
                {
                    pageState[item.Key] = item.Value;
                }
            }

            //var frameContent = FrameFacadeInternal.Frame.Content;
            //if (frameContent is Page current && frameContent is IDisposable disposable && page.FullName == CurrentPageType?.FullName)
            //{
            //    if (current.DataContext is INavigable dataContext)
            //    {
            //        await NavigatingFromAsync(current, page, parameter, dataContext, false, NavigationMode.Refresh);
            //        await NavigateFromAsync(current, dataContext, false);
            //    }

            //    await NavigateToAsync(NavigationMode.Refresh, parameter, current);

            //    FrameFacade.CurrentPageParam = parameter;
            //    FrameFacade.Frame.BackStack.Add(new PageStackEntry(page, SerializationService.Serialize(CurrentPageParam), infoOverride));
            //    return true;
            //}

            parameter = SerializationService.Serialize(parameter);

            return(FrameFacadeInternal.Navigate(page, parameter, infoOverride));
        }
示例#15
0
        public bool Run(params object[] args)
        {
            if (_.GetInventoryDisturbType() != _.INVENTORY_DISTURB_TYPE_ADDED)
            {
                return(false);
            }

            NWPlayer    player = _.GetLastDisturbed();
            NWPlaceable device = Object.OBJECT_SELF;
            NWItem      item   = _.GetInventoryDisturbItem();

            // Check the item type to see if it's valid.
            if (!IsValidItemType(item))
            {
                ItemService.ReturnItem(player, item);
                player.SendMessage("You cannot reassemble this item.");
                return(false);
            }

            // Only crafted items can be reassembled.
            if (string.IsNullOrWhiteSpace(item.GetLocalString("CRAFTER_PLAYER_ID")))
            {
                ItemService.ReturnItem(player, item);
                player.SendMessage("Only crafted items may be reassembled.");
                return(false);
            }

            // DMs cannot reassemble because they don't have the necessary DB records.
            if (player.IsDM)
            {
                ItemService.ReturnItem(player, item);
                player.SendMessage("DMs cannot reassemble items at this time.");
                return(false);
            }

            // Serialize the item into a string and store it into the temporary data for this player. Destroy the physical item.
            var model = CraftService.GetPlayerCraftingData(player);

            model.SerializedSalvageItem = SerializationService.Serialize(item);
            item.Destroy();

            // Start the Molecular Reassembly conversation.
            DialogService.StartConversation(player, device, "MolecularReassembly");

            return(true);
        }
示例#16
0
        protected internal NavigationService(Frame frame)
        {
            SerializationService            = Services.SerializationService.SerializationService.Json;
            IsInMainView                    = CoreApplication.MainView == CoreApplication.GetCurrentView();
            FrameFacadeInternal             = new FrameFacade(this, frame);
            FrameFacadeInternal.Navigating += async(s, e) =>
            {
                if (e.Suspending)
                {
                    return;
                }

                // allow the viewmodel to cancel navigation
                e.Cancel = !(await NavigatingFromAsync(false, e.NavigationMode));
                if (!e.Cancel)
                {
                    await NavigateFromAsync(false);
                }
            };
            FrameFacadeInternal.Navigated += async(s, e) =>
            {
                var parameter      = SerializationService.Deserialize(e.Parameter?.ToString());
                var currentContent = FrameFacadeInternal.Frame.Content;
                if (Equals(e.Parameter?.ToString(), SerializationService.Serialize(LastNavigationParameter)))
                {
                    parameter = LastNavigationParameter;
                }
                await this.GetDispatcherWrapper().DispatchAsync(async() =>
                {
                    try
                    {
                        if (currentContent == FrameFacadeInternal.Frame.Content)
                        {
                            await NavigateToAsync(e.NavigationMode, parameter, FrameFacadeInternal.Frame.Content);
                        }
                    }
                    catch (Exception ex)
                    {
                        DebugWrite($"DispatchAsync/NavigateToAsync {ex.Message}");
                        throw;
                    }
                }, 1);
            };
        }
示例#17
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            NWArea   area        = user.Area;
            NWPlayer player      = new NWPlayer(user);
            string   structureID = area.GetLocalString("PC_BASE_STRUCTURE_ID");

            PCBaseStructure pcbs      = DataService.Single <PCBaseStructure>(x => x.ID.ToString() == structureID);
            BaseStructure   structure = DataService.Get <BaseStructure>(pcbs.BaseStructureID);

            var dbItem = new PCBaseStructureItem
            {
                PCBaseStructureID = pcbs.ID,
                ItemGlobalID      = item.GlobalID.ToString(),
                ItemName          = item.Name,
                ItemResref        = item.Resref,
                ItemTag           = item.Tag,
                ItemObject        = SerializationService.Serialize(item)
            };

            DataService.SubmitDataChange(dbItem, DatabaseActionType.Insert);
            player.SendMessage(item.Name + " was successfully added to your ship.  Access the cargo bay via the ship's computer to remove it.");
            item.Destroy();
        }
示例#18
0
        public bool Navigate(Type page, object parameter = null, NavigationTransitionInfo infoOverride = null)
        {
            DebugWrite($"Page: {page}, Parameter: {parameter}, NavigationTransitionInfo: {infoOverride}");

            if (page == null)
            {
                throw new ArgumentNullException(nameof(page));
            }
            if (page.FullName.Equals(LastNavigationType))
            {
                if (parameter == LastNavigationParameter)
                {
                    return(false);
                }

                if (parameter != null && parameter.Equals(LastNavigationParameter))
                {
                    return(false);
                }
            }

            parameter = SerializationService.Serialize(parameter);
            return(FrameFacadeInternal.Navigate(page, parameter, infoOverride));
        }
示例#19
0
 private void button2_Click(object sender, EventArgs e)
 {
     serializationService.Serialize(texts.ToArray());
 }
示例#20
0
        public void Main()
        {
            NWPlaceable drill       = _.OBJECT_SELF;
            string      structureID = drill.GetLocalString("PC_BASE_STRUCTURE_ID");

            if (string.IsNullOrWhiteSpace(structureID))
            {
                string areaName = drill.Area.Name;
                Console.WriteLine("There was an error retrieving the PC_BASE_STRUCTURE_ID variable on drill in area: " + areaName);
                return;
            }

            Guid            structureGUID = new Guid(structureID);
            PCBaseStructure pcStructure   = DataService.PCBaseStructure.GetByID(structureGUID);
            PCBase          pcBase        = DataService.PCBase.GetByID(pcStructure.PCBaseID);
            PCBaseStructure tower         = BaseService.GetBaseControlTower(pcBase.ID);

            if (tower == null)
            {
                Console.WriteLine("Could not locate valid tower in Drill OnHeartbeat. PCBaseID = " + pcBase.ID);
                return;
            }

            // Check whether there's space in this tower.
            int capacity = BaseService.CalculateResourceCapacity(pcBase.ID);
            int count    = DataService.PCBaseStructureItem.GetNumberOfItemsContainedBy(tower.ID) + 1;

            if (count > capacity)
            {
                return;
            }

            BaseStructure baseStructure = DataService.BaseStructure.GetByID(pcStructure.BaseStructureID);
            DateTime      now           = DateTime.UtcNow;

            var outOfPowerEffect = drill.Effects.SingleOrDefault(x => _.GetEffectTag(x) == "CONTROL_TOWER_OUT_OF_POWER");

            if (now >= pcBase.DateFuelEnds)
            {
                if (outOfPowerEffect == null)
                {
                    outOfPowerEffect = _.EffectVisualEffect(VisualEffect.Vfx_Dur_Aura_Red);
                    outOfPowerEffect = _.TagEffect(outOfPowerEffect, "CONTROL_TOWER_OUT_OF_POWER");
                    _.ApplyEffectToObject(DurationType.Permanent, outOfPowerEffect, drill);
                }

                return;
            }
            else if (now < pcBase.DateFuelEnds && outOfPowerEffect != null)
            {
                _.RemoveEffect(drill, outOfPowerEffect);
            }

            int minuteReduce    = 2 * pcStructure.StructureBonus;
            int increaseMinutes = 60 - minuteReduce;
            int retrievalRating = baseStructure.RetrievalRating;

            if (increaseMinutes <= 20)
            {
                increaseMinutes = 20;
            }
            if (pcStructure.DateNextActivity == null)
            {
                pcStructure.DateNextActivity = now.AddMinutes(increaseMinutes);
                DataService.SubmitDataChange(pcStructure, DatabaseActionType.Update);
            }

            if (!(now >= pcStructure.DateNextActivity))
            {
                return;
            }

            // Time to spawn a new item and reset the timer.
            var    dbArea      = DataService.Area.GetByResref(pcBase.AreaResref);
            string sector      = pcBase.Sector;
            int    lootTableID = 0;

            switch (sector)
            {
            case "NE": lootTableID = dbArea.NortheastLootTableID ?? 0; break;

            case "NW": lootTableID = dbArea.NorthwestLootTableID ?? 0; break;

            case "SE": lootTableID = dbArea.SoutheastLootTableID ?? 0; break;

            case "SW": lootTableID = dbArea.SouthwestLootTableID ?? 0; break;
            }

            if (lootTableID <= 0)
            {
                Console.WriteLine("WARNING: Loot table ID not defined for area " + dbArea.Name + ". Drills cannot retrieve items.");
                return;
            }

            pcStructure.DateNextActivity = now.AddMinutes(increaseMinutes);

            var controlTower = BaseService.GetBaseControlTower(pcStructure.PCBaseID);

            if (controlTower == null)
            {
                Console.WriteLine("Could not locate control tower in drill heartbeat. PCBaseID = " + pcStructure.PCBaseID);
                return;
            }

            var itemDetails = LootService.PickRandomItemFromLootTable(lootTableID);

            var    tempStorage = _.GetObjectByTag("TEMP_ITEM_STORAGE");
            NWItem item        = _.CreateItemOnObject(itemDetails.Resref, tempStorage, itemDetails.Quantity);

            // Guard against invalid resrefs and missing items.
            if (!item.IsValid)
            {
                Console.WriteLine("ERROR: Could not create base drill item with resref '" + itemDetails.Resref + "'. Is this item valid?");
                return;
            }

            if (!string.IsNullOrWhiteSpace(itemDetails.SpawnRule))
            {
                var rule = SpawnService.GetSpawnRule(itemDetails.SpawnRule);
                rule.Run(item, retrievalRating);
            }

            var dbItem = new PCBaseStructureItem
            {
                PCBaseStructureID = controlTower.ID,
                ItemGlobalID      = item.GlobalID.ToString(),
                ItemName          = item.Name,
                ItemResref        = item.Resref,
                ItemTag           = item.Tag,
                ItemObject        = SerializationService.Serialize(item)
            };

            DataService.SubmitDataChange(pcStructure, DatabaseActionType.Update);
            DataService.SubmitDataChange(dbItem, DatabaseActionType.Insert);
            item.Destroy();
        }
示例#21
0
        public void Main()
        {
            NWPlayer    oPC           = (_.GetLastDisturbed());
            NWItem      item          = (_.GetInventoryDisturbItem());
            NWPlaceable container     = (NWGameObject.OBJECT_SELF);
            int         disturbType   = _.GetInventoryDisturbType();
            var         structureID   = new Guid(container.GetLocalString("PC_BASE_STRUCTURE_ID"));
            var         structure     = DataService.PCBaseStructure.GetByID(structureID);
            var         baseStructure = DataService.BaseStructure.GetByID(structure.BaseStructureID);
            int         itemLimit     = baseStructure.Storage + structure.StructureBonus;

            int    itemCount  = container.InventoryItems.Count();
            string itemResref = item.Resref;

            if (disturbType == _.INVENTORY_DISTURB_TYPE_ADDED)
            {
                if (_.GetHasInventory(item) == _.TRUE)
                {
                    item.SetLocalInt("RETURNING_ITEM", _.TRUE);
                    ItemService.ReturnItem(oPC, item);
                    oPC.SendMessage(ColorTokenService.Red("Containers cannot currently be stored inside banks."));
                    return;
                }

                if (itemCount > itemLimit)
                {
                    ItemService.ReturnItem(oPC, item);
                    oPC.SendMessage(ColorTokenService.Red("No more items can be placed inside."));
                }
                else if (item.BaseItemType == _.BASE_ITEM_GOLD)
                {
                    ItemService.ReturnItem(oPC, item);
                    oPC.SendMessage(ColorTokenService.Red("Credits cannot be placed inside."));
                }
                else
                {
                    PCBaseStructureItem itemEntity = new PCBaseStructureItem
                    {
                        ItemName          = item.Name,
                        ItemResref        = itemResref,
                        ItemTag           = item.Tag,
                        PCBaseStructureID = structureID,
                        ItemGlobalID      = item.GlobalID.ToString(),
                        ItemObject        = SerializationService.Serialize(item)
                    };
                    DataService.SubmitDataChange(itemEntity, DatabaseActionType.Insert);
                    MessageHub.Instance.Publish(new OnStoreStructureItem(oPC, itemEntity));
                }
            }
            else if (disturbType == _.INVENTORY_DISTURB_TYPE_REMOVED)
            {
                if (item.GetLocalInt("RETURNING_ITEM") == _.TRUE)
                {
                    item.DeleteLocalInt("RETURNING_ITEM");
                }
                else
                {
                    var dbItem = DataService.PCBaseStructureItem.GetByItemGlobalID(item.GlobalID.ToString());
                    DataService.SubmitDataChange(dbItem, DatabaseActionType.Delete);
                    MessageHub.Instance.Publish(new OnRemoveStructureItem(oPC, dbItem));
                }
            }

            oPC.SendMessage(ColorTokenService.White("Item Limit: " + itemCount + " / ") + ColorTokenService.Red(itemLimit.ToString()));
        }
示例#22
0
        private void HandleSaveOutfit(int responseID)
        {
            NWPlayer oPC      = GetPC();
            NWItem   oClothes = (_.GetItemInSlot(INVENTORY_SLOT_CHEST, oPC.Object));

            if (!CanModifyClothes())
            {
                oPC.FloatingText("You cannot save your currently equipped clothes.");
                return;
            }

            PCOutfit entity = GetPlayerOutfits(oPC);
            var      action = DatabaseActionType.Update;

            if (entity == null)
            {
                entity = new PCOutfit
                {
                    PlayerID = oPC.GlobalID
                };
                action = DatabaseActionType.Insert;
            }

            if (!oClothes.IsValid)
            {
                oPC.FloatingText(ColorTokenService.Red("You do not have clothes equipped"));
                return;
            }

            string clothesData = SerializationService.Serialize(oClothes);

            if (responseID == 1)
            {
                entity.Outfit1 = clothesData;
            }
            else if (responseID == 2)
            {
                entity.Outfit2 = clothesData;
            }
            else if (responseID == 3)
            {
                entity.Outfit3 = clothesData;
            }
            else if (responseID == 4)
            {
                entity.Outfit4 = clothesData;
            }
            else if (responseID == 5)
            {
                entity.Outfit5 = clothesData;
            }
            else if (responseID == 6)
            {
                entity.Outfit6 = clothesData;
            }
            else if (responseID == 7)
            {
                entity.Outfit7 = clothesData;
            }
            else if (responseID == 8)
            {
                entity.Outfit8 = clothesData;
            }
            else if (responseID == 9)
            {
                entity.Outfit9 = clothesData;
            }
            else if (responseID == 10)
            {
                entity.Outfit10 = clothesData;
            }

            DataService.SubmitDataChange(entity, action);
            ShowSaveOutfitOptions();
        }
示例#23
0
        public void Main()
        {
            NWPlaceable terminal = OBJECT_SELF;
            int         bankID   = terminal.GetLocalInt("BANK_ID");

            if (bankID <= 0)
            {
                return;
            }

            NWPlayer player      = GetLastDisturbed();
            NWItem   item        = GetInventoryDisturbItem();
            var      disturbType = GetInventoryDisturbType();
            int      itemCount   = terminal.InventoryItems.Count();
            int      itemLimit   = terminal.GetLocalInt("BANK_LIMIT");

            if (itemLimit <= 0)
            {
                itemLimit = 20;
            }

            if (disturbType == DisturbType.Added)
            {
                if (GetHasInventory(item) == true)
                {
                    SetLocalBool(item, "RETURNING_ITEM", true);
                    ItemService.ReturnItem(player, item);
                    player.SendMessage(ColorTokenService.Red("Containers cannot currently be stored inside banks."));
                    return;
                }

                if (itemCount > itemLimit)
                {
                    ItemService.ReturnItem(player, item);
                    player.SendMessage(ColorTokenService.Red("No more items can be placed inside."));
                }
                else
                {
                    BankItem itemEntity = new BankItem
                    {
                        ItemName   = item.Name,
                        ItemTag    = item.Tag,
                        ItemResref = item.Resref,
                        ItemID     = item.GlobalID.ToString(),
                        ItemObject = SerializationService.Serialize(item),
                        BankID     = bankID,
                        PlayerID   = player.GlobalID,
                        DateStored = DateTime.UtcNow
                    };

                    DataService.SubmitDataChange(itemEntity, DatabaseActionType.Insert);
                    MessageHub.Instance.Publish(new OnStoreBankItem(player, itemEntity));
                }
            }
            else if (disturbType == DisturbType.Removed)
            {
                if (GetLocalBool(item, "RETURNING_ITEM") == true)
                {
                    item.DeleteLocalInt("RETURNING_ITEM");
                }
                else
                {
                    var record = DataService.BankItem.GetByItemID(item.GlobalID.ToString());
                    DataService.SubmitDataChange(record, DatabaseActionType.Delete);
                    MessageHub.Instance.Publish(new OnRemoveBankItem(player, record));
                }
            }

            player.SendMessage(ColorTokenService.White("Item Limit: " + (itemCount > itemLimit ? itemLimit : itemCount) + " / ") + ColorTokenService.Red("" + itemLimit));
        }
示例#24
0
        public bool Run(params object[] args)
        {
            NWPlaceable terminal = Object.OBJECT_SELF;
            int         bankID   = terminal.GetLocalInt("BANK_ID");

            if (bankID <= 0)
            {
                return(false);
            }

            NWPlayer player      = _.GetLastDisturbed();
            NWItem   item        = _.GetInventoryDisturbItem();
            int      disturbType = _.GetInventoryDisturbType();
            int      itemCount   = terminal.InventoryItems.Count();
            int      itemLimit   = terminal.GetLocalInt("BANK_LIMIT");

            if (itemLimit <= 0)
            {
                itemLimit = 20;
            }

            if (disturbType == INVENTORY_DISTURB_TYPE_ADDED)
            {
                if (_.GetHasInventory(item) == TRUE)
                {
                    item.SetLocalInt("RETURNING_ITEM", TRUE);
                    ItemService.ReturnItem(player, item);
                    player.SendMessage(ColorTokenService.Red("Containers cannot currently be stored inside banks."));
                    return(false);
                }

                if (itemCount > itemLimit)
                {
                    ItemService.ReturnItem(player, item);
                    player.SendMessage(ColorTokenService.Red("No more items can be placed inside."));
                }
                else
                {
                    BankItem itemEntity = new BankItem
                    {
                        ItemName   = item.Name,
                        ItemTag    = item.Tag,
                        ItemResref = item.Resref,
                        ItemID     = item.GlobalID.ToString(),
                        ItemObject = SerializationService.Serialize(item),
                        BankID     = bankID,
                        PlayerID   = player.GlobalID,
                        DateStored = DateTime.UtcNow
                    };

                    DataService.SubmitDataChange(itemEntity, DatabaseActionType.Insert);
                }
            }
            else if (disturbType == INVENTORY_DISTURB_TYPE_REMOVED)
            {
                if (item.GetLocalInt("RETURNING_ITEM") == TRUE)
                {
                    item.DeleteLocalInt("RETURNING_ITEM");
                }
                else
                {
                    var record = DataService.Single <BankItem>(x => x.ItemID == item.GlobalID.ToString());
                    DataService.SubmitDataChange(record, DatabaseActionType.Delete);
                }
            }

            player.SendMessage(ColorTokenService.White("Item Limit: " + (itemCount > itemLimit ? itemLimit : itemCount) + " / ") + ColorTokenService.Red("" + itemLimit));
            return(true);
        }
示例#25
0
        private void HandleSaveHelmet(int responseID)
        {
            NWPlayer oPC      = GetPC();
            NWItem   oClothes = (GetItemInSlot(InventorySlot.Head, oPC.Object));

            if (!CanModifyHelmet())
            {
                oPC.FloatingText("You cannot save your currently equipped helmet.");
                return;
            }

            PCHelmet entity = GetPlayerHelmets(oPC);
            var      action = DatabaseActionType.Update;

            if (entity == null)
            {
                entity = new PCHelmet
                {
                    PlayerID = oPC.GlobalID
                };
                action = DatabaseActionType.Insert;
            }

            if (!oClothes.IsValid)
            {
                oPC.FloatingText(ColorTokenService.Red("You do not have a helmet equipped"));
                return;
            }

            string clothesData = SerializationService.Serialize(oClothes);

            if (responseID == 1)
            {
                entity.Helmet1 = clothesData;
            }
            else if (responseID == 2)
            {
                entity.Helmet2 = clothesData;
            }
            else if (responseID == 3)
            {
                entity.Helmet3 = clothesData;
            }
            else if (responseID == 4)
            {
                entity.Helmet4 = clothesData;
            }
            else if (responseID == 5)
            {
                entity.Helmet5 = clothesData;
            }
            else if (responseID == 6)
            {
                entity.Helmet6 = clothesData;
            }
            else if (responseID == 7)
            {
                entity.Helmet7 = clothesData;
            }
            else if (responseID == 8)
            {
                entity.Helmet8 = clothesData;
            }
            else if (responseID == 9)
            {
                entity.Helmet9 = clothesData;
            }
            else if (responseID == 10)
            {
                entity.Helmet10 = clothesData;
            }

            DataService.SubmitDataChange(entity, action);
            ShowSaveHelmetOptions();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Length > 0 && cboDishes.SelectedIndex > 0 && cboDrinks.SelectedIndex > 0 && cboDessert.SelectedIndex > 0 && cboEntrees.SelectedIndex > 0)
            {
                Dishes      dish    = new Dishes(cboDishes.SelectedItem.ToString());
                Drinks      drinks  = new Drinks(cboDrinks.SelectedItem.ToString());
                Dessert     dessert = new Dessert(cboDessert.SelectedItem.ToString());
                FoodEntrees entrees = new FoodEntrees(cboEntrees.SelectedItem.ToString());
                Orders      order   = new Orders(txtName.Text, dish, dessert, entrees, drinks);
                order.indexTable = indexMesa.Value;


                var ordersDeserialize = (List <Orders>)serializationService.Deserialize(OrdersDirectory, OrdersFileName);
                var orders            = Repository.Instancia.orders;


                if (ordersDeserialize != null)
                {
                    orders = ordersDeserialize ?? new List <Orders>();
                }

                if (lboPedidos.Items.Count != Convert.ToInt32(lblOrderNo.Text))
                {
                    orders.Add(order);
                    //service.AddOrder(order, OrdersDirectory, OrdersFileName);

                    btnCancel.Enabled    = true;
                    btnSendOrder.Enabled = true;

                    lboPedidos.BeginUpdate();


                    var orderIndex = orders.IndexOf(order);

                    var OrderQuantityDeserialize = serializationService.Deserialize(OrderQuantityDirectory, OrderQuantityFileName);

                    serializationService.Serialize(orderQuantity, OrderQuantityDirectory, OrderQuantityFileName);
                    serializationService.Serialize(orders, OrdersDirectory, OrdersFileName);

                    for (int i = 0; i < 1; i++)
                    {
                        lboPedidos.Items.Add($"Nombre : {orders[orderIndex].Name} |" +
                                             $"Entrada : {orders[orderIndex].foodEntrees.Name}| Bebida :{orders[orderIndex].drinks.Name} | " +
                                             $"Plato Fuerte :{orders[orderIndex].dishes.Name} | Postre :{orders[orderIndex].dessert.Name} ");
                    }
                    lboPedidos.EndUpdate();
                    txtName.Text             = "";
                    cboDessert.SelectedIndex = 0;
                    cboDishes.SelectedIndex  = 0;
                    cboDrinks.SelectedIndex  = 0;
                    cboEntrees.SelectedIndex = 0;
                }
                else
                {
                    MessageBox.Show($"Ha llegado al limite de ordenes, envie sus ordenes para ser procesadas", "Ordenes");
                    btnSave.Enabled          = false;
                    txtName.Text             = "";
                    cboDessert.SelectedIndex = 0;
                    cboDishes.SelectedIndex  = 0;
                    cboDrinks.SelectedIndex  = 0;
                    cboEntrees.SelectedIndex = 0;
                }
            }
            else
            {
                MessageBox.Show($"No pueden existir campos vacios ", "Advertencia");
            }
        }
示例#27
0
        private void HandleSaveWeapon(int responseID)
        {
            NWPlayer oPC      = GetPC();
            NWItem   oClothes = (GetItemInSlot(InventorySlot.RightHand, oPC.Object));

            if (!CanModifyWeapon())
            {
                oPC.FloatingText("You cannot save your currently equipped Weapon.");
                return;
            }

            PCWeapon entity = GetPlayerWeapons(oPC);
            var      action = DatabaseActionType.Update;

            if (entity == null)
            {
                entity = new PCWeapon
                {
                    PlayerID = oPC.GlobalID
                };
                action = DatabaseActionType.Insert;
            }

            if (!oClothes.IsValid)
            {
                oPC.FloatingText(ColorTokenService.Red("You do not have a Weapon equipped"));
                return;
            }

            string clothesData = SerializationService.Serialize(oClothes);

            if (responseID == 1)
            {
                entity.Weapon1 = clothesData;
            }
            else if (responseID == 2)
            {
                entity.Weapon2 = clothesData;
            }
            else if (responseID == 3)
            {
                entity.Weapon3 = clothesData;
            }
            else if (responseID == 4)
            {
                entity.Weapon4 = clothesData;
            }
            else if (responseID == 5)
            {
                entity.Weapon5 = clothesData;
            }
            else if (responseID == 6)
            {
                entity.Weapon6 = clothesData;
            }
            else if (responseID == 7)
            {
                entity.Weapon7 = clothesData;
            }
            else if (responseID == 8)
            {
                entity.Weapon8 = clothesData;
            }
            else if (responseID == 9)
            {
                entity.Weapon9 = clothesData;
            }
            else if (responseID == 10)
            {
                entity.Weapon10 = clothesData;
            }

            DataService.SubmitDataChange(entity, action);
            ShowSaveWeaponOptions();
        }