public void Import() { Log.LogInfo("start import"); ServiceLocatorMaster = new ServiceLocatorMaster(sysadminCntx); ServiceLocatorSchool = ServiceLocatorMaster.SchoolServiceLocator(districtId, null); if (!ServiceLocatorSchool.Context.DistrictId.HasValue) { throw new Exception("District id should be defined for import"); } var d = ServiceLocatorMaster.DistrictService.GetByIdOrNull(ServiceLocatorSchool.Context.DistrictId.Value); try { connectorLocator = ConnectorLocator.Create(ConnectionInfo.SisUserName, ConnectionInfo.SisPassword, ConnectionInfo.SisUrl); Log.LogInfo("download data to sync"); DownloadSyncData(); if (d.LastSync.HasValue) { DoRegularSync(true); } else { DoInitialSync(); } Log.LogInfo("updating district last sync"); d = ServiceLocatorMaster.DistrictService.GetByIdOrNull(ServiceLocatorSchool.Context.DistrictId.Value); UpdateDistrictLastSync(d, true); } catch (Exception) { UpdateDistrictLastSync(d, false); throw; } Log.LogInfo("process pictures"); ProcessPictures(); Log.LogInfo("setting link status"); var importedSchoolIds = context.GetSyncResult <School>().All.Select(x => x.SchoolID); foreach (var importedSchoolId in importedSchoolIds) { connectorLocator.LinkConnector.CompleteSync(importedSchoolId); } CreateUserLoginInfos(); Log.LogInfo("import is completed"); }