Example #1
0
        private void button11_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            System.IO.MemoryStream original_image_stream = new System.IO.MemoryStream(System.IO.File.ReadAllBytes(openFileDialog1.FileName));
            Image  original_image = Image.FromStream(original_image_stream);
            double aspect         = ((double)original_image.Width / (double)original_image.Height);
            int    width          = 165;
            int    height         = (int)(width / aspect);
            Image  resized        = original_image.GetThumbnailImage(width, height, null, IntPtr.Zero);

            pictureBox1.Image = resized;

            AzusaContext context = AzusaContext.GetInstance();
            bool         update  = context.DatabaseDriver.SedgeTree_TestForPhoto(target._guid.ToString());

            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            resized.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

            if (update)
            {
                context.DatabaseDriver.SedgeTree_UpdatePhoto(ms.ToArray(), target._guid.ToString());
            }
            else
            {
                context.DatabaseDriver.SedgeTree_InsertPhoto(ms.ToArray(), target._guid.ToString());
            }

            original_image_stream.Dispose();
            original_image.Dispose();
        }
Example #2
0
        public void ExecutePostConnectionTask()
        {
            AzusaContext context = AzusaContext.GetInstance();

            context.Splash.SetLabel("Frage €-Umrechungskurse ab...");
            if (!context.DatabaseDriver.CanUpdateExchangeRates)
            {
                return;
            }

            AzusifiedCube cube = context.DatabaseDriver.GetLatestEuroExchangeRates();

            if (cube == null)
            {
                cube           = new AzusifiedCube();
                cube.DateAdded = DateTime.MinValue;
            }

            cube.DateAdded = cube.DateAdded.Date;
            if (DateTime.Today > cube.DateAdded)
            {
                EcbClient ecbClient = EcbClient.GetInstance();
                Cube      ecbCube   = ecbClient.DownloadCube();
                cube = ecbClient.AzusifyCube(ecbCube);
                context.DatabaseDriver.InsertEuroExchangeRate(cube);
            }
        }
Example #3
0
        private void LoadPlugins()
        {
            AzusaContext azusaContext = AzusaContext.GetInstance();

            foreach (IImageAcquisitionPlugin plugin in azusaContext.ImageAcquisitionPlugins)
            {
                if (plugin.CanStart())
                {
                    ToolStripButton tsb = new ToolStripButton(plugin.Name);
                    tsb.Click += delegate(object sender, EventArgs args)
                    {
                        Image result = plugin.Acquire();
                        if (result != null)
                        {
                            Data = JpegCompressor.CompressJpeg(result, MaxPictureSize);
                        }
                        else
                        {
                            MessageBox.Show("Das Plug-In hat kein Bild geliefert!");
                        }
                    };
                    this.contextMenuStrip1.Items.Add(tsb);
                }
            }
        }
Example #4
0
        public static void Migrate()
        {
            AzusaContext   context = AzusaContext.GetInstance();
            PostgresDriver driver  = (PostgresDriver)context.DatabaseDriver;
            List <AttachmentMigrationCandidate> candidates = driver.GetAttachmentMigrationCandidates().ToList();

            driver.BeginTransaction();
            foreach (AttachmentMigrationCandidate candidate in candidates)
            {
                int mid = candidate.MediaId;
                if (candidate.CICM != null)
                {
                    driver.InsertAttachment(MigrateElement(candidate.CICM, 11, mid));
                }
                if (candidate.JedecId != null)
                {
                    driver.InsertAttachment(MigrateElement(candidate.JedecId, 15, mid));
                }
                if (candidate.MHddLog != null)
                {
                    driver.InsertAttachment(MigrateElement(candidate.MHddLog, 12, mid));
                }
                if (candidate.Priv != null)
                {
                    driver.InsertAttachment(MigrateElement(candidate.Priv, 14, mid));
                }
                if (candidate.ScsiInfo != null)
                {
                    driver.InsertAttachment(MigrateElement(candidate.ScsiInfo, 13, mid));
                }
            }

            driver.EndTransaction(true);
        }
