private ActionResult Download(DatabaseFile thisFile)
        {
            if (thisFile is null)
            {
                throw new ArgumentNullException(nameof(thisFile));
            }

            string Extension = thisFile.FileName.FromLast(".");
            string MimeType  = MimeMappings.GetMimeType(Extension);

            if (thisFile.Data.Length == 0)
            {
                if (MimeType.StartsWith("text/", StringComparison.OrdinalIgnoreCase))
                {
                    return(this.Content(System.IO.File.ReadAllText(thisFile.FullName)));
                }
                else
                {
                    FileStream fileStream = new FileStream(thisFile.FullName, FileMode.Open, FileAccess.Read);

                    FileStreamResult fsResult = new FileStreamResult(fileStream, MimeType)
                    {
                        EnableRangeProcessing = true,
                        FileDownloadName      = Path.GetFileName(thisFile.FullName)
                    };

                    return(fsResult);
                }
            }
            else
            {
                return(this.File(thisFile.Data, MimeType, thisFile.FileName));
            }
        }
Exemplo n.º 2
0
        public Dictionary <int, T> Load()
        {
            var items = new Dictionary <int, T>();

            try
            {
                using (DatabaseFile inputFile = MasterDatabase.Instance.GetFileToRead(database))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(inputFile.Stream);

                    XmlNode root = doc.DocumentElement;

                    if (root.LocalName != rootTag)
                    {
                        return(null);
                    }

                    foreach (XmlNode node in root.ChildNodes)
                    {
                        T item = deserializeItem(node);
                        if (item != null)
                        {
                            items.Add(item.ID, item);
                        }
                    }
                }
            }
            catch { }

            return(items);
        }
        public ActionResult ViewByPath(string Path)
        {
            if (Path is null)
            {
                throw new ArgumentNullException(nameof(Path));
            }

            Path = Path.Replace('/', '\\');

            string FullName = System.IO.Path.Combine(this.FileService.GetUserFilesRoot(), Path);

            DatabaseFile thisFile = this.DatabaseFileRepository.GetByFullName(FullName);

            if (thisFile is null)
            {
                return(this.NotFound());
            }
            if (!thisFile.IsDirectory)
            {
                return(this.Download(thisFile));
            }
            else
            {
                throw new UnauthorizedAccessException();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Saves the current trip.
        /// </summary>
        /// <returns><c>true</c>, if current trip was saved, <c>false</c> otherwise.</returns>
        private bool SaveCurrentTrip()
        {
            // check to make sure name is present
            if (entryTripName.Text is null || entryTripName.Text.Equals(""))
            {
                DependencyService.Get <ICrossPlatformToast>().ShortAlert("Trip name is required.");
                return(false);
            }

            trip.ProjectName          = project.ProjectName;
            trip.TripName             = entryTripName.Text;
            trip.AdditionalCollectors = (entryAdditionalCollectors.Text is null) ? "" : entryAdditionalCollectors.Text;
            trip.CollectionDate       = dpCollectionDate.Date;

            // check for duplicate names before saving
            if (DataFunctions.CheckExists(trip, trip.TripName))
            {
                DependencyService.Get <ICrossPlatformToast>().ShortAlert("You already have a trip with the same name!");
                return(false);
            }

            // save trip to database
            int autoKeyResult = DatabaseFile.GetConnection().Insert(trip);

            Debug.WriteLine("inserted trip, recordno is: " + autoKeyResult.ToString());

            return(true);
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void prepareBatchImportMigration(org.neo4j.io.layout.DatabaseLayout sourceDirectoryStructure, org.neo4j.io.layout.DatabaseLayout migrationStrcuture, org.neo4j.kernel.impl.store.format.RecordFormats oldFormat, org.neo4j.kernel.impl.store.format.RecordFormats newFormat) throws java.io.IOException
        private void PrepareBatchImportMigration(DatabaseLayout sourceDirectoryStructure, DatabaseLayout migrationStrcuture, RecordFormats oldFormat, RecordFormats newFormat)
        {
            CreateStore(migrationStrcuture, newFormat);

            // We use the batch importer for migrating the data, and we use it in a special way where we only
            // rewrite the stores that have actually changed format. We know that to be node and relationship
            // stores. Although since the batch importer also populates the counts store, all labels need to
            // be read, i.e. both inlined and those existing in dynamic records. That's why we need to copy
            // that dynamic record store over before doing the "batch import".
            //   Copying this file just as-is assumes that the format hasn't change. If that happens we're in
            // a different situation, where we first need to migrate this file.

            // The token stores also need to be migrated because we use those as-is and ask for their high ids
            // when using the importer in the store migration scenario.
            DatabaseFile[] storesFilesToMigrate = new DatabaseFile[] { DatabaseFile.LABEL_TOKEN_STORE, DatabaseFile.LABEL_TOKEN_NAMES_STORE, DatabaseFile.PROPERTY_KEY_TOKEN_STORE, DatabaseFile.PROPERTY_KEY_TOKEN_NAMES_STORE, DatabaseFile.RELATIONSHIP_TYPE_TOKEN_STORE, DatabaseFile.RELATIONSHIP_TYPE_TOKEN_NAMES_STORE, DatabaseFile.NODE_LABEL_STORE };
            if (newFormat.Dynamic().Equals(oldFormat.Dynamic()))
            {
                fileOperation(COPY, _fileSystem, sourceDirectoryStructure, migrationStrcuture, Arrays.asList(storesFilesToMigrate), true, ExistingTargetStrategy.FAIL);
            }
            else
            {
                // Migrate all token stores, schema store and dynamic node label ids, keeping their ids intact
                DirectRecordStoreMigrator migrator = new DirectRecordStoreMigrator(_pageCache, _fileSystem, _config);

                StoreType[] storesToMigrate = new StoreType[] { StoreType.LABEL_TOKEN, StoreType.LABEL_TOKEN_NAME, StoreType.PROPERTY_KEY_TOKEN, StoreType.PROPERTY_KEY_TOKEN_NAME, StoreType.RELATIONSHIP_TYPE_TOKEN, StoreType.RELATIONSHIP_TYPE_TOKEN_NAME, StoreType.NODE_LABEL, StoreType.SCHEMA };

                // Migrate these stores silently because they are usually very small
                ProgressReporter progressReporter = SilentProgressReporter.INSTANCE;

                migrator.Migrate(sourceDirectoryStructure, oldFormat, migrationStrcuture, newFormat, progressReporter, storesToMigrate, StoreType.NODE);
            }
        }
Exemplo n.º 6
0
        private bool WasModifiedLast(DatabaseFile databaseFile, List <uint> collisions)
        {
            var dirent = databaseFile.GetDirent();

            foreach (var cluster in collisions)
            {
                var clusterEnts = clusterMap[(uint)cluster];
                foreach (var ent in clusterEnts)
                {
                    var entDirent = ent.GetDirent();

                    // Skip when we encounter the same dirent
                    if (dirent.Offset == entDirent.Offset)
                    {
                        continue;
                    }

                    if (dirent.LastAccessTime.AsDateTime() < entDirent.LastAccessTime.AsDateTime())
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Saves the current project.
        /// </summary>
        /// <returns><c>true</c>, if current project was saved, <c>false</c> otherwise.</returns>
        private bool SaveCurrentProject()
        {
            // check to make sure name is present
            if (entryProjectName.Text is null || entryProjectName.Text.Equals(""))
            {
                DependencyService.Get <ICrossPlatformToast>().ShortAlert("Project name is required.");
                return(false);
            }

            project.ProjectName      = entryProjectName.Text;
            project.PrimaryCollector = entryPrimaryCollectorProject.Text;
            project.CreatedDate      = dpCreatedDate.Date;

            // check for duplicate names first
            if (DataFunctions.CheckExists(project, project.ProjectName))
            {
                DependencyService.Get <ICrossPlatformToast>().ShortAlert($"'{project.ProjectName}' already exists...");
                return(false);
            }

            // save project to database
            int autoKeyResult = DatabaseFile.GetConnection().Insert(project);

            Debug.WriteLine("inserted project, recordno is: " + autoKeyResult.ToString());

            return(true);
        }
Exemplo n.º 8
0
        private void PopulateListView(List <DatabaseFile> dirents, DatabaseFile parent)
        {
            listView1.BeginUpdate();
            listView1.Items.Clear();

            var upDir = listView1.Items.Add("");

            upDir.SubItems.Add("...");
            if (parent != null)
            {
                upDir.Tag = new NodeTag(parent, NodeType.Dirent);
            }
            else
            {
                NodeTag nodeTag = (NodeTag)currentClusterNode.Tag;
                upDir.Tag = new NodeTag(nodeTag.Tag as List <DatabaseFile>, NodeType.Cluster);
            }

            List <ListViewItem> items = new List <ListViewItem>();
            int index = 1;

            foreach (DatabaseFile databaseFile in dirents)
            {
                ListViewItem item = new ListViewItem(index.ToString());
                item.Tag = new NodeTag(databaseFile, NodeType.Dirent);

                item.SubItems.Add(databaseFile.FileName);

                DateTime creationTime   = databaseFile.CreationTime.AsDateTime();
                DateTime lastWriteTime  = databaseFile.LastWriteTime.AsDateTime();
                DateTime lastAccessTime = databaseFile.LastAccessTime.AsDateTime();

                string sizeStr = "";
                if (!databaseFile.IsDirectory())
                {
                    item.ImageIndex = 1;
                    sizeStr         = Utility.FormatBytes(databaseFile.FileSize);
                }
                else
                {
                    item.ImageIndex = 0;
                }

                item.SubItems.Add(sizeStr);
                item.SubItems.Add(creationTime.ToString());
                item.SubItems.Add(lastWriteTime.ToString());
                item.SubItems.Add(lastAccessTime.ToString());
                item.SubItems.Add("0x" + databaseFile.Offset.ToString("x"));
                item.SubItems.Add(databaseFile.Cluster.ToString());

                item.BackColor = statusColor[databaseFile.GetRanking()];

                index++;

                items.Add(item);
            }

            listView1.Items.AddRange(items.ToArray());
            listView1.EndUpdate();
        }
Exemplo n.º 9
0
        private void LoadProject_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.InitialDirectory = "d:\\";
            dialog.RestoreDirectory = true;
            dialog.Filter           = "工程文件 (*.db) | *.db";
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string   delimStr  = "\\";
                char[]   delimiter = delimStr.ToCharArray();
                string[] sArray;

                ProjectPath_textBox.Text = dialog.FileName;
                projectPath_output       = dialog.FileName;
                projectName          = projectPath_output.Substring(0, projectPath_output.Length - 3);
                sArray               = projectName.Split(delimiter);
                projectName          = sArray[sArray.Length - 1];
                projectFolder_output = sArray[0];
                for (int i = 1; i < sArray.Length - 1; i++)
                {
                    projectFolder_output = projectFolder_output + "\\" + sArray[i];
                }

                this.ExportWord_button.IsEnabled  = true;
                this.ExportExcel_button.IsEnabled = true;
                this.checkBox.IsEnabled           = true;

                databaseFile = new DatabaseFile(projectPath_output);
                databaseFile.ReadDbFile();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Connects to a database.
        /// </summary>
        /// <param name="database">
        /// The database to connect to.
        /// </param>
        /// <returns>
        /// The database connection.
        /// </returns>
        public static SqliteConnection Connect(DatabaseFile database)
        {
            string file = database == DatabaseFile.Data ? DATA_FILE : UPLOAD_FILE;

            return(new SqliteConnection(
                       string.Format("Data Source={0};Mode=ReadWrite", file)));
        }
Exemplo n.º 11
0
        /// <summary>
        /// btnSaveTrip Click event.
        /// Handles the Saving, or Updating, of the current Trip.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        public async void btnSaveTrip_Clicked(object sender, EventArgs e)
        {
            if (userIsEditing)
            {
                trip.AdditionalCollectors = (entryAdditionalCollectors.Text is null) ? "" : entryAdditionalCollectors.Text;
                trip.CollectionDate       = dateChanged ? dpCollectionDate.Date : trip.CollectionDate;

                int updateResult = DatabaseFile.GetConnection().Update(trip, typeof(Trip));
                if (updateResult == 1)
                {
                    DependencyService.Get <ICrossPlatformToast>().ShortAlert(trip.TripName + " update succeeded.");
                    editWasSaved = true;
                    return;
                }
                else
                {
                    DependencyService.Get <ICrossPlatformToast>().ShortAlert(trip.TripName + " update failed.");
                    return;
                }
            }

            SaveCurrentTrip();

            // automatically navigate to Site page after saving Trip
            await Navigation.PushAsync(new SitePage(trip));

            Navigation.RemovePage(this);
        }
Exemplo n.º 12
0
        /// <summary>
        /// btnSaveProject Click event.
        /// Handles the Saving, or Updating, of the current Project.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        private async void btnSaveProject_Clicked(object sender, EventArgs e)
        {
            if (userIsEditing)
            {
                project.PrimaryCollector = (entryPrimaryCollectorProject.Text is null) ? "" : entryPrimaryCollectorProject.Text;
                project.CreatedDate      = dateChanged ? dpCreatedDate.Date : project.CreatedDate;

                int updateResult = DatabaseFile.GetConnection().Update(project, typeof(Project));
                if (updateResult == 1)
                {
                    DependencyService.Get <ICrossPlatformToast>().ShortAlert(project.ProjectName + " update succeeded.");
                    editWasSaved = true;
                    return;
                }
                else
                {
                    DependencyService.Get <ICrossPlatformToast>().ShortAlert(project.ProjectName + " update failed.");
                    return;
                }
            }

            SaveCurrentProject();

            // automatically navigate to the collecting page after saving the project
            await Navigation.PushAsync(new CollectingPage(project));

            Navigation.RemovePage(this);
        }
Exemplo n.º 13
0
        private async void RunRecoverDirectoryEntryTaskAsync(string path, DatabaseFile databaseFile)
        {
            RecoveryTask recoverTask = null;

            var numFiles = databaseFile.CountFiles();

            _taskRunner.Maximum  = numFiles;
            _taskRunner.Interval = 1;

            await _taskRunner.RunTaskAsync("Save File",
                                           (CancellationToken cancellationToken, IProgress <int> progress) =>
            {
                recoverTask = new RecoveryTask(this._volume, cancellationToken, progress);
                recoverTask.Save(path, databaseFile);
            },
                                           (int progress) =>
            {
                string currentFile = recoverTask.GetCurrentFile();
                _taskRunner.UpdateLabel($"{progress}/{numFiles}: {currentFile}");
                _taskRunner.UpdateProgress(progress);
            },
                                           () =>
            {
                Console.WriteLine("Finished saving files.");
            });
        }
Exemplo n.º 14
0
        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 1)
            {
                return;
            }

            //Console.WriteLine($"Current Cluster Node: {currentClusterNode.Text}");

            NodeTag nodeTag = (NodeTag)listView1.SelectedItems[0].Tag;

            switch (nodeTag.Type)
            {
            case NodeType.Dirent:
                DatabaseFile databaseFile = nodeTag.Tag as DatabaseFile;

                if (databaseFile.IsDirectory())
                {
                    PopulateListView(databaseFile.Children, databaseFile.GetParent());
                }

                break;

            case NodeType.Cluster:
                List <DatabaseFile> dirents = nodeTag.Tag as List <DatabaseFile>;

                PopulateListView(dirents, null);

                break;
            }
        }
Exemplo n.º 15
0
        private void listRecoverSelectedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count == 0)
            {
                return;
            }

            var selectedItems = listView1.SelectedItems;

            using (var dialog = new FolderBrowserDialog())
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    List <DatabaseFile> selectedFiles = new List <DatabaseFile>();

                    foreach (ListViewItem selectedItem in selectedItems)
                    {
                        NodeTag nodeTag = (NodeTag)selectedItem.Tag;

                        switch (nodeTag.Type)
                        {
                        case NodeType.Dirent:
                            DatabaseFile databaseFile = nodeTag.Tag as DatabaseFile;

                            selectedFiles.Add(databaseFile);

                            break;
                        }
                    }

                    RunRecoverClusterTaskAsync(dialog.SelectedPath, selectedFiles);
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// btnSaveSite Click event.
        /// Handles Save/Update of the current Site.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        public async void btnSaveSite_Clicked(object sender, EventArgs e)
        {
            if (userIsEditing)
            {
                site.AssociatedTaxa = (entryAssocTaxa.Text is null) ? "" : entryAssocTaxa.Text;
                site.GPSCoordinates = siteGPS.Equals("") ? site.GPSCoordinates : siteGPS;
                site.Habitat        = (entryHabitat.Text is null) ? "" : entryHabitat.Text;
                site.Locality       = (entryLocality.Text is null) ? "" : entryLocality.Text;
                site.LocationNotes  = (entryLocationNotes.Text is null) ? "" : entryLocationNotes.Text;

                int updateResult = DatabaseFile.GetConnection().Update(site, typeof(Site));
                if (updateResult == 1)
                {
                    DependencyService.Get <ICrossPlatformToast>().ShortAlert(site.SiteName + " update succeeded.");
                    return;
                }
                else
                {
                    DependencyService.Get <ICrossPlatformToast>().ShortAlert(site.SiteName + " update failed.");
                    return;
                }
            }

            SaveCurrentSite();

            // automatically navigate to the specimen page after creating the site
            await Navigation.PushAsync(new SpecimenPage(site));

            Navigation.RemovePage(this);
        }
Exemplo n.º 17
0
        private void treeRecoverSelectedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var dialog = new FolderBrowserDialog())
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    var selectedNode = treeView1.SelectedNode;

                    NodeTag nodeTag = (NodeTag)selectedNode.Tag;
                    switch (nodeTag.Type)
                    {
                    case NodeType.Cluster:
                        List <DatabaseFile> dirents = nodeTag.Tag as List <DatabaseFile>;

                        string clusterDir = dialog.SelectedPath + "/" + selectedNode.Text;
                        Directory.CreateDirectory(clusterDir);
                        RunRecoverClusterTaskAsync(clusterDir, dirents);

                        break;

                    case NodeType.Dirent:
                        DatabaseFile dirent = nodeTag.Tag as DatabaseFile;

                        RunRecoverClusterTaskAsync(dialog.SelectedPath, new List <DatabaseFile> {
                            dirent
                        });

                        break;
                    }

                    Console.WriteLine("Finished recovering files.");
                }
            }
        }
