private void configureDownloadANSL(IList<ISerializableObject> selection)
            {
                var syncList = new ObjectSyncList();
                syncList.addList(selection);
                syncList.initialize(LookupSynchronizationInformation.getFieldDataList(), LookupSynchronizationInformation.getReflexiveReferences(), LookupSynchronizationInformation.getReflexiveIDFields());

                _ansl = new AnalyzeSyncObjectList(syncList, _mobileDB, _repository, _sync);
            }
Esempio n. 2
0
            private void configureDownloadANSL(IList <ISerializableObject> selection)
            {
                var syncList = new ObjectSyncList();

                syncList.addList(selection);
                syncList.initialize(LookupSynchronizationInformation.getFieldDataList(), LookupSynchronizationInformation.getReflexiveReferences(), LookupSynchronizationInformation.getReflexiveIDFields());

                _ansl = new AnalyzeSyncObjectList(syncList, _mobileDB, _repository, _sync);
            }
Esempio n. 3
0
            private void configureUploadANSL()
            {
                var syncList = new ObjectSyncList();

                foreach (Type t in uploadTypes())
                {
                    syncList.Load(t, _mobileDB);
                }
                syncList.initialize(LookupSynchronizationInformation.getFieldDataList(), LookupSynchronizationInformation.getReflexiveReferences(), LookupSynchronizationInformation.getReflexiveIDFields());
                var snsb = new SNSBPictureTransfer(_userNo, _projectID, _mobileDB, ApplicationPathManager.getFolderPath(ApplicationFolder.Pictures));

                _ansl = new AnalyzeSyncObjectList(syncList, _mobileDB, _repository, _sync, snsb);
            }
 public AnalyzeSyncObjectList(ObjectSyncList list, Serializer source, Serializer sink, Serializer sync)
 {
     if (list.initialized == false)
     {
         throw new Exception();
     }
     sourceSerializer = source;
     sinkSerializer = sink;
     syncSerializer = sync;
     orderedSourceObjects = list.objectList;
     analyzedList = new List<ListContainer>();
     analyzed = false;
 }
            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();
            }
        private void loadCollectionDefinitionsWorker(IReportDetailedProgress progress)
        {
            ObjectSyncList transferList = new ObjectSyncList();
            progress.advanceProgress(5);
            String sql = null;
            IList<ISerializableObject> list = null;
            progress.ProgressDescriptionID = 1160;
            try
            {
                sql = @"SELECT * FROM [" + OptionsAccess.RepositoryOptions.InitialCatalog + "].[dbo].[AnalysisProjectList] (" + ConnectionsAccess.Profile.ProjectID + ")";
                list = ConnectionsAccess.RepositoryDB.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 = ConnectionsAccess.RepositoryDB.Connector.LoadList(typeof(AnalysisResult), rana);
                    transferList.addList(resultList);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                _Log.ErrorFormat("Exception while updating AnalysisTaxonomicGroups: {0}", e); ;
            }

            sql = @"SELECT AnalysisID,TaxonomicGroup,RowGUID FROM [" + OptionsAccess.RepositoryOptions.InitialCatalog + "].[dbo].[AnalysisTaxonomicGroupForProject] (" + ConnectionsAccess.Profile.ProjectID + ")";
            IList<AnalysisTaxonomicGroup> atgList = new List<AnalysisTaxonomicGroup>();
            IDbConnection connRepository = ConnectionsAccess.RepositoryDB.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)
            {
                MessageBox.Show(e.Message);
                _Log.ErrorFormat("Exception while updating AnalysisTaxonomicGroups: {0}", e); ;
                connRepository.Close();
            }

            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);
                        }
                    }
                }
            }

            double progressPerType = 90d / _defTypes.Count;
            foreach (Type t in _defTypes)
            {
                transferList.Load(t, ConnectionsAccess.RepositoryDB);
                progress.advanceProgress(progressPerType);
            }
            transferList.initialize(LookupSynchronizationInformation.downloadDefinitionsList(), LookupSynchronizationInformation.getReflexiveReferences(), LookupSynchronizationInformation.getReflexiveIDFields());

            List<ISerializableObject> orderedObjects = transferList.orderedObjects;
            progress.ProgressDescriptionID = 1161;
            foreach (ISerializableObject iso in orderedObjects)
            {
                try
                {
                    ConnectionsAccess.MobileDB.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 = ConnectionsAccess.MobileDB.Connector.Load(iso.GetType(), r);
                            atg.Rowguid = isoStored.Rowguid;
                        }
                        else
                        {
                            IRestriction r = RestrictionFactory.Eq(iso.GetType(), "_guid", iso.Rowguid);
                            ISerializableObject isoStored = ConnectionsAccess.MobileDB.Connector.Load(iso.GetType(), r);
                        }
                        ConnectionsAccess.MobileDB.Connector.UpdatePlain(iso);
                    }
                    catch (Exception ex)
                    {
                        _Log.ErrorFormat("Exception while transferring [{0}]: [{1}]",iso,ex);
                    }
                }
            }
        }
