public static void TakeDBFileGroupSnapShot(SQLInformation.Data.ApplicationDataSet.DBFileGroupsRow dbFileGroupRow) { #if TRACE long startTicks = VNC.AppLog.Trace4("Start", LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 4); #endif Data.ApplicationDataSet.DBFileGroupInfoRow infoRow = null; try { infoRow = Common.ApplicationDataSet.DBFileGroupInfo.NewDBFileGroupInfoRow(); infoRow.SnapShotDate = dbFileGroupRow.SnapShotDate; infoRow.Size = dbFileGroupRow.Size; infoRow.DBFileGroup_ID = dbFileGroupRow.ID; infoRow.Database_ID = dbFileGroupRow.Database_ID; Common.ApplicationDataSet.DBFileGroupInfo.AddDBFileGroupInfoRow(infoRow); Common.ApplicationDataSet.DBFileGroupInfoTA.Update(Common.ApplicationDataSet.DBFileGroupInfo); } catch (Exception ex) { VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 11); infoRow.SnapShotDate = DateTime.Now; infoRow.SnapShotError = ex.ToString().Substring(0, 256); Common.ApplicationDataSet.DBFileGroupInfoTA.Update(Common.ApplicationDataSet.DBFileGroupInfo); } #if TRACE VNC.AppLog.Trace4("End", LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 12, startTicks); #endif }
private static void Update(MSMO.FileGroup fileGroup, SQLInformation.Data.ApplicationDataSet.DBFileGroupsRow dataRow) { try { fileGroup.UpdateDataSet(dataRow); UpdateDatabaseWithSnapShot(dataRow, ""); // Add the snapshot SMO.Helper.TakeDBFileGroupSnapShot(dataRow); // Add info about the DataFiles belonging to this filegroup. DataFile.LoadFromSMO(fileGroup, dataRow.ID, dataRow.Database_ID); } catch (Exception ex) { VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 6); UpdateDatabaseWithSnapShot(dataRow, ex.ToString().Substring(0, 256)); } }
private static SQLInformation.Data.ApplicationDataSet.DBFileGroupsRow Add(MSMO.FileGroup fileGroup, Guid databaseID) { SQLInformation.Data.ApplicationDataSet.DBFileGroupsRow dataRow = null; try { dataRow = Common.ApplicationDataSet.DBFileGroups.NewDBFileGroupsRow(); dataRow.ID = Guid.NewGuid(); dataRow.Database_ID = databaseID; dataRow.Name_FileGroup = fileGroup.Name; dataRow.Size = fileGroup.Size; Common.ApplicationDataSet.DBFileGroups.AddDBFileGroupsRow(dataRow); //fileGroupID = newFileGroup.ID; dataRow.SnapShotDate = DateTime.Now; dataRow.SnapShotError = ""; // Need to update before calling LoadDBDataFiles_FromSMO Common.ApplicationDataSet.DBFileGroupsTA.Update(Common.ApplicationDataSet.DBFileGroups); DataFile.LoadFromSMO(fileGroup, dataRow.ID, databaseID); } catch (Exception ex) { VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 5); // TODO(crhodes): // Wrap anything above that throws an exception that we want to ignore, // e.g. property not available because of SQL Edition. UpdateDatabaseWithSnapShot(dataRow, ex.ToString().Substring(0, 256)); } return(dataRow); }
private static SQLInformation.Data.ApplicationDataSet.DBFileGroupsRow GetInfoFromSMO(MSMO.FileGroup fileGroup, Guid databaseID) { #if TRACE long startTicks = VNC.AppLog.Trace4("Enter", LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 2); #endif SQLInformation.Data.ApplicationDataSet.DBFileGroupsRow dataRow = null; try { var dbs = from tb in Common.ApplicationDataSet.DBFileGroups where tb.Database_ID == databaseID select tb; var dbs2 = from db2 in dbs where db2.Name_FileGroup == fileGroup.Name select db2; if (dbs2.Count() > 0) { dataRow = dbs2.First(); Update(fileGroup, dataRow); } else { dataRow = Add(fileGroup, databaseID); } } catch (Exception ex) { VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 3); } #if TRACE VNC.AppLog.Trace4("Exit", LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 4, startTicks); #endif return(dataRow); }