Exemplo n.º 18
0
        private void listRecoverCurrentDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var dialog = new FolderBrowserDialog())
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    // TODO: Create `DirectoryEntry currentDirectory` for this class
                    //  so that we don't go through the list items.
                    //  Also, should we be dumping to a cluster directory?
                    List <DatabaseFile> selectedFiles = new List <DatabaseFile>();

                    foreach (ListViewItem item in listView1.Items)
                    {
                        if (item.Index == 0)
                        {
                            continue;
                        }

                        NodeTag nodeTag = (NodeTag)item.Tag;

                        switch (nodeTag.Type)
                        {
                        case NodeType.Dirent:
                            DatabaseFile databaseFile = nodeTag.Tag as DatabaseFile;

                            selectedFiles.Add(databaseFile);

                            break;
                        }
                    }

                    RunRecoverClusterTaskAsync(dialog.SelectedPath, selectedFiles);
                }
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Saves the current specimen.
        /// </summary>
        /// <returns><c>true</c>, if current specimen was saved, <c>false</c> otherwise.</returns>
        private bool SaveCurrentSpecimen()
        {
            specimen.SiteName        = site.SiteName;
            specimen.GPSCoordinates  = site.GPSCoordinates;
            specimen.OccurrenceNotes = entryOccurrenceNotes.Text is null ? "" : entryOccurrenceNotes.Text;
            specimen.Substrate       = entrySubstrate.Text is null ? "" : entrySubstrate.Text;
            specimen.IndividualCount = entryIndivCount.Text is null ? "" : entryIndivCount.Text;
            specimen.Cultivated      = switchCultivated.IsToggled;

            AppVariables.CollectionCount = AppVariables.CollectionCount > 0 ? AppVariables.CollectionCount + 1 : 1;

            specimen.SpecimenNumber = AppVariables.CollectionCount;

            specimen.FieldIdentification = entryFieldID.Text is null ? "" : entryFieldID.Text;

            specimen.SpecimenName = "Specimen-" + specimen.SpecimenNumber;

            specimen.LifeStage = pickerLifeStage.SelectedItem is null ? "" : pickerLifeStage.SelectedItem.ToString();

            int autoKeyResult = DatabaseFile.GetConnection().Insert(specimen);

            Debug.WriteLine("inserted specimen, recordno is: " + autoKeyResult.ToString());

            // anytime we add a specimen we need to write back the CollectionCount
            AppVarsFile.WriteAppVars();

            return(true);
        }
