private void downloadFieldDataWorker(IReportDetailedProgress progess)
        {
            ObjectSyncList syncList = new ObjectSyncList();
            syncList.addList(SelectionBuilder.FinishedSelection);
            //this.setProgressInformation("Initializing");
            syncList.initialize(LookupSynchronizationInformation.getFieldDataList(), LookupSynchronizationInformation.getReflexiveReferences(), LookupSynchronizationInformation.getReflexiveIDFields());
            //this.setProgressValue(10);
            //this.setProgressInformation("Analyzing");
            AnalyzeSyncObjectList ansl = new AnalyzeSyncObjectList(syncList, ConnectionsAccess.RepositoryDB, ConnectionsAccess.MobileDB, ConnectionsAccess.Synchronization);
            ansl.analyzeAll();
            //this.setProgressInformation("Analysis Complete");
            //this.setProgressValue(20);
            //Alles außer InsertState auf ignore setzen
            List<ListContainer> conflicted;
            List<ListContainer> conflictResolved;
            List<ListContainer> synchronized;
            List<ListContainer> insert;
            List<ListContainer> update;
            List<ListContainer> ignore;
            List<ListContainer> delete;
            List<ListContainer> premature;
            conflicted = ansl.getObjectsOfState(SyncStates_Enum.ConflictState);
            conflictResolved = ansl.getObjectsOfState(SyncStates_Enum.ConflictResolvedState);
            synchronized = ansl.getObjectsOfState(SyncStates_Enum.SynchronizedState);
            insert = ansl.getObjectsOfState(SyncStates_Enum.InsertState);
            update = ansl.getObjectsOfState(SyncStates_Enum.UpdateState);
            ignore = ansl.getObjectsOfState(SyncStates_Enum.IgnoreState);
            delete = ansl.getObjectsOfState(SyncStates_Enum.DeletedState);
            premature = ansl.getObjectsOfState(SyncStates_Enum.PrematureState);

            //this.setProgressValue(30);
            //this.setProgressInformation("Warning: Only InsertState is allowed at the moment. All other states will be set to IgnoreState");
            System.Threading.Thread.Sleep(1000);
            //this.setProgressInformation("Synchronizing");

            foreach (ListContainer lc in conflicted)
            {
                lc.State = SyncStates_Enum.IgnoreState;
            }
            //this.setProgressValue(40);
            foreach (ListContainer lc in conflictResolved)
            {
                lc.State = SyncStates_Enum.IgnoreState;
            }
            //this.setProgressValue(50);
            foreach (ListContainer lc in synchronized)
            {
                lc.State = SyncStates_Enum.IgnoreState;//Exception throwen?
            }
            //this.setProgressValue(60);
            foreach (ListContainer lc in update)
            {
                lc.State = SyncStates_Enum.IgnoreState;
            }
            //this.setProgressValue(70);
            foreach (ListContainer lc in delete)
            {
                lc.State = SyncStates_Enum.IgnoreState;
            }
            //this.setProgressValue(80);
            foreach (ListContainer lc in premature)
            {
                lc.State = SyncStates_Enum.IgnoreState;//Exception throwen?
            }
            //this.setProgressValue(90);
            ansl.synchronizeAll();
            //this.setProgressInformation("Complete");
            //this.setProgressValue(100);
            //this.endMobileConnection(true);

            SyncStatus.Instance.Sync |= SyncStatus.SyncState.FieldDataDownload;
        }
        private void uploadFieldDataWorker(IReportDetailedProgress actor)
        {
            if (ConnectionsAccess.Instance.State.CheckForFlags(Diversity_Synchronization.ConnectionsAccess.ConnectionState.DatabasesConnected))
            {
                actor.IsProgressIndeterminate = true;
                actor.ProgressDescriptionID = 1141;

                ObjectSyncList syncList = new ObjectSyncList();
                List<Type> uploadTypes = new List<Type>();
                uploadTypes.Add(typeof(CollectionAgent));
                uploadTypes.Add(typeof(CollectionEvent));
                uploadTypes.Add(typeof(CollectionEventImage));
                uploadTypes.Add(typeof(CollectionEventLocalisation));
                uploadTypes.Add(typeof(CollectionEventProperty));
                uploadTypes.Add(typeof(CollectionSpecimen));
                uploadTypes.Add(typeof(CollectionSpecimenImage));
                uploadTypes.Add(typeof(Identification));
                uploadTypes.Add(typeof(IdentificationUnit));
                uploadTypes.Add(typeof(IdentificationUnitAnalysis));
                uploadTypes.Add(typeof(IdentificationUnitGeoAnalysis));
                uploadTypes.Add(typeof(CollectionEventSeries));
                uploadTypes.Add(typeof(CollectionProject));
                //Bis hier: Korrepondiert zu DBVersion 31
                foreach (Type t in uploadTypes)
                {
                    syncList.Load(t, ConnectionsAccess.MobileDB);
                }

                syncList.initialize(LookupSynchronizationInformation.getFieldDataList(), LookupSynchronizationInformation.getReflexiveReferences(), LookupSynchronizationInformation.getReflexiveIDFields());
                String userNumber =(ConnectionsAccess.Profile.AgentURI==null)?"":ConnectionsAccess.Profile.AgentURI.Replace(@"http://id.snsb.info/Agents/", "");
                if (userNumber == "")
                {
                    //TODO Empty User No
                }

                SNSBPictureTransfer snsb = new SNSBPictureTransfer(userNumber,(int) ConnectionsAccess.Profile.ProjectID, ConnectionsAccess.MobileDB,OptionsAccess.getFolderPath(ApplicationFolder.Pictures));

                AnalyzeSyncObjectList ansl = new AnalyzeSyncObjectList(syncList, ConnectionsAccess.MobileDB, ConnectionsAccess.RepositoryDB, ConnectionsAccess.Synchronization,snsb);
                ansl.analyzeAll();

                //Alles außer InsertState auf ignore setzen
                List<ListContainer> conflicted;
                List<ListContainer> conflictResolved;
                List<ListContainer> synchronized;
                List<ListContainer> insert;
                List<ListContainer> update;
                List<ListContainer> ignore;
                List<ListContainer> delete;
                List<ListContainer> premature;
                conflicted = ansl.getObjectsOfState(SyncStates_Enum.ConflictState);
                conflictResolved = ansl.getObjectsOfState(SyncStates_Enum.ConflictResolvedState);
                synchronized = ansl.getObjectsOfState(SyncStates_Enum.SynchronizedState);
                insert = ansl.getObjectsOfState(SyncStates_Enum.InsertState);
                update = ansl.getObjectsOfState(SyncStates_Enum.UpdateState);
                ignore = ansl.getObjectsOfState(SyncStates_Enum.IgnoreState);
                delete = ansl.getObjectsOfState(SyncStates_Enum.DeletedState);
                premature = ansl.getObjectsOfState(SyncStates_Enum.PrematureState);
                //ProgressDescription = "Warning: Only InsertState is allowed at the moment. All other states will be set to IgnoreState";
                System.Threading.Thread.Sleep(1000);

                foreach (ListContainer lc in conflicted)
                {
                    lc.State = SyncStates_Enum.IgnoreState;
                }
                foreach (ListContainer lc in conflictResolved)
                {
                    lc.State = SyncStates_Enum.IgnoreState;
                }
                foreach (ListContainer lc in synchronized)
                {
                    lc.State = SyncStates_Enum.IgnoreState;//Exception throwen?
                }
                foreach (ListContainer lc in update)
                {
                    lc.State = SyncStates_Enum.IgnoreState;
                }
                foreach (ListContainer lc in delete)
                {
                    lc.State = SyncStates_Enum.IgnoreState;
                }
                foreach (ListContainer lc in premature)
                {
                    lc.State = SyncStates_Enum.IgnoreState;//Exception throwen?
                }
                ansl.synchronizeAll();

                SyncStatus.Instance.Sync |= SyncStatus.SyncState.FieldDataUpload;
            }
        }
