public void connectToRepository(RepositoryOptions ro, string user, string password)
 {
     if (string.IsNullOrEmpty(ro.InitialCatalog) ||
         string.IsNullOrEmpty(ro.IPAddress) ||
         string.IsNullOrEmpty(ro.IPPort) ||
         string.IsNullOrEmpty(user) ||
         string.IsNullOrEmpty(password) ||
         string.IsNullOrEmpty(ro.TaxonNamesInitialCatalog))
         return;
     //RepositoryOptions aktualisieren?
     if (ro.SqlAuthentification)
     {
         if (ro.LastUsername != user)
         {
             ro.LastUsername = user;
             OptionsAccess.RepositoryOptions = ro;
         }
     }
     else
     {
         if (ro.LastUsername != Environment.UserName)
         {
             ro.LastUsername = Environment.UserName;
             OptionsAccess.RepositoryOptions = ro;
         }
     }
     StringBuilder praef=new StringBuilder();
     praef.Append("[").Append(ro.InitialCatalog).Append("].[dbo].");
     String praefix = praef.ToString();
     StringBuilder taxPraef = new StringBuilder();
     taxPraef.Append("[").Append(ro.TaxonNamesInitialCatalog).Append("].[dbo].");
     String taxonPraefix = taxPraef.ToString();
     StringBuilder syncPraef = new StringBuilder();
     syncPraef.Append("[").Append("Synchronisation_Test").Append("].");
     String syncPraefix = syncPraef.ToString();
     if(ro.SqlAuthentification)
     {
         RepositoryDB = new MS_SqlServerIPSerializer(ro.LastUsername, password ,ro.IPAddress, ro.IPPort, ro.InitialCatalog, praefix);
         RepositoryDefinitions = new MS_SqlServerIPSerializer(ro.LastUsername, password, ro.IPAddress, ro.IPPort, ro.TaxonNamesInitialCatalog,taxonPraefix);
         Synchronization = new MS_SqlServerIPSerializer(ro.LastUsername, password, ro.IPAddress, ro.IPPort, syncDBCatalog,syncPraefix);
     }
     else
     {
         RepositoryDB = new MS_SqlServerWASerializier(ro.IPAddress+","+ro.IPPort, ro.InitialCatalog,praefix);
         RepositoryDefinitions = new MS_SqlServerWASerializier(ro.IPAddress + "," + ro.IPPort, ro.TaxonNamesInitialCatalog,taxonPraefix);
         Synchronization = new MS_SqlServerWASerializier(ro.IPAddress + "," + ro.IPPort, syncDBCatalog,syncPraefix);
     }
     //Verbindung zum Repository herstellen
     connectRepositoryDB();
     connectSynchronization(ro);
     connectRepositoryDefinitions();
 }
        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;
            }
        }
Ejemplo n.º 3
0
        public int CompareTo(object obj)
        {
            RepositoryOptions sOp = null;

            if (obj is RepositoryOptions)
            {
                sOp = obj as RepositoryOptions;
            }
            else
            {
                return(1);
            }

            if (sOp != null)
            {
                if (this.connectionName.CompareTo(sOp.connectionName) != 0)
                {
                    return(1);
                }
                else
                {
                    if (this.sqlAuthentification.CompareTo(sOp.sqlAuthentification) != 0)
                    {
                        return(1);
                    }
                    else
                    {
                        if (this.lastUsername.CompareTo(sOp.lastUsername) != 0)
                        {
                            return(1);
                        }
                        else
                        {
                            if (this.ipAddress.CompareTo(sOp.ipAddress) != 0)
                            {
                                return(1);
                            }
                            else
                            {
                                if (this.ipPort.CompareTo(sOp.ipPort) != 0)
                                {
                                    return(1);
                                }
                                else
                                {
                                    if (this.initialCatalogPath.CompareTo(sOp.initialCatalogPath) != 0)
                                    {
                                        return(1);
                                    }
                                    else
                                    {
                                        if (this.taxonNamesInitialCatalogPath.CompareTo(sOp.taxonNamesInitialCatalogPath) != 0)
                                        {
                                            return(1);
                                        }
                                        else
                                        {
                                            return(0);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(1);
        }