Exemplo n.º 20
0
        /// <summary>
        /// btnSaveSpecimen Click event.
        /// Saves or Updates the current Specimen.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        public void btnSaveSpecimen_Clicked(object sender, EventArgs e)
        {
            if (userIsEditing)
            {
                specimen.Substrate       = entrySubstrate.Text;
                specimen.IndividualCount = entryIndivCount.Text;
                specimen.Cultivated      = switchCultivated.IsToggled;
                specimen.OccurrenceNotes = entryOccurrenceNotes.Text;
                specimen.LifeStage       = pickerLifeStage.SelectedItem.ToString();
                specimen.GPSCoordinates  = site.GPSCoordinates;

                int updateResult = DatabaseFile.GetConnection().Update(specimen, typeof(Specimen));
                if (updateResult == 1)
                {
                    DependencyService.Get <ICrossPlatformToast>().ShortAlert(specimen.SpecimenName + " save succeeded.");
                    return;
                }
                else
                {
                    DependencyService.Get <ICrossPlatformToast>().ShortAlert(specimen.SpecimenName + " save failed");
                    return;
                }
            }

            SaveCurrentSpecimen();

            DependencyService.Get <ICrossPlatformToast>().ShortAlert("Saved " + specimen.SpecimenName);
            btnNewSpecimen_Clicked(this, e); // we could continue here or force the user to go back to the CollectingPage, need more user input...
        }
        private static async Task ReturnFile(HttpContext context, DatabaseFile databaseFile)
        {
            string Extension = databaseFile.FileName.FromLast(".");
            string MimeType  = MimeMappings.GetMimeType(Extension);

            context.Response.StatusCode  = (int)HttpStatusCode.OK;
            context.Response.ContentType = MimeType;

            if (string.IsNullOrEmpty(context.Request.Headers["Range"]))
            {
                byte[] fileData;

                if (databaseFile.Data.Length != 0)
                {
                    fileData = databaseFile.Data;
                }
                else
                {
                    fileData = File.ReadAllBytes(databaseFile.FullName);
                }

                context.Response.ContentLength = fileData.Length;

                using (Stream stream = context.Response.Body)
                {
                    await stream.WriteAsync(fileData, 0, fileData.Length);

                    await stream.FlushAsync();
                }
            }
            else
            {
                await RangeDownload(databaseFile.FullName, context);
            }
        }
