Beispiel #1
0
        public void GetTest4()
        {
            InitDomainRecords();
            DomainManager target = CreateManager();
            string        name   = BuildDomainName(GetRndDomainID());

            using (ConfigDatabase db = CreateConfigDatabase())
            {
                Domain actual = target.Get(db, name);
                Assert.Equal(name, actual.Name);
            }
        }
Beispiel #2
0
 public void RemoveTest2()
 {
     using (ConfigDatabase db = CreateConfigDatabase())
     {
         AnchorManager target = CreateManager();
         Assert.Equal(MAXDOMAINCOUNT * MAXCERTPEROWNER, target.Get(-1, MAXDOMAINCOUNT * MAXCERTPEROWNER + 1).Count());
         string ownerName = string.Format("CN={0}", BuildDomainName(GetRndDomainID()));
         target.Remove(db, ownerName);
         db.SubmitChanges();
         Assert.Equal(MAXDOMAINCOUNT * MAXCERTPEROWNER - MAXCERTPEROWNER, target.Get(-1, MAXDOMAINCOUNT * MAXCERTPEROWNER + 1).Count());
     }
 }
Beispiel #3
0
        public void RemoveTest()
        {
            CertificateManager target = CreateManager();
            const long         certID = 1;

            Assert.NotNull(target.Get(certID));
            using (ConfigDatabase db = CreateConfigDatabase())
            {
                target.Remove(db, certID);
            }
            Assert.Null(target.Get(certID));
        }
Beispiel #4
0
        public void GetTest6()
        {
            CertificateManager target = CreateManager();
            long certID = GetRndCertID();

            using (ConfigDatabase db = CreateConfigDatabase())
            {
                Certificate cert = target.Get(db, certID);
                Assert.NotNull(cert);
                Assert.Equal(certID, cert.ID);
            }
        }
Beispiel #5
0
        public void RemoveAllTest()
        {
            InitDomainRecords();
            DomainManager target = CreateManager();

            Assert.Equal(MAXDOMAINCOUNT, target.Get(string.Empty, MAXDOMAINCOUNT + 1).Count());
            using (ConfigDatabase db = CreateConfigDatabase())
            {
                target.RemoveAll(db);
            }
            Assert.Equal(0, target.Get(string.Empty, MAXDOMAINCOUNT + 1).Count());
        }
        public void GetTest9()
        {
            InitAddressRecords();
            AddressManager mgr          = CreateManager();
            string         emailAddress = BuildEmailAddress(1, 1);

            using (ConfigDatabase db = CreateConfigDatabase())
            {
                Address add = mgr.Get(db, emailAddress);
                Assert.Equal(emailAddress, add.EmailAddress);
            }
        }
Beispiel #7
0
        public void GetTest6()
        {
            AnchorManager target = CreateManager();

            using (ConfigDatabase db = CreateConfigDatabase())
            {
                const long           lastCertID = 0;
                const int            maxResults = MAXCERTPEROWNER * MAXDOMAINCOUNT + 1;
                IEnumerable <Anchor> actual     = target.Get(db, lastCertID, maxResults);
                Assert.Equal(MAXCERTPEROWNER * MAXDOMAINCOUNT, actual.Count());
            }
        }
        /// <summary>
        /// This method will clean, load and verify MDN records in the DB for testing purposes
        /// </summary>
        /// <param name="mgr">MdnManager instance used for controlling the Mdn records</param>
        /// <param name="db">ConfigDatabase instance used as the target storage mechanism for the records</param>
        protected void InitOldMdnRecords(MdnManager mgr, ConfigDatabase db)
        {
            mgr.RemoveAll();
            mgr.Start(db, TestOldMdns.ToArray());

            //----------------------------------------------------------------------------------------------------
            //---submit changes to db and verify existence of records
            db.SubmitChanges();
            foreach (KeyValuePair <long, KeyValuePair <int, string> > kp in TestAddressNames)
            {
                //Assert.NotNull(mgr.Get(kp.Value.Value));
            }
        }
