Esempio n. 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();
        }
Esempio n. 2
0
        private void OrderResume_Load(object sender, EventArgs e)
        {
            var sendOrdersDeserialize = (List <Orders>)serializationService.Deserialize(SendOrdersDirectory, SendOrdersFileName);

            var sendOrdersTable = new List <Orders>();
            int n = 1;

            sendOrdersTable  = sendOrdersDeserialize ?? new List <Orders>();
            lblMesa.Text     = (indexMesa.Value + n).ToString();
            lblPersonas.Text = orderQuantity.Value.ToString();

            ComboBoxItem opcionPorDefecto = new ComboBoxItem
            {
                Text  = "Seleccione un Nombre",
                Value = null
            };

            cboNames.Items.Add(opcionPorDefecto);
            if (sendOrdersTable != null)
            {
                for (int i = 0; i < sendOrdersTable.Count; i++)
                {
                    if (sendOrdersTable[i].indexTable == indexMesa.Value)
                    {
                        if (sendOrdersTable[i].indexTable == indexMesa)
                        {
                            cboNames.Items.Add(sendOrdersTable[i].Name);
                        }
                    }
                }
            }
            cboNames.SelectedItem = opcionPorDefecto;
        }
Esempio n. 3
0
        public void ShouldDeserializeValidRecord()
        {
            // act
            var marketData = service.Deserialize(GetFileInfo("1_valid_record"))
                             .Single();

            marketData.DataPointId.Should().Be(100);
            marketData.Value.Should().Be("100");
            marketData.DateTime.Should().Be(new DateTime(2017, 5, 27, 22, 0, 0)); // 2017-05-27 22:00:00
            marketData.Instrument.InstrumentId.Should().Be(100);
            marketData.Instrument.Name.Should().Be("Name1");
        }
        public void GenerateSmallFiles()
        {
            var instruments = Builder <Instrument> .CreateListOfSize(3)
                              .Build()
                              .ToList();

            var marketData = Builder <MarketData> .CreateListOfSize(10)
                             .TheFirst(3)
                             .With(x => x.Instrument = instruments[0])
                             .TheNext(4)
                             .With(x => x.Instrument = instruments[1])
                             .TheNext(3)
                             .With(x => x.Instrument = instruments[2])
                             .Build()
                             .ToList();

            var rd       = new SerializationService();
            var baseDir  = AppDomain.CurrentDomain.BaseDirectory;
            var combine  = Path.Combine(baseDir, "TestData\\in_valid_records.json");
            var fileInfo = new FileInfo(combine);

            new FileSevice().CreateFile(fileInfo);

            rd.SerializeFast(marketData, fileInfo);

            var marketDatas = rd.Deserialize(fileInfo);

            marketDatas.Count.Should().Be(10);
        }
Esempio n. 5
0
        private void FacadeNavigatingCancelEventHandler(object sender, NavigatingCancelEventArgs e)
        {
            DebugWrite();

            object parameter = null;

            try
            {
                parameter = SerializationService.Deserialize(e.Parameter?.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("Your parameter must be serializable. If it isn't, then use SessionState.", ex);
            }
            var args = new NavigatingEventArgs(e, Content as Page, parameter);

            if (NavigationModeHint != NavigationMode.New)
            {
                args.NavigationMode = NavigationModeHint;
            }
            NavigationModeHint = NavigationMode.New;
            foreach (var handler in _navigatingEventHandlers)
            {
                handler(this, args);
            }
            e.Cancel = args.Cancel;
        }
Esempio n. 6
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);
        }
        private async void FacadeNavigatingCancelEventHandler(object sender, NavigatingCancelEventArgs e)
        {
            DebugWrite();

            object parameter = null;

            try
            {
                parameter = SerializationService.Deserialize(e.Parameter?.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("Your parameter must be serializable. If it isn't, then use SessionState.", ex);
            }
            var deferral = new DeferralManager();
            var args     = new NavigatingEventArgs(deferral, e, Content as Page, e.SourcePageType, parameter, e.Parameter);

            if (NavigationModeHint != NavigationMode.New)
            {
                args.NavigationMode = NavigationModeHint;
            }
            NavigationModeHint = NavigationMode.New;
            _navigatingEventHandlers.ForEach(x => x(this, args));
            await deferral.WaitForDeferralsAsync().ConfigureAwait(false);

            e.Cancel = args.Cancel;
        }
Esempio n. 8
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);
            };
        }