Exemplo n.º 22
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            currentClusterNode = e.Node;
            while (currentClusterNode.Parent != null)
            {
                currentClusterNode = currentClusterNode.Parent;
            }

            //Console.WriteLine($"Current Cluster Node: {currentClusterNode.Text}");

            NodeTag nodeTag = (NodeTag)e.Node.Tag;

            switch (nodeTag.Type)
            {
            case NodeType.Cluster:
                List <DatabaseFile> dirents = (List <DatabaseFile>)nodeTag.Tag;

                PopulateListView(dirents, null);

                break;

            case NodeType.Dirent:
                DatabaseFile databaseFile = (DatabaseFile)nodeTag.Tag;

                PopulateListView(databaseFile.Children, databaseFile.GetParent());

                break;
            }
        }
Exemplo n.º 23
0
 /// <summary>
 /// 选择文件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSelectFile_Click(object sender, EventArgs e)
 {
     if (openFileDialog.ShowDialog( ) == DialogResult.OK)
     {
         DBF       = new DatabaseFile(openFileDialog.FileName);
         TableName = new FileInfo(openFileDialog.FileName).Name.Split('.')[0];                //设置表名
     }
 }
Exemplo n.º 24
0
        //0     UInt64      Object ID
        //8     UInt64      Page ID
        //16    UInt64      Commit ID
        //24    UInt32      Group ID
        //28    Byte        Commit Type
        //29    Byte        Flags
        //30    UShort      Reserved

        private ContentDatabaseSession(DatabaseFile file)
        {
            this.file     = file;
            tocPage       = file.FindBlob(PAGE_TYPE_TOC);
            nameTablePage = file.FindBlob(PAGE_TYPE_NAMETABLE);
            objects       = new List <DatabaseObjectHeader>();
            nameTable     = new List <string>();
        }