Beispiel #9
0
 public void Add(ConfigDatabase db, Bundle bundle)
 {
     if (db == null)
     {
         throw new ArgumentNullException("db");
     }
     if (bundle == null)
     {
         throw new ConfigStoreException(ConfigStoreError.InvalidBundle);
     }
     
     db.Bundles.InsertOnSubmit(bundle);
 }
Beispiel #10
0
        public void RemoveTest5()
        {
            CertificateManager target = CreateManager();

            Assert.Equal(MAXDOMAINCOUNT * MAXCERTPEROWNER, target.Get(-1, MAXDOMAINCOUNT * MAXCERTPEROWNER + 1).Count());

            using (ConfigDatabase db = CreateConfigDatabase())
            {
                string ownerName = string.Format("{0}", BuildDomainName(1));
                target.Remove(db, ownerName);
            }
            Assert.Equal(MAXDOMAINCOUNT * MAXCERTPEROWNER - MAXCERTPEROWNER, target.Get(-1, MAXDOMAINCOUNT * MAXCERTPEROWNER + 1).Count());
        }
Beispiel #11
0
 public void AddTest3()
 {
     using (ConfigDatabase db = CreateConfigDatabase())
     {
         DomainManager target = CreateManager();
         target.RemoveAll();
         Assert.Equal(0, target.Count());
         string name = BuildDomainName(GetRndDomainID());
         target.Add(db, name);
         db.SubmitChanges();
         Assert.NotNull(target.Get(name));
     }
 }
Beispiel #12
0
 public void Add(ConfigDatabase db, Anchor anchor)
 {
     if (db == null)
     {
         throw new ArgumentNullException("db");
     }
     if (anchor == null)
     {
         throw new ConfigStoreException(ConfigStoreError.InvalidAnchor);
     }
     
     db.Anchors.InsertOnSubmit(anchor);
 }
Beispiel #13
0
 private bool SaveToFile(object node, string path)
 {
     try
     {
         ConfigDatabase.SaveToFile(node, path);
     }
     catch (Exception e)
     {
         LastApplyException = e;
         return(false);
     }
     return(true);
 }
Beispiel #14
0
 public void RemoveTest()
 {
     using (ConfigDatabase db = CreateConfigDatabase())
     {
         AnchorManager target     = CreateManager();
         List <Anchor> certs      = this.GetCleanEnumerable <Anchor>(TestAnchors);
         string        owner      = certs[0].Owner;
         string        thumbprint = certs[0].Thumbprint;
         Assert.NotNull(target.Get(owner, thumbprint));
         target.Remove(db, owner, thumbprint);
         Assert.Null(target.Get(owner, thumbprint));
     }
 }
Beispiel #15
0
        public void Add(ConfigDatabase db, DnsRecord record)
        {
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }

            if (record == null)
            {
                throw new ConfigStoreException(ConfigStoreError.InvalidDnsRecord);
            }
            db.DnsRecords.InsertOnSubmit(record);
        }
Beispiel #16
0
    /// <summary>
    /// 读取所有表信息
    /// </summary>
    public void LoadAllConfig()
    {
        string    resName = "Config/ConfigDatabase";
        TextAsset ta      = Resources.Load <TextAsset>(resName);

        if (null != ta)
        {
            //初始化所有配置
            ConfigDatabase data = ProtoBuf.Meta.RuntimeTypeModel.Default.Deserialize(new MemoryStream(ta.bytes), null, typeof(ConfigDatabase)) as ConfigDatabase;
            mGetCfg = new GetConfig();
            mGetCfg.InitConfig(data);
        }
        LoadContent();
    }