Example #5
0
        public RestDriver()
        {
            context    = AzusaContext.GetInstance();
            errorState = RestDriverErrorState.NoError;
            string url = context.ReadIniKey("rest", "url", null);

            if (url == null)
            {
                errorState = RestDriverErrorState.UrlUnspecified;
                return;
            }

            if (string.IsNullOrEmpty(context.LicenseKey))
            {
                errorState = RestDriverErrorState.LicenseUnspecified;
            }
            license = context.LicenseKey;

            webClient             = new WebClient();
            webClient.BaseAddress = url;
            webClient.Encoding    = Encoding.UTF8;
            webClient.Headers.Add("User-Agent", "AzusaERP 1.0");
            webClient.Headers.Add("Azusa-Machine-Name", Environment.MachineName);
            webClient.Headers.Add("Azusa-Username", Environment.UserName);
            webClient.Headers.Add("Azusa-User-Domain-Name", Environment.UserDomainName);
            webClient.Headers.Add("Azusa-License", license);
            webClient.Headers.Add("Authorization", "Azusa-License");
            webClient.Headers.Add("Azusa-License-Buffer-Size", context.LicenseLength.ToString());
        }
        private static void Gather(Media medium, XDvdFsFileSystemEntry entry, FilesystemMetadataEntity parent)
        {
            IDatabaseDriver dbDriver = AzusaContext.GetInstance().DatabaseDriver;

            FilesystemMetadataEntity dirEntity = new FilesystemMetadataEntity();

            dirEntity.FullName    = entry.FullPath;
            dirEntity.IsDirectory = entry.IsFolder;
            dirEntity.MediaId     = medium.Id;
            dirEntity.Modified    = null;
            dirEntity.ParentId    = parent != null ? parent.Id : -1;
            if (entry.IsFolder)
            {
                dbDriver.AddFilesystemInfo(dirEntity);
                foreach (XDvdFsFileSystemEntry subfile in entry.Files)
                {
                    Gather(medium, subfile, dirEntity);
                }
            }
            else
            {
                int    readSize = (int)Math.Min(2048, entry.LogicalFileSize);
                byte[] buffer   = new byte[readSize];
                Stream inStream = entry.GetStream();
                readSize = inStream.Read(buffer, 0, readSize);
                inStream.Close();
                Array.Resize(ref buffer, readSize);
                dirEntity.Header = buffer;
                dbDriver.AddFilesystemInfo(dirEntity);
            }
        }
Example #7
0
        private void DeviceToDatabaseThread(object rawSerialPort)
        {
            MainForm   mainForm   = AzusaContext.GetInstance().MainForm;
            SerialPort serialPort = (SerialPort)rawSerialPort;

            if (serialPort == null)
            {
                return;
            }
            serialPort.Open();
            AzusaDexTimeline result;

            try
            {
                result = LoadTimelineFromDevice(serialPort);
            }
            catch (Exception e)
            {
                mainForm.SetStatusBar("Auslesen fehlgeschlagen: " + e);
                serialPort.Close();
                return;
            }
            serialPort.Close();
            DoImport(result);

            mainForm.Invoke((MethodInvoker) delegate
            {
                gerätespeicherInAzusaDexXMLToolStripMenuItem.Enabled = true;
                gerätespeicherAuslesenToolStripMenuItem.Enabled      = false;
                UpdateDates();
            });
        }
Example #8
0
        private void cSVExportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            int tableSize = listBox1.Items.Count - 1;
            int startItem = Math.Max(0, tableSize - 100);

            AzusaDexTimeline timeline = new AzusaDexTimeline();

            for (int i = startItem; i < tableSize; i++)
            {
                ListBoxDateWrapper             dateWrapper = (ListBoxDateWrapper)listBox1.Items[i];
                IEnumerable <DexTimelineEntry> entries     = DexcomHistoryService.GetDexTimelineEntries(dateWrapper.Value);
                foreach (DexTimelineEntry entry in entries)
                {
                    timeline.Data.Add(entry);
                }
            }
            timeline.Order();
            FileInfo fi = new FileInfo(saveFileDialog1.FileName);

            if (fi.Exists)
            {
                fi.Delete();
            }
            timeline.SaveCsv(fi, true, true, false);
            AzusaContext.GetInstance().MainForm.SetStatusBar("CSV-Export fertig!");
        }
