void ProfileSvc_ProfileLoaded(AsyncOperationInstance operation)
        {
            ProfileSvc.ProfileLoaded -= ProfileSvc_ProfileLoaded;
            var project = ProfileSvc.ProjectID;

            var paths = Settings.getOptions().Paths;


            if (CM.truncateSyncTable())
            {
                CM.disconnectFromMobileDB();
                SessionMgr.endSession();
                SessionMgr.startSession();
                var workingPaths = SessionMgr.createCleanWorkingCopies(paths);
                CM.connectToMobileDB(workingPaths);
            }
            else
            {
                if (CurrentOperation != null)
                {
                    CurrentOperation.failure("Actions_Error_CouldntTruncateSync", "");
                }
                _Log.Info("Could not truncate Sync Table, aborting clean.");
            }


            if (ProfileSvc.ProjectID != project)
            {
                ProfileSvc.ProjectID = project;
            }
            if (CurrentOperation != null)
            {
                CurrentOperation.success();
            }
        }
Esempio n. 2
0
        public AsyncOperationInstance loadDefinitions()
        {
            var op = new AsyncOperationInstance(false, DefinitionsLoaded);

            new Action <AsyncOperationInstance>(_defLoader.loadCollectionDefinitions).BeginInvoke(op, null, null);
            return(op);
        }
Esempio n. 3
0
        public AsyncOperationInstance loadProperties()
        {
            var op = new AsyncOperationInstance(false, PropertiesLoaded);

            new Action <AsyncOperationInstance>(_propLoader.updateProperties).BeginInvoke(op, null, null);
            return(op);
        }
        public ProgressInterval(AsyncOperationInstance p, float delta , int steps)
        {
            if(p==null)
                throw new ArgumentNullException();

            _progress = p;
            _initialProgress = p.Progress;
            calculateDeltas(delta, steps);
        }
Esempio n. 5
0
 void  OperationStateChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName == AsyncOperationInstance.StatePropertyName)
     {
         var op = (sender as AsyncOperationInstance);
         if (op != null && op.State != OperationState.Running)
         {
             CurrentOperation = null;
         }
     }
 }
        public AsyncOperationInstance downloadData(IList<ISerializableObject> selection)
        {
            var op = new AsyncOperationInstance(false,DownloadFinished);

            new Action(() =>
            {
                new Synchronizer(this, op).downloadFieldDataWorker(selection);
            }).BeginInvoke(null, null);

            return op;
        }
Esempio n. 7
0
        public AsyncOperationInstance loadTaxonLists(IEnumerable <Model.TaxonList> taxa)
        {
            var op = new AsyncOperationInstance(false, TaxaLoaded);

            op.StatusDescription = "Services_Definitions_LoadingTaxa";
            new Action(() =>
            {
                _taxLoader.startTaxonDownload(taxa, op);
            }).BeginInvoke(null, null);

            return(op);
        }
Esempio n. 8
0
        public AsyncOperationInstance uploadData(string userNr, int projectID)
        {
            var op = new AsyncOperationInstance(false, UploadFinished);


            new Action(() =>
            {
                new Synchronizer(this, op).uploadFieldDataWorker(userNr, projectID);
            }).BeginInvoke(null, null);

            return(op);
        }
Esempio n. 9
0
        public AsyncOperationInstance downloadData(IList <ISerializableObject> selection)
        {
            var op = new AsyncOperationInstance(false, DownloadFinished);


            new Action(() =>
            {
                new Synchronizer(this, op).downloadFieldDataWorker(selection);
            }).BeginInvoke(null, null);

            return(op);
        }
