public static DynamicVolume GetVolume(List <DynamicDisk> disks, VolumeManagerDatabase database, VolumeRecord volumeRecord) { List <ComponentRecord> componentRecords = database.FindComponentsByVolumeID(volumeRecord.VolumeId); if (volumeRecord.NumberOfComponents != (ulong)componentRecords.Count || componentRecords.Count == 0) { // database record is invalid throw new InvalidDataException("Number of components in volume record does not match actual number of component records"); } if (componentRecords.Count == 1) { ComponentRecord componentRecord = componentRecords[0]; return(GetVolume(disks, database, volumeRecord, componentRecord)); } else // Mirrored volume { // Mirrored Simple Volume is the only kind of mirror suppored by Windows (only 2-way mirror is supported) // Veritas also supports Mirrored Stripe / Mirrored RAID-5 / Mirrored Spanned Volume (up to 32-way mirror is supported) List <DynamicVolume> volumes = new List <DynamicVolume>(); foreach (ComponentRecord componentRecord in componentRecords) { DynamicVolume volume = GetVolume(disks, database, volumeRecord, componentRecord); volumes.Add(volume); } MirroredVolume mirroredVolume = new MirroredVolume(volumes, volumeRecord.VolumeGuid, database.DiskGroupGuid); mirroredVolume.VolumeID = volumeRecord.VolumeId; mirroredVolume.Name = volumeRecord.Name; return(mirroredVolume); } }
public List <ComponentRecord> componentRecords; // Array of Component records, ordered in writing direction. public void Read(TTFReader r, int markClassCount) { r.ReadInt(out this.componentCount); this.componentRecords = new List <ComponentRecord>(); for (int i = 0; i < this.componentCount; ++i) { ComponentRecord cr = new ComponentRecord(); cr.Read(r, markClassCount); this.componentRecords.Add(cr); } }
public static LigatureAttachTable ReadFrom(BinaryReader reader, ushort classCount) { LigatureAttachTable table = new LigatureAttachTable(); ushort componentCount = reader.ReadUInt16(); ComponentRecord[] componentRecs = new ComponentRecord[componentCount]; table.records = componentRecs; for (int i = 0; i < componentCount; ++i) { componentRecs[i] = new ComponentRecord( Utils.ReadInt16Array(reader, classCount)); } return(table); }
private ComponentRecord GetComponentRecord(int componentId, TRACK_INSPECTION_DETAIL inspectionDetail, string uom) { var dalComponent = new BLL.Core.Domain.Component(_context, componentId); var photo = dalComponent.GetComponentPhoto(); var x = new ComponentRecord(); x.Id = inspectionDetail.inspection_detail_auto; x.WornPercentage = Decimal.Round(inspectionDetail.worn_percentage, 2); x.Name = dalComponent.GetComponentDescription(); x.Photo = photo != null?Convert.ToBase64String(photo) : ""; x.Position = dalComponent.GetPositionLabel(); x.MeasurementPoints = GetMeasurementPointsForComponent(dalComponent, inspectionDetail, uom); return(x); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here graphics.PreferredBackBufferWidth = 800; graphics.PreferredBackBufferHeight = 600; RasterizerState customState = new RasterizerState(); graphics.GraphicsDevice.RasterizerState = customState; graphics.ApplyChanges(); ComponentRecord.RegisterAttribute <Sprite>("Sprite"); ComponentRecord.RegisterAttribute <AnimatedSprite>("AnimatedSprite"); ComponentRecord.RegisterAttribute <Transform>("Transform"); ComponentRecord.RegisterAttribute <GUIButton>("GUIButton"); ComponentRecord.RegisterAttribute <GUILabel>("GUILabel"); ComponentRecord.RegisterAttribute <GUITextBox>("GUITextBox"); ComponentRecord.RegisterAttribute <GUIImage>("GUIImage"); ComponentRecord.RegisterAttribute <AABBCollider>("AABBCollider"); ComponentRecord.RegisterAttribute <SATCollider>("SATCollider"); ComponentRecord.RegisterAttribute <CharacterController>("CharacterController"); Debug.InitializeDebug(GraphicsDevice, this); DebugConsole.DebugConsoleInit(this, graphics); GameSerializer.Init(this); GameScript.InitGameScript(); Transform.UpdateGraphicsSize(graphics); InputManager.InitInputManager(this); Camera.InitCamera(graphics); GUILabel.Initialize(this); Exiting += new EventHandler <EventArgs>((object obj, EventArgs args) => { Debug.CloseDebug(); }); DebugConsole.RegisterCommand("reset", (string[] args) => { reset(); }); w = new World(); this.IsMouseVisible = true; base.Initialize(); }
public static DatabaseRecord ReadFrom(byte[] buffer, int offset) { DatabaseRecord result = null; if (Utilities.ToInt32BigEndian(buffer, offset + 0xC) != 0) { switch ((RecordType)(buffer[offset + 0x13] & 0xF)) { case RecordType.Volume: result = new VolumeRecord(); break; case RecordType.Component: result = new ComponentRecord(); break; case RecordType.Extent: result = new ExtentRecord(); break; case RecordType.Disk: result = new DiskRecord(); break; case RecordType.DiskGroup: result = new DiskGroupRecord(); break; default: throw new NotImplementedException("Unrecognized record type: " + buffer[offset + 0x13]); } result.DoReadFrom(buffer, offset); } return result; }
public TestDatabaseReader() { var elementId = 1; var elementVersionId = 1; var propertyId = 1; var websiteVersionId = 1; var dataScopeId = 1; var dataTypeId = 1; var dataTypeVersionId = 1; _dataScopes = new DataScopeRecord[0]; _dataTypes = new DataTypeRecord[0]; _dataTypeVersions = new DataTypeVersionRecord[0]; _components = new ComponentRecord[0]; _componentVersions = new ComponentVersionRecord[0]; _properties = new ElementPropertyRecord[0]; _propertyValues = new ElementPropertyValueRecord[0]; _regions = new [] { new RegionRecord { RecordId = elementId++, Name = "example_region_1", CreatedBy = "urn:user:1234", CreatedWhen = DateTime.UtcNow }, new RegionRecord { RecordId = elementId++, Name = "example_region_2", CreatedBy = "urn:user:1234", CreatedWhen = DateTime.UtcNow } }; _layouts = new [] { new LayoutRecord { RecordId = elementId++, Name = "page_layout", CreatedBy = "urn:user:1234", CreatedWhen = DateTime.UtcNow } }; _regionVersions = new [] { new RegionVersionRecord { ParentRecordId = _regions[0].RecordId, RecordId = elementVersionId++, Version = 1, LayoutName = "layouts:col_2_left_fixed" }, new RegionVersionRecord { ParentRecordId = _regions[1].RecordId, RecordId = elementVersionId++, Version = 1, RegionTemplates = new [] { new RegionTemplateRecord { PageArea = PageArea.Body, TemplatePath = "/template1" } } } }; _layoutVersions = new [] { new LayoutVersionRecord { ParentRecordId = _layouts[0].RecordId, RecordId = elementVersionId++, Version = 1, AssetDeployment = AssetDeployment.Inherit, ZoneNesting = "header,main,footer", Zones = new [] { new LayoutZoneRecord { ZoneName = "header", ContentType = "html", ContentName = "header", ContentValue = "<h1>Header V1</h1>" }, new LayoutZoneRecord { ZoneName = "footer", ContentType = "html", ContentName = "footer", ContentValue = "<h1>Footer V1</h1>" } } }, new LayoutVersionRecord { ParentRecordId = _layouts[0].RecordId, RecordId = elementVersionId++, Version = 2, AssetDeployment = AssetDeployment.Inherit, ZoneNesting = "header,main,footer", Zones = new [] { new LayoutZoneRecord { ZoneName = "header", RegionId = _regions[0].RecordId }, new LayoutZoneRecord { ZoneName = "footer", RegionId = _regions[1].RecordId } } } }; _pages = new [] { new PageRecord { RecordId = elementId++, CreatedBy = "urn:user:1234", CreatedWhen = DateTime.UtcNow, Name = "page_1" }, new PageRecord { RecordId = elementId++, CreatedBy = "urn:user:1234", CreatedWhen = DateTime.UtcNow, Name = "page_2" } }; _pageVersions = new [] { new PageVersionRecord { ParentRecordId = _pages[0].RecordId, RecordId = elementVersionId++, Version = 1, LayoutId = _layouts[0].RecordId, AssetDeployment = AssetDeployment.PerWebsite, Title = "First CMS Page", Routes = new [] { new PageRouteRecord { Path = "/cms/page1", Priority = 200 }, new PageRouteRecord { Path = "/cms/page1_old_url", Priority = -10 } }, LayoutZones = new [] { new LayoutZoneRecord { ZoneName = "main", ContentType = "html", ContentName = "cms-page1", ContentValue = "<p>This is CMS page 1</p>" } } }, new PageVersionRecord { ParentRecordId = _pages[1].RecordId, RecordId = elementVersionId++, Version = 1, AssetDeployment = AssetDeployment.PerWebsite, LayoutId = _layouts[0].RecordId, Title = "Second CMS Page", Routes = new [] { new PageRouteRecord { Path = "/cms/page2", Priority = 200 } }, LayoutZones = new [] { new LayoutZoneRecord { ZoneName = "main", ContentType = "html", ContentName = "cms-page1", ContentValue = "<p>This is CMS page 2</p>" } } }, new PageVersionRecord { ParentRecordId = _pages[0].RecordId, RecordId = elementVersionId++, Version = 2, LayoutId = _layouts[0].RecordId, AssetDeployment = AssetDeployment.PerWebsite, Title = "First CMS Page", Routes = new [] { new PageRouteRecord { Path = "/cms/page1", Priority = 200 }, new PageRouteRecord { Path = "/cms/page1_old_url", Priority = -10 } }, LayoutZones = new [] { new LayoutZoneRecord { ZoneName = "main", ContentType = "html", ContentName = "cms-page1", ContentValue = "<p>This is CMS page 1</p>" } } }, new PageVersionRecord { ParentRecordId = _pages[1].RecordId, RecordId = elementVersionId++, Version = 2, LayoutId = _layouts[0].RecordId, AssetDeployment = AssetDeployment.PerWebsite, Title = "Second CMS Page", Routes = new [] { new PageRouteRecord { Path = "/cms/page2", Priority = 200 } }, LayoutZones = new [] { new LayoutZoneRecord { ZoneName = "main", ContentType = "html", ContentName = "cms-page1", ContentValue = "<p>This is CMS page 2</p>" } } } }; _websiteVersions = new [] { new WebsiteVersionRecord { RecordId = websiteVersionId++, Name = "1.0", Description = "First version", CreatedBy = "urn:user:1234", CreatedWhen = DateTime.UtcNow, }, new WebsiteVersionRecord { RecordId = websiteVersionId++, Name = "1.1", Description = "Modified layout", CreatedBy = "urn:user:1234", CreatedWhen = DateTime.UtcNow, } }; _environments = new[] { new EnvironmentRecord { RecordId = 1, Name = "prod", CreatedBy = "urn:user:1234", CreatedWhen = DateTime.UtcNow, DisplayName = "Production", BaseUrl = "http://sample1.localhost/", WebsiteVersionId = _websiteVersions[0].RecordId }, new EnvironmentRecord { RecordId = 1, Name = "stage", CreatedBy = "urn:user:1234", CreatedWhen = DateTime.UtcNow, DisplayName = "Staging", BaseUrl = "http://staging.sample1.localhost/", WebsiteVersionId = _websiteVersions[1].RecordId } }; _websiteVersionPages = new [] { new WebsiteVersionPageRecord { WebsiteVersionId = _websiteVersions[0].RecordId, PageId = _pageVersions[0].ParentRecordId, PageVersionId = _pageVersions[0].RecordId }, new WebsiteVersionPageRecord { WebsiteVersionId = _websiteVersions[0].RecordId, PageId = _pageVersions[1].ParentRecordId, PageVersionId = _pageVersions[1].RecordId }, new WebsiteVersionPageRecord { WebsiteVersionId = _websiteVersions[1].RecordId, PageId = _pageVersions[2].ParentRecordId, PageVersionId = _pageVersions[2].RecordId }, new WebsiteVersionPageRecord { WebsiteVersionId = _websiteVersions[1].RecordId, PageId = _pageVersions[3].ParentRecordId, PageVersionId = _pageVersions[3].RecordId } }; _websiteVersionLayouts = new [] { new WebsiteVersionLayoutRecord { WebsiteVersionId = _websiteVersions[0].RecordId, LayoutId = _layoutVersions[0].ParentRecordId, LayoutVersionId = _layoutVersions[0].RecordId }, new WebsiteVersionLayoutRecord { WebsiteVersionId = _websiteVersions[1].RecordId, LayoutId = _layoutVersions[1].ParentRecordId, LayoutVersionId = _layoutVersions[1].RecordId } }; _websiteVersionRegions = new [] { new WebsiteVersionRegionRecord { WebsiteVersionId = _websiteVersions[0].RecordId, RegionId = _regionVersions[0].ParentRecordId, RegionVersionId = _regionVersions[0].RecordId }, new WebsiteVersionRegionRecord { WebsiteVersionId = _websiteVersions[0].RecordId, RegionId = _regionVersions[1].ParentRecordId, RegionVersionId = _regionVersions[1].RecordId }, new WebsiteVersionRegionRecord { WebsiteVersionId = _websiteVersions[1].RecordId, RegionId = _regionVersions[0].ParentRecordId, RegionVersionId = _regionVersions[0].RecordId }, new WebsiteVersionRegionRecord { WebsiteVersionId = _websiteVersions[1].RecordId, RegionId = _regionVersions[1].ParentRecordId, RegionVersionId = _regionVersions[1].RecordId } }; _websiteVersionDataTypes = new WebsiteVersionDataTypeRecord [0]; _websiteVersionComponents = new WebsiteVersionComponentRecord [0]; }
private static SpannedVolume GetSpannedVolume(List <DynamicDisk> disks, VolumeManagerDatabase database, ComponentRecord componentRecord, VolumeRecord volumeRecord) { List <DynamicColumn> columns = GetDynamicVolumeColumns(disks, database, componentRecord, volumeRecord); SpannedVolume volume = new SpannedVolume(columns[0], volumeRecord.VolumeGuid, database.DiskGroupGuid); volume.VolumeID = volumeRecord.VolumeId; volume.Name = volumeRecord.Name; volume.DiskGroupName = database.DiskGroupName; return(volume); }
private static Raid5Volume GetRAID5Volume(List <DynamicDisk> disks, VolumeManagerDatabase database, ComponentRecord componentRecord, VolumeRecord volumeRecord) { List <DynamicColumn> columns = GetDynamicVolumeColumns(disks, database, componentRecord, volumeRecord); Raid5Volume volume = new Raid5Volume(columns, (int)componentRecord.StripeSizeLBA, volumeRecord.VolumeGuid, database.DiskGroupGuid); volume.VolumeID = volumeRecord.VolumeId; volume.Name = volumeRecord.Name; volume.DiskGroupName = database.DiskGroupName; return(volume); }
private static SimpleVolume GetSimpleVolume(List <DynamicDisk> disks, VolumeManagerDatabase database, ComponentRecord componentRecord, VolumeRecord volumeRecord) { List <ExtentRecord> extentRecords = database.FindExtentsByComponentID(componentRecord.ComponentId); if (extentRecords.Count == 1) { ExtentRecord extentRecord = extentRecords[0]; DiskRecord diskRecord = database.FindDiskByDiskID(extentRecord.DiskId); DynamicDisk disk = DynamicDiskHelper.FindDisk(disks, diskRecord.DiskGuid); // we add nulls as well DynamicDiskExtent extent = DynamicDiskExtentHelper.GetDiskExtent(disk, extentRecord); SimpleVolume volume = new SimpleVolume(extent, volumeRecord.VolumeGuid, database.DiskGroupGuid); volume.VolumeID = volumeRecord.VolumeId; volume.Name = volumeRecord.Name; volume.DiskGroupName = database.DiskGroupName; return(volume); } else { // component / extent records are invalid throw new InvalidDataException("Number of extents in component record does not match actual number of extent records"); } }
private static List <DynamicColumn> GetDynamicVolumeColumns(List <DynamicDisk> disks, VolumeManagerDatabase database, ComponentRecord componentRecord, VolumeRecord volumeRecord) { // extentRecords are sorted by offset in column List <ExtentRecord> extentRecords = database.FindExtentsByComponentID(componentRecord.ComponentId); if (componentRecord.NumberOfExtents != extentRecords.Count || extentRecords.Count == 0) { // database record is invalid throw new InvalidDataException("Number of extents in component record does not match actual number of extent records"); } SortedList <uint, List <DynamicDiskExtent> > columns = new SortedList <uint, List <DynamicDiskExtent> >(); foreach (ExtentRecord extentRecord in extentRecords) { DiskRecord diskRecord = database.FindDiskByDiskID(extentRecord.DiskId); DynamicDisk disk = DynamicDiskHelper.FindDisk(disks, diskRecord.DiskGuid); // we add nulls as well DynamicDiskExtent extent = DynamicDiskExtentHelper.GetDiskExtent(disk, extentRecord); if (columns.ContainsKey(extentRecord.ColumnIndex)) { columns[extentRecord.ColumnIndex].Add(extent); } else { List <DynamicDiskExtent> list = new List <DynamicDiskExtent>(); list.Add(extent); columns.Add(extentRecord.ColumnIndex, list); } } List <DynamicColumn> result = new List <DynamicColumn>(); foreach (List <DynamicDiskExtent> extents in columns.Values) { result.Add(new DynamicColumn(extents)); } return(result); }
private static DynamicVolume GetVolume(List <DynamicDisk> disks, VolumeManagerDatabase database, VolumeRecord volumeRecord, ComponentRecord componentRecord) { if (componentRecord.ExtentLayout == ExtentLayoutName.Concatenated) { if (componentRecord.NumberOfExtents == 1) { // Simple volume return(GetSimpleVolume(disks, database, componentRecord, volumeRecord));; } else { // spanned volume SpannedVolume volume = GetSpannedVolume(disks, database, componentRecord, volumeRecord); return(volume); } } else if (componentRecord.ExtentLayout == ExtentLayoutName.Stripe) { // striped volume StripedVolume volume = GetStripedVolume(disks, database, componentRecord, volumeRecord); return(volume); } else if (componentRecord.ExtentLayout == ExtentLayoutName.RAID5) { Raid5Volume volume = GetRAID5Volume(disks, database, componentRecord, volumeRecord); return(volume); } else { return(null); } }
public static LigatureAttachTable ReadFrom(BinaryReader reader, ushort classCount) { LigatureAttachTable table = new LigatureAttachTable(); ushort componentCount = reader.ReadUInt16(); ComponentRecord[] componentRecs = new ComponentRecord[componentCount]; table.records = componentRecs; for (int i = 0; i < componentCount; ++i) { componentRecs[i] = new ComponentRecord( Utils.ReadInt16Array(reader, classCount)); } return table; }
private SparseStream OpenComponent(ComponentRecord component) { if (component.MergeType == ExtentMergeType.Concatenated) { List<ExtentRecord> extents = new List<ExtentRecord>(_database.GetComponentExtents(component.Id)); extents.Sort(CompareExtentOffsets); // Sanity Check... long pos = 0; foreach (var extent in extents) { if (extent.OffsetInVolumeLba != pos) { throw new IOException("Volume extents are non-contiguous"); } pos += extent.SizeLba; } List<SparseStream> streams = new List<SparseStream>(); foreach (var extent in extents) { streams.Add(OpenExtent(extent)); } return new ConcatStream(Ownership.Dispose, streams.ToArray()); } else if (component.MergeType == ExtentMergeType.Interleaved) { List<ExtentRecord> extents = new List<ExtentRecord>(_database.GetComponentExtents(component.Id)); extents.Sort(CompareExtentInterleaveOrder); List<SparseStream> streams = new List<SparseStream>(); foreach (var extent in extents) { streams.Add(OpenExtent(extent)); } return new StripedStream(component.StripeSizeSectors * Sizes.Sector, Ownership.Dispose, streams.ToArray()); } else { throw new NotImplementedException("Unknown component mode: " + component.MergeType); } }
private LogicalVolumeStatus GetComponentStatus(ComponentRecord cmpnt) { // NOTE: no support for RAID, so either valid or failed... LogicalVolumeStatus status = LogicalVolumeStatus.Healthy; foreach (var extent in _database.GetComponentExtents(cmpnt.Id)) { DiskRecord disk = _database.GetDisk(extent.DiskId); if (!_disks.ContainsKey(new Guid(disk.DiskGuidString))) { status = LogicalVolumeStatus.Failed; break; } } return status; }
public ComponentRecord GetComponentRecord(uint i) { ComponentRecord cr = null; if (i < ComponentCount) { ushort sizeofComponentRecord = (ushort)(2 * m_ClassCount); uint offset = m_offsetLigatureAttach + (uint)FieldOffsets.ComponentRecordArray + i*sizeofComponentRecord; cr = new ComponentRecord(offset, m_bufTable, m_offsetLigatureAttach, m_ClassCount); } return cr; }