Example #9
0
        public void CopyFolder(IMailFolder folder, Folder sqlEntity, bool update, string password)
        {
            try
            {
                folder.Open(FolderAccess.ReadOnly);
            }
            catch (Exception)
            {
                return;
            }

            Random           rng   = AzusaContext.GetInstance().RandomNumberGenerator;
            IList <UniqueId> uuids = folder.Search(FolderService.GetSearchQuery(sqlEntity));

            foreach (UniqueId uuid in uuids)
            {
                if (MessageService.TestForMessage((int)uuid.Id))
                {
                    continue;
                }

                var message = folder.GetMessage(uuid);

                byte[] saltBuffer = new byte[16];
                rng.NextBytes(saltBuffer);
                Array.Copy(azusaString, 0, saltBuffer, 0, azusaString.Length);
                int iterations = rng.Next(1000, short.MaxValue);
                Rfc2898DeriveBytes deriveBytes = new Rfc2898DeriveBytes(password, saltBuffer, iterations);
                Aes aes = Aes.Create();
                aes.Key = deriveBytes.GetBytes(32);
                aes.IV  = deriveBytes.GetBytes(16);
                MemoryStream ms           = new MemoryStream();
                CryptoStream cryptoStream = new CryptoStream(ms, aes.CreateEncryptor(), CryptoStreamMode.Write);
                message.WriteTo(cryptoStream);
                cryptoStream.Flush();

                Mail child = new Mail();
                child.Uid          = (int)uuid.Id;
                child.MessageUtime = message.Date.DateTime.ToUnixTime();
                child.Folder       = sqlEntity.id;
                child.From         = message.From[0].ToString();
                if (message.To.Count > 0)
                {
                    child.To = message.To[0].ToString();
                }
                else
                {
                    child.To = null;
                }
                child.Subject    = message.Subject;
                child.Salt       = saltBuffer;
                child.Iterations = (short)iterations;
                child.Data       = new byte[ms.Position];
                Array.Copy(ms.GetBuffer(), 0, child.Data, 0, ms.Position);

                MessageService.StoreMessage(child);
            }

            folder.Close(false);
        }
Example #10
0
        private void hBA1CSchätzenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IDatabaseDriver  database              = AzusaContext.GetInstance().DatabaseDriver;
            DexTimelineEntry latestGlucose         = database.Dexcom_GetLatestGlucoseEntry();
            DateTime         scope                 = latestGlucose.Timestamp.AddMonths(-3);
            IEnumerable <DexTimelineEntry> entries = database.Dexcom_GetGlucoseEntriesAfter(scope);

            uint totalGlucose     = 0;
            uint numGlucoseValues = 0;

            foreach (DexTimelineEntry entry in entries)
            {
                if (entry.Glucose.HasValue)
                {
                    totalGlucose += entry.Glucose.Value;
                    numGlucoseValues++;
                }
            }

            double avgGlucose = (double)totalGlucose / (double)numGlucoseValues;
            double hba1c      = 0.031;

            hba1c *= avgGlucose;
            hba1c += 2.393;

            string text = String.Format("Geschätzer HBA1c: {0}%", hba1c);

            Debug.WriteLine(text);
            MessageBox.Show(text);
        }
Example #11
0
        private void DoImport(object rawTimeline)
        {
            AzusaDexTimeline timeline = (AzusaDexTimeline)rawTimeline;
            MainForm         mainForm = AzusaContext.GetInstance().MainForm;

            DexcomHistoryService.Import(timeline);
            Invoke((MethodInvoker)UpdateDates);
        }
Example #12
0
 public SetupForm()
 {
     InitializeComponent();
     context                    = AzusaContext.GetInstance();
     azusaIniFileInfo           = new FileInfo("azusa.ini");
     toolStripStatusLabel1.Text = "";
     InitForm();
 }
Example #13
0
 public MediaPickerForm()
 {
     InitializeComponent();
     dbDriver     = AzusaContext.GetInstance().DatabaseDriver;
     DialogResult = DialogResult.Cancel;
     UpdateControls();
     shelfSelector1.OnShelfSelectionChanged += ShelfSelector1_OnShelfSelectionChanged;
     shelfSelector1.SelectedIndex            = 1;
 }
Example #14
0
        public static void StoreMessage(Mail mail)
        {
            if (TestForMessage(mail.Uid))
            {
                return;
            }

            AzusaContext.GetInstance().DatabaseDriver.MailArchive_StoreMessage(mail);
        }
 public static SedgeTreeMemoryCardEmulation GetInstance()
 {
     if (singleton == null)
     {
         singleton         = new SedgeTreeMemoryCardEmulation();
         singleton.context = AzusaContext.GetInstance();
         singleton.LoadData();
     }
     return(singleton);
 }
