public void uploadFieldDataWorker(string userNr, int projectID) { _operation.IsProgressIndeterminate = true; _operation.StatusDescription = "Services_FieldData_CalculatingDifferences"; getSerializers(); _userNr = userNr; _projectID = projectID; if (_mobileDB != null && _repository != null && _sync != null) { configureUploadANSL(); try { analyzeData(); syncData(); _operation.success(); } catch (Exception ex) { _Log.ErrorFormat("Exception while updloading Data: [{0}]", ex); _operation.failure("Services_FieldData_Error_ErrorUploading", ""); } } else { _Log.Error("At least one Serializer is missing!"); } _operation.failure("Services_FieldData_Error_MissingServices", ""); }
private void updateProfile() { _profile = null; if (Connections != null) { if (Settings != null && (_settings = Settings.getOptions()) != null) { if ((_mobileSerializer = Connections.MobileDB) != null) { MessengerInstance.Send <StatusNotification>("Services_UserProfile_SearchingProfile"); //Prüfen ob ein UserProfile zum LoginNamen existiert. IList <UserProfile> profiles = new List <UserProfile>(); IRestriction r = RestrictionFactory.Eq(typeof(UserProfile), "_LoginName", _settings.Username); //IRestriction r = RestrictionFactory.Eq(typeof(UserProfile), "_LoginName", "TestEditor"); profiles = _mobileSerializer.Connector.LoadList <UserProfile>(r); if (profiles.Count > 0) { _profile = profiles[0]; } else { MessengerInstance.Send <StatusNotification>("Services_UserProfile_CreatingNew"); _profile = createProfile(); } MessengerInstance.Send <StatusNotification>("Services_UserProfile_Loaded"); _operation.success(); } else { _Log.Error("Mobile DB not connected"); } } else { _Log.Error("Settings N/A"); } } else { _Log.Error("Connections N/A"); } _operation.failure("Services_UserProfile_Error_MissingConnectivitiy", ""); }
public void updateProperties(AsyncOperationInstance progress) { _progress = progress; _progress.StatusDescription = "Services_Definitions_LoadingProperties"; if (_owner.Connections != null) { var definitions = _owner.Connections.Definitions; if (definitions != null) { _prefix = definitions.Praefix; //IRestriction r = RestrictionFactory.TypeRestriction(typeof(PropertyNames)); //properties = taxonrepSerializer.Connector.LoadList<PropertyNames>(r);//geht nicht , weil auf der Sicht keine GUID definiert ist _connDefinitions = definitions.CreateConnection(); } else { _Log.Error("Definitions serializer not available!"); } var mobile = _owner.Connections.MobileTaxa; if (mobile != null) { _connMobileDefinitions = mobile.CreateConnection(); } else { _Log.Error("Mobile Definitions serializer not available!"); } } else { _Log.Error("Connections provider not available."); } if (_connDefinitions != null && _connMobileDefinitions != null) { updateProperties("LebensraumTypen", "LebensraumTypenLfU"); updateProperties("Pflanzengesellschaften", "Pflanzengesellschaften"); _progress.success(); } _progress.failure("Services_Definitions_Error_MissingServices", ""); }
public void startTaxonDownload(IEnumerable <TaxonList> selectedTaxa, AsyncOperationInstance operation) { if (selectedTaxa == null || selectedTaxa.Count() == 0) { operation.success(); _Log.Info("No Taxon Lists selected"); return; } _operation = operation; _selectedTaxa = selectedTaxa; try { createConnections(); openConnections(); downloadTaxonLists(); _operation.StatusDescription = "Services_Definitions_UpdatingTaxonConfig"; _operation.IsProgressIndeterminate = true; fillTaxonListsForUser(); updateSelectedTaxonLists(); _operation.success(); } catch (Exception e) { _Log.ErrorFormat("Error while downloading Taxon Lists: [{0}]", e); _operation.failure("Services_Definitions_Error_LoadingTaxa", ""); } finally { closeConnections(); } }
private void asyncQuery() { if (_owner.Connections != null) { var repo = _owner.Connections.Repository; if (repo != null) { repo.Progress = new ProgressInterval(_operation, 100f, 1); _queryResult = repo.Connector.LoadList(_configuredSearch.ObjectType, GetQueryRestriction()); _operation.success(_queryResult); } else { _Log.Error("Repository N/A"); } } else { _Log.Error("ConnectionsProvider N/A"); } _operation.failure("Services_FieldData_Error_MissingServices", ""); }
public void startTaxonDownload(IEnumerable<TaxonList> selectedTaxa, AsyncOperationInstance operation) { if (selectedTaxa == null || selectedTaxa.Count() == 0) { operation.success(); _Log.Info("No Taxon Lists selected"); return; } _operation = operation; _selectedTaxa = selectedTaxa; try { createConnections(); openConnections(); downloadTaxonLists(); _operation.StatusDescription = "Services_Definitions_UpdatingTaxonConfig"; _operation.IsProgressIndeterminate = true; fillTaxonListsForUser(); updateSelectedTaxonLists(); _operation.success(); } catch (Exception e) { _Log.ErrorFormat("Error while downloading Taxon Lists: [{0}]", e); _operation.failure("Services_Definitions_Error_LoadingTaxa",""); } finally { closeConnections(); } }
public void loadCollectionDefinitions(AsyncOperationInstance progress) { progress.StatusDescription = "Services_Definitions_LoadingCollectionDefinitions"; var uOptions = _owner.Settings.getOptions(); //TODO var connectionProfile = uOptions.CurrentConnection; //TODO var projectID = _owner.Profiles.ProjectID; var repSerializer = _owner.Connections.Repository; var mobSerializer = _owner.Connections.MobileDB; ObjectSyncList transferList = new ObjectSyncList(); String sql = @"SELECT * FROM [" + connectionProfile.InitialCatalog + "].[dbo].[AnalysisProjectList] (" + projectID + ")"; IList <ISerializableObject> list = repSerializer.Connector.LoadList(typeof(Analysis), sql); transferList.addList(list); foreach (ISerializableObject iso in list) { Analysis ana = (Analysis)iso; IRestriction rana = RestrictionFactory.Eq(typeof(AnalysisResult), "_AnalysisID", ana.AnalysisID); IList <ISerializableObject> resultList = repSerializer.Connector.LoadList(typeof(AnalysisResult), rana); transferList.addList(resultList); } sql = @"SELECT AnalysisID,TaxonomicGroup,RowGUID FROM [" + connectionProfile.InitialCatalog + "].[dbo].[AnalysisTaxonomicGroupForProject] (" + projectID + ")"; IList <AnalysisTaxonomicGroup> atgList = new List <AnalysisTaxonomicGroup>(); IDbConnection connRepository = repSerializer.CreateConnection(); connRepository.Open(); IDbCommand com = connRepository.CreateCommand(); com.CommandText = sql; IDataReader reader = null; try { reader = com.ExecuteReader(); while (reader.Read()) { AnalysisTaxonomicGroup atg = new AnalysisTaxonomicGroup(); atg.AnalysisID = reader.GetInt32(0); atg.TaxonomicGroup = reader.GetString(1); atg.Rowguid = Guid.NewGuid(); atgList.Add(atg); } connRepository.Close(); } catch (Exception e) { connRepository.Close(); _Log.ErrorFormat("Error loading Collection Definitions: [{0}]", e); progress.failure("Services_Definitions_Error_MissingRights", ""); } foreach (AnalysisTaxonomicGroup atg in atgList) { foreach (ISerializableObject iso in list) { if (iso.GetType().Equals(typeof(Analysis))) { Analysis ana = (Analysis)iso; if (ana.AnalysisID == atg.AnalysisID) { transferList.addObject(atg); } } } } float progressPerType = 100f / _defTypes.Count; progress.IsProgressIndeterminate = false; foreach (Type t in _defTypes) { repSerializer.Progress = new ProgressInterval(progress, progressPerType, 1); transferList.Load(t, repSerializer); } transferList.initialize(LookupSynchronizationInformation.downloadDefinitionsList(), LookupSynchronizationInformation.getReflexiveReferences(), LookupSynchronizationInformation.getReflexiveIDFields()); List <ISerializableObject> orderedObjects = transferList.orderedObjects; foreach (ISerializableObject iso in orderedObjects) { try { mobSerializer.Connector.InsertPlain(iso); } catch (Exception) { try { if (iso.GetType().Equals(typeof(AnalysisTaxonomicGroup))) { AnalysisTaxonomicGroup atg = (AnalysisTaxonomicGroup)iso; IRestriction r1 = RestrictionFactory.Eq(iso.GetType(), "_AnalysisID", atg.AnalysisID); IRestriction r2 = RestrictionFactory.Eq(iso.GetType(), "_TaxonomicGroup", atg.TaxonomicGroup); IRestriction r = RestrictionFactory.And().Add(r1).Add(r2); ISerializableObject isoStored = mobSerializer.Connector.Load(iso.GetType(), r); atg.Rowguid = isoStored.Rowguid; } else { IRestriction r = RestrictionFactory.Eq(iso.GetType(), "_guid", iso.Rowguid); ISerializableObject isoStored = mobSerializer.Connector.Load(iso.GetType(), r); } mobSerializer.Connector.UpdatePlain(iso); } catch (Exception ex) { _Log.ErrorFormat("Exception while transferring [{0}]: [{1}]", iso, ex); } } } progress.success(); }
public void updateProperties(AsyncOperationInstance progress) { _progress = progress; _progress.StatusDescription = "Services_Definitions_LoadingProperties"; if (_owner.Connections != null) { var definitions = _owner.Connections.Definitions; if (definitions != null) { _prefix = definitions.Praefix; //IRestriction r = RestrictionFactory.TypeRestriction(typeof(PropertyNames)); //properties = taxonrepSerializer.Connector.LoadList<PropertyNames>(r);//geht nicht , weil auf der Sicht keine GUID definiert ist _connDefinitions = definitions.CreateConnection(); } else _Log.Error("Definitions serializer not available!"); var mobile = _owner.Connections.MobileTaxa; if (mobile != null) { _connMobileDefinitions = mobile.CreateConnection(); } else _Log.Error("Mobile Definitions serializer not available!"); } else _Log.Error("Connections provider not available."); if (_connDefinitions != null && _connMobileDefinitions != null) { updateProperties("LebensraumTypen", "LebensraumTypenLfU"); updateProperties("Pflanzengesellschaften", "Pflanzengesellschaften"); _progress.success(); } _progress.failure("Services_Definitions_Error_MissingServices", ""); }
public void loadCollectionDefinitions(AsyncOperationInstance progress) { progress.StatusDescription = "Services_Definitions_LoadingCollectionDefinitions"; var uOptions = _owner.Settings.getOptions(); //TODO var connectionProfile = uOptions.CurrentConnection; //TODO var projectID = _owner.Profiles.ProjectID; var repSerializer = _owner.Connections.Repository; var mobSerializer = _owner.Connections.MobileDB; ObjectSyncList transferList = new ObjectSyncList(); String sql = @"SELECT * FROM [" + connectionProfile.InitialCatalog + "].[dbo].[AnalysisProjectList] (" + projectID + ")"; IList<ISerializableObject> list = repSerializer.Connector.LoadList(typeof(Analysis), sql); transferList.addList(list); foreach (ISerializableObject iso in list) { Analysis ana = (Analysis)iso; IRestriction rana = RestrictionFactory.Eq(typeof(AnalysisResult), "_AnalysisID", ana.AnalysisID); IList<ISerializableObject> resultList = repSerializer.Connector.LoadList(typeof(AnalysisResult), rana); transferList.addList(resultList); } sql = @"SELECT AnalysisID,TaxonomicGroup,RowGUID FROM [" + connectionProfile.InitialCatalog + "].[dbo].[AnalysisTaxonomicGroupForProject] (" + projectID + ")"; IList<AnalysisTaxonomicGroup> atgList = new List<AnalysisTaxonomicGroup>(); IDbConnection connRepository = repSerializer.CreateConnection(); connRepository.Open(); IDbCommand com = connRepository.CreateCommand(); com.CommandText = sql; IDataReader reader = null; try { reader = com.ExecuteReader(); while (reader.Read()) { AnalysisTaxonomicGroup atg = new AnalysisTaxonomicGroup(); atg.AnalysisID = reader.GetInt32(0); atg.TaxonomicGroup = reader.GetString(1); atg.Rowguid = Guid.NewGuid(); atgList.Add(atg); } connRepository.Close(); } catch (Exception e) { connRepository.Close(); _Log.ErrorFormat("Error loading Collection Definitions: [{0}]", e); progress.failure("Services_Definitions_Error_MissingRights",""); } foreach (AnalysisTaxonomicGroup atg in atgList) { foreach (ISerializableObject iso in list) { if (iso.GetType().Equals(typeof(Analysis))) { Analysis ana = (Analysis)iso; if (ana.AnalysisID == atg.AnalysisID) { transferList.addObject(atg); } } } } float progressPerType = 100f / _defTypes.Count; progress.IsProgressIndeterminate = false; foreach (Type t in _defTypes) { repSerializer.Progress = new ProgressInterval(progress, progressPerType, 1); transferList.Load(t, repSerializer); } transferList.initialize(LookupSynchronizationInformation.downloadDefinitionsList(), LookupSynchronizationInformation.getReflexiveReferences(), LookupSynchronizationInformation.getReflexiveIDFields()); List<ISerializableObject> orderedObjects = transferList.orderedObjects; foreach (ISerializableObject iso in orderedObjects) { try { mobSerializer.Connector.InsertPlain(iso); } catch (Exception) { try { if (iso.GetType().Equals(typeof(AnalysisTaxonomicGroup))) { AnalysisTaxonomicGroup atg = (AnalysisTaxonomicGroup)iso; IRestriction r1 = RestrictionFactory.Eq(iso.GetType(), "_AnalysisID", atg.AnalysisID); IRestriction r2 = RestrictionFactory.Eq(iso.GetType(), "_TaxonomicGroup", atg.TaxonomicGroup); IRestriction r = RestrictionFactory.And().Add(r1).Add(r2); ISerializableObject isoStored = mobSerializer.Connector.Load(iso.GetType(), r); atg.Rowguid = isoStored.Rowguid; } else { IRestriction r = RestrictionFactory.Eq(iso.GetType(), "_guid", iso.Rowguid); ISerializableObject isoStored = mobSerializer.Connector.Load(iso.GetType(), r); } mobSerializer.Connector.UpdatePlain(iso); } catch (Exception ex) { _Log.ErrorFormat("Exception while transferring [{0}]: [{1}]", iso, ex); } } } progress.success(); }