Beispiel #17
0
 public ConfigData?GetLanguageData(string language)
 {
     if (_configData == null || _configDataJsonNode == null)
     {
         _errorOutput.WriteLine("Error: Database not loaded");
         return(null);
     }
     if (!_configDataTranslateJsonNodes.TryGetValue(language, out var translationJsonNode))
     {
         _errorOutput.WriteLine("Error: Language not found");
         return(null);
     }
     return(ConfigDatabase.Build(_configDataJsonNode, translationJsonNode));
 }
 /// <summary>
 /// This method will clean, load and verify Certificate records based on the certs stored in the
 /// metadata\certs folder into the db for testing purposes
 /// </summary>
 /// <param name="mgr">CertificateManager instance used for controlling the Certificate records</param>
 /// <param name="db">ConfigDatabase instance used as the target storage mechanism for the records</param>
 /// <remarks>
 /// this approach goes out to db each time it is called, however it ensures that clean records
 /// are present for every test that is execute, if it is taking too long, simply cut down on the
 /// number of items using the consts above
 /// </remarks>
 protected void InitCertRecords(CertificateManager mgr
                                , ConfigDatabase db)
 {
     mgr.RemoveAll(db);
     for (int i = 1; i <= MAXDOMAINCOUNT; i++)
     {
         //----------------------------------------------------------------------------------------------------
         //---cheezy but will add MAXCERTPEROWNER certs per each relative domain
         for (int t = 1; t <= MAXCERTPEROWNER; t++)
         {
             mgr.Add(GetCertificateFromTestCertPfx(i, t));
         }
     }
 }
Beispiel #19
0
        public void GetTest6()
        {
            InitMXRecords();
            MXManager     mgr = new MXManager(new ConfigStore(CONNSTR));
            List <string> lst = AllMXDomainNames();

            Assert.Equal(MAXDOMAINCOUNT * MAXSMTPCOUNT, lst.Count());
            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                IEnumerable <MX> mxs = mgr.Get(db, lst.ToArray());

                Assert.Equal(mgr.Count(), mxs.Count());
            }
        }
Beispiel #20
0
 /// <summary>
 /// Creates columns for the devices table.
 /// </summary>
 private static DataGridViewColumn[] CreateDeviceTableColumns(ConfigDatabase configDatabase)
 {
     return(TranslateHeaders("DeviceTable", new DataGridViewColumn[]
     {
         NewTextBoxColumn("DeviceNum", new ColumnOptions(ColumnKind.PrimaryKey)),
         NewTextBoxColumn("Name", new ColumnOptions(ColumnLength.Name)),
         NewTextBoxColumn("Code", new ColumnOptions(ColumnLength.Code)),
         NewComboBoxColumn("DevTypeID", "Name", configDatabase.DevTypeTable, true),
         NewTextBoxColumn("NumAddress"),
         NewTextBoxColumn("StrAddress", new ColumnOptions(ColumnLength.Default)),
         NewComboBoxColumn("CommLineNum", "Name", configDatabase.CommLineTable, true),
         NewTextBoxColumn("Descr", new ColumnOptions(ColumnLength.Description))
     }));
 }
Beispiel #21
0
        public void RemoveTest()
        {
            InitDomainRecords();
            DomainManager target = CreateManager();
            string        name   = BuildDomainName(GetRndDomainID());

            Assert.NotNull(target.Get(name));
            using (ConfigDatabase db = CreateConfigDatabase())
            {
                target.Remove(name);
                db.SubmitChanges();
            }
            Assert.Null(target.Get(name));
        }
Beispiel #22
0
 public void AddTest(Certificate cert)
 {
     using (ConfigDatabase db = CreateConfigDatabase())
     {
         CertificateManager target = CreateManager();
         target.RemoveAll();
         target.Add(db, cert);
         db.SubmitChanges();
         Certificate certNew = target.Get(1); //---should always be 1 (table was truncated above);
         Assert.NotNull(cert);
         Assert.Equal(cert.Owner, certNew.Owner);
         Assert.Equal(cert.Thumbprint, certNew.Thumbprint);
     }
 }
