The Peer Discovery Service is the central location where peers can announce their existence and get information about other peers. The primary services here are registering a user's email address, getting peer counts and lists, and registering a peer.
Inheritance: System.Web.Services.WebService, IPeerDiscoveryService
Exemplo n.º 1
0
        public DataSet GetAllSpecies(string version, string filter)
        {
            if (version == null)
            {
                // Special versioning case, if all parameters are not specified then we return an appropriate error.
                InstallerInfo.WriteEventLog("GetAllSpecies", "Suspect: " + Context.Request.ServerVariables["REMOTE_ADDR"].ToString());
                return(null);
            }

            // Let's verify that this version is even allowed.
            string errorMessage = "";
            PeerDiscoveryService discoveryService = new PeerDiscoveryService();

            if (discoveryService.IsVersionDisabled(version, out errorMessage) == true)
            {
                return(null);
            }

            if (filter == null)
            {
                filter = string.Empty;
            }

            version = new Version(version).ToString(3);

            try
            {
                using (SqlConnection myConnection = new SqlConnection(ServerSettings.SpeciesDsn))
                {
                    myConnection.Open();

                    SqlCommand mySqlCommand = null;
                    switch (filter)
                    {
                    case "All":
                        mySqlCommand = new SqlCommand("TerrariumGrabAllSpecies", myConnection);
                        break;

                    default:
                        mySqlCommand = new SqlCommand("TerrariumGrabAllRecentSpecies", myConnection);
                        break;
                    }
                    SqlDataAdapter adapter = new SqlDataAdapter(mySqlCommand);
                    mySqlCommand.CommandType = CommandType.StoredProcedure;

                    SqlParameter parmVersion = mySqlCommand.Parameters.Add("@Version", SqlDbType.VarChar, 255);
                    parmVersion.Value = version;

                    DataSet data = new DataSet();
                    adapter.Fill(data);
                    return(data);
                }
            }
            catch (Exception e)
            {
                InstallerInfo.WriteEventLog("GetAllSpecies", e.ToString());
                return(null);
            }
        }
Exemplo n.º 2
0
        public DataSet GetAllSpecies(string version, string filter)
        {
            if ( version == null )
                {
                    // Special versioning case, if all parameters are not specified then we return an appropriate error.
                    InstallerInfo.WriteEventLog("GetAllSpecies", "Suspect: " + Context.Request.ServerVariables["REMOTE_ADDR"].ToString());
                    return null;
                }

                // Let's verify that this version is even allowed.
                string errorMessage = "";
                PeerDiscoveryService discoveryService = new PeerDiscoveryService();
                if ( discoveryService.IsVersionDisabled( version, out errorMessage ) == true )
                {
                    return null;
                }

                if (filter == null)
                    filter = string.Empty;

                version = new Version(version).ToString(3);

                try
                {
                    using(SqlConnection myConnection = new SqlConnection(ServerSettings.SpeciesDsn))
                    {
                        myConnection.Open();

                        SqlCommand mySqlCommand = null;
                        switch(filter)
                        {
                            case "All":
                                mySqlCommand = new SqlCommand("TerrariumGrabAllSpecies", myConnection);
                                break;
                            default:
                                mySqlCommand = new SqlCommand("TerrariumGrabAllRecentSpecies", myConnection);
                                break;
                        }
                        SqlDataAdapter adapter = new SqlDataAdapter(mySqlCommand);
                        mySqlCommand.CommandType = CommandType.StoredProcedure;

                        SqlParameter parmVersion = mySqlCommand.Parameters.Add("@Version", SqlDbType.VarChar, 255);
                        parmVersion.Value = version;

                        DataSet data = new DataSet();
                        adapter.Fill(data);
                        return data;
                    }
                }
                catch(Exception e)
                {
                    InstallerInfo.WriteEventLog("GetAllSpecies", e.ToString());
                    return null;
                }
        }