Example #16
0
        private void azusaDexXMLImportierenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog(AzusaContext.GetInstance().MainForm) != DialogResult.OK)
            {
                return;
            }

            FileInfo         fi       = new FileInfo(openFileDialog1.FileName);
            AzusaDexTimeline timeline = AzusaDexTimeline.LoadFrom(fi);

            new Thread(DoImport).Start(timeline);
        }
Example #17
0
        public void OnLoad()
        {
            context  = AzusaContext.GetInstance();
            database = context.DatabaseDriver;

            foreach (MediaType mediaType in database.GetMediaTypes())
            {
                if (!string.IsNullOrEmpty(mediaType.VnDbKey))
                {
                    imageList1.Images.Add(mediaType.VnDbKey, Image.FromStream(new MemoryStream(mediaType.Icon)));
                }
            }
        }
Example #18
0
 public CurrencyConverterTextBox()
 {
     InitializeComponent();
     context = AzusaContext.GetInstance();
     if (context != null)
     {
         if (context.DatabaseDriver != null)
         {
             cube = context.DatabaseDriver.GetLatestEuroExchangeRates();
         }
     }
     jPYEURToolStripMenuItem.Enabled = cube != null;
     uSDEURToolStripMenuItem.Enabled = cube != null;
     gBPEURToolStripMenuItem.Enabled = cube != null;
 }
Example #19
0
        private void goButton_Click(object sender, EventArgs e)
        {
            BandcampImportWorker bandcampImportWorker = new BandcampImportWorker(new DirectoryInfo(this.inputFolderBrowserDialog.SelectedPath));

            bandcampImportWorker.Shelf           = shelfSelector1.SelectedShelf;
            bandcampImportWorker.TargetFolder    = new DirectoryInfo(this.outputFolderBrowserDialog.SelectedPath);
            bandcampImportWorker.IsDiscography   = discographyCheckbox.Checked;
            bandcampImportWorker.DiscographyName = discographyNameTextBox.Text;
            bandcampImportWorker.Context         = AzusaContext.GetInstance();

            WorkerForm workerForm = new WorkerForm(bandcampImportWorker);

            workerForm.ShowDialog(this);
            this.Close();
        }
Example #20
0
        private void gerätespeicherInAzusaDexXMLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MainForm   mf = AzusaContext.GetInstance().MainForm;
            SerialPort sp = SelectComPortForm.ShowSelectionFor(mf);

            if (sp == null)
            {
                return;
            }
            gerätespeicherInAzusaDexXMLToolStripMenuItem.Enabled = false;
            gerätespeicherAuslesenToolStripMenuItem.Enabled      = false;
            Thread thread = new Thread(ReadToXmlThread);

            thread.Start(sp);
        }
Example #21
0
        public static bool CreateIfNotExists(Folder folder)
        {
            AzusaContext context = AzusaContext.GetInstance();

            bool exists = context.DatabaseDriver.MailArchive_TestForFolder(folder.id);

            if (exists)
            {
                return(false);
            }

            context.DatabaseDriver.MailArchive_InsertFolder(folder);

            return(true);
        }
        public void ExecutePostConnectionTask()
        {
            AzusaContext context = AzusaContext.GetInstance();

            if (!context.DatabaseDriver.CanUpdateExchangeRates)
            {
                return;
            }

            DateTime lastUpdate = context.DatabaseDriver.GetLatestCryptoExchangeRateUpdateDate();

            if (lastUpdate.Date >= DateTime.Today)
            {
                return;
            }

            string apiKey = context.ReadIniKey("cryptocompare", "apikey", null);

            if (string.IsNullOrEmpty(apiKey))
            {
                return;
            }

            context.Splash.SetLabel("Frage Krypto-Umrechungskurse ab...");

            CryptoCompareClient cryptoCompareClient = CryptoCompareClient.Instance;

            cryptoCompareClient.SetApiKey(apiKey);
            Task <PriceSingleResponse> task = cryptoCompareClient.Prices.SingleSymbolPriceAsync("EUR", new [] { "BTC", "LTC", "DOGE", "XCH", "ETH" });

            task.Wait();
            PriceSingleResponse euro = task.Result;

            if (euro.Count == 0)
            {
                return;
            }

            CryptoExchangeRates result = new CryptoExchangeRates();

            result.btc  = Convert.ToDouble(euro["BTC"]);
            result.ltc  = Convert.ToDouble(euro["LTC"]);
            result.doge = Convert.ToDouble(euro["DOGE"]);
            result.xch  = Convert.ToDouble(euro["XCH"]);
            result.eth  = Convert.ToDouble(euro["ETH"]);
            context.DatabaseDriver.InsertCryptoExchangeRate(result);
        }