Beispiel #23
0
 public void GetTest1()
 {
     using (ConfigDatabase db = CreateConfigDatabase())
     {
         AnchorManager target     = CreateManager();
         List <Anchor> certs      = this.GetCleanEnumerable <Anchor>(TestAnchors);
         string        owner      = certs[GetRndCertID()].Owner;
         string        thumbprint = certs[GetRndCertID()].Thumbprint;
         Anchor        expected   = certs[GetRndCertID()];
         Anchor        actual     = target.Get(db, owner, thumbprint);
         Assert.Equal(expected.Owner, actual.Owner);
         Assert.Equal(expected.Thumbprint, actual.Thumbprint);
     }
 }
Beispiel #24
0
 public void GetTest()
 {
     using (ConfigDatabase db = CreateConfigDatabase())
     {
         AnchorManager target = CreateManager();
         string        owner  = string.Format("CN={0}", BuildDomainName(GetRndDomainID()));
         Anchor[]      actual = target.Get(db, owner).ToArray();
         Assert.Equal(MAXCERTPEROWNER, actual.Count());
         foreach (Anchor cert in actual)
         {
             Assert.Equal(owner, cert.Owner);
         }
     }
 }
Beispiel #25
0
 public bool Save()
 {
     if (_configData == null || _configDataJsonNode == null)
     {
         _errorOutput.WriteLine("Error: Database not loaded");
         return(false);
     }
     ConfigDatabase.SaveToFile(_configDataJsonNode, _fileSourceSettings.DatabaseFilePath);
     foreach (var pair in _configDataTranslateJsonNodes)
     {
         var path = _fileSourceSettings.DatabaseTranslateFilePath(pair.Key);
         ConfigDatabase.SaveToFile(pair.Value, path);
     }
     return(true);
 }
Beispiel #26
0
 public void Add(ConfigDatabase db, Certificate cert)
 {
     if (db == null)
     {
         throw new ArgumentNullException("db");
     }
     
     if (cert == null)
     {
         throw new ConfigStoreException(ConfigStoreError.InvalidCertificate);
     }
     
     cert.ValidateHasData();
     db.Certificates.InsertOnSubmit(cert);
 }
Beispiel #27
0
        public void AddTest(Anchor anc)
        {
            AnchorManager target = CreateManager();

            using (ConfigDatabase db = CreateConfigDatabase())
            {
                target.RemoveAll();
                target.Add(db, anc);
                db.SubmitChanges();
                Anchor certNew = target.Get(anc.Owner, anc.Thumbprint); //---should always be 1 (table was truncated above);
                Assert.NotNull(anc);
                Assert.Equal(anc.Owner, certNew.Owner);
                Assert.Equal(anc.Thumbprint, certNew.Thumbprint);
            }
        }
Beispiel #28
0
 public void SetStatusTest1()
 {
     using (ConfigDatabase db = CreateConfigDatabase())
     {
         for (long i = 1; i <= MAXCERTPEROWNER * MAXDOMAINCOUNT; i++)
         {
             CertificateManager target = CreateManager();
             Certificate        cert   = target.Get(i);
             Dump(string.Format("SetStatusTest1 Subject[{0}] Status:[{1}]", cert == null ? "null cert" : cert.Owner, cert?.Status.ToString() ?? "null cert"));
             Assert.Equal(EntityStatus.New, cert.Status);
             target.SetStatus(db, i, EntityStatus.Enabled);
             cert = target.Get(i);
             Assert.Equal(EntityStatus.Enabled, cert.Status);
         }
     }
 }
