Exemplo n.º 1
0
        public static int GetCalculatedCounterSettingValue(Guid OrgId, Guid InstId, Guid SettingId)
        {
            int?counterVal = null;

            counterVal = (int?)Micajah.Common.Application.CacheManager.Current.Get(string.Format("CounterSettingValue{0}{1}{2}", OrgId, InstId, SettingId));

            if (counterVal.HasValue)
            {
                return(counterVal.Value);
            }

            string cnnString = GetSettingsValuesHistoryDbConnectionString();

            if (!string.IsNullOrEmpty(cnnString))
            {
                DataTable dt = SelectByQuery(string.Format("SELECT TOP 1 SettingValue FROM SettingsValuesHistory WHERE OrganizationId='{0}' AND InstanceId='{1}' AND SettingId='{2}' ORDER BY Id DESC", OrgId, InstId, SettingId));
                if (dt.Rows.Count > 0 && !dt.Rows[0].IsNull(0))
                {
                    int cVal = 0;
                    if (int.TryParse(dt.Rows[0][0].ToString(), out cVal))
                    {
                        Micajah.Common.Application.CacheManager.Current.Put(string.Format("CounterSettingValue{0}{1}{2}", OrgId, InstId, SettingId), cVal, TimeSpan.FromMinutes(1440));
                        return(cVal);
                    }
                }
            }

            Micajah.Common.Bll.Handlers.SettingHandler handler = Micajah.Common.Bll.Handlers.SettingHandler.Current;

            Setting s = SettingProvider.GetSetting(SettingId);

            counterVal = handler.GetUsedItemsCount(s, OrgId, InstId);

            Micajah.Common.Application.CacheManager.Current.Put(string.Format("CounterSettingValue{0}{1}{2}", OrgId, InstId, SettingId), counterVal.Value, TimeSpan.FromMinutes(1440));

            return(counterVal.Value);
        }
        public override bool ValidateUser(string username, string password)
        {
            Member member = _context.Members.FirstOrDefault(m => m.UserName == username);
            SettingProvider settings = new SettingProvider();

            if (member != null)
            {
                var principalCtx = new PrincipalContext(
                    ContextType.ApplicationDirectory,
                    settings.GetSetting<string>("Auth_AdamLdapAddress"),
                    settings.GetSetting<string>("Auth_AdamAuthContainer"),
                    settings.GetSetting<string>("Auth_AdamLdapUserName"),
                    settings.GetSetting<string>("Auth_AdamLdapPassword")
                    );

                return principalCtx.ValidateCredentials(username, password);
            }
            return false;
        }