Esempio n. 9
0
        public async Task <List <Manga> > GetAllManga()
        {
            var serviceFolder = await GetServiceFolder();

            SerializationService serializer = new SerializationService();

            var listManga = await serializer.Deserialize(serviceFolder, _allMangaFileName, typeof(List <Manga>)) as List <Manga>;

            return(listManga);
        }
Esempio n. 10
0
        public NavigationService(Frame frame, int session, string id)
        {
            SerializationService            = Services.Serialization.SerializationService.Json;
            IsInMainView                    = CoreApplication.MainView == CoreApplication.GetCurrentView();
            SessionId                       = session;
            FrameFacadeInternal             = new FrameFacade(this, frame, id);
            FrameFacadeInternal.Navigating += async(s, e) =>
            {
                if (e.Suspending)
                {
                    return;
                }

                var page = FrameFacadeInternal.Content as Page;
                if (page != null)
                {
                    // call navagable override (navigating)
                    var dataContext = ResolveForPage(page);
                    if (dataContext != null)
                    {
                        // allow the viewmodel to cancel navigation
                        e.Cancel = !(await NavigatingFromAsync(page, e.PageType, e.Parameter, dataContext, false, e.NavigationMode));
                        if (!e.Cancel)
                        {
                            await NavigateFromAsync(page, dataContext, false).ConfigureAwait(false);
                        }
                    }

                    if (page is IDisposable disposable)
                    {
                        disposable.Dispose();
                    }
                }
            };
            FrameFacadeInternal.Navigated += async(s, e) =>
            {
                var parameter      = SerializationService.Deserialize(e.Parameter?.ToString());
                var currentContent = FrameFacadeInternal.Frame.Content;
                //await this.GetDispatcherWrapper().DispatchAsync(async () =>
                //{
                try
                {
                    if (currentContent == FrameFacadeInternal.Frame.Content)
                    {
                        await NavigateToAsync(e.NavigationMode, parameter, FrameFacadeInternal.Frame.Content).ConfigureAwait(false);
                    }
                }
                catch (Exception ex)
                {
                    DebugWrite($"DispatchAsync/NavigateToAsync {ex.Message}");
                    throw;
                }
                //}, 1).ConfigureAwait(false);
            };
        }
        internal IAsyncUploadConfiguration GetConfiguration(string rawData)
        {
            string[] strArray = rawData.Split(new char[] { '&' });
            string   str      = strArray[0];
            Type     type     = Type.GetType(CryptoService.Decrypt(strArray[1]));
            IAsyncUploadConfiguration configuration = (IAsyncUploadConfiguration)SerializationService.Deserialize(str, type, true);

            configuration.TargetFolder     = DecryptFolder(configuration.TargetFolder);
            configuration.TempTargetFolder = DecryptFolder(configuration.TempTargetFolder);
            return(configuration);
        }
Esempio n. 12
0
        public async Task <bool> GoForwardAsync()
        {
            if (!FrameFacade.CanGoForward)
            {
                return(false);
            }
            var next      = FrameFacade.ForwardStack.FirstOrDefault();
            var parameter = SerializationService.Deserialize(next.Parameter?.ToString());

            return(await NavigationOrchestratorAsync(next.SourcePageType, parameter, NavigationMode.Forward, () =>
            {
                FrameFacade.GoForward();
                return true;
            }));
        }
Esempio n. 13
0
        public async Task <bool> GoBackAsync(NavigationTransitionInfo infoOverride = null)
        {
            if (!CanGoBack)
            {
                return(false);
            }
            var previous  = FrameFacade.BackStack.LastOrDefault();
            var parameter = SerializationService.Deserialize(previous.Parameter?.ToString());

            return(await NavigationOrchestratorAsync(previous.SourcePageType, parameter, NavigationMode.Back, () =>
            {
                FrameFacade.GoBack(infoOverride);
                return true;
            }));
        }
        void FacadeNavigatedEventHandler(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e)
        {
            DebugWrite();

            CurrentPageType  = e.SourcePageType;
            CurrentPageParam = SerializationService.Deserialize(e.Parameter?.ToString());
            var args = new NavigatedEventArgs(e, Content as Page);

            if (NavigationModeHint != NavigationMode.New)
            {
                args.NavigationMode = NavigationModeHint;
            }
            NavigationModeHint = NavigationMode.New;
            foreach (var handler in _navigatedEventHandlers)
            {
                handler(this, args);
            }
        }
