Esempio n. 1
0
        /// <summary>
        /// Puts the key value pair that you obtain from a storedProcedure into the application object.
        /// To access the dictionary, use key "kvpd_[spName]"
        /// To access the list, use key "kvpl_[spName]"
        /// </summary>
        /// <param name="appID"></param>
        public void PutKVPInDictionary(string spName)
        {
            try
            {
                Dictionary <string, string> d = new Dictionary <String, string>();
                List <string> l    = new List <string>();
                clsDB         myDB = new clsDB();
                SqlCommand    cmd  = new SqlCommand();
                using (myDB.OpenConnection())
                {
                    using (SqlDataReader dR = (SqlDataReader)myDB.ExecuteSP(spName, null,
                                                                            clsDB.SPExMode.READER, ref cmd))
                    {
                        if (dR != null && dR.HasRows)
                        {
                            while (dR.Read())
                            {
                                d.Add(Convert.ToString(dR[DBK.keyACTUALVALUE]), Convert.ToString(dR[DBK.valDISPLAYEDVALUE]));
                                l.Add(Convert.ToString(dR[DBK.keyACTUALVALUE]));
                                l.Add(Convert.ToString(dR[DBK.valDISPLAYEDVALUE]));
                            }
                        }
                    }
                }


                HttpContext.Current.Application["kvpd_" + spName] = d;
                HttpContext.Current.Application["kvpl_" + spName] = l;
            }
            catch (Exception ex)
            {
                string x = ex.Message;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Converts an object from a database to a string.
        /// If the object is Null, return an empty string ("")
        /// </summary>
        /// <param name="dbVal"></param>
        /// <returns></returns>

        /// <summary>
        /// Puts the key value pair with fkAppID = appID that is defined in webKVP into the application object.
        /// To access the dictionary, use key "kvpd_[APPID]"
        /// To access the list, use key "kvpl_[APPID]"
        /// </summary>
        /// <param name="appID"></param>
        public void PutKVPInDictionary(Int64 appID)
        {
            try
            {
                Dictionary <string, string> d = new Dictionary <String, string>();
                List <string>       l         = new List <string>();
                clsDB               myDB      = new clsDB();
                SqlCommand          cmd       = new SqlCommand();
                List <SqlParameter> ps        = new List <SqlParameter>();
                ps.Add(new SqlParameter("@" + DBK.fkGROUPID, appID));
                using (myDB.OpenConnection())
                {
                    using (SqlDataReader dR = (SqlDataReader)myDB.ExecuteSP(DBK.SP.spGETWEBKEYVALUEPAIRINFO, ps,
                                                                            clsDB.SPExMode.READER, ref cmd))
                    {
                        if (dR != null && dR.HasRows)
                        {
                            while (dR.Read())
                            {
                                d.Add(Convert.ToString(dR[DBK.keyACTUALVALUE]), Convert.ToString(dR[DBK.valDISPLAYEDVALUE]));
                                l.Add(Convert.ToString(dR[DBK.keyACTUALVALUE]));
                                l.Add(Convert.ToString(dR[DBK.valDISPLAYEDVALUE]));
                            }
                        }
                    }
                }


                HttpContext.Current.Application["kvpd_" + Convert.ToString(appID)] = d;
                HttpContext.Current.Application["kvpl_" + Convert.ToString(appID)] = l;
            }
            catch (Exception ex)
            {
                string x = ex.Message;
            }
        }