Ejemplo n.º 3
0
        //private void uploadFreeSynchronization()
        //{
        //    if (this.startMobileConnection(true))
        //    {
        //        buttonUpload.Text = "Analyzing";
        //        this.mobileDBSyncTool = new UBT.AI4.Bio.DivMobi.SyncTool.SyncTool.SyncTool(mobileDBSerializer, syncDBSerializer, divMobiTypes);
        //        this.repositorySyncTool = new UBT.AI4.Bio.DivMobi.SyncTool.SyncTool.SyncTool(repositorySerializer, syncDBSerializer, divMobiTypes);
        //        this.SyncPool = mobileDBSyncTool.CreateSyncPool();
        //        this.repositorySyncTool.Analyze(this.SyncPool);
        //        buttonUpload.Text = "Analysis Complete";
        //        //Alles außer InsertState auf ignore setzen
        //        List<SyncContainer> conflicted;
        //        List<SyncContainer> conflictResolved;
        //        List<SyncContainer> synchronized;
        //        List<SyncContainer> insert;
        //        List<SyncContainer> update;
        //        List<SyncContainer> ignore;
        //        List<SyncContainer> truncate;
        //        List<SyncContainer> delete;
        //        List<SyncContainer> premature;
        //        conflicted = (List<SyncContainer>)SyncPool.GetSyncContainer<ConflictState>();
        //        conflictResolved = (List<SyncContainer>)SyncPool.GetSyncContainer<ConflictResolvedState>();
        //        synchronized = (List<SyncContainer>)SyncPool.GetSyncContainer<SynchronizedState>();
        //        insert = (List<SyncContainer>)SyncPool.GetSyncContainer<InsertState>();
        //        update = (List<SyncContainer>)SyncPool.GetSyncContainer<UpdateState>();
        //        ignore = (List<SyncContainer>)SyncPool.GetSyncContainer<IgnoreState>();
        //        truncate = (List<SyncContainer>)SyncPool.GetSyncContainer<TruncateState>();
        //        delete = (List<SyncContainer>)SyncPool.GetSyncContainer<DeletedState>();
        //        premature = (List<SyncContainer>)SyncPool.GetSyncContainer<PrematureState>();
        //        MessageBox.Show("Warning: Only InsertState is allowed at the moment. All other states will be set to IgnoreState");
        //        buttonUpload.Text = "Synchronizing";
        //        foreach (SyncContainer sc in conflicted)
        //        {
        //            sc.Ignore();
        //        }
        //        foreach (SyncContainer sc in conflictResolved)
        //        {
        //            sc.Ignore();
        //        }
        //        foreach (SyncContainer sc in synchronized)
        //        {
        //            sc.Ignore();
        //        }
        //        foreach (SyncContainer sc in update)
        //        {
        //            sc.Ignore();
        //        }
        //        foreach (SyncContainer sc in truncate)
        //        {
        //            sc.Ignore();
        //        }
        //        foreach (SyncContainer sc in delete)
        //        {
        //            sc.Ignore();
        //        }
        //        foreach (SyncContainer sc in premature)
        //        {
        //            sc.Ignore();
        //        }
        //        repositorySyncTool.Synchronize(this.SyncPool);
        //        buttonUpload.Text = "Complete";
        //        buttonUpload.Enabled = false;
        //        this.endMobileConnection(false);
        //    }
        //}
        private void getFieldDataListSynchronization(List<ISerializableObject> list)
        {
            if (this.startMobileConnection(true))
            {
                ObjectSyncList syncList = new ObjectSyncList();
                syncList.addList(list);
                this.setProgressInformation("Initializing");
                syncList.initialize(LookupSynchronizationInformation.getFieldDataList(), LookupSynchronizationInformation.getReflexiveReferences(), LookupSynchronizationInformation.getReflexiveIDFields());
                this.setProgressValue(10);
                this.setProgressInformation("Analyzing");
                AnalyzeSyncObjectList ansl = new AnalyzeSyncObjectList(syncList, repositorySerializer, mobileDBSerializer, syncDBSerializer);
                ansl.analyzeAll();
                this.setProgressInformation("Analysis Complete");
                this.setProgressValue(20);
                //Alles außer InsertState auf ignore setzen
                List<ListContainer> conflicted;
                List<ListContainer> conflictResolved;
                List<ListContainer> synchronized;
                List<ListContainer> insert;
                List<ListContainer> update;
                List<ListContainer> ignore;
                List<ListContainer> delete;
                List<ListContainer> premature;
                conflicted = ansl.getObjectsOfState(SyncStates_Enum.ConflictState);
                conflictResolved = ansl.getObjectsOfState(SyncStates_Enum.ConflictResolvedState);
                synchronized = ansl.getObjectsOfState(SyncStates_Enum.SynchronizedState);
                insert = ansl.getObjectsOfState(SyncStates_Enum.InsertState);
                update = ansl.getObjectsOfState(SyncStates_Enum.UpdateState);
                ignore = ansl.getObjectsOfState(SyncStates_Enum.IgnoreState);
                delete = ansl.getObjectsOfState(SyncStates_Enum.DeletedState);
                premature = ansl.getObjectsOfState(SyncStates_Enum.PrematureState);

                this.setProgressValue(30);
                this.setProgressInformation("Warning: Only InsertState is allowed at the moment. All other states will be set to IgnoreState");
                System.Threading.Thread.Sleep(3000);
                this.setProgressInformation("Synchronizing");

                foreach (ListContainer lc in conflicted)
                {
                    lc.State = SyncStates_Enum.IgnoreState;
                }
                this.setProgressValue(40);
                foreach (ListContainer lc in conflictResolved)
                {
                    lc.State = SyncStates_Enum.IgnoreState;
                }
                this.setProgressValue(50);
                foreach (ListContainer lc in synchronized)
                {
                    lc.State = SyncStates_Enum.IgnoreState;//Exception throwen?
                }
                this.setProgressValue(60);
                foreach (ListContainer lc in update)
                {
                    lc.State = SyncStates_Enum.IgnoreState;
                }
                this.setProgressValue(70);
                foreach (ListContainer lc in delete)
                {
                    lc.State = SyncStates_Enum.IgnoreState;
                }
                this.setProgressValue(80);
                foreach (ListContainer lc in premature)
                {
                    lc.State = SyncStates_Enum.IgnoreState;//Exception throwen?
                }
                this.setProgressValue(90);
                ansl.synchronizeAll();
                this.setProgressInformation("Complete");
                this.setProgressValue(100);
                this.endMobileConnection(true);
            }
        }
        private void InsertButton_Click(object sender, EventArgs e)
        {
            ObjectSyncList syncList = new ObjectSyncList();
                List<Type> uploadTypes = new List<Type>();
                //uploadTypes.Add(typeof(Analysis));//ANalysen müssen aufgrund der referenzen gesondert behandelt werden.
                uploadTypes.Add(typeof(CollectionEventSeries));
                uploadTypes.Add(typeof(CollectionAgent));
                uploadTypes.Add(typeof(CollectionEvent));
                uploadTypes.Add(typeof(CollectionEventLocalisation));
                uploadTypes.Add(typeof(CollectionEventProperty));
                uploadTypes.Add(typeof(CollectionProject));
                uploadTypes.Add(typeof(CollectionSpecimen));
                uploadTypes.Add(typeof(Identification));
                uploadTypes.Add(typeof(IdentificationUnit));
                //uploadTypes.Add(typeof(IdentificationUnitAnalysis));
                //uploadTypes.Add(typeof(IdentificationUnitGeoAnalysis));
                //Bis hier: Korrepondiert zu DBVersion 31
                foreach (Type t in uploadTypes)
                {
                    syncList.Load(t, mobileDBSerializer);
                }
                syncList.initialize(LookupSynchronizationInformation.getFieldDataList(), LookupSynchronizationInformation.getReflexiveReferences(), LookupSynchronizationInformation.getReflexiveIDFields());
                AnalyzeSyncObjectList ansl = new AnalyzeSyncObjectList(syncList, mobileDBSerializer, repositorySerializer, syncDBSerializer);
                ansl.analyzeAll();
                //Alles außer InsertState auf ignore setzen
                List<ListContainer> conflicted;
                List<ListContainer> conflictResolved;
                List<ListContainer> synchronized;
                List<ListContainer> insert;
                List<ListContainer> update;
                List<ListContainer> ignore;
                List<ListContainer> delete;
                List<ListContainer> premature;
                conflicted = ansl.getObjectsOfState(SyncStates_Enum.ConflictState);
                conflictResolved = ansl.getObjectsOfState(SyncStates_Enum.ConflictResolvedState);
                synchronized = ansl.getObjectsOfState(SyncStates_Enum.SynchronizedState);
                insert = ansl.getObjectsOfState(SyncStates_Enum.InsertState);
                update = ansl.getObjectsOfState(SyncStates_Enum.UpdateState);
                ignore = ansl.getObjectsOfState(SyncStates_Enum.IgnoreState);
                delete = ansl.getObjectsOfState(SyncStates_Enum.DeletedState);
                premature = ansl.getObjectsOfState(SyncStates_Enum.PrematureState);
                MessageBox.Show("Warning: Only InsertState is allowed at the moment. All other states will be set to IgnoreState");
                System.Threading.Thread.Sleep(1000);
                MessageBox.Show("Inserting");

                foreach (ListContainer lc in conflicted)
                {
                    lc.State = SyncStates_Enum.IgnoreState;
                }
                foreach (ListContainer lc in conflictResolved)
                {
                    lc.State = SyncStates_Enum.IgnoreState;
                }
                foreach (ListContainer lc in synchronized)
                {
                    lc.State = SyncStates_Enum.IgnoreState;//Exception throwen?
                }
                foreach (ListContainer lc in update)
                {
                    lc.State = SyncStates_Enum.IgnoreState;
                }
                foreach (ListContainer lc in delete)
                {
                    lc.State = SyncStates_Enum.IgnoreState;
                }
                foreach (ListContainer lc in premature)
                {
                    lc.State = SyncStates_Enum.IgnoreState;//Exception throwen?
                }
                ansl.synchronizeAll();
                MessageBox.Show("Finished");
        }
