예제 #1
0
        public static int SongVoteThreshold()
        {
            if (m_SongVoteThreshold.HasValue)
            {
                return(m_SongVoteThreshold.Value);
            }

            using (var s_Db = Database.GetConnection())
            {
                var s_Setting = s_Db.SingleById <CoreSetting>("votethreshold");

                if (s_Setting == null)
                {
                    s_Setting = new CoreSetting()
                    {
                        Key = "votethreshold", Value = "0"
                    };
                    s_Db.Insert(s_Setting);
                }

                m_SongVoteThreshold = Int32.Parse(s_Setting.Value);
            }

            return(m_SongVoteThreshold.Value);
        }
예제 #2
0
        public static int MaxHistorySongs()
        {
            if (m_MaxHistorySongs.HasValue)
            {
                return(m_MaxHistorySongs.Value);
            }

            using (var s_Db = Database.GetConnection())
            {
                var s_Setting = s_Db.SingleById <CoreSetting>("history");

                if (s_Setting == null)
                {
                    s_Setting = new CoreSetting()
                    {
                        Key = "history", Value = "1"
                    };
                    s_Db.Insert(s_Setting);
                }

                m_MaxHistorySongs = Int32.Parse(s_Setting.Value);
            }

            return(m_MaxHistorySongs.Value);
        }
예제 #3
0
        public static bool CanCommandWithoutGuest()
        {
            if (m_CanCommandWithoutGuest.HasValue)
            {
                return(m_CanCommandWithoutGuest.Value);
            }

            using (var s_Db = Database.GetConnection())
            {
                var s_Setting = s_Db.SingleById <CoreSetting>("cmdguest");

                if (s_Setting == null)
                {
                    s_Setting = new CoreSetting()
                    {
                        Key = "cmdguest", Value = true.ToString()
                    };
                    s_Db.Insert(s_Setting);
                }

                m_CanCommandWithoutGuest = Boolean.Parse(s_Setting.Value);
            }

            return(m_CanCommandWithoutGuest.Value);
        }
예제 #4
0
        public static char CommandPrefix()
        {
            if (m_CommandPrefix.HasValue)
            {
                return(m_CommandPrefix.Value);
            }

            using (var s_Db = Database.GetConnection())
            {
                var s_Setting = s_Db.SingleById <CoreSetting>("cmdprefix");

                if (s_Setting == null)
                {
                    s_Setting = new CoreSetting()
                    {
                        Key = "cmdprefix", Value = "!"
                    };
                    s_Db.Insert(s_Setting);
                }

                m_CommandPrefix = Char.Parse(s_Setting.Value);
            }

            return(m_CommandPrefix.Value);
        }
예제 #5
0
        public static void CommandPrefix(char p_Prefix)
        {
            if (Char.IsLetterOrDigit(p_Prefix))
            {
                return;
            }

            using (var s_Db = Database.GetConnection())
            {
                var s_Setting = s_Db.SingleById <CoreSetting>("cmdprefix");

                if (s_Setting == null)
                {
                    s_Setting = new CoreSetting()
                    {
                        Key = "cmdprefix", Value = p_Prefix.ToString()
                    };
                    s_Db.Insert(s_Setting);
                }
                else
                {
                    s_Setting.Value = p_Prefix.ToString();
                    s_Db.Update(s_Setting);
                }
            }

            m_CommandPrefix = p_Prefix;
        }
예제 #6
0
        public static void SongVoteThreshold(int p_Threshold)
        {
            if (p_Threshold > 0)
            {
                return;
            }

            using (var s_Db = Database.GetConnection())
            {
                var s_Setting = s_Db.SingleById <CoreSetting>("votethreshold");

                if (s_Setting == null)
                {
                    s_Setting = new CoreSetting()
                    {
                        Key = "votethreshold", Value = p_Threshold.ToString()
                    };
                    s_Db.Insert(s_Setting);
                }
                else
                {
                    s_Setting.Value = p_Threshold.ToString();
                    s_Db.Update(s_Setting);
                }
            }

            m_SongVoteThreshold = p_Threshold;
        }