Beispiel #29
0
 /// <summary>
 /// Creates columns for the view table.
 /// </summary>
 private static DataGridViewColumn[] CreateViewTableColumns(ConfigDatabase configDatabase)
 {
     return(TranslateHeaders("ViewTable", new DataGridViewColumn[]
     {
         NewTextBoxColumn("ViewID", new ColumnOptions(ColumnKind.PrimaryKey)),
         NewTextBoxColumn("Path", new ColumnOptions(ColumnKind.Path, ColumnLength.Long)),
         NewButtonColumn("Path", new ColumnOptions(ColumnKind.SelectFolderButton)),
         NewButtonColumn("Path", new ColumnOptions(ColumnKind.SelectFileButton)),
         NewComboBoxColumn("ViewTypeID", "Name", configDatabase.ViewTypeTable, true),
         NewComboBoxColumn("ObjNum", "Name", configDatabase.ObjTable, true),
         NewTextBoxColumn("Args", new ColumnOptions(ColumnLength.Default)),
         NewTextBoxColumn("Title", new ColumnOptions(ColumnLength.Long)),
         NewTextBoxColumn("Ord"),
         NewCheckBoxColumn("Hidden"),
     }));
 }
 public void GetByDomainTest()
 {
     InitAddressRecords();
     using (ConfigDatabase db = CreateConfigDatabase())
     {
         InitAddressRecords();
         AddressManager mgr        = CreateManager();
         string         domainName = BuildDomainName(1);
         Address[]      addrs      = mgr.GetAllForDomain(db, domainName.ToUpper(), int.MaxValue).ToArray();
         Assert.Equal(MAXADDRESSCOUNT, addrs.Length);
         foreach (Address addr in addrs)
         {
             Assert.Equal(1, addr.DomainID);
         }
     }
 }
Beispiel #31
0
        public void GetTest7()
        {
            InitAddressRecords();
            AddressManager mgr = CreateManager();

            using (ConfigDatabase db = CreateConfigDatabase())
            {
                long[] addressIDs            = new long[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
                IEnumerable <Address> actual = mgr.Get(db, addressIDs);
                Assert.Equal(addressIDs.Length, actual.Count());
                for (int t = 0; t < addressIDs.Length; t++)
                {
                    Assert.True(addressIDs.Contains(actual.ToArray()[t].ID));
                }
            }
        }
Beispiel #32
0
        public void GetTest6()
        {
            InitDomainRecords();
            DomainManager target = CreateManager();

            string[] names = TestDomainNames.ToArray();
            using (ConfigDatabase db = CreateConfigDatabase())
            {
                Domain[] actual = target.Get(db, names).ToArray();
                Assert.Equal(names.Length, actual.Length);
                foreach (Domain dom in actual)
                {
                    Assert.True(names.Contains(dom.Name));
                }
            }
        }
Beispiel #33
0
        public void GetTest13()
        {
            InitAddressRecords();
            AddressManager mgr = CreateManager();

            using (ConfigDatabase db = CreateConfigDatabase())
            {
                string[] emailAddresses      = new[] { BuildEmailAddress(1, 1), BuildEmailAddress(2, 1), BuildEmailAddress(3, 1) };
                IEnumerable <Address> actual = mgr.Get(db, emailAddresses);
                Assert.Equal(emailAddresses.Length, actual.Count());

                for (int t = 0; t < actual.Count(); t++)
                {
                    Assert.True(emailAddresses.Contains(actual.ToArray()[t].EmailAddress));
                }
            }
        }
Beispiel #34
0
        public void Add(ConfigDatabase db
            , DnsRecord[] dnsRecords)
        {
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }

            if (dnsRecords == null || dnsRecords.Length.Equals(0))
            {
                return;
            }
            foreach (DnsRecord dnsRecord in dnsRecords)
            {
                db.DnsRecords.InsertOnSubmit(dnsRecord);
            }
        }
