Beispiel #1
0
        public virtual void TestCompressionTools()
        {
            IndexableField binaryFldCompressed = new StoredField("binaryCompressed", CompressionTools.Compress(BinaryValCompressed.GetBytes(Encoding.UTF8)));
            IndexableField stringFldCompressed = new StoredField("stringCompressed", CompressionTools.CompressString(BinaryValCompressed));

            var doc = new Documents.Document {binaryFldCompressed, stringFldCompressed};

            using (Directory dir = NewDirectory())
            using (RandomIndexWriter writer = new RandomIndexWriter(Random(), dir))
            {
                writer.AddDocument(doc);

                using (IndexReader reader = writer.Reader)
                {
                    Documents.Document docFromReader = reader.Document(0);
                    Assert.IsTrue(docFromReader != null);

                    string binaryFldCompressedTest =
                        Encoding.UTF8.GetString(
                            CompressionTools.Decompress(docFromReader.GetBinaryValue("binaryCompressed")));
                    //new string(CompressionTools.Decompress(docFromReader.GetBinaryValue("binaryCompressed")), IOUtils.CHARSET_UTF_8);
                    Assert.IsTrue(binaryFldCompressedTest.Equals(BinaryValCompressed));
                    Assert.IsTrue(
                        CompressionTools.DecompressString(docFromReader.GetBinaryValue("stringCompressed"))
                            .Equals(BinaryValCompressed));
                }

            }
        }
            public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
            {
                report.CustomInfo = new BugReportExtraInfo();

                var data = string.Concat("<BugReport>", report.ToString(), exception.ToString(), "</BugReport>");

                return(_sender.SendData(CompressionTools.ZipString(data)));
            }
 private byte[] Uncompress(byte[] b)
 {
     try
     {
         return(CompressionTools.Decompress(b));
     }
     catch (Exception e)
     {
         // this will happen if the field is not compressed
         throw new CorruptIndexException("field data are in wrong format: " + e, e);
     }
 }
        /// <summary>
        ///     Send usage data specified mail address
        /// </summary>
        public static void SendUsageData()
        {
            if (DataSender == null)
            {
                throw new InvalidOperationException("DataSender must be set before sending data");
            }

            lock (OperationLock)
            {
                DataSender.SendData(CompressionTools.ZipString(CurrentData.ToString(SaveOptions.DisableFormatting)));
            }
        }
        public bool SendData(string value)
        {
            try
            {
                var compressed = CompressionTools.BrotliCompress(value);

                using var s = Program.GetHttpClient();
                var response = s.PostAsync(new Uri($"SendStats?userId={userId}&data={Convert.ToBase64String(compressed)}", UriKind.Relative), null).Result;
                response.EnsureSuccessStatusCode();
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to send stats: " + e);
                return(false);
            }
            return(true);
        }
Beispiel #6
0
 public void OnlyGZipStream()
 {
     UseDefaultConfiguration(defaultConfiguration =>
     {
         UseDifferentBufferSizes(defaultConfiguration, bufferSize =>
         {
             UseMeasure(stopMeasure =>
             {
                 var source = defaultConfiguration.CompressingFile;
                 var target = defaultConfiguration.CompressedFile;
                 target.WriteByParts(
                     source.ReadByParts(bufferSize)
                     .Select(part => CompressionTools.CompressPart(part)));
                 stopMeasure();
             }, defaultConfiguration.CompressingFile);
         });
     });
 }
Beispiel #7
0
            public override bool Send(string fileName, Stream file, Report report, SerializableException exception)
            {
                try
                {
                    report.CustomInfo = new BugReportExtraInfo();
                    var data = string.Concat("<BugReport>", report.ToString(), exception.ToString(), "</BugReport>");

                    var compressed = CompressionTools.BrotliCompress(data);

                    using var s = Program.GetHttpClient();
                    var result = s.PostAsync(new Uri($"SendCrashReport?userId={Properties.Settings.Default.MiscUserId}&data={Convert.ToBase64String(compressed)}", UriKind.Relative), null).Result;
                    result.EnsureSuccessStatusCode();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to send crash report: " + e);
                    return(false);
                }
                return(true);
            }
Beispiel #8
0
        private void frmConverter_Load(object sender, EventArgs e)
        {
            Icon = Resources.kukkii;

            // Tools
            CompressionTools.LoadCompressionTools(compressionToolStripMenuItem);
            EncryptionTools.LoadEncryptionTools(encryptionToolStripMenuItem);
            HashTools.LoadHashTools(hashToolStripMenuItem);

            // Image Border Styles
            tsbImageBorderStyle.DropDownItems.AddRange(Enum.GetNames(typeof(ImageBoxBorderStyle)).Select(s => new ToolStripMenuItem {
                Image = (Image)Resources.ResourceManager.GetObject(_stylesImages[s]), Text = _stylesText[s], Tag = s
            }).ToArray());
            foreach (var tsb in tsbImageBorderStyle.DropDownItems)
            {
                ((ToolStripMenuItem)tsb).Click += tsbImageBorderStyle_Click;
            }

            UpdateForm();
            UpdatePreview();
        }