Exemplo n.º 25
0
 public void ShowData()
 {
     DatabaseFile _db = new DatabaseFile();
     using (IObjectContainer db = Db4oFactory.OpenFile(_db.DB_FILE))
     {
         var r = from DatabaseClass p in db select p;
         ddd.ItemsSource = r;
     }
 }
Exemplo n.º 26
0
 public void Delete(DatabaseFile obj)
 {
     using (InsightEntities db = new InsightEntities())
     {
         db.DatabaseFiles.Attach(obj);
         db.DatabaseFiles.Remove(obj);
         db.SaveChanges();
     }
 }
Exemplo n.º 27
0
 public DatabaseFile Insert(DatabaseFile obj)
 {
     using (InsightEntities db = new InsightEntities())
     {
         db.DatabaseFiles.Add(obj);
         db.SaveChanges();
         return(obj);
     }
 }
Exemplo n.º 28
0
 public void Update(DatabaseFile obj)
 {
     using (InsightEntities db = new InsightEntities())
     {
         db.DatabaseFiles.Attach(obj);
         db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Exemplo n.º 29
0
        public async Task CreateFileAsync(int userId, string fileName)
        {
            var uriFileName = Guid.NewGuid().ToString();
            var uri         = Path.Combine("Files", uriFileName);
            var dbFile      = new DatabaseFile(userId, fileName, uri);
            await _dbFileRepository.AddAsync(dbFile);

            _fileRepository.CreateFile(dbFile.Uri);
        }
Exemplo n.º 30
0
        public static DatabaseFile Load(FileStream stream)
        {
            DatabaseFile databaseFile = new DatabaseFile();

            databaseFile.Header = new Header(stream);
            databaseFile.Table  = LoadTable(stream);

            return(databaseFile);
        }
        /// <summary>
        /// Adds an existing database file as an attachment to the message
        /// </summary>
        /// <param name="source">The target email message</param>
        /// <param name="db">The database file to add as an attachment</param>
        public static void AddAttachment(this EmailMessage source, DatabaseFile db)
        {
            if (source is null)
            {
                throw new System.ArgumentNullException(nameof(source));
            }

            source.Attachments.Add(db);
        }
Exemplo n.º 32
0
 void addStoreComm(DatabaseClass item)
 {
     DatabaseFile _db = new DatabaseFile();
     using (IObjectContainer db = Db4oFactory.OpenFile(_db.DB_FILE))
     {
         db.Store(item);
         db.Commit();
     }
 }
Exemplo n.º 33
0
        private void ddd_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                DatabaseFile _db = new DatabaseFile();
                using (IObjectContainer db = Db4oFactory.OpenFile(_db.DB_FILE))
                {
                    var temp = ddd.SelectedItem as DatabaseClass;
                    var q = from DatabaseClass p in db
                            where p.IDProduct == temp.IDProduct
                            select p.Details;

                    detailsGrid.ItemsSource = q;

                    var k = from DatabaseClass p in db
                            where p.IDProduct == temp.IDProduct
                            select p.Subprod;

                    subprodGrid.ItemsSource = k;
                }
            }
            catch { }
        }
