Example: IDO Method Critical Numbers

To set up a program, create a simple critical number in the Critical Numbers form.

An example of IDO method-based critical number:
[IDOMethod]
      public int UserNamesCount( int KpiNum, DateTime AsOfDate, ref decimal Amount,
         string Parm1, string Parm2, string Parm3, string Parm4, string Parm5, string Parm6, string Parm7, string Parm8, string Parm9,
         string Parm10, string Parm11, string Parm12, string Parm13, string Parm14, string Parm15, string Parm16, string Parm17, string Parm18, string Parm19,
         string Parm20, string Parm21, string Parm22, string Parm23, string Parm24, string Parm25, string Parm26, string Parm27, string Parm28, string Parm29,
         string Parm30, string Parm31, string Parm32, string Parm33, string Parm34, string Parm35, string Parm36, string Parm37, string Parm38, string Parm39,
         string Parm40, string Parm41, string Parm42, string Parm43, string Parm44, string Parm45, string Parm46, string Parm47, string Parm48, string Parm49,
         string Parm50 )
      {
         int severity = 0;
         object result;

         using ( ApplicationDB appDB = IDORuntime.Context.CreateApplicationDB() )
         {
            using ( var cmd = appDB.CreateCommand() )
            {
               cmd.CommandType = CommandType.Text;
               cmd.Connection = appDB.Connection;
               cmd.CommandText = string.Concat( " SELECT COUNT(*) ",
                                                " FROM usernames un "
                                              );
               cmd.CommandText = IDORuntime.AppDataProvider.MassageQueryForProvider( cmd.CommandText );

               try
               {
                  result = cmd.ExecuteScalar();

                  if ( result == null )
                     Amount = 0;
                  else
                     Amount = int.Parse( result.ToString() );
               }
               catch
               {
                  severity = 16;
                  Amount = 0;
               }
            }
         }

         return severity;
      }