Example #1
0
        /// <summary>
        /// Gets SDI info from HDB and returns a DataTable
        /// </summary>
        /// <param name="conx"></param>
        /// <param name="sdiString"></param>
        /// <returns></returns>
        private static DataTable queryHdbInfo(UniConnection conx, string sdiString)
        {
            // Initialize stuff...
            var           dTab    = new DataTable();
            List <string> sdiList = new List <string>(sdiString.Split(','));

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Connect to and get HDB data
            if (jrDebug)
            {
                Console.Write("Downloading sdi info... ");
            }
            UniCommand cmd = new UniCommand("GET_HDB_CGI_INFO", conx);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("o_cursorOutput", UniDbType.Cursor).Direction = ParameterDirection.Output;
            cmd.Parameters.Add("i_sdiList", UniDbType.Char).Value            = sdiString;
            UniDataReader dr          = cmd.ExecuteReader();
            var           schemaTable = dr.GetSchemaTable();

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Put DB data into a .NET DataTable
            dTab.Load(dr);

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Return output
            if (jrDebug)
            {
                Console.WriteLine("Success!");
            }
            dr.Dispose();
            cmd.Dispose();
            return(dTab);
        }
Example #2
0
        /// <summary>
        /// Gets unique SDIs given a particular MRID and M-Table interval
        /// </summary>
        /// <param name="conx"></param>
        /// <param name="mridString"></param>
        /// <param name="interval"></param>
        /// <returns></returns>
        private static string getUniqueSdisFromMTable(UniConnection conx, string mridString, string interval)
        {
            // Initialize stuff...
            string sdiString = "";
            string sql       = "SELECT UNIQUE(SITE_DATATYPE_ID) FROM M_" + interval + " WHERE MODEL_RUN_ID IN (" + mridString + ")";

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Connect to and get HDB data
            if (jrDebug)
            {
                Console.Write("Getting Unique SDIs... ");
            }
            UniCommand cmd = new UniCommand(sql, conx);

            cmd.CommandType = System.Data.CommandType.Text;
            UniDataReader dr          = cmd.ExecuteReader();
            var           schemaTable = dr.GetSchemaTable();

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Build a string of SDIS with a comma delimiter
            while (dr.Read())
            {
                sdiString = sdiString + dr[0].ToString() + ",";
            }
            dr.Dispose();
            cmd.Dispose();
            if (jrDebug)
            {
                Console.WriteLine("Success!");
            }

            return(sdiString);
        }
Example #3
0
        /// <summary>
        /// Gets Oracle DB data using the GET_HDB_CGI_DATA stored procedure and returns a DataTable with a common date range and sdi columns
        /// </summary>
        /// <param name="conx"></param>
        /// <param name="sdiList"></param>
        /// <param name="runIDs"></param>
        /// <returns></returns>
        private static DataTable queryHdbDataUsingStoredProcedure(UniConnection conx, string sdiList, string tStep,
                                                                  string startDate, string endDate, string sourceTable = "R", string modelRunIds = null)
        {
            // Initialize stuff...
            var dTab = new DataTable();

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Connect to and get HDB data
            if (jrDebug)
            {
                Console.Write("Downloading data... ");
            }
            UniCommand cmd = new UniCommand("GET_HDB_CGI_DATA", conx);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("o_cursorOutput", UniDbType.Cursor).Direction = ParameterDirection.Output;
            cmd.Parameters.Add("i_sdiList", UniDbType.VarChar).Value         = sdiList;
            cmd.Parameters.Add("i_tStep", UniDbType.Char).Value        = tStep;
            cmd.Parameters.Add("i_startDate", UniDbType.VarChar).Value = startDate.ToUpper();
            cmd.Parameters.Add("i_endDate", UniDbType.VarChar).Value   = endDate.ToUpper();
            cmd.Parameters.Add("i_sourceTable", UniDbType.Char).Value  = sourceTable;
            cmd.Parameters.Add("i_modelRunIds", UniDbType.Char).Value  = modelRunIds;
            UniDataReader dr          = cmd.ExecuteReader();
            var           schemaTable = dr.GetSchemaTable();

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Put DB data into a .NET DataTable
            dTab.Load(dr);

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Return output
            if (jrDebug)
            {
                Console.WriteLine("Success!");
            }
            dr.Dispose();
            cmd.Dispose();
            return(dTab);
        }