Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void UpdateWithSrhr4229()
- {
- var xl = OfficeHelper.GetExistingExcelInstance();
- var workbooks = xl.Workbooks.Cast<Workbook>();
- var recognizationSource = workbooks.Single(x => x.Keywords.Contains("Recognization"));
- var recognization = new RecognizationContext(recognizationSource);
- //i have lines like these, when i could have directly used recognization.Employees.DoStuffs(....)
- var employees = recognization.Employees as EntityList<Employee>;
- var locations = recognization.Locations as EntityList<Location>;
- var managers = recognization.Managers as EntityList<Manager>;
- var persons = recognization.Persons as EntityList<Person>;
- var srhrSource = workbooks.First(x => x.Name == "Copie de 2015-02-20-14-39-26_Rapp_SRHR4229.xls");
- var srhr = new SrhrContext(srhrSource);
- var srhr4229 = srhr.SRHR4229 as EntityList<SRHR4229>;
- var snapshot = srhr4229.GetTable();
- //sanityCheck
- IntegrityCheck(employees.GetTable(), e => e.ManagerID, managers.GetTable(), m => m.ID, "Employee::ManagerID ⊂ Manager:ManagerID");
- IntegrityCheck(employees.GetTable(), e => e.LocationID, locations.GetTable(), l => l.ID, "Employee::LocationID ⊂ Location:LocationID");
- IntegrityCheck(managers.GetTable(), m => m.LocationID, locations.GetTable(), l => l.ID, "Manager::LocationID ⊂ Location:LocationID");
- IntegrityCheck(employees.GetTable(), e => e.ID, persons.GetTable(), p => p.ID, "Employee::ID ⊂ Person:ID");
- IntegrityCheck(managers.GetTable(), m => m.ID, persons.GetTable(), p => p.ID, "Manager::ID ⊂ Person:ID");
- employees.GetTable().Select(e => new { Employee = e, Srhr = snapshot.FirstOrDefault (x => x.Matricule == e.ID) })
- .Where(x => x.Srhr != null)
- .Where(x => x.Employee.LocationID != AddressUtility.FormatLocationID(x.Srhr.Code_Postal, x.Srhr.Compl_Add))
- .Select(x => new { x.Employee, LocationID = AddressUtility.FormatLocationID(x.Srhr.Code_Postal, x.Srhr.Compl_Add) })
- //.Select(x => new { x.Employee.ID, x.Employee.LocationID, NewLocationID = x.LocationID, }).Dump();
- .ToObservable().Do(x =>
- {
- var employee = x.Employee;
- employee.LocationID = x.LocationID;
- employees.Update(employee);
- }).DumpLatest("Updating Employee LocationID...");
Advertisement
Add Comment
Please, Sign In to add comment