Exemple #1
0
        protected override async Task <object> Process()
        {
            var appModel = ApplicationModel;

            Dictionary <string, ParameterValueData> parameterValues;

            try
            {
                parameterValues = (await GetParameterDictionary())
                                  .Where(kvp => resolution.OperationModel.Parameter.ContainsKey(kvp.Key))
                                  .ToDictionary(kvp => kvp.Key, kvp =>
                                                new DataCompressor(appModel, resolution.OperationModel.Parameter[kvp.Key].ViewModelId)
                                                .DecompressParameterValueData(kvp.Value)
                                                );
            }
            catch (TypeNotFoundException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new BadRequestException(ex);
            }

            var variableData = await ServiceContext.ObjectService.DoAsync(resolution.Reference, resolution.OperationModel.Name, parameterValues);

            var compressor = new DataCompressor(appModel, resolution.OperationModel.Result.ViewModelId);

            return(compressor.Compress(variableData));
        }
Exemple #2
0
        protected override Task <object> Process()
        {
            var objectData = ServiceContext.ObjectService.Get(resolution.Reference);
            var compressor = new DataCompressor(ApplicationModel, resolution.Reference.ViewModelId);

            return(Task.FromResult(compressor.Compress(objectData)));
        }
Exemple #3
0
        public Package Pack(IEnumerable <DataTable> data)
        {
            DataSerializer serializer = new DataSerializer(_serializationStrategy);
            DataCompressor compressor = new DataCompressor(_compressionStrategy);

            var turbinesDataJson   = serializer.Serialize(data);
            var turbinesDataBinary = compressor.Compress(turbinesDataJson);

            return(new Package
            {
                DataType = PayloadDataType.Data10Minutes,
                EncryptionAlgorithm = EncryptionAlgorithmType.AES,
                Retention = -1,
                TimeStamp = DateTime.Now,
                Payload = turbinesDataBinary
            });
        }
Exemple #4
0
        private void WaveIn_DataAvailable(object sender, WaveInEventArgs e)
        {
            var data = new DataModel
            {
                Guid           = _guid,
                RawAudioSample = e.Buffer,
                RadioModel     = new SendableRadioModel {
                    Frequency = Frequency
                },
                NetworkTask = NetworkTaskData
            };

            var bytes = _converter.ConvertToBytes(data);

            var compressed = _compressor.Compress(bytes);

            _transmitter.Write(compressed);
        }
Exemple #5
0
        public void TestCompression1()
        {
            var samples1_1000 = Sample1.GenerateSamples(100000);
            //TestSample1Sanity(1000, samples1_1000);

            Stopwatch w = new Stopwatch();

            w.Start();
            EnumerationFinder <Sample1> finder = new EnumerationFinder <Sample1>(samples1_1000);

            finder.GenerateEnumeration(x => x.Category);
            finder.GenerateEnumeration(x => x.CategoryId);
            finder.GenerateEnumeration(x => x.Manager);

            var packedData = DataCompressor <Sample1> .Compress(samples1_1000, finder.Schema, finder.EnumerationList);

            w.Stop();
            var elapsedMillis = w.Elapsed.TotalMilliseconds;

            var originalJson   = JsonUtils.ConvertToJson(samples1_1000).ToCharArray().Length;
            var compressedJson = JsonUtils.ConvertToJson(packedData).ToCharArray().Length;

            Assert.IsNotNull(packedData);
        }