Esempio n. 10
0
        public AsyncOperationInstance <IList <ISerializableObject> > startSearch(SearchSpecification search, int currentProjectID)
        {
            var op = new AsyncOperationInstance <IList <ISerializableObject> >(false, SearchFinished);


            new Action(() =>
            {
                new Search(this, op).executeSearch(search, currentProjectID);
            }).BeginInvoke(null, null);

            return(op);
        }
 private void CleanFinished(AsyncOperationInstance op)
 {
     DispatcherHelper.CheckBeginInvokeOnUI(() =>
     {
         CurrentOperation = null;
         if (op.State == OperationState.Succeeded)
         {
             MessengerInstance.Send <NavigateToPage>(Page.Connections);
         }
         else
         {
             showError(op);
         }
     });
 }
 void FieldDataUploadFinished(AsyncOperationInstance operation)
 {
     DispatcherHelper.CheckBeginInvokeOnUI(() =>
     {
         if (operation.State == OperationState.Succeeded)
         {
             MessengerInstance.Send <SyncStepFinished>(SyncState.FieldDataUploaded);
         }
         else
         {
             showMessageBox("Actions_Error_UploadHeader", "Actions_Error_Advice", null);
         }
         MessengerInstance.Send <HideProgress>(new HideProgress());
         IsBusy = false;
     });
 }
        void SearchFinished(AsyncOperationInstance <IList <ISerializableObject> > operation, IList <ISerializableObject> result)
        {
            List <IISOViewModel> selectionList = buildQueryResult(result);

            DispatcherHelper.CheckBeginInvokeOnUI(
                () =>
            {
                _queryResult = selectionList;

                QueryResultTree = new AsyncTreeViewModel(ISOStore);

                RaiseQueryResultChanged();

                CurrentOperation = null;
            });
        }
Esempio n. 14
0
            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", "");
            }
 void PropertiesLoaded(AsyncOperationInstance operation)
 {
     DispatcherHelper.CheckBeginInvokeOnUI(
         () =>
     {
         MessengerInstance.Send <HideProgress>(new HideProgress());
         if (operation.State == OperationState.Succeeded)
         {
             MessengerInstance.Send <SyncStepFinished>(SyncState.PropertyNamesDownloaded);
         }
         else
         {
             showMessageBox("Actions_Error_PropertyNamesHeader", "Actions_Error_Advice", null);     //TODO?
         }
         IsBusy = false;
     }
         );
 }
Esempio n. 16
0
 void DefinitionsProvíder_DefinitionsLoaded(AsyncOperationInstance operation)
 {
     if (operation.State == OperationState.Succeeded)
     {
         if (DefinitionsProvider != null)
         {
             DefinitionsProvider.DefinitionsLoaded -= DefinitionsProvíder_DefinitionsLoaded;
         }
         if (ProfileProvider != null)
         {
             ProfileProvider.ProfileLoaded += new AsyncOperationFinishedHandler(ProfileProvider_ProfileLoaded);
             ProfileProvider.tryLoadProfile();
         }
     }
     else
     {
         CurrentOperation = null;
         showError(operation);
     }
 }
        void FDSvc_DownloadFinished(AsyncOperationInstance operation)
        {
            if (FDSvc != null)
            {
                FDSvc.DownloadFinished -= FDSvc_DownloadFinished;
            }

            CurrentOperation = null;

            if (operation.State == OperationState.Succeeded)
            {
                MessengerInstance.Send <SyncStepFinished>(SyncState.FieldDataDownloaded);
            }
            else
            {
                showError(operation);
            }

            base.OnNavigateNext();
        }
        private List <IISOViewModel> buildQueryResult(IList <ISerializableObject> result)
        {
            CurrentOperation = new AsyncOperationInstance(true, null)
            {
                StatusDescription       = "SelectFD_Status_FillingResults",
                Progress                = 0,
                IsProgressIndeterminate = false,
            };

            List <IISOViewModel> list = new List <IISOViewModel>(result.Count());

            if (result.Count() == 0)
            {
                sendNotification("SelectFD_ResultEmpty");
                return(list);
            }

            ProgressInterval localProgress = null;

            localProgress = new ProgressInterval(CurrentOperation, 100f, result.Count());

            var conversionQuery = from obj in result
                                  select ISOStore.addOrRetrieveVMForISO(obj);

            foreach (var line in conversionQuery)
            {
                list.Add(line);
                if (localProgress != null)
                {
                    if (localProgress.IsCancelRequested)
                    {
                        break;
                    }
                    else
                    {
                        localProgress.advance();
                    }
                }
            }
            return(list);
        }
        void DefinitionsSvc_TaxaLoaded(AsyncOperationInstance operation)
        {
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                if (DefinitionsSvc != null)
                {
                    DefinitionsSvc.TaxaLoaded -= DefinitionsSvc_TaxaLoaded;
                }

                CurrentOperation = null;

                if (operation.State == OperationState.Succeeded)
                {
                    MessengerInstance.Send <SyncStepFinished>(SyncState.TaxaDownloaded);
                }
                else
                {
                    showError(operation);
                }
            });
        }
        private void executeCleanDB()
        {
            if (SessionMgr != null)
            {
                if (CM != null)
                {
                    if (ProfileSvc != null)
                    {
                        if (Settings != null)
                        {
                            CurrentOperation = new AsyncOperationInstance(false, new AsyncOperationFinishedHandler(CleanFinished))
                            {
                                IsProgressIndeterminate = true,
                                StatusDescription       = "Actions_Cleaning_DB"
                            };

                            ProfileSvc.ProfileLoaded += new AsyncOperationFinishedHandler(ProfileSvc_ProfileLoaded);
                            ProfileSvc.tryLoadProfile();
                        }
                        else
                        {
                            _Log.Error("Settings N/A");
                        }
                    }
                    else
                    {
                        _Log.Error("ProfileService N/A");
                    }
                }
                else
                {
                    _Log.Error("ConnectionManager N/A");
                }
            }
            else
            {
                _Log.Error("Session Manager N/A");
            }
        }
