daily pastebin goal
33%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  [DisableConcurrentExecution(1000)]
  2.         public async Task SyncAll()
  3.         {
  4.             var list = new List<Task<List<StaffEntity>>> {SynchronizeHr(), SynchronizeHeadHr(), SynchronizeManager()};
  5.  
  6.             var comparer = new CustomEqualityComparer<StaffEntity>(
  7.                 (a, b) => a.Sid == b.Sid,
  8.                 a => a.Sid.GetHashCode());
  9.  
  10.             var result = (await Task.WhenAll(list)).SelectMany(x=>x).Distinct(comparer).ToList();
  11.  
  12.             await _locker.WaitAsync();
  13.             try
  14.             {
  15.                 var users = await StaffRepository.WhereAsync(x=>!x.IsDeleted);
  16.            
  17.                 var diff = result.Except(users.Intersect(result, comparer), comparer).ToList();
  18.  
  19.                 if (diff.Any())
  20.                 {
  21.                     foreach (var staff in diff)
  22.                     {
  23.                         await StaffRepository.CreateAsync(staff);
  24.                         await StaffRepository.SaveAsync();
  25.                     }
  26.                 }
  27.                
  28.             }
  29.             finally
  30.             {
  31.                 _locker.Release();
  32.             }
  33.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top