Beispiel #35
0
        public void RemoveDomainTest()
        {
            InitAddressRecords();
            AddressManager mgr      = CreateManager();
            const long     domainID = 1;

            using (ConfigDatabase db = CreateConfigDatabase())
            {
                //----------------------------------------------------------------------------------------------------
                //---make sure that we have max addresses for the given domain
                Address[] adds = mgr.Get(db, domainID, string.Empty, MAXADDRESSCOUNT + 1).ToArray();
                Assert.Equal(MAXADDRESSCOUNT, adds.Count());

                mgr.RemoveDomain(db, domainID);
                adds = mgr.Get(db, domainID, string.Empty, MAXADDRESSCOUNT + 1).ToArray();
                Assert.Equal(0, adds.Count());
            }
        }
Beispiel #36
0
 public DnsRecord[] Get(ConfigDatabase db
     , string domainName)
 {
     return db.DnsRecords.Get(domainName
         , null).ToArray();
 }
Beispiel #37
0
 public void Remove(ConfigDatabase db, long[] certificateIDs)
 {
     if (db == null)
     {
         throw new ArgumentNullException("db");
     }
     if (certificateIDs.IsNullOrEmpty())
     {
         throw new ConfigStoreException(ConfigStoreError.InvalidIDs);
     }
     //
     // Todo: this in a single query
     //
     for (int i = 0; i < certificateIDs.Length; ++i)
     {
         db.Anchors.ExecDelete(certificateIDs[i]);
     }
 }
Beispiel #38
0
        private void UpdateLastCheckedForDbObjectDefinition(ConfigDatabase db, string dbObjName, string dbObjType)
        {
            List<SqlParameter> sqlParamList = new List<SqlParameter>();
            sqlParamList.Add(new SqlParameter("dbObjName", dbObjName));
            sqlParamList.Add(new SqlParameter("dbObjType", dbObjType));

            string query = @"UPDATE {0} SET lastChecked=getdate() WHERE dbObjectName=@dbObjName AND dbObjectType=@dbObjType";
            query = string.Format(query, DbObjDefTableName);

            ExecuteNonQuery(db.name, db.conn, query, sqlParamList, false);
        }
Beispiel #39
0
        private void UpdateDbObjectDefinition(ConfigDatabase db, string dbObjName, string dbObjType, string dbObjDef)
        {
            List<SqlParameter> sqlParamList = new List<SqlParameter>();
            sqlParamList.Add(new SqlParameter("dbObjName", dbObjName));
            sqlParamList.Add(new SqlParameter("dbObjType", dbObjType));
            sqlParamList.Add(new SqlParameter("dbObjDef", dbObjDef));

            string query = @"
                IF EXISTS(SELECT * FROM {0} WHERE dbObjectName=@dbObjName AND dbObjectType=@dbObjType)
                BEGIN
                    UPDATE {0} SET dbObjectDefinition=@dbObjDef, lastUpdated=getdate()
	                    WHERE dbObjectName=@dbObjName AND dbObjectType=@dbObjType
                END
                ELSE
                BEGIN
                    INSERT {0}(dbObjectName,dbObjectType,dbObjectDefinition,lastUpdated,lastChecked) values(@dbObjName,@dbObjType,@dbObjDef,getdate(),getdate())
                END
                ";
            query = string.Format(query, DbObjDefTableName);

            ExecuteNonQuery(db.name, db.conn, query, sqlParamList, false);
        }
Beispiel #40
0
        private bool HasDbObjectDefinitionChanged(ConfigDatabase db, string dbObjName, string dbObjType, string dbObjDef)
        {
            List<SqlParameter> sqlParamList = new List<SqlParameter>();
            sqlParamList.Add(new SqlParameter("dbObjName", dbObjName));
            sqlParamList.Add(new SqlParameter("dbObjType", dbObjType));

            string query = @"SELECT dbObjectDefinition FROM {0} WHERE dbObjectName=@dbObjName AND dbObjectType=@dbObjType";
            query = string.Format(query, DbObjDefTableName);

            object result = ExecuteScalar(db, query, sqlParamList);

            bool hasChanged = true;
            if (result != null)
            {
                string dbObjDefFromDb = (string)result;
                hasChanged = !dbObjDefFromDb.Equals(dbObjDef);
            }

            UpdateLastCheckedForDbObjectDefinition(db, dbObjName, dbObjType);
            return hasChanged;
        }