Esempio n. 15
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);
            };
        }
        internal void HandleChunkUploadRequest(string serializedMetaData)
        {
            ChunkMetaData data = (ChunkMetaData)SerializationService.Deserialize(serializedMetaData, typeof(ChunkMetaData));

            if (data.IsSingleChunkUpload)
            {
                this.RequestData.UploadedFile = new AsyncPostedFile(this.RequestData.UploadedFile, this.FullPath, this.RequestData.UploadedFile.ContentLength, false);
                (this.RequestData.UploadedFile as AsyncPostedFile).NormalizeWith(this.RequestData.FormValues);
                this.ProcessUploadedFile();
            }
            else if (this.ValidateSize(data.TotalFileSize, this.Configuration.MaxFileSize))
            {
                if (!this.IsFileSizeValid(Convert.ToInt32(data.TotalFileSize), this.Configuration.MaxFileSize))
                {
                    this.ResponseWriter.WriteToResponse("{ \"invalidFileSize\" : true }");
                }
                else
                {
                    bool flag  = data.ChunkIndex == --data.TotalChunks;
                    bool flag2 = data.ChunkIndex == 0;
                    this.TemporaryFileName = data.UploadID;
                    this.FileAppender.AppendTo(this.FullPath);
                    if (flag)
                    {
                        this.RequestData.UploadedFile = new AsyncPostedFile(this.RequestData.UploadedFile, this.FullPath, this.FileAppender.AppendedContentLength, true);
                        (this.RequestData.UploadedFile as AsyncPostedFile).NormalizeWith(this.RequestData.FormValues);
                        this.ProcessUploadedFile();
                    }
                    else
                    {
                        if (flag2)
                        {
                            this.AddCacheDependency(this.Context, data.UploadID, this.Configuration.TimeToLive, this.FullPath);
                        }
                        this.ResponseWriter.WriteToResponse("next");
                    }
                }
            }
        }
        private void OrdersForm_Load(object sender, EventArgs e)
        {
            btnCancel.Enabled    = false;
            btnSendOrder.Enabled = false;

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

            var ordersTable = Repository.Instancia.orders;

            ordersTable = ordersDeserialize ?? new List <Orders>();

            lblTableNo.Text = indexMesa.ToString();
            int n = 1;

            lblTableNo.Text = (indexMesa.Value + n).ToString();

            lboPedidos.BeginUpdate();

            lboPedidos.Items.Clear();

            lblOrderNo.Text = orderQuantity.Value.ToString();

            if (ordersTable != null)
            {
                for (int i = 0; i < ordersTable.Count; i++)
                {
                    if (ordersTable[i].indexTable == indexMesa.Value)
                    {
                        if (ordersTable[i].indexTable == indexMesa)
                        {
                            btnCancel.Enabled    = true;
                            btnSendOrder.Enabled = true;
                            lboPedidos.Items.Add($"Nombre : {ordersTable[i].Name} |" +
                                                 $"Entrada : {ordersTable[i].foodEntrees.Name} | Bebida : {ordersTable[i].drinks.Name} | " +
                                                 $"Plato Fuerte : {ordersTable[i].dishes.Name} | Postre : {ordersTable[i].dessert.Name}");
                        }
                    }
                }
            }


            lboPedidos.EndUpdate();

            fillLists();
        }
Esempio n. 18
0
        public async Task <bool> GoForwardAsync()
        {
            if (!FrameFacade.CanGoForward)
            {
                return(false);
            }
            var next      = FrameFacade.ForwardStack.FirstOrDefault();
            var parameter = SerializationService.Deserialize(next.Parameter?.ToString());

            return(await NavigationOrchestratorAsync(next.SourcePageType, parameter, NavigationMode.Forward, () =>
            {
                try
                {
                    FrameFacade.GoForward();
                    return true;
                }
                catch (Exception ex)
                {
                    // Catch and ignore exceptions
                    DebugWrite(ex.Message, Severities.Error);
                    return false;
                }
            }));
        }
Esempio n. 19
0
        public async Task <bool> GoBackAsync(NavigationTransitionInfo infoOverride = null)
        {
            if (!CanGoBack)
            {
                return(false);
            }
            var previous  = FrameFacade.BackStack.LastOrDefault();
            var parameter = SerializationService.Deserialize(previous.Parameter?.ToString());

            return(await NavigationOrchestratorAsync(previous.SourcePageType, parameter, NavigationMode.Back, () =>
            {
                try
                {
                    FrameFacade.GoBack(infoOverride);
                    return true;
                }
                catch (Exception ex)
                {
                    // Catch and ignore exceptions
                    DebugWrite(ex.Message, Severities.Error);
                    return false;
                }
            }));
        }