Пример #1
0
        /// <summary>
        /// Добавление значения статистики
        /// Client = 0 - обращение с сайта
        /// Client = 1 - обращение с клиента
        /// </summary>
        public static void AddLoginStatistic(LoginStatistics item)
        {
            using (var ctx = new DataClasses1DataContext())
            {
                if (string.IsNullOrEmpty(item.Version))
                {
                    item.Version = string.Empty;
                }

                var obj = ctx.LoginStatistics.FirstOrDefault(x => x.UserName == item.UserName && x.Ip == item.Ip && x.Client == item.Client && x.Version == item.Version);

                if (obj != null)
                {
                    obj.Count++;
                    obj.WhenLastDate = item.WhenLastDate;
                }
                else
                {
                    ctx.LoginStatistics.InsertOnSubmit(item);
                }

                try
                {
                    ctx.SubmitChanges();
                }
                catch (System.Exception ex)
                {
                    DataHelper.AddException(ex);
                }
            }
        }
Пример #2
0
 public static LoginStatistics GetLoginStatistic(LoginStatistics item)
 {
     using (var ctx = new DataClasses1DataContext())
     {
         var obj = ctx.LoginStatistics.FirstOrDefault(x => x.UserName == item.UserName && x.Ip == item.Ip);
         return(obj);
     }
 }
Пример #3
0
 public static LoginStatistics GetLoginStatistic(LoginStatistics item)
 {
     using (var ctx = new RentooloEntities())
     {
         var obj = ctx.LoginStatistics.FirstOrDefault(x => x.UserName == item.UserName && x.Ip == item.Ip);
         return(obj);
     }
 }
Пример #4
0
        public static bool CheckUserAuthorization(string login, string password, string ip, string version)
        {
            bool result = CheckUserAuthorization(login, password);

            if (result)
            {
                LoginStatistics loginStatistic = new LoginStatistics
                {
                    Ip           = ip,
                    UserName     = login,
                    Client       = 1,
                    Version      = version,
                    WhenLastDate = DateTime.Now
                };

                AddLoginStatistic(loginStatistic);
            }

            return(result);
        }