示例#1
0
        private void OnSnapShot_Weekly(object sender, RoutedEventArgs e)
        {
            ExpandMask.DatabaseExpandSetting databaseExpandSetting = new ExpandMask.DatabaseExpandSetting(SQLInformation.Data.Config.ExpandSetting_Weekly_Database);
            ExpandMask.InstanceExpandSetting instanceExpandSetting = new ExpandMask.InstanceExpandSetting(SQLInformation.Data.Config.ExpandSetting_Weekly_Instance);

            SQLInformation.Helper.TakeSnapShot(instanceExpandSetting, databaseExpandSetting);
        }
示例#2
0
        public static void LoadFromSMO(Data.ApplicationDataSet.InstancesDataTable instances,
                                       ExpandMask.InstanceExpandSetting instanceExpandSetting,
                                       ExpandMask.JobServerExpandSetting jobServerExpandSetting,
                                       ExpandMask.DatabaseExpandSetting databaseExpandSetting)
        {
#if TRACE
            long startTicks = VNC.AppLog.Info("Enter", LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 0);
#endif

            foreach (Data.ApplicationDataSet.InstancesRow instanceRow in instances)
            {
                if (instanceRow.IsMonitored && instanceExpandSetting.IsMonitored)
                {
                    var updatedInstanceRow = GetInfoFromSMO(instanceRow, instanceExpandSetting, jobServerExpandSetting, databaseExpandSetting);

                    // Some information  is not provided by SMO.  Add it in.

                    updatedInstanceRow.ADDomain     = instanceRow.ADDomain;
                    updatedInstanceRow.Environment  = instanceRow.Environment;
                    updatedInstanceRow.SecurityZone = instanceRow.SecurityZone;

                    Helper.TakeInstanceSnapShot(updatedInstanceRow);
                }
            }

#if TRACE
            VNC.AppLog.Info("Exit", LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 1, startTicks);
#endif
        }
        private void OnSnapShot_IntraDay(object sender, RoutedEventArgs e)
        {
            ExpandMask.InstanceExpandSetting  instanceExpandSetting  = new ExpandMask.InstanceExpandSetting(SQLInformation.Data.Config.ExpandSetting_IntraDay_Instance);
            ExpandMask.JobServerExpandSetting jobServerExpandSetting = new ExpandMask.JobServerExpandSetting(SQLInformation.Data.Config.ExpandSetting_Daily_JobServer);
            ExpandMask.DatabaseExpandSetting  databaseExpandSetting  = new ExpandMask.DatabaseExpandSetting(SQLInformation.Data.Config.ExpandSetting_IntraDay_Database);


            SQLInformation.Helper.TakeSnapShot(instanceExpandSetting, jobServerExpandSetting, databaseExpandSetting);
        }
