示例#1
0
        /// <summary>
        /// Initializes a new instance of the ServerRole class.
        /// </summary>
        public ServerRole(SMO.ServerRole serverRole)
        {
            //AddinHelper.Common.WriteToDebugWindow(string.Format("SMOH.{0}({1})", "ServerRole", serverRole));

            // Save the real thing in case we need to get something from it.

            _serverRole = serverRole;

            // NB. Not all properties are available depending on login credentials
            // Wrap in TC blocks.

            try { Name = serverRole.Name; }                           catch (Exception) { Name = "<No Access>"; }
        }
示例#2
0
        private static SQLInformation.Data.ApplicationDataSet.ServerRolesRow Add(MSMO.ServerRole serverRole, Guid instanceID, string instanceName)
        {
            SQLInformation.Data.ApplicationDataSet.ServerRolesRow dataRow = null;

            try
            {
                dataRow = Common.ApplicationDataSet.ServerRoles.NewServerRolesRow();

                dataRow.ID = Guid.NewGuid();

                dataRow.Name_ServerRole = serverRole.Name;
                dataRow.Instance_ID     = instanceID;
                dataRow.Name_Instance   = instanceName;

                // Not until SQL 2012
                //try
                //{
                //    newServerRoleRow.CreateDate = serverRole.DateCreated;
                //}
                //catch (Exception ex)
                //{
                //    VNC.AppLog.Warning(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 4);
                //}

                //try
                //{
                //    newServerRoleRow.DateLastModified = serverRole.DateModified;
                //}
                //catch (Exception ex)
                //{
                //    VNC.AppLog.Warning(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 5);
                //}

                dataRow.SnapShotDate  = DateTime.Now;
                dataRow.SnapShotError = "";

                Common.ApplicationDataSet.ServerRoles.AddServerRolesRow(dataRow);
                Common.ApplicationDataSet.ServerRolesTA.Update(Common.ApplicationDataSet.ServerRoles);
            }
            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);
        }
示例#3
0
 public static void UpdateDataSet(this MSMO.ServerRole serverRole, Data.ApplicationDataSet.ServerRolesRow dataRow)
 {
     try
     {
         //dataRow.X = serverRole.X;
     }
     catch (Exception ex)
     {
         VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 7);
         // TODO(crhodes):
         // Wrap anything above that throws an exception that we want to ignore,
         // e.g. property not available because of SQL Edition.
     }
 }
示例#4
0
 public static void UpdateDataSet(this MSMO.ServerRole serverRole, Data.ApplicationDataSet.ServerRolesRow serverRoleRow)
 {
     try
     {
         // Determine what might change and update it
     }
     catch (Exception ex)
     {
         // TODO(crhodes):  Need to wrap anything above that throws an exception
         // that we want to ignore, e.g. property not available because of
         // SQL Edition.
         PLLog.Error(ex, PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 2);
         throw ex;
     }
 }
示例#5
0
        private static void Update(MSMO.ServerRole serverRole, SQLInformation.Data.ApplicationDataSet.ServerRolesRow dataRow)
        {
            try
            {
                serverRole.UpdateDataSet(dataRow);

                UpdateDatabaseWithSnapShot(dataRow, "");
            }
            catch (Exception ex)
            {
                VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 6);

                UpdateDatabaseWithSnapShot(dataRow, ex.ToString().Substring(0, 256));
            }
        }
示例#6
0
        private static SQLInformation.Data.ApplicationDataSet.ServerRolesRow GetInfoFromSMO(MSMO.ServerRole serverRole, Guid instanceID, string instanceName)
        {
#if TRACE
            long startTicks = VNC.AppLog.Trace4("Enter", LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 2);
#endif
            SQLInformation.Data.ApplicationDataSet.ServerRolesRow dataRow = null;

            try
            {
                var dbs = from sr in Common.ApplicationDataSet.ServerRoles
                          where sr.Instance_ID == instanceID
                          select sr;

                var dbs2 = from db2 in dbs
                           where db2.Name_ServerRole == serverRole.Name
                           select db2;

                if (dbs2.Count() > 0)
                {
                    dataRow = dbs2.First();
                    Update(serverRole, dataRow);
                }
                else
                {
                    dataRow = Add(serverRole, instanceID, instanceName);
                }
            }
            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);
        }