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)); } }
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(); } }
/// <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); }
//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); } }
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); }
/// <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); }
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(); }
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(); } }
/// <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))); }
/// <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); }
/// <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); }
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."); }); }
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; } }
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); } } }
/// <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); }
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."); } } }
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); } } }
/// <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); }
/// <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); } }
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; } }
/// <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]; //设置表名 } }
//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>(); }
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; } }
public void Delete(DatabaseFile obj) { using (InsightEntities db = new InsightEntities()) { db.DatabaseFiles.Attach(obj); db.DatabaseFiles.Remove(obj); db.SaveChanges(); } }
public DatabaseFile Insert(DatabaseFile obj) { using (InsightEntities db = new InsightEntities()) { db.DatabaseFiles.Add(obj); db.SaveChanges(); return(obj); } }
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(); } }
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); }
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); }
void addStoreComm(DatabaseClass item) { DatabaseFile _db = new DatabaseFile(); using (IObjectContainer db = Db4oFactory.OpenFile(_db.DB_FILE)) { db.Store(item); db.Commit(); } }
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 { } }
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; }