Esempio n. 21
0
        void ProfileProvider_ProfileLoaded(AsyncOperationInstance operation)
        {
            if (ProfileProvider != null)
            {
                ProfileProvider.ProfileLoaded -= ProfileProvider_ProfileLoaded;
            }

            CurrentOperation = null;

            if (Selection != null)
            {
                if (operation.State == OperationState.Succeeded)
                {
                    ProfileProvider.ProjectID = Selection.ID;
                    base.OnNavigateNext();
                }
                else
                {
                    showError(operation);
                }
            }
        }
            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 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", "");
            }
        void UserProfile_ProfileLoaded(AsyncOperationInstance operation)
        {
            if (UserProfile != null)
            {
                UserProfile.ProfileLoaded -= UserProfile_ProfileLoaded;
            }

            if (operation.State == OperationState.Succeeded)
            {
                string currentDB = null;
                string homeDB    = null;
                if (UserProfile != null)
                {
                    homeDB = UserProfile.HomeDB;
                }
                if (UserOptions != null)
                {
                    var options = UserOptions.getOptions();
                    if (options != null && options.CurrentConnection != null)
                    {
                        currentDB = options.CurrentConnection.InitialCatalog;
                    }
                }
                if (currentDB != homeDB)
                {
                    nonHomeDBConnected();
                }
                else
                {
                    base.OnNavigateNext();
                }
            }
            else
            {
                showError(operation);
            }
        }
 void FieldDataUploadFinished(AsyncOperationInstance operation)
 {
     DispatcherHelper.CheckBeginInvokeOnUI(() =>
     {
         if (operation.State == OperationState.Succeeded)
             MessengerInstance.Send<SyncStepFinished>(SyncState.FieldDataUploaded);
         else
             showMessageBox("Actions_Error_UploadHeader", "Actions_Error_Advice", null);
         MessengerInstance.Send<HideProgress>(new HideProgress());
         IsBusy = false;
     });
 }
        private void executeCleanDB()
        {
            if (SessionMgr != null)
            {
                if (CM != null)
                {
                    if (ProfileSvc != null)
                    {
                        if (Settings != null)
                        {
                            CurrentOperation = new AsyncOperationInstance(false, new AsyncOperationFinishedHandler(CleanFinished))
                            {
                                IsProgressIndeterminate = true,
                                StatusDescription = "Actions_Cleaning_DB"
                            };

                            ProfileSvc.ProfileLoaded += new AsyncOperationFinishedHandler(ProfileSvc_ProfileLoaded);
                            ProfileSvc.tryLoadProfile();

                        }
                        else
                            _Log.Error("Settings N/A");
                    }
                    else
                        _Log.Error("ProfileService N/A");
                }
                else
                    _Log.Error("ConnectionManager N/A");
            }
            else
                _Log.Error("Session Manager N/A");
        }
        void DefinitionsSvc_TaxaLoaded(AsyncOperationInstance operation)
        {
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                if (DefinitionsSvc != null)
                    DefinitionsSvc.TaxaLoaded -= DefinitionsSvc_TaxaLoaded;

                CurrentOperation = null;

                if (operation.State == OperationState.Succeeded)
                    MessengerInstance.Send<SyncStepFinished>(SyncState.TaxaDownloaded);
                else
                    showError(operation);
            });
        }
 private void CleanFinished(AsyncOperationInstance op)
 {
     DispatcherHelper.CheckBeginInvokeOnUI(() =>
     {
         CurrentOperation = null;
         if (op.State == OperationState.Succeeded)
             MessengerInstance.Send<NavigateToPage>(Page.Connections);
         else
             showError(op);
     });
 }
        public AsyncOperationInstance uploadData(string userNr, int projectID)
        {
            var op = new AsyncOperationInstance(false, UploadFinished);

            new Action(() =>
            {
                new Synchronizer(this, op).uploadFieldDataWorker(userNr, projectID);
            }).BeginInvoke(null, null);

            return op;
        }
 public AsyncOperationInstance loadProperties()
 {
     var op = new AsyncOperationInstance(false, PropertiesLoaded);
     new Action<AsyncOperationInstance>(_propLoader.updateProperties).BeginInvoke(op, null, null);
     return op;
 }
        public AsyncOperationInstance loadTaxonLists(IEnumerable<Model.TaxonList> taxa)
        {
            var op = new AsyncOperationInstance(false, TaxaLoaded);
            op.StatusDescription = "Services_Definitions_LoadingTaxa";
            new Action(()=>
            {
                _taxLoader.startTaxonDownload(taxa,op);
            }).BeginInvoke(null,null);

            return op;
        }
 public Synchronizer(FieldDataService owner, AsyncOperationInstance op)
 {
     _owner = owner;
     _operation = op;
 }
        void ProfileSvc_ProfileLoaded(AsyncOperationInstance operation)
        {
            ProfileSvc.ProfileLoaded -= ProfileSvc_ProfileLoaded;
            var project = ProfileSvc.ProjectID;

            var paths = Settings.getOptions().Paths;

            if (CM.truncateSyncTable())
            {
                CM.disconnectFromMobileDB();
                SessionMgr.endSession();
                SessionMgr.startSession();
                var workingPaths = SessionMgr.createCleanWorkingCopies(paths);
                CM.connectToMobileDB(workingPaths);
            }
            else
            {
                if(CurrentOperation != null)
                    CurrentOperation.failure("Actions_Error_CouldntTruncateSync", "");
                _Log.Info("Could not truncate Sync Table, aborting clean.");
            }

            if (ProfileSvc.ProjectID != project)
                ProfileSvc.ProjectID = project;
            if(CurrentOperation != null)
                CurrentOperation.success();
        }
 void DefinitionsProvíder_DefinitionsLoaded(AsyncOperationInstance operation)
 {
     if (operation.State == OperationState.Succeeded)
     {
         if (DefinitionsProvider != null)
             DefinitionsProvider.DefinitionsLoaded -= DefinitionsProvíder_DefinitionsLoaded;
         if (ProfileProvider != null)
         {
             ProfileProvider.ProfileLoaded += new AsyncOperationFinishedHandler(ProfileProvider_ProfileLoaded);
             ProfileProvider.tryLoadProfile();
         }
     }
     else
     {
         CurrentOperation = null;
         showError(operation);
     }
 }
        void FDSvc_DownloadFinished(AsyncOperationInstance operation)
        {
            if (FDSvc != null)
                FDSvc.DownloadFinished -= FDSvc_DownloadFinished;

            CurrentOperation = null;

            if (operation.State == OperationState.Succeeded)
            {
                MessengerInstance.Send<SyncStepFinished>(SyncState.FieldDataDownloaded);
            }
            else
                showError(operation);

            base.OnNavigateNext();
        }
        void SearchFinished(AsyncOperationInstance<IList<ISerializableObject>> operation, IList<ISerializableObject> result)
        {
            List<IISOViewModel> selectionList = buildQueryResult(result);
            DispatcherHelper.CheckBeginInvokeOnUI(
                () =>
                {
                    _queryResult = selectionList;

                    QueryResultTree = new AsyncTreeViewModel(ISOStore);

                    RaiseQueryResultChanged();

                    CurrentOperation = null;
                });
        }
        void ProfileProvider_ProfileLoaded(AsyncOperationInstance operation)
        {
            if (ProfileProvider != null)
                ProfileProvider.ProfileLoaded -= ProfileProvider_ProfileLoaded;

            CurrentOperation = null;

            if(Selection != null)
                if (operation.State == OperationState.Succeeded)
                {
                    ProfileProvider.ProjectID = Selection.ID;
                    base.OnNavigateNext();
                }
                else
                {
                    showError(operation);
                }
        }
 void PropertiesLoaded(AsyncOperationInstance operation)
 {
     DispatcherHelper.CheckBeginInvokeOnUI(
         () =>
         {
             MessengerInstance.Send<HideProgress>(new HideProgress());
             if (operation.State == OperationState.Succeeded)
                 MessengerInstance.Send<SyncStepFinished>(SyncState.PropertyNamesDownloaded);
             else
                 showMessageBox("Actions_Error_PropertyNamesHeader", "Actions_Error_Advice", null); //TODO?
             IsBusy = false;
         }
         );
 }