示例#4
0
        public static void TakeWeeklySnapShot()
        {
            ExpandMask.InstanceExpandSetting  instanceExpandSetting  = new ExpandMask.InstanceExpandSetting(SQLInformation.Data.Config.ExpandSetting_Weekly_Instance);
            ExpandMask.JobServerExpandSetting jobServerExpandSetting = new ExpandMask.JobServerExpandSetting(SQLInformation.Data.Config.ExpandSetting_Daily_JobServer);
            ExpandMask.DatabaseExpandSetting  databaseExpandSetting  = new ExpandMask.DatabaseExpandSetting(SQLInformation.Data.Config.ExpandSetting_Weekly_Database);


            SQLInformation.Helper.TakeSnapShot(instanceExpandSetting, jobServerExpandSetting, databaseExpandSetting);
        }
        private void OnSave(object sender, RoutedEventArgs e)
        {
            int instanceExpandMask  = 0;
            int databaseExpandMask  = 0;
            int jobServerExpandMask = 0;

            try
            {
                foreach (var item in cbe_IsMonitored.SelectedItems)
                {
                    instanceExpandMask += ((KeyValuePair <string, int>)item).Value;
                }

                foreach (var item in cbe_DefaultDatabaseExpandMask.SelectedItems)
                {
                    databaseExpandMask += ((KeyValuePair <string, int>)item).Value;
                }

                foreach (var item in cbe_DefaultJobServerExpandMask.SelectedItems)
                {
                    jobServerExpandMask += ((KeyValuePair <string, int>)item).Value;
                }

                ExpandMask.InstanceExpandSetting instanceExpandSetting = new ExpandMask.InstanceExpandSetting(instanceExpandMask);

                SQLInformation.Data.ApplicationDataSet.InstancesRow newInstance = Common.ApplicationDataSet.Instances.NewInstancesRow();

                newInstance.ID            = Guid.Parse(textEdit_ID.Text);
                newInstance.Name_Instance = txtEdit_Name_Instance.Text;
                newInstance.Port          = int.Parse(tePortNumber.Text);
                newInstance.NetName       = cbe_NetName.Text;
                newInstance.ADDomain      = cbe_ADDomain.Text;
                newInstance.Environment   = cbe_Environment.Text;
                newInstance.SecurityZone  = cbe_SecurityZone.Text;

                newInstance.IsMonitored = instanceExpandSetting.IsMonitored;

                newInstance.ExpandContent     = instanceExpandSetting.ExpandContent;
                newInstance.ExpandJobServer   = instanceExpandSetting.ExpandJobServer;
                newInstance.ExpandStorage     = instanceExpandSetting.ExpandStorage;
                newInstance.ExpandLogins      = instanceExpandSetting.ExpandLogins;
                newInstance.ExpandServerRoles = instanceExpandSetting.ExpandServerRoles;
                newInstance.ExpandTriggers    = instanceExpandSetting.ExpandTriggers;

                newInstance.DefaultDatabaseExpandMask  = databaseExpandMask;
                newInstance.DefaultJobServerExpandMask = jobServerExpandMask;

                Common.ApplicationDataSet.Instances.AddInstancesRow(newInstance);
                Common.ApplicationDataSet.InstancesTA.Update(Common.ApplicationDataSet.Instances);
            }
            catch (Exception ex)
            {
                PLLog.Error(ex, PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 2);
            }
        }
        private void OnSnapShot_Weekly(object sender, RoutedEventArgs e)
        {
            try
            {
                ExpandMask.InstanceExpandSetting  instanceExpandSetting  = new ExpandMask.InstanceExpandSetting(SQLInformation.Data.Config.ExpandSetting_Weekly_Instance);
                ExpandMask.JobServerExpandSetting jobServerExpandSetting = new ExpandMask.JobServerExpandSetting(SQLInformation.Data.Config.ExpandSetting_Weekly_JobServer);
                ExpandMask.DatabaseExpandSetting  databaseExpandSetting  = new ExpandMask.DatabaseExpandSetting(SQLInformation.Data.Config.ExpandSetting_Weekly_Database);


                SQLInformation.Helper.TakeSnapShot(instanceExpandSetting, jobServerExpandSetting, databaseExpandSetting);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
示例#7
0
        public static void TakeWeekly()
        {
            try
            {
                ExpandMask.InstanceExpandSetting  instanceExpandSetting  = new ExpandMask.InstanceExpandSetting(SQLInformation.Data.Config.ExpandSetting_Weekly_Instance);
                ExpandMask.JobServerExpandSetting jobServerExpandSetting = new ExpandMask.JobServerExpandSetting(SQLInformation.Data.Config.ExpandSetting_Weekly_JobServer);
                ExpandMask.DatabaseExpandSetting  databaseExpandSetting  = new ExpandMask.DatabaseExpandSetting(SQLInformation.Data.Config.ExpandSetting_Weekly_Database);


                SQLInformation.Helper.TakeSnapShot(instanceExpandSetting, jobServerExpandSetting, databaseExpandSetting);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
示例#8
0
        private void OnCreateNewInstance(object sender, RoutedEventArgs e)
        {
            int instanceExpandMask  = 0;
            int databaseExpandMask  = 0;
            int jobServerExpandMask = 0;


            Window parentWindow = Window.GetWindow(this);

            string newInstanceFullName = null;

            newInstanceFullName = string.Format("{0}{1}{2}", cbe_NetName.Text, (te_Name_Instance.Text.Length > 0 ? @"\" : ""), te_Name_Instance.Text);
            string serverName = tb_Name_Server.Text;
            int    portNumber = 0;

            int.TryParse(te_PortNumber.Text, out portNumber);


            if (InstanceIsNotAccessible(newInstanceFullName, serverName, portNumber))
            {
                MessageBox.Show(string.Format("Instance {0} not accessible.", newInstanceFullName));
                return;
            }

            if (InstanceAlreadyExists(newInstanceFullName))
            {
                MessageBox.Show(string.Format("Entry for Instance {0} already exists.", newInstanceFullName));
                InitializeComponent();
                return;
            }

            try
            {
                foreach (var item in cbe_IsMonitored.SelectedItems)
                {
                    instanceExpandMask += ((KeyValuePair <string, int>)item).Value;
                }

                foreach (var item in cbe_DefaultDatabaseExpandMask.SelectedItems)
                {
                    databaseExpandMask += ((KeyValuePair <string, int>)item).Value;
                }

                foreach (var item in cbe_DefaultJobServerExpandMask.SelectedItems)
                {
                    jobServerExpandMask += ((KeyValuePair <string, int>)item).Value;
                }

                ExpandMask.InstanceExpandSetting instanceSetting = new ExpandMask.InstanceExpandSetting(instanceExpandMask);

                SQLInformation.Data.ApplicationDataSet.InstancesRow newInstance = Common.ApplicationDataSet.Instances.NewInstancesRow();

                newInstance.ID            = Guid.NewGuid();
                newInstance.Name_Instance = newInstanceFullName;
                newInstance.Port          = portNumber;

                newInstance.NetName      = cbe_NetName.Text;
                newInstance.ADDomain     = cbe_ADDomain.Text;
                newInstance.Environment  = cbe_Environment.Text;
                newInstance.SecurityZone = cbe_SecurityZone.Text;

                newInstance.IsMonitored = instanceSetting.IsMonitored;

                newInstance.ExpandContent       = instanceSetting.ExpandContent;
                newInstance.ExpandJobServer     = instanceSetting.ExpandJobServer;
                newInstance.ExpandStorage       = instanceSetting.ExpandStorage;
                newInstance.ExpandLinkedServers = instanceSetting.ExpandLinkedServers;
                newInstance.ExpandLogins        = instanceSetting.ExpandLogins;
                newInstance.ExpandServerRoles   = instanceSetting.ExpandServerRoles;
                newInstance.ExpandTriggers      = instanceSetting.ExpandTriggers;

                newInstance.DefaultDatabaseExpandMask  = databaseExpandMask;
                newInstance.DefaultJobServerExpandMask = jobServerExpandMask;

                Common.ApplicationDataSet.Instances.AddInstancesRow(newInstance);
                Common.ApplicationDataSet.Instances_Update();
                //Common.ApplicationDataSet.InstancesTA.Update(Common.ApplicationDataSet.Instances);

                string progressMessage = string.Format("Instance: {0}  Added successfully", newInstance.Name_Instance);

                //StatusMessage1 = progressMessage;
                tb_ProgressStatus1.Text = progressMessage;
                //tb_ProgressStatus1.Dispatcher.BeginInvoke((Action)(() => tb_ProgressStatus1.Text = progressMessage), System.Windows.Threading.DispatcherPriority.Normal);

                //tb_ProgressStatus1.Dispatcher.BeginInvoke(new Action(() => tb_ProgressStatus1.Text = progressMessage), System.Windows.Threading.DispatcherPriority.Normal);

                //parentWindow.Dispatcher.BeginInvoke((Action)(() => tb_ProgressStatus1.Text = progressMessage), System.Windows.Threading.DispatcherPriority.Normal);
                string progressMessage2 = "Attempting to create SMO Crawler Login.  This may take a while";


                tb_ProgressStatus2.Dispatcher.BeginInvoke((Action)(() => tb_ProgressStatus2.Text = progressMessage2), System.Windows.Threading.DispatcherPriority.Normal);

                string message = "";

                if (SQLInformation.SMO.Actions.Instance.CreateSQLMonitorLogin(newInstance.Name_Instance, out message))
                {
                    tb_ProgressStatus2.Dispatcher.InvokeAsync((Action)(() => tb_ProgressStatus2.Text = "SMO Crawler Logon created successfully"), System.Windows.Threading.DispatcherPriority.Normal);
                }
                else
                {
                    MessageBox.Show(string.Format(
                                        "SMO Crawler Logon not created:\n{0}\nVerify current user ({1}) has sufficient permission to create a new Login in instance.",
                                        message, Common.CurrentUser.Identity.Name));
                }

                InitializeControls();
            }
            catch (Exception ex)
            {
                VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 2);
            }
        }
示例#9
0
        public static SQLInformation.Data.ApplicationDataSet.InstancesRow GetInfoFromSMO(Data.ApplicationDataSet.InstancesRow dataRow,
                                                                                         ExpandMask.InstanceExpandSetting instanceExpandSetting,
                                                                                         ExpandMask.JobServerExpandSetting jobServerExpandSetting,
                                                                                         ExpandMask.DatabaseExpandSetting databaseExpandSetting)
        {
#if TRACE
            long startTicks = VNC.AppLog.Info(
                string.Format("Enter ({0}) IES:{1}  JES:{2}  DES:{3}",
                              dataRow.Name_Instance,
                              instanceExpandSetting.ExpandMask, jobServerExpandSetting.ExpandMask, databaseExpandSetting.ExpandMask),
                LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 2);
#endif
            long stopwatchFrequency = Stopwatch.Frequency;

            MSMO.Server serverInstance = null;

            // First try to connect to the instance and retrieve a simple property.
            // If cannot, don't bother doing more.
            try
            {
                serverInstance = Server.GetFromSMO(dataRow.Name_Instance);

                string s = serverInstance.NetName;

                // If we got to the server make everything upper case.

                dataRow.NetName       = s.ToUpper();
                dataRow.Name_Instance = dataRow.Name_Instance.ToUpper();
            }
            catch (Microsoft.SqlServer.Management.Common.ConnectionFailureException)
            {
                dataRow.SnapShotDuration = (Stopwatch.GetTimestamp() - startTicks) / stopwatchFrequency;

                // Make names lower case to indicate error.

                dataRow.NetName       = dataRow.NetName.ToLower();
                dataRow.Name_Instance = dataRow.Name_Instance.ToLower();
                dataRow.SnapShotError = "Connection Failure Exception";

                Common.ApplicationDataSet.Instances_Update();

                //UpdateDatabaseWithSnapShot(dataRow, "Connection Failure Exception");

                VNC.AppLog.Warning(string.Format("Connection Failure Exception: {0}", dataRow.Name_Instance), LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 3);
                return(dataRow);
            }
            catch (Exception ex)
            {
                //VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 4);

                dataRow.SnapShotDuration = (Stopwatch.GetTimestamp() - startTicks) / stopwatchFrequency;
                dataRow.NetName          = dataRow.NetName.ToLower();
                dataRow.Name_Instance    = dataRow.Name_Instance.ToLower();

                ReportException(ex, dataRow, CLASS_BASE_ERRORNUMBER + 4);

                //UpdateDatabaseWithSnapShot(dataRow, ex.ToString().Substring(0, 256));
                return(dataRow);
            }

            try
            {
                Update(serverInstance, dataRow);

                //UpdateDatabaseWithSnapShot(dataRow, "");

                if (dataRow.ExpandJobServer && instanceExpandSetting.ExpandJobServer)
                {
                    JobServer.LoadFromSMO(serverInstance.JobServer, dataRow.ID, dataRow.Name_Instance, jobServerExpandSetting);
                }

                if (dataRow.ExpandLinkedServers && instanceExpandSetting.ExpandLinkedServers)
                {
                    LinkedServer.LoadFromSMO(serverInstance, dataRow.ID, dataRow.Name_Instance);
                }

                if (dataRow.ExpandLogins && instanceExpandSetting.ExpandLogins)
                {
                    Login.LoadFromSMO(serverInstance, dataRow.ID, dataRow.Name_Instance);
                }

                if (dataRow.ExpandServerRoles && instanceExpandSetting.ExpandServerRoles)
                {
                    ServerRole.LoadFromSMO(serverInstance, dataRow.ID, dataRow.Name_Instance);
                }

                if (dataRow.ExpandTriggers && instanceExpandSetting.ExpandTriggers)
                {
                    ServerDdlTrigger.LoadFromSMO(serverInstance, dataRow.ID, dataRow.Name_Instance);
                }

                if ((dataRow.ExpandContent && instanceExpandSetting.ExpandContent) ||
                    (dataRow.ExpandStorage && instanceExpandSetting.ExpandStorage))
                {
                    Database.LoadFromSMO(serverInstance, dataRow.ID, databaseExpandSetting);
                }

                // We now have all the information for the instance.
                // This will get pushed to the snapshot by our caller.

                UpdateTotalStorageUsed(dataRow);

                dataRow.SnapShotDuration = (Stopwatch.GetTimestamp() - startTicks) / stopwatchFrequency;

                Common.ApplicationDataSet.Instances_Update();
                //Common.ApplicationDataSet.InstancesTA.Update(Common.ApplicationDataSet.Instances);
            }
            catch (Exception ex)
            {
                //VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 5);

                dataRow.SnapShotDuration = (Stopwatch.GetTimestamp() - startTicks) / stopwatchFrequency;
                dataRow.NetName          = dataRow.NetName.ToLower();
                dataRow.Name_Instance    = dataRow.Name_Instance.ToLower();

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

                ReportException(ex, dataRow, CLASS_BASE_ERRORNUMBER + 5);
                //Common.ApplicationDataSet.Instances_Update();

                //UpdateDatabaseWithSnapShot(dataRow, ex.ToString().Substring(0, 256));
            }
#if TRACE
            VNC.AppLog.Info(string.Format("Exit ({0})", dataRow.Name_Instance), LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 6, startTicks);
#endif
            return(dataRow);
        }