Пример #1
0
 private void connectSynchronization(RepositoryOptions ro)
 {
     try
     {
         String syncIt  = "[" + ro.LastUsername + "].SyncItem";
         String fieldSt = "[" + ro.LastUsername + "].FieldState";
         MappingDictionary.Mapping.Add(typeof(SyncItem), syncIt);
         MappingDictionary.Mapping.Add(typeof(FieldState), fieldSt);
         Synchronization.RegisterType(typeof(SyncItem));
         Synchronization.RegisterType(typeof(FieldState));
         Synchronization.Activate();
         State |= ConnectionState.ConnectedToSynchronization;
     }
     catch// (Exception syncDBEx)
     {
         Synchronization = null;
         MappingDictionary.Mapping.Clear();
         State &= ~ConnectionState.ConnectedToSynchronization;
     }
 }
        private void connectRepository(ConnectionProfile repo)
        {
            //Verbindung zum Repository herstellen
            try
            {
                Repository.RegisterTypes(divMobiTypes());
                Repository.RegisterType(typeof(UserProxy));
                Repository.Activate();
                try
                {
                    String syncIt  = "[" + _userName + "].SyncItem";
                    String fieldSt = "[" + _userName + "].FieldState";
                    if (!MappingDictionary.Mapping.ContainsKey(typeof(SyncItem)))
                    {
                        MappingDictionary.Mapping.Add(typeof(SyncItem), syncIt);
                    }
                    if (!MappingDictionary.Mapping.ContainsKey(typeof(FieldState)))
                    {
                        MappingDictionary.Mapping.Add(typeof(FieldState), fieldSt);
                    }

                    Synchronization.RegisterType(typeof(SyncItem));
                    Synchronization.RegisterType(typeof(FieldState));
                    Synchronization.Activate();
                }
                catch// (Exception syncDBEx)
                {
                    Synchronization = null;
                    MappingDictionary.Mapping.Clear();
                }

                try
                {
                    //Taxon Serializer erstellen

                    Definitions.RegisterType(typeof(TaxonNames));
                    Definitions.RegisterType(typeof(PropertyNames));
                }
                catch //(Exception repTaxEx)
                {
                    Definitions = null;
                }
            }
            catch// (Exception repositoryEx)
            {
                Repository = null;
            }

            var state = State;

            if (Repository != null)
            {
                state |= ConnectionState.ConnectedToRepository;
            }
            if (Definitions != null)
            {
                state |= ConnectionState.ConnectedToRepTax;
            }
            if (Synchronization != null)
            {
                state |= ConnectionState.ConnectedToSynchronization;
            }
            State = state;
        }