Exemplo n.º 1
0
        /// <summary>
        /// Get the RSS cache.
        /// </summary>
        /// <param name="catalogCode">Catalog code representing the RSS</param>
        public static FoeServerRssFeed GetRssFeedCache(string catalogCode)
        {
            FoeServerRssFeed feed = null;

            SqlConnection conn = FoeServerDb.OpenDb();
            SqlCommand    cmd  = conn.CreateCommand();

            cmd.CommandText = "select * from RssFeeds where Code=@code";
            cmd.Parameters.Add("@code", SqlDbType.NVarChar, 10);
            cmd.Prepare();
            cmd.Parameters["@code"].Value = catalogCode;

            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                feed               = new FoeServerRssFeed();
                feed.Id            = (int)FoeServerDb.GetInt32(reader, "Id");
                feed.Rss           = FoeServerDb.GetString(reader, "Rss");
                feed.Code          = FoeServerDb.GetString(reader, "Code");
                feed.DtLastUpdated = (DateTime)FoeServerDb.GetDateTime(reader, "DtLastUpdated");
            }
            reader.Close();
            conn.Close();

            return(feed);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the next available request.
        /// </summary>
        /// <returns>The next available request. If no more request is available, null will be returned.</returns>
        public FoeRequester GetNextRequest()
        {
            FoeRequester req = null;

            // check if we are currently connected to DB
            if ((_conn != null) && (_conn.State != System.Data.ConnectionState.Open))
            {
                _conn.Close();
            }

            LoadRequests();

            // Load request messages
            while (_reader.Read())
            {
                req                = new FoeRequester();
                req.Id             = (int)FoeServerDb.GetInt32(_reader, "Id");
                req.Type           = _requestType;
                req.UserEmail      = FoeServerDb.GetString(_reader, "UserEmail");
                req.RequestId      = FoeServerDb.GetString(_reader, "RequestId");
                req.ProcessorEmail = FoeServerDb.GetString(_reader, "ProcessorEmail");
                req.RequestMessage = FoeServerDb.GetString(_reader, "RequestMessage");
                req.DtReceived     = (DateTime)FoeServerDb.GetDateTime(_reader, "DtReceived");
                req.DtProcessed    = null;
                req.Status         = FoeServerDb.GetString(_reader, "Status");
            }

            return(req);
        }
        /// <summary>
        /// Return a FoeServerAutoSubscriber object extract from next record in the SqlDataReader object provided.
        /// </summary>
        /// <param name="reader">SqlDataReader object that contains the query results.</param>
        /// <returns>The FoeServerAutoSubscriber object representing the next record in the SqlDataReader object.</returns>
        public static FoeServerAutoSubscriber GetNextAutoSubscriberFromSqlReader(SqlDataReader reader)
        {
            FoeServerAutoSubscriber sub = null;

            if ((reader != null) && (reader.Read()))
            {
                sub               = new FoeServerAutoSubscriber();
                sub.Id            = (int)FoeServerDb.GetInt32(reader, "Id");
                sub.UserEmail     = FoeServerDb.GetString(reader, "UserEmail");
                sub.CatalogCode   = FoeServerDb.GetString(reader, "CatalogCode");
                sub.RequestId     = FoeServerDb.GetString(reader, "RequestId");
                sub.DtSubscribed  = (DateTime)FoeServerDb.GetDateTime(reader, "DtSubscribed");
                sub.DtLastUpdated = FoeServerDb.GetDateTime(reader, "DtLastUpdated");
            }

            return(sub);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get user information in an FoeUser object.
        /// </summary>
        /// <param name="userEmail">user's email address</param>
        /// <returns>A FoeUser object populated with user info. If user is not found, then null is returned.</returns>
        public static FoeUser GetUser(string userEmail)
        {
            FoeUser user = null;

            // open connection to FOE DB
            SqlConnection conn = FoeServerDb.OpenDb();
            SqlCommand    cmd  = conn.CreateCommand();

            // get user
            string sql = "select * from Users where Email=@email";

            cmd.CommandText = sql;
            cmd.Parameters.Add("@email", SqlDbType.NVarChar, 256);
            cmd.Prepare();
            cmd.Parameters["@email"].Value = userEmail.Trim().ToLower();
            SqlDataReader reader = cmd.ExecuteReader();

            // see if user exists
            if (reader.HasRows)
            {
                reader.Read();

                // create a new user object;
                user = new FoeUser();

                // populate user information
                user.Id             = FoeServerDb.GetInt32(reader, "Id");
                user.Email          = FoeServerDb.GetString(reader, "Email");
                user.UserId         = FoeServerDb.GetString(reader, "UserId");
                user.DtCreated      = FoeServerDb.GetDateTime(reader, "DtCreated");
                user.ProcessorEmail = FoeServerDb.GetString(reader, "ProcessorEmail");
            }

            reader.Close();
            conn.Close();

            return(user);
        }