示例#1
0
 public SyncService()
 {
     AdUserService = new AdUserService();
     DbUserService = new DbUserService();
     HelperService = new HelperService();
     FaxApiService = new FaxApiService();
     LogService    = new LogService();
 }
        private void SyncMissingDbUsers()
        {
            this.LogService.LogEvent("START: Sync missing users in was/is table");
            var adUsers      = AdUserService.GetCachedUsers();
            var dbUsers      = DbUserService.GetAllUsers();
            var dbUsersIds   = dbUsers.Select(x => x.AttorneyUserID.ToLower()).ToList();
            var missingUsers = adUsers.Where(x => !dbUsersIds.Contains(x.UserId.ToLower())).ToList();

            DbUserService.AddMissingUsers(missingUsers);
            this.LogService.LogEvent("FINISH: Sync missing users in was/is table");
        }
        private void UpdateDbUsersFromExecutionResults(Dictionary <Attorney, bool> listOfExecutionResults)
        {
            this.LogService.LogEvent("START: Update Database with Sync Results - was/is.");
            var listSuccesfulyUpdatedUsers = new List <IDbUser>();

            foreach (var result in listOfExecutionResults)
            {
                var sucessfulyExecuted = result.Value;
                if (sucessfulyExecuted)
                {
                    var dbUser = BuildDbUserFromAttorney(result.Key);
                    listSuccesfulyUpdatedUsers.Add(dbUser);
                }
            }

            DbUserService.UpdateUsers(listSuccesfulyUpdatedUsers);
            this.LogService.LogEvent("FINISH: Update Database with Sync Results - was/is.");
        }
        private List <Attorney> LoadAttorneys()
        {
            this.LogService.LogEvent("START: Load Attorneys: Loading the data from AD and mapping with DB user.");
            var dbUsers            = DbUserService.GetAllUsers();
            var blackListedNumbers = HelperService.GetBlackListedFaxNumbers();

            var listAttoryes = new List <Attorney>();

            foreach (var user in dbUsers)
            {
                var attorneyObj = BuildAttorney(user, blackListedNumbers);
                if (attorneyObj.NotNull())
                {
                    listAttoryes.Add(attorneyObj);
                }
            }
            this.LogService.LogEvent("FINISH: Load Attorneys: Loading the data from AD and mapping with DB user.");
            return(listAttoryes);
        }