Beispiel #41
0
 public IEnumerable<DnsRecord> Get(ConfigDatabase db, long lastRecordID, int maxResults)
 {
     return db.DnsRecords.Get(lastRecordID, maxResults);
 }
Beispiel #42
0
        public void SetStatus(ConfigDatabase db, string owner, EntityStatus status)
        {
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }

            db.Anchors.ExecUpdateStatus(owner, status);
        }
Beispiel #43
0
        private void CheckSnapShotDbConnections(ConfigDatabase db)
        {
            DataReader.DbConnections dbConns = GetDbConnections(db);

            if (dbConns.Count > 0)
            {
                string msg = "Can't continue because there are connections open on database " + db.name + " that supports snapshot recreation.  Connections:";
                msg += System.Environment.NewLine + dbConns.OutputConnections();
                throw new Exception(msg);
            }
        }
Beispiel #44
0
 /// <summary>
 /// simple method to remove an dns record by ID 
 /// </summary>
 /// <param name="db">database context to use</param>
 /// <param name="recordID">long holding the id of the record to be deleted</param>
 public void Remove(ConfigDatabase db
     , long recordID)
 {
     db.DnsRecords.ExecDelete(recordID);
 }
Beispiel #45
0
        public void Update(ConfigDatabase db, DnsRecord dnsRecord)
        {
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }

            if (dnsRecord == null)
            {
                throw new ConfigStoreException(ConfigStoreError.InvalidDnsRecord);
            }

            DnsRecord update = Get(db, dnsRecord.ID);
            update.ApplyChanges(dnsRecord);
        }
Beispiel #46
0
        public void Remove(ConfigDatabase db, string ownerName)
        {
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }
            if (string.IsNullOrEmpty(ownerName))
            {
                throw new ConfigStoreException(ConfigStoreError.InvalidOwnerName);
            }

            db.Anchors.ExecDelete(ownerName);
        }
Beispiel #47
0
 public void RemoveAll(ConfigDatabase db)
 {
     db.Anchors.ExecTruncate();
 }
Beispiel #48
0
        public IEnumerable<Anchor> Get(ConfigDatabase db, long lastCertID, int maxResults)
        {
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }

            return db.Anchors.Get(lastCertID, maxResults);
        }
Beispiel #49
0
 public DnsRecord[] Get(ConfigDatabase db
     , string domainName
     , Common.DnsResolver.DnsStandard.RecordType typeID)
 {
     return db.DnsRecords.Get(domainName
         , (int)typeID).ToArray();
 }
Beispiel #50
0
        private object ExecuteScalar(ConfigDatabase db, string SQL, List<SqlParameter> sqlParamList)
        {
            object result;

            string connstr = db.conn.makeConnectionString(db.name);
            SqlConnection MySqlConn = new SqlConnection(connstr);
            MySqlConn.Open();
            try
            {
                using (SqlCommand MySqlCmd = new SqlCommand(SQL, MySqlConn))
                {
                    AddParamsToCmd(MySqlCmd, sqlParamList);
                    result = MySqlCmd.ExecuteScalar();
                    MySqlCmd.Parameters.Clear();
                }
            }
            finally
            {
                MySqlConn.Close();
            }

            return result;
        }
Beispiel #51
0
 public IEnumerable<DnsRecord> Get(ConfigDatabase db
     , long lastRecordID
     , int maxResults
     , Common.DnsResolver.DnsStandard.RecordType typeID)
 {
     return db.DnsRecords.Get(lastRecordID
         , maxResults
         , (int)typeID);
 }
