Exemplo n.º 1
0
        /// <summary>
        /// Get registry key.
        /// </summary>
        /// <param name="registryName">Registry key name.</param>
        /// <returns>FoeClientRegistryEntry object. Returns null if key is not available.</returns>
        public static FoeClientRegistryEntry GetEntry(string registryName)
        {
            FoeClientRegistryEntry entry = null;
            SQLiteConnection       conn  = FoeClientDb.Open();

            // Connect to database and prepare command
            SQLiteCommand cmd = conn.CreateCommand();

            cmd.CommandText = "select * from registry where name=@name";
            cmd.Parameters.Add("@name", System.Data.DbType.String, 128);
            cmd.Prepare();
            cmd.Parameters["@name"].Value = registryName;

            // read registry entry
            SQLiteDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                entry       = new FoeClientRegistryEntry();
                entry.Name  = registryName;
                entry.Value = reader.GetString(reader.GetOrdinal("value"));
            }
            reader.Close();
            conn.Close();

            return(entry);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get registry key.
        /// </summary>
        /// <param name="registryName">Registry key name.</param>
        /// <returns>FoeClientRegistryEntry object. Returns null if key is not available.</returns>
        public static FoeClientRegistryEntry GetEntry(string registryName)
        {
            FoeClientRegistryEntry entry = null;
            SQLiteConnection conn = FoeClientDb.Open();

            // Connect to database and prepare command
            SQLiteCommand cmd = conn.CreateCommand();
            cmd.CommandText = "select * from registry where name=@name";
            cmd.Parameters.Add("@name", System.Data.DbType.String, 128);
            cmd.Prepare();
            cmd.Parameters["@name"].Value = registryName;

            // read registry entry
            SQLiteDataReader reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                entry = new FoeClientRegistryEntry();
                entry.Name = registryName;
                entry.Value = reader.GetString(reader.GetOrdinal("value"));
            }
            reader.Close();
            conn.Close();

            return entry;
        }
Exemplo n.º 3
0
        public static bool IsUserRegistered()
        {
            FoeClientRegistryEntry reg = FoeClientRegistry.GetEntry("userid");

            if ((reg != null) && (reg.Value != null) && (reg.Value.Length > 0))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        public static void SendRegistration()
        {
            // Check if user's email is available
            FoeClientRegistryEntry email = FoeClientRegistry.GetEntry("useremail");

            if ((email == null) || (email.Value == null) || (email.Value.Length < 3))
            {
                // Invalid user email
                return;
            }

            // Prepare message to send to server
            FoeMessage message = new FoeMessage();

            message.Add(new FoeMessageItem("UserEmail", email.Value));

            // Get SMTP server configurations
            SmtpServer server = null;

            try
            {
                server = FoeClientMessage.GetSmtpServer();
            }
            catch (Exception except)
            {
                throw new Exception("Invalid SMTP configurations.\r\n" + except.ToString());
            }

            // Send email
            try
            {
                string requestId = FoeClientRequest.GenerateId();
                FoeClientMessage.SendMessage(
                    server,
                    email.Value,
                    FoeClientRegistry.GetEntry("processoremail").Value,
                    SubjectGenerator.RequestSubject(RequestType.Registration, requestId, "Newbie"),
                    message);

                // Save request info
                FoeClientRequestItem req = new FoeClientRequestItem();
                req.Id          = requestId;
                req.Type        = "reg";
                req.DtRequested = DateTime.Now;
                FoeClientRequest.Add(req);
            }
            catch (Exception except)
            {
                throw new Exception("Error sending message.\r\n" + except.ToString());
            }
        }