コード例 #1
0
 public static void InsertCredentials(SnmpCredentials crendentials)
 {
     using (SqlCommand textCommand = SqlHelper.GetTextCommand("INSERT INTO [SNMPV3Credentials]\r\n           ([CredentialName]\r\n           ,[SNMPV3Username]\r\n           ,[SNMPV3Context]\r\n           ,[SNMPV3PrivMethod]\r\n           ,[SNMPV3PrivKey]\r\n           ,[SNMPV3PrivKeyIsPwd]\r\n           ,[SNMPV3AuthKey]\r\n           ,[SNMPV3AuthMethod]\r\n           ,[SNMPV3AuthKeyIsPwd])\r\n     VALUES\r\n           (@CredentialName\r\n           ,@SNMPV3Username\r\n           ,@SNMPV3Context\r\n           ,@SNMPV3PrivMethod\r\n           ,@SNMPV3PrivKey\r\n           ,@SNMPV3PrivKeyIsPwd\r\n           ,@SNMPV3AuthKey\r\n           ,@SNMPV3AuthMethod\r\n           ,@SNMPV3AuthKeyIsPwd)"))
     {
         textCommand.Parameters.Add("@CredentialName", SqlDbType.NVarChar, 200).Value  = (object)crendentials.get_CredentialName();
         textCommand.Parameters.Add("@SNMPV3Username", SqlDbType.NVarChar, 50).Value   = (object)crendentials.get_SNMPv3UserName();
         textCommand.Parameters.Add("@SNMPV3Context", SqlDbType.NVarChar, 50).Value    = (object)crendentials.get_SnmpV3Context();
         textCommand.Parameters.Add("@SNMPV3PrivMethod", SqlDbType.NVarChar, 50).Value = (object)crendentials.get_SNMPv3PrivacyType().ToString();
         textCommand.Parameters.Add("@SNMPV3PrivKey", SqlDbType.NVarChar, 50).Value    = (object)crendentials.get_SNMPv3PrivacyPassword();
         textCommand.Parameters.Add("@SNMPV3PrivKeyIsPwd", SqlDbType.Bit).Value        = (object)crendentials.get_SNMPV3PrivKeyIsPwd();
         textCommand.Parameters.Add("@SNMPV3AuthKey", SqlDbType.NVarChar, 50).Value    = (object)crendentials.get_SNMPv3AuthPassword();
         textCommand.Parameters.Add("@SNMPV3AuthMethod", SqlDbType.NVarChar, 50).Value = (object)crendentials.get_SNMPv3AuthType().ToString();
         textCommand.Parameters.Add("@SNMPV3AuthKeyIsPwd", SqlDbType.Bit).Value        = (object)crendentials.get_SNMPV3AuthKeyIsPwd();
         SqlHelper.ExecuteNonQuery(textCommand);
     }
 }
コード例 #2
0
 public static void UpdateCredentials(SnmpCredentials credentials)
 {
     using (SqlCommand textCommand = SqlHelper.GetTextCommand("UPDATE [SNMPV3Credentials]\r\n\t\t\t\t\t\t\t\tSET [SNMPV3Username] = @SNMPV3Username\r\n\t\t\t\t\t\t\t\t,[SNMPV3Context] = @SNMPV3Context\r\n\t\t\t\t\t\t\t\t,[SNMPV3PrivMethod] = @SNMPV3PrivMethod\r\n\t\t\t\t\t\t\t\t,[SNMPV3PrivKey] = @SNMPV3PrivKey\r\n\t\t\t\t\t\t\t\t,[SNMPV3PrivKeyIsPwd] = @SNMPV3PrivKeyIsPwd\r\n\t\t\t\t\t\t\t\t,[SNMPV3AuthKey] = @SNMPV3AuthKey\r\n\t\t\t\t\t\t\t\t,[SNMPV3AuthMethod] = @SNMPV3AuthMethod\r\n\t\t\t\t\t\t\t\t,[SNMPV3AuthKeyIsPwd] = @SNMPV3AuthKeyIsPwd\r\n\t\t\t\t\t\t\t\tWHERE [CredentialName] = @CredentialName"))
     {
         textCommand.Parameters.Add("@CredentialName", SqlDbType.NVarChar, 200).Value  = (object)credentials.get_CredentialName();
         textCommand.Parameters.Add("@SNMPV3Username", SqlDbType.NVarChar, 50).Value   = (object)credentials.get_SNMPv3UserName();
         textCommand.Parameters.Add("@SNMPV3Context", SqlDbType.NVarChar, 50).Value    = (object)credentials.get_SnmpV3Context();
         textCommand.Parameters.Add("@SNMPV3PrivMethod", SqlDbType.NVarChar, 50).Value = (object)credentials.get_SNMPv3PrivacyType().ToString();
         textCommand.Parameters.Add("@SNMPV3PrivKey", SqlDbType.NVarChar, 50).Value    = (object)credentials.get_SNMPv3PrivacyPassword();
         textCommand.Parameters.Add("@SNMPV3PrivKeyIsPwd", SqlDbType.Bit).Value        = (object)credentials.get_SNMPV3PrivKeyIsPwd();
         textCommand.Parameters.Add("@SNMPV3AuthKey", SqlDbType.NVarChar, 50).Value    = (object)credentials.get_SNMPv3AuthPassword();
         textCommand.Parameters.Add("@SNMPV3AuthMethod", SqlDbType.NVarChar, 50).Value = (object)credentials.get_SNMPv3AuthType().ToString();
         textCommand.Parameters.Add("@SNMPV3AuthKeyIsPwd", SqlDbType.Bit).Value        = (object)credentials.get_SNMPV3AuthKeyIsPwd();
         SqlHelper.ExecuteNonQuery(textCommand);
     }
 }