public DBPaths resumeSession(DBPaths paths)
 {
     throw new NotImplementedException();
 }
        private bool tryCopyToWorking(string mobileDB, string mobileTaxa)
        {
            bool success = true;

            var workingMobileDB = _currentSessionFolder + "\\" + ApplicationPathManager.MOBILEDB_FILE;
            success &= copyFile(mobileDB, workingMobileDB);

            var workingMobileTaxa = _currentSessionFolder + "\\" + ApplicationPathManager.TAXONDB_FILE;
            success &= copyFile(mobileTaxa, workingMobileTaxa);

            if (success)
            {
                _workingPaths = new DBPaths()
                {
                    MobileDB = workingMobileDB,
                    MobileTaxa = workingMobileTaxa
                };
            }

            return success;
        }
        public void connectToMobileDB(DBPaths paths)
        {
            int i = 0;
            try
            {
                MobileDB = new MS_SqlCeSerializer(paths.MobileDB);
                i++;//1
                MobileDB.RegisterTypes(divMobiTypes());
                i++;
                MobileDB.RegisterType(typeof(UserProfile));
                i++;
                MobileDB.Activate();
                i++;

                //mobile Tax Serializer erzeugen
                try
                {
                    MobileTaxa = new MS_SqlCeSerializer(paths.MobileTaxa);

                    i++;
                    MobileTaxa.RegisterType(typeof(TaxonNames));
                    MobileTaxa.RegisterType(typeof(PropertyNames));
                    i++;//9
                }
                catch
                {
                    MobileTaxa = null;
                }
            }
            catch (Exception mobileDBEx)
            {
                _Log.ErrorFormat("ConnectionError {0} {1}", i, mobileDBEx.Message != null ? mobileDBEx.Message : "");
                MobileDB = null;
            }
            finally
            {
                i = 0;
                if (MobileDB != null)
                {
                    State |= ConnectionState.ConnectedToMobile;
                    i = 10;
                }
                else
                {
                    State &= ~ConnectionState.ConnectedToMobile;
                    i = 20;
                }
                if (MobileTaxa != null)
                {
                    State |= ConnectionState.ConnectedToMobileTax;
                    i = i + 100;
                }
                else
                {
                    State &= ~ConnectionState.ConnectedToMobileTax;
                    i = i + 200;
                }
                if (i != 110)
                    _Log.ErrorFormat("Final Result: {0}", i);
            }
        }
        private bool initSessionFromPaths(DBPaths paths)
        {
            if (paths != null)
            {
                _paths = paths;

                copyPictures();

                return true;
            }
            else
                _Log.Error("Can't create Working Copies: No Settings available");

            return false;
        }
        public DBPaths resumeSession(DBPaths paths)
        {
            var sessionToResume = lastSession();
            var sessionInfo = getSessionInfo(sessionToResume);

            var mobilePath = sessionToResume + "\\" + ApplicationPathManager.MOBILEDB_FILE;
            var taxonPath = sessionToResume + "\\" + ApplicationPathManager.TAXONDB_FILE;

            if (File.Exists(mobilePath) && File.Exists(taxonPath))
            {
                _currentSessionFolder = sessionToResume;
                updateLogger();

                _paths = paths;

                _workingPaths = new DBPaths()
                {
                    MobileDB = mobilePath,
                    MobileTaxa = taxonPath
                };
                if (sessionInfo != null)
                {
                    State = sessionInfo.SState;
                    Sync = sessionInfo.SSync;
                }
                else
                {
                    State = SessionState.New;
                    Sync = SyncState.None;
                }

                return _workingPaths;
            }
            else
            {
                _Log.Error("Can't resume. Files missing.");
                startSession();
                return createWorkingCopies(paths);
            }
        }
        public DBPaths createWorkingCopies(DBPaths paths)
        {
            if (initSessionFromPaths(paths))
            {
                if (tryCopyToWorking(_paths.MobileDB, _paths.MobileTaxa))
                {
                    MessengerInstance.Send<StatusNotification>("Services_Session_WorkingCopiesCreated");
                    return _workingPaths;
                }
            }

            return null;
        }
        public DBPaths createCleanWorkingCopies(DBPaths paths)
        {
            if (initSessionFromPaths(paths))
            {
                var emptyDB = ApplicationPathManager.getFilePath(ApplicationFile.EmptyDB);
                var emptyTaxa = ApplicationPathManager.getFilePath(ApplicationFile.EmptyTaxonDB);

                MessengerInstance.Send<StatusNotification>("Services_Session_CreatingCleanCopies");

                if (tryCopyToWorking(emptyDB, emptyTaxa))
                {
                    State = SessionState.Cleaned;
                    return _workingPaths;
                }
            }
            return null;
        }
 public void connectToMobileDB(DBPaths paths)
 {
     State |= Model.ConnectionState.MobileConnected;
 }