Ejemplo n.º 1
0
 public static string GetConfigEntry(string key, string Default, string Explanation = "")
 {
     try
     {
         using (var db = new DAL.SteinbachEntities())
         {
             string res = db.config.Where(s => s.mkey == key).FirstOrDefault().value;
             return(res);
         }
     }
     catch (Exception ex)
     {
         try
         {
             using (var db = new DAL.SteinbachEntities())
             {
                 var c = new DAL.config {
                     mkey = key, value = Default, Description = Explanation
                 };
                 db.AddToconfig(c);
                 db.SaveChanges();
                 return(Default);
             }
         }
         catch (Exception)
         {
             return("");
         }
     }
 }
Ejemplo n.º 2
0
        public static T GetConfigEntry(string key, string Default, string Explanation = "")
        {
            string result = string.Empty;

            try
            {
                using (var db = new DAL.SteinbachEntities())
                {
                    var res = db.config.Where(s => s.mkey == key).FirstOrDefault();

                    if (res != null)
                    {
                        result = res.value;
                    }
                    else
                    {
                        var c = new DAL.config {
                            mkey = key, value = Default, Description = Explanation
                        };
                        db.AddToconfig(c);
                        db.SaveChanges();
                        result = Default;
                    }
                }



                object ReturnVal = result;


                if (typeof(T) == typeof(string))
                {
                    return((T)ReturnVal);
                }

                else if (typeof(T) == typeof(int))
                {
                    int  iOut  = 0;
                    bool check = int.TryParse(result, out iOut);

                    if (check)
                    {
                        object ret = iOut;
                        return((T)ret);
                    }
                }

                return(default(T));
            }
            catch (Exception)
            {
                return(default(T));
            }
        }
Ejemplo n.º 3
0
        public OnlineCusSvr()
        {
            if (session["cusSvrMode"] == null || session["cusSvrUserMaxAmount"] == null || session["cusSvrUserDelLevel"] == null || session["maxCusSvrConnLevel"] == null || session["maxUserConnNum"] == null || session["countSizeLevel"] == null || session["showCountDownSizeLevel"] == null || session["branchCountDownAjaxSizeLevel"] == null || session["levelSeconds"] == null)
            {
                DAL.config configData = dal.GetConfigData();
                session["cusSvrMode"]             = configData.cusSvrMode;
                session["cusSvrUserMaxAmount"]    = configData.cusSvrUserMaxAmount;
                session["cusSvrUserDelLevel"]     = configData.cusSvrUserDelLevel;
                session["maxCusSvrConnLevel"]     = configData.maxCusSvrConnLevel;
                session["maxUserConnNum"]         = configData.maxUserConnNum;
                session["countSizeLevel"]         = configData.countSizeLevel;
                session["showCountDownSizeLevel"] = configData.showCountDownSizeLevel;
                //session["branchCountDownAjaxSizeLevel"] = configData.branchCountDownAjaxSizeLevel;
                session["levelSeconds"] = configData.levelSeconds;
            }

            whichMode = Convert.ToInt32(session["cusSvrMode"]);
        }