示例#1
0
        private void SaveExtendedProperties(SQLInformation.Data.ApplicationDataSet.DatabasesRow database)
        {
            var instanceName = from item in Common.ApplicationDataSet.Instances
                               where item.ID == database.Instance_ID
                               select item.Name_Instance;

            SMO.Server server = new SMO.Server((string)instanceName.First());
            server.ConnectionContext.LoginSecure    = false; // SQL Authentication
            server.ConnectionContext.Login          = "******";
            server.ConnectionContext.Password       = "******";
            server.ConnectionContext.ConnectTimeout = 10;    // Seconds

            SMO.ExtendedPropertyCollection extendedProps = server.Databases[database.Name_Database].ExtendedProperties;

            SMO.Database smoDatabase = server.Databases[database.Name_Database];

            try
            {
                extendedProps["EP_Area"].Value = database.EP_Area;
                extendedProps["EP_Area"].Alter();
            }
            catch (Exception)
            {
                SMO.ExtendedProperty ep = new SMO.ExtendedProperty(smoDatabase, "EP_Area", database.EP_Area);
                ep.Create();
            }

            try
            {
                extendedProps["EP_DBApprover"].Value = database.EP_DBApprover;
                extendedProps["EP_DBApprover"].Alter();
            }
            catch (Exception)
            {
                SMO.ExtendedProperty ep = new SMO.ExtendedProperty(smoDatabase, "EP_DBApprover", database.EP_DBApprover);
                ep.Create();
            }

            try
            {
                extendedProps["EP_DRTier"].Value = database.EP_DRTier;
                extendedProps["EP_DRTier"].Alter();
            }
            catch (Exception)
            {
                SMO.ExtendedProperty ep = new SMO.ExtendedProperty(smoDatabase, "EP_DRTier", database.EP_DRTier);
                ep.Create();
            }

            try
            {
                extendedProps["EP_PrimaryDBContact"].Value = database.EP_PrimaryDBContact;
                extendedProps["EP_PrimaryDBContact"].Alter();
            }
            catch (Exception)
            {
                SMO.ExtendedProperty ep = new SMO.ExtendedProperty(smoDatabase, "EP_PrimaryDBContact", database.EP_PrimaryDBContact);
                ep.Create();
            }

            try
            {
                extendedProps["EP_Team"].Value = database.EP_Team;
                extendedProps["EP_Team"].Alter();
            }
            catch (Exception)
            {
                SMO.ExtendedProperty ep = new SMO.ExtendedProperty(smoDatabase, "EP_Team", database.EP_Team);
                ep.Create();
            }
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the ExtendedProperty class.
 /// </summary>
 public ExtendedProperty(SMO.ExtendedProperty extendedProperty)
 {
     AddinHelper.Common.WriteToDebugWindow(string.Format("SMOH.{0}({1})", "ExtendedProperty", extendedProperty));
     Name  = extendedProperty.Name;
     Value = extendedProperty.Value.ToString();
 }
示例#3
0
        private void SaveExtendedProperties(SQLInformation.Data.ApplicationDataSet.DatabasesRow database)
        {
            var instances = from item in Common.ApplicationDataSet.Instances
                            where item.ID == database.Instance_ID
                            select new { Name = item.Name_Instance, Port = item.Port };
            string instanceName = (string)instances.First().Name;
            int    port         = (int)instances.First().Port;

            //MSMO.Server server = new MSMO.Server((string)instances.First());
            Microsoft.SqlServer.Management.Common.ServerConnection connection = new Microsoft.SqlServer.Management.Common.ServerConnection();
            connection.ServerInstance  = string.Format("{0},{1}", instanceName, port);
            connection.NetworkProtocol = Microsoft.SqlServer.Management.Common.NetworkProtocol.TcpIp;

            MSMO.Server server = new MSMO.Server(connection);


            server.ConnectionContext.LoginSecure = true;   // SQL Authentication
            //server.ConnectionContext.Login = "******";
            //server.ConnectionContext.Password = "******";
            server.ConnectionContext.ConnectTimeout = 10;    // Seconds

            MSMO.ExtendedPropertyCollection extendedProps = server.Databases[database.Name_Database].ExtendedProperties;

            MSMO.Database smoDatabase = server.Databases[database.Name_Database];

            try
            {
                //extendedProps["EP_Area"].Value = database.EP_Area;
                extendedProps["EP_Area"].Value = te_EP_Area.Text;
                extendedProps["EP_Area"].Alter();
            }
            catch (Exception)
            {
                MSMO.ExtendedProperty ep = new MSMO.ExtendedProperty(smoDatabase, "EP_Area", te_EP_Area.Text);
                //MSMO.ExtendedProperty ep = new MSMO.ExtendedProperty(smoDatabase, "EP_Area", database.EP_Area);
                ep.Create();
            }

            try
            {
                extendedProps["EP_DBApprover"].Value = te_EP_DBApprover.Text;
                extendedProps["EP_DBApprover"].Alter();
            }
            catch (Exception)
            {
                MSMO.ExtendedProperty ep = new MSMO.ExtendedProperty(smoDatabase, "EP_DBApprover", te_EP_DBApprover.Text);
                ep.Create();
            }

            try
            {
                extendedProps["EP_DRTier"].Value = te_EP_DRTier.Text;
                extendedProps["EP_DRTier"].Alter();
            }
            catch (Exception)
            {
                MSMO.ExtendedProperty ep = new MSMO.ExtendedProperty(smoDatabase, "EP_DRTier", te_EP_DRTier.Text);
                ep.Create();
            }

            try
            {
                extendedProps["EP_PrimaryDBContact"].Value = te_EP_PrimaryDBContact.Text;
                extendedProps["EP_PrimaryDBContact"].Alter();
            }
            catch (Exception)
            {
                MSMO.ExtendedProperty ep = new MSMO.ExtendedProperty(smoDatabase, "EP_PrimaryDBContact", te_EP_PrimaryDBContact.Text);
                ep.Create();
            }

            try
            {
                extendedProps["EP_Team"].Value = te_EP_Team.Text;
                extendedProps["EP_Team"].Alter();
            }
            catch (Exception)
            {
                MSMO.ExtendedProperty ep = new MSMO.ExtendedProperty(smoDatabase, "EP_Team", te_EP_Team.Text);
                ep.Create();
            }
        }