Beispiel #1
0
        private void btnBuild3GbXML_Click(object sender, EventArgs e)
        {
            AbortRequested = false;
            ObjectEnabling(false);
            PhraseGenerator pg = new PhraseGenerator();

            MassiveXML.Clear();
            long TotalSize  = 0;
            int  OuterIndex = 0;

            while (!AbortRequested && TotalSize < 25000000L)
            {
                OuterIndex++;
                this.lblFileSizeXML.Text = string.Format("{0} bytes and still working", Formatting.KiloToYotta(TotalSize));
                this.lblFileSizeXML.Refresh();
                Application.DoEvents();
                System.Threading.Thread.Sleep(100);
                long ThisSize = 0;
                SerializableDictionary <int, string> Localized = new SerializableDictionary <int, string>();
                int InnerIndex = 0;
                while (!AbortRequested && ThisSize < 10000000L)
                {
                    foreach (string Phrase in pg.GetPhrase(1000))
                    {
                        InnerIndex++;
                        Localized.Add(InnerIndex, Phrase);
                        ThisSize += (long)Phrase.Length;
                    }
                    Application.DoEvents();
                }
                MassiveXML.Add(OuterIndex, Localized);
                TotalSize += ThisSize;
            }
            if (!AbortRequested)
            {
                this.lblFileSizeXML.Text = string.Format("{0} bytes..Saving XML file", Formatting.KiloToYotta(TotalSize));
                this.lblFileSizeXML.Refresh();
                ObjectXMLSerializer <SerializableDictionary <int, SerializableDictionary <int, string> > > .SaveDocumentFormat(MassiveXML, this.lblFileNameXML.Text);

                this.lblFileSizeXML.Text = string.Format("{0} bytes..Saving XML GZ file", Formatting.KiloToYotta(TotalSize));
                this.lblFileSizeXML.Refresh();
                ObjectXMLSerializer <SerializableDictionary <int, SerializableDictionary <int, string> > > .SaveCompressedDocumentFormat(MassiveXML, this.lblFileNameXML.Text + ".gz");

                string rawSize = Formatting.KiloToYotta((double)new FileInfo(this.lblFileNameXML.Text).Length);
                string gzSize  = Formatting.KiloToYotta((double)new FileInfo(this.lblFileNameXML.Text + ".gz").Length);

                this.lblFileSizeXML.Text = string.Format("Save Complete: Memory = {0}, XML = {1}, XML/GZ = {2}",
                                                         TotalSize, rawSize, gzSize);
                //new FileInfo(this.lblFileNameXML.Text).Length,
                //new FileInfo(this.lblFileNameXML.Text + ".gz").Length);
            }
            else
            {
                this.lblFileSizeXML.Text = "Aborted by operator";
            }
            ObjectEnabling(true);
        }