public static async Task<List<User>> SearchUsersPerKeywordAsync(this IAdminAccessBll accessBll, SessionToken token, string keyword)
 {
     var result = await AdminAccessWs.SearchUsersPerKeywordAsync(
                     token.ToWebSeriveObject<WS.SessionToken>(),
                     keyword);
     return ProxyHelper.ToListOf<WS.User, BLL.User>(result);
 }
 public static async Task<List<User>> GetUserAsync(this IAdminAccessBll accessBll, SessionToken token, PagingData page)
 {
     var result = await AdminAccessWs.GetUsersAsync(
                     token.ToWebSeriveObject<WS.SessionToken>(),
                     page.ToWebSeriveObject<WS.PagingData>());
     return ProxyHelper.ToListOf<WS.User, BLL.User>(result);
 }
Пример #3
0
        public override bool DelayPerformance(SessionToken token, Performance oldPerformance, Performance newPerformance)
        {
            if (!IsUserAuthenticated(token)
                || !IsPerformanceValid(oldPerformance)
                || !IsPerformanceValid(newPerformance)
                || Equals(oldPerformance, newPerformance))
            {
                return false;
            }

            Performance checkResult = null;
            PerformanceDao.SelectById(oldPerformance.DateTime,
                oldPerformance.Artist.ArtistId)
                .OnSuccess(response => checkResult = response.ResultObject);

            if (checkResult == null)
                return false;

            var insertStatus = DaoStatus.Failed;
            using (var scope = new TransactionScope())
            {
                var deleteStatus = PerformanceDao.Delete(oldPerformance).ResponseStatus;
                if (deleteStatus == DaoStatus.Successful)
                    insertStatus = PerformanceDao.Insert(newPerformance).ResponseStatus;
                if (insertStatus == DaoStatus.Successful)
                    scope.Complete();
            }
            return insertStatus == DaoStatus.Successful;
        }
Пример #4
0
 public void RegisterUserSession(SessionToken token, IAuthAccessBll authAccessBll)
 {
     lock (_sessionDirectory)
     {
         if (token?.SessionId == null || token.User == null)
             return;
         _sessionDirectory[token] = authAccessBll;
         Console.WriteLine($"Registered new session key: {token}");
     }
 }
Пример #5
0
 public User GetUserFromSession(SessionToken token)
 {
     lock (_sessionDirectory)
     {
         if (_sessionDirectory.ContainsKey(token)
             && _sessionDirectory.AsParallel().Any(x => x.Key.Equals(token)))
             return token.User;
     }
     return null;
 }
Пример #6
0
 public void DeleteUserSession(SessionToken token)
 {
     lock (_sessionDirectory)
     {
         var value = _sessionDirectory.Keys.AsParallel().FirstOrDefault(x => x.User.Equals(token.User));
         if (value == null)
             return;
         _sessionDirectory.Remove(value);
         Console.WriteLine($"Removed session key: {value}");
     }
 }
Пример #7
0
 public override List<string> GetUserAutoCompletion(SessionToken token, string keyword)
 {
     if (!IsUserAuthenticated(token))
         return new List<string>();
     Func<List<string>> func = () =>
     {
         var set = new HashSet<string>();
         if (keyword != null && keyword.Length >= 2)
         {
             SearchUsersPerKeyword(token, keyword)?.ForEach(u =>
             {
                 if (Regex.IsMatch(u.FirstName, keyword, RegexOptions.IgnoreCase))
                     set.Add(u.FirstName);
                 if (Regex.IsMatch(u.LastName, keyword, RegexOptions.IgnoreCase))
                     set.Add(u.LastName);
                 if (u.Artist != null && Regex.IsMatch(u.Artist.Name, keyword, RegexOptions.IgnoreCase))
                     set.Add(u.Artist.Name);
             });
         }
         return set.ToList();
     };
     return EvaluateSessionPagingResult(token, func);
 }
Пример #8
0
 public bool ModifyPerformance(SessionToken token, Performance performance) => AdminAccessDelegate.ModifyPerformance(token, performance);