Beispiel #52
0
        private DbConnections GetDbConnections(ConfigDatabase db)
        {
            DbConnections dbConns = new DbConnections();
            dbConns.dbName = db.name;

            string SQL = "SELECT * FROM master..sysprocesses where dbid=db_id('"+db.name+"') AND SPID >= 50";

            using (SqlDataReader dataReader = Execute("master", db.conn, SQL, false))
            {
                while (dataReader.Read())
                {
                    DbConnection dbConn = new DbConnection();
                    dbConn.spid = dataReader.GetInt16(dataReader.GetOrdinal("spid"));
                    dbConn.hostName = dataReader.GetString(dataReader.GetOrdinal("hostname")).Trim();
                    dbConn.program_name = dataReader.GetString(dataReader.GetOrdinal("program_name")).Trim();
                    dbConns.dbConnList.Add(dbConn);
                }
            }

            return dbConns;
        }
Beispiel #53
0
 /// <summary>
 /// simple method to remove an dns record by ID 
 /// </summary>
 /// <param name="db">database context to use</param>
 /// <param name="dnsRecord">DnsRecord instance to be removed</param>
 public void Remove(ConfigDatabase db
     , DnsRecord dnsRecord)
 {
     db.DnsRecords.DeleteOnSubmit(dnsRecord);
 }
Beispiel #54
0
 public IEnumerable<Anchor> Get(ConfigDatabase db, string owner)
 {
     if (db == null)
     {
         throw new ArgumentNullException("db");
     }
     if (string.IsNullOrEmpty(owner))
     {
         throw new ConfigStoreException(ConfigStoreError.InvalidOwnerName);
     }
     
     return db.Anchors.Get(owner);
 }
Beispiel #55
0
 /// <summary>
 /// removes all dnsrecords from the store
 /// </summary>
 /// <param name="db">ConfigDatabase instance context</param>
 public void RemoveAll(ConfigDatabase db)
 {
     db.DnsRecords.DeleteAll();
 }
Beispiel #56
0
 public void RemoveAll(ConfigDatabase db)
 {
     db.Bundles.ExecTruncate();
 }
Beispiel #57
0
        private void ReadConfigDatabases(XmlDocument doc)
        {
            XmlNodeList nodes = doc.SelectNodes("/updatesp/database");
            if (nodes.Count == 0)
            {
                throw new Exception("Unable to read database configuration: can't find any /updatesp/database nodes");
            }

            foreach (XmlNode node in nodes)
            {
                ConfigDatabase db = new ConfigDatabase();

                db.name = node.SelectSingleNode("name").InnerText;
                string connName = node.SelectSingleNode("connection").InnerText;
                db.conn = (ConfigConnection)_configConnections[connName];

                if (node.SelectSingleNode("snapshot") != null)
                {
                    db.snapshot         = node.SelectSingleNode("snapshot").InnerText;
                    db.snapshotfilename = node.SelectSingleNode("snapshotfilename").InnerText;
                }

                _configDatabases.Add(db);
            }
        }
Beispiel #58
0
 public Anchor Get(ConfigDatabase db, string owner, string thumbprint)
 {
     if (db == null)
     {
         throw new ArgumentNullException("db");
     }
     if (string.IsNullOrEmpty(owner))            
     {
         throw new ConfigStoreException(ConfigStoreError.InvalidOwnerName);
     }
     if (string.IsNullOrEmpty(thumbprint))
     {
         throw new ConfigStoreException(ConfigStoreError.InvalidThumbprint);
     }
     return db.Anchors.Get(owner, thumbprint);
 }
Beispiel #59
0
        public DnsRecord Get(ConfigDatabase db, long recordID)
        {
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }

            return db.DnsRecords.Get(recordID);
        }
Beispiel #60
0
 public void SetStatus(ConfigDatabase db, long BundleID, EntityStatus status)
 {
     if (db == null)
     {
         throw new ArgumentNullException("db");
     }
     db.Bundles.ExecUpdateStatus(BundleID, status);
 }