Exemplo n.º 34
0
        public List<DatabaseFile> GetDatabaseFileInfo()
        {
            List<DatabaseFile> DBFS = new List<DatabaseFile>();

            // Create database connection to OML and open it
            SqlConnection sqlConn = OpenDatabase(DatabaseInformation.MasterDatabaseConnectionString);

            SqlDataReader reader;

            if (!ExecuteReader(sqlConn, "select * from oml.dbo.sysfiles", out reader))
            {
                return null;
            }

            while (reader.Read())
            {
                DatabaseFile DBF = new DatabaseFile();
                DBF.Name = (string)reader["name"];
                DBF.Size = (int)reader["size"] / 128;
                DBF.SizeString = ((int)reader["size"] / 128).ToString() + "MB";

                if ((int)reader["maxsize"] > 0)
                {
                    DBF.MaxSize = (int)reader["maxsize"] / 128;
                    DBF.MaxSizeString = ((int)reader["maxsize"] / 128).ToString() + "MB";
                }
                else
                {
                    DBF.MaxSize = 0;
                    if ((int)reader["maxsize"] == 0)
                        DBF.MaxSizeString = "No Growth";
                    else
                        DBF.MaxSizeString = "Unlimited Growth";
                }

                if ((int)reader["growth"] == 0)
                {
                    DBF.Growth = 0;
                    DBF.GrowthString = "No Growth";

                }
                else
                {
                    if (((int)reader["status"] & 0x100000) != 0)
                    {
                        // Percentage growth
                        DBF.Growth = (int)reader["growth"];
                        DBF.GrowthString = (int)reader["growth"] + "%";
                    }
                    else
                    {
                        DBF.Growth = (int)reader["growth"] / 128;
                        DBF.GrowthString = ((int)reader["growth"] / 128).ToString() + "MB";

                    }
                }

                DBFS.Add(DBF);
            }
            return DBFS;
        }