Ejemplo n.º 5
0
        private void getDefinitionsListSynchronization()
        {
            if (this.startMobileConnection(true))
            {
                this.setProgressInformation("Create Mobile Connection");
                ObjectSyncList syncList = new ObjectSyncList();
                this.setProgressValue(10);
                this.setProgressInformation("Read Definitions from Database");
                //String sql = @"SELECT * FROM [DiversityCollection_Monitoring].[dbo].[AnalysisProjectList] (372)";
                String sql = @"SELECT * FROM [" + this.InitialCatalog + "].[dbo].[AnalysisProjectList] (" + this.projectID + ")";
                IList<ISerializableObject> list = repositorySerializer.Connector.LoadList(typeof(Analysis), sql);
                syncList.addList(list);
                //sql = @"SELECT AnalysisID,TaxonomicGroup FROM [DiversityCollection_Monitoring].[dbo].[AnalysisTaxonomicGroupForProject] (372)";
                sql = @"SELECT AnalysisID,TaxonomicGroup,RowGUID FROM [" + this.InitialCatalog + "].[dbo].[AnalysisTaxonomicGroupForProject] (" + this.projectID + ")";
                IList<AnalysisTaxonomicGroup> atgList = new List<AnalysisTaxonomicGroup>();
                DbConnection connRepository = this.repositorySerializer.CreateConnection();
                connRepository.Open();
                DbCommand com = connRepository.CreateCommand();
                com.CommandText = sql;
                DbDataReader 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 = reader.GetGuid(2);
                        atgList.Add(atg);
                    }
                    connRepository.Close();
                }
                catch (Exception e)
                {
                    this.setProgressInformation("Exception while updating AnalysisTaxonomicGroups");
                    connRepository.Close();
                }

                foreach (AnalysisTaxonomicGroup atg in atgList)
                {
                    foreach (ISerializableObject iso in list)
                    {
                        bool idFound = false;
                        if (iso.GetType().Equals(typeof(Analysis)))
                        {
                            Analysis ana = (Analysis)iso;
                            if (ana.AnalysisID == atg.AnalysisID)
                            {
                                idFound = true;
                            }
                        }
                        if (idFound == true)
                        {
                            syncList.addObject(atg);
                            break;
                        }
                    }
                }

                foreach (AnalysisTaxonomicGroup atg in atgList)
                {
                    foreach (ISerializableObject iso in list)
                    {
                        bool idFound = false;
                        if (iso.GetType().Equals(typeof(Analysis)))
                        {
                            Analysis ana = (Analysis)iso;
                            if (ana.AnalysisID == atg.AnalysisID)
                            {
                                idFound = true;
                            }
                        }
                        if (idFound == true)
                        {
                            syncList.addObject(atg);
                            break;
                        }
                    }
                }
                this.setProgressValue(20);
                syncList.Load(typeof(Property), repositorySerializer);
                syncList.Load(typeof(CollEventImageType_Enum), repositorySerializer);
                syncList.Load(typeof(CollSpecimenImageType_Enum), repositorySerializer);
                syncList.Load(typeof(CollTaxonomicGroup_Enum), repositorySerializer);
                syncList.Load(typeof(LocalisationSystem), repositorySerializer);
                syncList.Load(typeof(CollCircumstances_Enum), repositorySerializer);//
                syncList.Load(typeof(CollUnitRelationType_Enum), repositorySerializer);
                //poolBuilder.Load(typeof(CollEventSeriesImageType_Enum));
                syncList.Load(typeof(CollIdentificationCategory_Enum), repositorySerializer);
                //poolBuilder.Load(typeof(CollTypeStatus_Enum));
                //__poolBuilder.Load(typeof(CollIdentificationQualifier_Enum));
                //poolBuilder.Load(typeof(CollLabelTranscriptionState_Enum));
                //poolBuilder.Load(typeof(CollLabelType_Enum));
                //poolBuilder.Load(typeof(CollMaterialCategory_Enum));
                syncList.initialize(LookupSynchronizationInformation.downloadDefinitionsList(), LookupSynchronizationInformation.getReflexiveReferences(), LookupSynchronizationInformation.getReflexiveIDFields());
                AnalyzeSyncObjectList anal = new AnalyzeSyncObjectList(syncList, repositorySerializer, mobileDBSerializer, syncDBSerializer);
                anal.analyzeAll();
                //Im Moment ist noch kein ConflictHandling möglich (und auch nicht nötig)
                this.setProgressInformation("Synchronizing");
                this.setProgressValue(50);
                //Für debugging
                IRestriction rs = RestrictionFactory.TypeRestriction(typeof(SyncItem));
                IList<ISerializableObject> sync = syncDBSerializer.Connector.LoadList(typeof(SyncItem), rs);
                this.setProgressInformation("Synchronized: " + sync.Count.ToString());

                anal.synchronizeAll();
                this.setProgressInformation("Synchronization Complete");
                this.setProgressValue(100);
                if (this.endMobileConnection(true))
                {
                    this.buttonGetDefinitions.Enabled = false;
                }
            }
        }