Esempio n. 7
0
        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");
        }
Esempio n. 8
0
        private void loadCollectionDefinitionsWorker(IReportDetailedProgress progress)
        {
            ObjectSyncList transferList = new ObjectSyncList();

            progress.advanceProgress(5);
            String sql = null;
            IList <ISerializableObject> list = null;

            progress.ProgressDescriptionID = 1160;
            try
            {
                sql  = @"SELECT * FROM [" + OptionsAccess.RepositoryOptions.InitialCatalog + "].[dbo].[AnalysisProjectList] (" + ConnectionsAccess.Profile.ProjectID + ")";
                list = ConnectionsAccess.RepositoryDB.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 = ConnectionsAccess.RepositoryDB.Connector.LoadList(typeof(AnalysisResult), rana);
                    transferList.addList(resultList);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                _Log.ErrorFormat("Exception while updating AnalysisTaxonomicGroups: {0}", e);;
            }


            sql = @"SELECT AnalysisID,TaxonomicGroup,RowGUID FROM [" + OptionsAccess.RepositoryOptions.InitialCatalog + "].[dbo].[AnalysisTaxonomicGroupForProject] (" + ConnectionsAccess.Profile.ProjectID + ")";
            IList <AnalysisTaxonomicGroup> atgList = new List <AnalysisTaxonomicGroup>();
            IDbConnection connRepository           = ConnectionsAccess.RepositoryDB.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)
            {
                MessageBox.Show(e.Message);
                _Log.ErrorFormat("Exception while updating AnalysisTaxonomicGroups: {0}", e);;
                connRepository.Close();
            }


            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);
                        }
                    }
                }
            }


            double progressPerType = 90d / _defTypes.Count;

            foreach (Type t in _defTypes)
            {
                transferList.Load(t, ConnectionsAccess.RepositoryDB);
                progress.advanceProgress(progressPerType);
            }
            transferList.initialize(LookupSynchronizationInformation.downloadDefinitionsList(), LookupSynchronizationInformation.getReflexiveReferences(), LookupSynchronizationInformation.getReflexiveIDFields());


            List <ISerializableObject> orderedObjects = transferList.orderedObjects;

            progress.ProgressDescriptionID = 1161;
            foreach (ISerializableObject iso in orderedObjects)
            {
                try
                {
                    ConnectionsAccess.MobileDB.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 = ConnectionsAccess.MobileDB.Connector.Load(iso.GetType(), r);
                            atg.Rowguid = isoStored.Rowguid;
                        }
                        else
                        {
                            IRestriction        r         = RestrictionFactory.Eq(iso.GetType(), "_guid", iso.Rowguid);
                            ISerializableObject isoStored = ConnectionsAccess.MobileDB.Connector.Load(iso.GetType(), r);
                        }
                        ConnectionsAccess.MobileDB.Connector.UpdatePlain(iso);
                    }
                    catch (Exception ex)
                    {
                        _Log.ErrorFormat("Exception while transferring [{0}]: [{1}]", iso, ex);
                    }
                }
            }
        }
Esempio n. 9
0
        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 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;
            }
        }
        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");
        }
Esempio n. 13
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);
            }
        }
Esempio n. 14
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;
                }
            }
        }
 public AnalyzeSyncObjectList(ObjectSyncList list, Serializer source, Serializer sink, Serializer sync,IPictureTransfer pictrans)
     : this(list,source, sink, sync)
 {
     this.pictrans = pictrans;
 }
Esempio n. 16
0
        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;
            }
        }
 private void configureUploadANSL()
 {
     var syncList = new ObjectSyncList();
     foreach (Type t in uploadTypes())
     {
         syncList.Load(t, _mobileDB);
     }
     syncList.initialize(LookupSynchronizationInformation.getFieldDataList(), LookupSynchronizationInformation.getReflexiveReferences(), LookupSynchronizationInformation.getReflexiveIDFields());
     var snsb = new SNSBPictureTransfer(_userNo, _projectID, _mobileDB, ApplicationPathManager.getFolderPath(ApplicationFolder.Pictures));
     _ansl = new AnalyzeSyncObjectList(syncList, _mobileDB, _repository, _sync, snsb);
 }
            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();
            }