internal void LoadFromSmo(smo::LogFile smolf) { this.Name = smolf.Name; this.LogicalName = smolf.Name; this.Filename = smolf.FileName; this.DatabaseFileType = DatabaseFileType.Log; this.DeploymentState = Registry.DeploymentState.Deployed; this.RunningState = Registry.RunningState.Running; this.AllocatedSpace = (long)Math.Ceiling(smolf.Size * 0x400L); // given in KB, bug in docs! this.UsedSpace = (long)(smolf.UsedSpace * 0x400L); this.ReservedSpace = smolf.MaxSize == -1 ? 0L : (long)(smolf.MaxSize * 0x400L); }
/* *** TODO: delete /// <summary> /// Adds files to a database based on the cluster schema information. /// </summary> /// <param name="databaseInstance">The database instance object.</param> /// <param name="dto">The SMO object pointing to the target database.</param> private void CreateFiles(smo::Database dto) { this.LoadFiles(false); foreach (DatabaseInstanceFile f in this.Files.Values) { f.DeploymentState = DeploymentState.Deploying; f.Save(); string localFilename = f.GetFullLocalFilename(); string networkFilename = f.GetFullUncFilename(); // Check directory string dir = Path.GetDirectoryName(networkFilename); if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); // Create new file logfile if (f.DatabaseFileType == DatabaseFileType.Log) { smo::LogFile lf = new smo::LogFile(dto, f.Filename); lf.FileName = localFilename; lf.Growth = 0; lf.GrowthType = smo::FileGrowthType.None; //nf.MaxSize = (double)fi.AllocatedSpace / 0x400; // in kilobytes lf.Size = (double)f.AllocatedSpace / 0x400; // in kilobytes dto.LogFiles.Add(lf); } f.DeploymentState = DeploymentState.Deployed; f.Save(); } }*/ /// <summary> /// Adds file group to a database based on the cluster schema information. /// </summary> /// <param name="databaseInstance">The database instance object.</param> /// <param name="dto">The SMO object pointing to the target database.</param> private void CreateFileGroups(smo::Database dto) { // Add FileGroups this.LoadFileGroups(false); foreach (DatabaseInstanceFileGroup fg in this.FileGroups.Values) { fg.DeploymentState = DeploymentState.Deploying; fg.Save(); if (fg.FileGroupType == FileGroupType.Log) { fg.LoadFiles(false); foreach (DatabaseInstanceFile fi in fg.Files.Values) { fi.DeploymentState = DeploymentState.Deploying; fi.Save(); string localFilename = fi.GetFullLocalFilename(); string networkFilename = fi.GetFullUncFilename(); // Check directory string dir = Path.GetDirectoryName(networkFilename); if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); // Create new File smo::LogFile lf = new smo::LogFile(dto, fi.LogicalName); lf.FileName = localFilename; lf.Growth = 0; lf.GrowthType = smo::FileGrowthType.None; //nf.MaxSize = (double)fi.AllocatedSpace / 0x400; // in kilobytes lf.Size = (double)fi.AllocatedSpace / 0x400; // in kilobytes dto.LogFiles.Add(lf); fi.DeploymentState = DeploymentState.Deployed; fi.Save(); } } else if (fg.FileGroupType == FileGroupType.Data) { // Create new File Group smo::FileGroup nfg = new smo::FileGroup(dto, fg.FileGroupName); // Add files to the File Group fg.LoadFiles(false); foreach (DatabaseInstanceFile fi in fg.Files.Values) { fi.DeploymentState = DeploymentState.Deploying; fi.Save(); string localFilename = fi.GetFullLocalFilename(); string networkFilename = fi.GetFullUncFilename(); // Check directory string dir = Path.GetDirectoryName(networkFilename); if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); // Create new File smo::DataFile nf = new smo::DataFile(nfg, fi.LogicalName); nf.FileName = localFilename; nf.Growth = 0; nf.GrowthType = smo::FileGrowthType.None; //nf.MaxSize = (double)fi.AllocatedSpace / 0x400; // in kilobytes nf.Size = (double)fi.AllocatedSpace / 0x400; // in kilobytes nfg.Files.Add(nf); fi.DeploymentState = DeploymentState.Deployed; fi.Save(); } // Add new File Group to the Database dto.FileGroups.Add(nfg); } else { throw new NotImplementedException(); } fg.DeploymentState = DeploymentState.Deployed; fg.Save(); } this.Context.LogEvent(new Event("Jhu.Graywulf.Registry.DatabaseInstance.CreateFileGroups", this.Guid)); }
internal void DiscoverLogFile(smo::LogFile smofile, List <Entity> update, List <Entity> delete, List <Entity> create) { InitializeDiscovery(update, delete, create); LoadFromSmo(smofile); DiscoverDiskVolume(); }