Esempio n. 39
0
 public Search(FieldDataService owner, AsyncOperationInstance <IList <ISerializableObject> > op)
 {
     _owner     = owner;
     _operation = op;
 }
 public void tryLoadProfile()
 {
     _operation = new AsyncOperationInstance(false, ProfileLoaded);
     new Action(updateProfile).BeginInvoke(null, null);
 }
            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 AsyncOperationInstance loadDefinitions()
 {
     var op = new AsyncOperationInstance(false, DefinitionsLoaded);
     new Action<AsyncOperationInstance>(_defLoader.loadCollectionDefinitions).BeginInvoke(op,null, null);
     return op;
 }
 public void tryLoadProfile()
 {
     _operation = new AsyncOperationInstance(false, ProfileLoaded);
     new Action(updateProfile).BeginInvoke(null, null);
 }
Esempio n. 44
0
 public Synchronizer(FieldDataService owner, AsyncOperationInstance op)
 {
     _owner     = owner;
     _operation = op;
 }
Esempio n. 45
0
 protected void showError(AsyncOperationInstance op)
 {
     showMessageBox("MessageBox_Error_Title", op.StatusDescription, null);
 }
        public AsyncOperationInstance<IList<ISerializableObject>> startSearch(SearchSpecification search, int currentProjectID)
        {
            var op = new AsyncOperationInstance<IList<ISerializableObject>>(false, SearchFinished);

            new Action(() =>
            {
                new Search(this, op).executeSearch(search, currentProjectID);
            }).BeginInvoke(null, null);

            return op;
        }
        private List<IISOViewModel> buildQueryResult(IList<ISerializableObject> result)
        {
            CurrentOperation = new AsyncOperationInstance(true, null)
            {
                StatusDescription = "SelectFD_Status_FillingResults",
                Progress = 0,
                IsProgressIndeterminate = false,
            };

            List<IISOViewModel> list = new List<IISOViewModel>(result.Count());
            if (result.Count() == 0)
            {
                sendNotification("SelectFD_ResultEmpty");
                return list;
            }

            ProgressInterval localProgress = null;
            localProgress = new ProgressInterval(CurrentOperation, 100f, result.Count());

            var conversionQuery = from obj in result
                                  select ISOStore.addOrRetrieveVMForISO(obj);

            foreach(var line in conversionQuery)
            {
                list.Add(line);
                if (localProgress != null)
                    if (localProgress.IsCancelRequested)
                        break;
                    else
                        localProgress.advance();
            }
            return list;
        }
            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();
            }