Example #23
0
        public void OnLoad()
        {
            context = AzusaContext.GetInstance();
            if (!context.Ini.ContainsKey(IniKey))
            {
                return;
            }

            IniSection iniSection = context.Ini[IniKey];

            if (!iniSection.ContainsKey("path"))
            {
                throw new Exception("path missing");
            }

            if (iniSection.ContainsKey("disable"))
            {
                if (Convert.ToInt32(iniSection["disable"]) > 0)
                {
                    return;
                }
            }

            DirectoryInfo di = new DirectoryInfo(iniSection["path"]);

            if (!di.Exists)
            {
                throw new DirectoryNotFoundException(di.FullName);
            }

            context.Splash.SetLabel("Starte Anime-Bilder-Datenbank...");
            streamBlob = new AzusaStreamBlob(di, true);

            context.Splash.SetLabel("Lese Tag-Index der Bilder-Datenbank...");
            IEnumerable <GelbooruTag> tags = context.DatabaseDriver.Gelbooru_GetAllTags();

            gelbooruTags = new List <GelbooruTag>();
            foreach (GelbooruTag tag in tags)
            {
                if (!BAD_WORDS.Contains(tag.Tag))
                {
                    gelbooruTags.Add(tag);
                }
            }
            textBox1_TextChanged(null, null);
        }
Example #24
0
        public static void Import(AzusaDexTimeline timeline)
        {
            AzusaContext    context        = AzusaContext.GetInstance();
            IDatabaseDriver databaseDriver = context.DatabaseDriver;
            int             addedStamps    = 0;

            foreach (DexTimelineEntry entry in timeline.Data)
            {
                context.MainForm.SetStatusBar(String.Format("Verarbeite Zeitstempel {0}", entry.Timestamp));
                if (!TestForTimestamp(entry.Timestamp))
                {
                    bool result = databaseDriver.Dexcom_InsertTimestamp(entry);
                    addedStamps++;
                }
            }

            context.MainForm.SetStatusBar(String.Format("Fertig. {0} neue Zeitstempel hinzugefügt.", addedStamps));
        }
Example #25
0
        public AttachmentEditor(Media currentMedia, AzusaContext context)
        {
            _currentMedia = currentMedia;
            _context      = context;
            InitializeComponent();
            if (attachmentTypes == null)
            {
                attachmentTypes = context.DatabaseDriver.GetAllMediaAttachmentTypes().ToDictionary(x => x.id);
            }

            Dictionary <int, AttachmentType> missingAttachmentTypes = new Dictionary <int, AttachmentType>();

            foreach (var keyValuePair in attachmentTypes)
            {
                missingAttachmentTypes.Add(keyValuePair.Key, keyValuePair.Value);
            }

            imageList1.Images.Add(Resources.Find_VS);
            imageList1.Images.Add(Resources.accept);
            imageList1.Images.Add(Resources.link_break);

            foreach (Attachment attachment in context.DatabaseDriver.GetAllMediaAttachments(currentMedia))
            {
                attachment._IsInDatabase = true;
                attachment.Text          = attachmentTypes[attachment._TypeId].name;
                listView1.Items.Add(attachment);
                missingAttachmentTypes.Remove(attachment._TypeId);
            }

            foreach (AttachmentType attachmentType in missingAttachmentTypes.Values)
            {
                Attachment added = new Attachment();
                added._IsInDatabase = false;
                added._MediaId      = currentMedia.Id;
                added._TypeId       = attachmentType.id;
                added._Complete     = false;
                added.Text          = attachmentType.name;
                listView1.Items.Add(added);
            }

            listView1.SelectedIndices.Add(0);
            Text = String.Format("Anhänge für {0}", currentMedia.Name);
        }