예제 #7
0
        /// <summary>
        ///     Settings will not be null. Default values will be pushed.
        /// </summary>
        /// <returns></returns>
        private static bool CreateDefaultCoreSetting()
        {
            var s = Setting;

            if (s == null)
            {
                //no setting exist , need to create a default setting.
                using (var db = new DevIdentityDbContext()) {
                    _setting = new CoreSetting {
                        // Set the id to be auto in db.
                        CoreSettingID          = 1,
                        ApplicationName        = "Developers Organism Component",
                        ApplicationSubtitle    = "Subtitle",
                        ApplicationDescription = "Developers Organism component for website maintenance.",
                        CompanyName            = "Developers Organism",
                        Language                               = "English",
                        LiveUrl                                = "http://www.developers-organism.com",
                        AdminLocation                          = "Admin",
                        TestingUrl                             = "http://*****:*****@gmail.com",
                        DeveloperEmail                         = "*****@*****.**",
                        OfficePhone                            = 018,
                        Fax                                    = 018,
                        MarketingEmail                         = "*****@*****.**",
                        SupportEmail                           = "*****@*****.**",
                        MarketingPhone                         = 018,
                        SupportPhone                           = 018,
                        IsAuthenticationEnabled                = false,
                        IsInTestingEnvironment                 = true,
                        DoesRegisterCodeNeverExpires           = true,
                        IsRegisterCodeRequiredToRegister       = false,
                        ShouldRegistrationCodeBeLinkedWithUser = true,
                        SenderEmailPassword                    = "******",
                        Address                                = "Address of your office.",
                        OfficeEmail                            = "*****@*****.**",
                        SenderEmail                            = "*****@*****.**",
                        SenderDisplay                          = "Your sender display",
                        SmtpHost                               = "smtp.gmail.com",
                        SmtpMailPort                           = 587,
                        GoogleMetaTag                          = "Meta tag",
                        FacebookClientID                       = 123,
                        FacebookSecret                         = "FB App Secret",
                        IsFacebookAuthentication               = true,
                        NotifyDeveloperOnError                 = true,
                        IsConfirmMailRequired                  = true,
                        IsSmtpssl                              = true,
                        IsFirstUserFound                       = false
                    };
                    db.CoreSettings.Add(_setting);
                    var i = db.SaveChanges();
                    if (i >= 0)
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            return(false);
        }
예제 #8
0
파일: CoreSetting.cs 프로젝트: xhute/Kooboo
        public void Update(string name, Dictionary <string, string> model, ApiCall call)
        {
            var Core = new CoreSetting();

            Core.Name   = name;
            Core.Values = model;
            call.WebSite.SiteDb().CoreSetting.AddOrUpdate(Core);
        }
예제 #9
0
        public ActionResult Index(CoreSetting coreSetting, string tab)
        {
            ViewBag.tab = tab;

            if (ModelState.IsValid)
            {
                _db.Entry(coreSetting).State = EntityState.Modified;
                _db.SaveChanges();
                AppConfig.RefreshSetting();
                AppVar.SetSavedStatus(ViewBag);
            }
            AppVar.SetErrorStatus(ViewBag);
            return(View(coreSetting));
        }
예제 #10
0
        public static void RefreshSetting()
        {
            using (var db = new DevIdentityDbContext()) {
                CreateDefaultCoreSetting();
                _setting = db.CoreSettings.FirstOrDefault();
                Setting  = db.CoreSettings.FirstOrDefault();
                if (_setting == null)
                {
                    throw new Exception("Couldn't create or get the core settings. Please check the creation.");
                }
                Zone.LoadTimeZonesIntoMemory();
                AppVar.Setting = _setting;
                AppVar.SetCommonMetaDescriptionToEmpty();

                SetupDevMvcComponent();
                UrlRoute.HostUrl = AppVar.Url;

                //if false then no email on error.
                Config.IsNotifyDeveloper = Setting.NotifyDeveloperOnError;
            }
        }
예제 #11
0
        public static object GetSetting(CoreSetting coresetting, Type SettingType)
        {
            if (SettingType == null)
            {
                return(null);
            }

            var result = Activator.CreateInstance(SettingType);

            if (coresetting != null && coresetting.Values != null && coresetting.Values.Any())
            {
                var properties = SettingType.GetProperties().ToList();
                var fields     = SettingType.GetFields().ToList();
                foreach (var item in coresetting.Values)
                {
                    if (item.Value != null)
                    {
                        var prop = properties.Find(p => p.Name.Equals(item.Key, StringComparison.OrdinalIgnoreCase));

                        if (prop != null)
                        {
                            var value = Lib.Reflection.TypeHelper.ChangeType(item.Value, prop.PropertyType);
                            prop.SetValue(result, value);
                        }
                        else
                        {
                            var field = fields.Find(f => f.Name.Equals(item.Key, StringComparison.OrdinalIgnoreCase));
                            if (field != null)
                            {
                                var value = Lib.Reflection.TypeHelper.ChangeType(item.Value, field.FieldType);
                                field.SetValue(result, value);
                            }
                        }
                    }
                }
            }

            return(result);
        }
예제 #12
0
        public static void MaxHistorySongs(int p_Songs)
        {
            using (var s_Db = Database.GetConnection())
            {
                var s_Setting = s_Db.SingleById <CoreSetting>("history");

                if (s_Setting == null)
                {
                    s_Setting = new CoreSetting()
                    {
                        Key = "history", Value = p_Songs.ToString()
                    };
                    s_Db.Insert(s_Setting);
                }
                else
                {
                    s_Setting.Value = p_Songs.ToString();
                    s_Db.Update(s_Setting);
                }
            }

            m_MaxHistorySongs = p_Songs;
        }
예제 #13
0
        public static void CanCommandWithoutGuest(bool p_Value)
        {
            using (var s_Db = Database.GetConnection())
            {
                var s_Setting = s_Db.SingleById <CoreSetting>("cmdguest");

                if (s_Setting == null)
                {
                    s_Setting = new CoreSetting()
                    {
                        Key = "cmdguest", Value = p_Value.ToString()
                    };
                    s_Db.Insert(s_Setting);
                }
                else
                {
                    s_Setting.Value = p_Value.ToString();
                    s_Db.Update(s_Setting);
                }
            }

            m_CanCommandWithoutGuest = p_Value;
        }
        public static void RefreshSetting()
        {
            using (var db = new DevIdentityDbContext()) {
                CreateDefaultCoreSetting();

                _setting = db.CoreSettings.FirstOrDefault();
                if (_setting == null)
                {
                    throw new Exception("Couldn't create or get the core settings. Please check the creation.");
                }
                InitalizeDevelopersOrganismComponent(true);
                AppVar.IsInTestEnvironment = Setting.IsInTestingEnvironment;

                AppVar.Name     = Setting.ApplicationName.ToString();
                AppVar.Subtitle = Setting.ApplicationSubtitle.ToString();
                AppVar.Setting  = Setting;
                AppVar.SetCommonMetaDescriptionToEmpty();
                //Configure this with add a sender email.
                DevMVCComponent.Starter.Mailer = new DevMVCComponent.Mailers.CustomMailConfig(Setting.SenderEmail, Setting.SenderEmailPassword, Setting.SmtpHost, Setting.SmtpMailPort, Setting.IsSMTPSSL);
                //if false then no email on error.
                DevMVCComponent.Config.IsNotifyDeveloper = Setting.NotifyDeveloperOnError;
            }
        }
예제 #15
0
        public static CoreSetting GetCoreSetting(ISiteSetting siteSetting)
        {
            var dbsettiing = new CoreSetting
            {
                Name = siteSetting.Name
            };

            var allprops = Lib.Reflection.TypeHelper.GetPublicPropertyOrFields(siteSetting.GetType());

            foreach (var item in allprops)
            {
                if (item is PropertyInfo)
                {
                    var info = item as PropertyInfo;

                    var value = info.GetValue(siteSetting);

                    if (value != null)
                    {
                        dbsettiing.Values.Add(info.Name, value.ToString());
                    }
                }
                else if (item is FieldInfo)
                {
                    var info = item as FieldInfo;

                    var value = info.GetValue(siteSetting);

                    if (value != null)
                    {
                        dbsettiing.Values.Add(info.Name, value.ToString());
                    }
                }
            }

            return(dbsettiing);
        }
예제 #16
0
 public static ISiteSetting GetSiteSetting(CoreSetting coresetting, Type SettingType)
 {
     return(GetSetting(coresetting, SettingType) as ISiteSetting);
 }