Пример #9
0
 public bool LoginAdmin(SessionToken token) => AdminAccessDelegate.LoginAdmin(token);
Пример #10
0
 public bool SendNotification(SessionToken token, Notification notification) => AdminAccessDelegate.SendNotification(token, notification);
Пример #11
0
 public bool RemoveVenue(SessionToken token, Venue venue) => AdminAccessDelegate.RemoveVenue(token, venue);
Пример #12
0
 public bool RemoveArtist(SessionToken token, Artist artist) => AdminAccessDelegate.RemoveArtist(token, artist);
Пример #13
0
 public bool IsValidAdmin(SessionToken token) => AdminAccessDelegate.IsValidAdmin(token);
Пример #14
0
 public bool ModifyArtistRange(SessionToken token, List<Artist> artists) => AdminAccessDelegate.ModifyArtistRange(token, artists);
Пример #15
0
        public override bool SendNotification(SessionToken token, Notification notification)
        {
            if (!IsUserAuthenticated(token) || !IsNotificationValid(notification))
                return false;

            try
            {
                using (var mailMessage = new MailMessage(notification.Sender, notification.Recipient)
                {
                    Subject = notification.Subject,
                    Body = notification.Body,
                    IsBodyHtml = true
                })
                using (var smtpClient = new SmtpClient(EmailNotificationServer, EmailNotificationPort)
                {
                    Credentials = new NetworkCredential(EmailNotificationUsername, EmailNotificationPassword),
                    DeliveryMethod = SmtpDeliveryMethod.Network,
                    EnableSsl = true
                })
                {
                    smtpClient.Send(mailMessage);
                }
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
Пример #16
0
 public List<string> GetUserAutoCompletion(SessionToken token, string keyword) => AdminAccessDelegate.GetUserAutoCompletion(token, keyword);
Пример #17
0
 public PagingData RequestUserPagingData(SessionToken token) => AdminAccessDelegate.RequestUserPagingData(token);
Пример #18
0
 public bool ModifyLocationRange(SessionToken token, List<Location> locations) => AdminAccessDelegate.ModifyLocationRange(token, locations);
Пример #19
0
 public bool ModifyArtist(SessionToken token, Artist artist) => AdminAccessDelegate.ModifyArtist(token, artist);
Пример #20
0
 public bool ModifyLocation(SessionToken token, Location location) => AdminAccessDelegate.ModifyLocation(token, location);
Пример #21
0
 public bool ModifyVenue(SessionToken token, Venue venue) => AdminAccessDelegate.ModifyVenue(token, venue);
Пример #22
0
 public bool RemoveLocation(SessionToken token, Location location) => AdminAccessDelegate.RemoveLocation(token, location);
Пример #23
0
 public bool RemovePerformance(SessionToken token, Performance performance) => AdminAccessDelegate.RemovePerformance(token, performance);
Пример #24
0
 public bool ModifyVenueRange(SessionToken token, List<Venue> venues) => AdminAccessDelegate.ModifyVenueRange(token, venues);
Пример #25
0
 public bool IsUserAuthenticated(SessionToken token) => AdminAccessDelegate.IsUserAuthenticated(token);
Пример #26
0
 public bool ModifyPerformanceRange(SessionToken token, List<Performance> performances) => AdminAccessDelegate.ModifyPerformanceRange(token, performances);
Пример #27
0
 public void LogoutAdmin(SessionToken token) => AdminAccessDelegate.LogoutAdmin(token);
Пример #28
0
 public List<User> GetUsers(SessionToken token, PagingData page) => AdminAccessDelegate.GetUsers(token, page);
Пример #29
0
 public bool DelayPerformance(SessionToken token, Performance oldPerformance, Performance newPerformance) => AdminAccessDelegate.DelayPerformance(token, oldPerformance, newPerformance);
Пример #30
0
 public List<User> SearchUsersPerKeyword(SessionToken token, string keyword) => AdminAccessDelegate.SearchUsersPerKeyword(token, keyword);