Example #26
0
        public Editor(Person _t)
        {
            data = SedgeTreeMemoryCardEmulation.GetInstance().GetData();
            AzusaContext context = AzusaContext.GetInstance();

            target = _t;
            InitializeComponent();
            UpdateView(_t);


            byte[] buffer = context.DatabaseDriver.SedgeTree_GetPhotoByPerson(_t);
            if (buffer != null)
            {
                pictureBox1.Image = Image.FromStream(new System.IO.MemoryStream(buffer));
            }

            button2.Enabled = data.ContainsFemales;
            button3.Enabled = data.ConatinsMales;
        }
        public void OnLoad()
        {
            AzusaContext.GetInstance().Splash.SetLabel("Abfragen der Warwalking Touren...");

            TreeNode toursRoot = new TreeNode("Touren");
            TreeNode lastTour  = null;

            foreach (Tour tour in TourService.GetAllTours())
            {
                lastTour = new TourNode(tour);
                toursRoot.Nodes.Add(lastTour);
            }
            toursRoot.Expand();

            treeView1.Nodes.Add(toursRoot);
            if (lastTour != null)
            {
                treeView1.SelectedNode = lastTour;
            }
        }
Example #28
0
        public static void Migrate()
        {
            AzusaContext    context = AzusaContext.GetInstance();
            IDatabaseDriver contextDatabaseDriver = context.DatabaseDriver;
            List <string>   allTableNames         = contextDatabaseDriver.GetAllPublicTableNames();

            foreach (string oldTableName in allTableNames)
            {
                int    colonIndex   = oldTableName.IndexOf('_');
                string schemaName   = oldTableName.Substring(0, colonIndex);
                string newTableName = oldTableName.Substring(colonIndex + 1);
                if (schemaName.Equals("dump"))
                {
                    colonIndex   = newTableName.IndexOf('_');
                    schemaName   = schemaName + "_" + newTableName.Substring(0, colonIndex);
                    newTableName = newTableName.Substring(colonIndex + 1);
                }
                contextDatabaseDriver.CreateSchema(schemaName);
                contextDatabaseDriver.MoveAndRenameTable("public", oldTableName, schemaName, newTableName);
            }
        }
Example #29
0
        public ShelfSelector()
        {
            InitializeComponent();
            IDatabaseDriver databaseDriver = AzusaContext.GetInstance().DatabaseDriver;

            if (databaseDriver != null)
            {
                IEnumerable <Shelf> shelves = databaseDriver.GetAllShelves();
                foreach (Shelf shelf in shelves)
                {
                    comboBox1.Items.Add(shelf);
                }
            }
            else
            {
                Shelf dummy = new Shelf();
                dummy.Name = "This won't work in the designer!";
                comboBox1.Items.Add(dummy);
            }
            comboBox1.SelectedIndex = 0;
        }
        private static void Gather(Media medium, DirectoryInfo di, FilesystemMetadataEntity parent)
        {
            IDatabaseDriver dbDriver = AzusaContext.GetInstance().DatabaseDriver;

            FilesystemMetadataEntity dirEntity = new FilesystemMetadataEntity();

            dirEntity.FullName    = di.FullName.Replace(di.Root.FullName, "");
            dirEntity.IsDirectory = true;
            dirEntity.MediaId     = medium.Id;
            dirEntity.Modified    = di.LastWriteTime;
            dirEntity.ParentId    = parent != null ? parent.Id : -1;
            dbDriver.AddFilesystemInfo(dirEntity);

            foreach (DirectoryInfo subdir in di.GetDirectories())
            {
                Gather(medium, subdir, dirEntity);
            }

            foreach (FileInfo file in di.GetFiles())
            {
                FilesystemMetadataEntity fileEntity = new FilesystemMetadataEntity();
                fileEntity.FullName    = file.FullName;
                fileEntity.IsDirectory = false;
                fileEntity.MediaId     = medium.Id;
                fileEntity.Modified    = file.LastWriteTime;
                fileEntity.ParentId    = dirEntity.Id;
                fileEntity.Size        = file.Length;

                int    readSize = (int)Math.Min(2048, file.Length);
                byte[] buffer   = new byte[readSize];
                Stream inStream = file.OpenRead();
                readSize = inStream.Read(buffer, 0, readSize);
                inStream.Close();
                Array.Resize(ref buffer, readSize);
                fileEntity.Header = buffer;

                dbDriver.AddFilesystemInfo(fileEntity);
            }
        }