コード例 #1
0
ファイル: MapUpdater.cs プロジェクト: microsoft/PrimeDNS
        /*
         * UpdatePrimeDnsMapRow() updates the row containing the mentioned hostName to newly passed values in PrimeDNSMap Table.
         */
        private static void UpdatePrimeDnsMapRow(PrimeDnsMapRow pUpdatedMapRow)
        {
            PrimeDns.Semaphore.Wait();
            var updateCommand = "UPDATE " + AppConfig.ConstTableNamePrimeDnsMap +
                                $" SET IPAddressList=\"{pUpdatedMapRow.GetStringOfIpAddressList()}\", LastUpdatedTime=\"{pUpdatedMapRow.LastUpdatedTime}\", LastCheckedTime=\"{pUpdatedMapRow.LastCheckedTime}\", TimeToLiveInSeconds={pUpdatedMapRow.TimeToLiveInSeconds}" +
                                $" WHERE HostName=\"{pUpdatedMapRow.HostName}\"";

            try
            {
                var query = SqliteConnect.ExecuteNonQuery(updateCommand, _mapConnectionString);
                //PrimeDns.logger._LogInformation("Updated PrimeDNSMap table successfully", Logger.CSqliteExecuteNonQuery, null);
            }
            catch (Exception error)
            {
                PrimeDns.Log._LogError("Error occured while updating PrimeDNSMap table", Logger.ConstSqliteExecuteNonQuery, error);
            }
            PrimeDns.Semaphore.Release();
        }
コード例 #2
0
ファイル: MapUpdater.cs プロジェクト: microsoft/PrimeDNS
        /*
         * WriteToPrimeDnsMap() inserts a given row data into PrimeDNSMap Table.
         */
        public static void WriteToPrimeDnsMap(PrimeDnsMapRow pMapRowToBeInserted)
        {
            PrimeDns.Semaphore.Wait();
            var insertSql = "Insert into " + AppConfig.ConstTableNamePrimeDnsMap +
                            $" ( HostName, IPAddressList, LastUpdatedTime, LastCheckedTime, TimeToLiveInSeconds) values (\"{pMapRowToBeInserted.HostName}\", \"{pMapRowToBeInserted.GetStringOfIpAddressList()}\", \"{pMapRowToBeInserted.LastUpdatedTime}\", \"{pMapRowToBeInserted.LastCheckedTime}\", {pMapRowToBeInserted.TimeToLiveInSeconds})";

            try
            {
                var query = SqliteConnect.ExecuteNonQuery(insertSql, _mapConnectionString);
                //PrimeDns.logger._LogInformation("Data inserted into PrimeDNSMap table successfully", Logger.CSqliteExecuteNonQuery, null);
            }
            catch (Exception error)
            {
                PrimeDns.Log._LogError("Error occured while inserting data into PrimeDNSMap table", Logger.ConstSqliteExecuteNonQuery, error);
            }
            PrimeDns.Semaphore.Release();
        }