Example #1
0
        // -------------------------- UpdateUserId --------------------------
        // change the UserId in the AcVisitorMaster table row
        public virtual void UpdateUserId(
            Web.AcPage InPage, string InVisitorId, string InUserId)
        {
            SqlConnection conn = null;
            SqlCommand    cmd  = new SqlCommand( );

            try
            {
                conn            = InPage.GetDatabaseConnection( );
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new SqlParameter("@VisitorId", InVisitorId));
                cmd.Parameters.Add(new SqlParameter("@UserId", InUserId));
                cmd.CommandText =
                    "UPDATE " + TableName +
                    " SET UserId = @UserId " +
                    "WHERE VisitorId = @VisitorId";
                cmd.ExecuteNonQuery( );
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close( );
                }
            }
        }
        // ------------------------- AcLoadMaster.Chain ----------------------------
        // chain to row by OnlineId key
        public virtual AcLoadMasterRow Chain(Web.AcPage InPage, string InLoadId)
        {
            AcLoadMasterRow row  = null;
            SqlConnection   conn = null;
            SqlCommand      cmd;
            SqlDataReader   reader = null;
            bool            rc;

            try
            {
                conn = InPage.GetDatabaseConnection( );

                cmd             = new SqlCommand( );
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new SqlParameter("@LoadId", InLoadId));
                cmd.CommandText =
                    "SELECT *" +
                    " FROM " + TableName +
                    " WHERE LoadId = @LoadId";

                reader = cmd.ExecuteReader();
                rc     = reader.Read();

                // no rows
                if (rc == false)
                {
                    throw (new LoadMasterException("LoadId " + InLoadId +
                                                   " is not found in AcLoadMaster table"));
                }

                // got a row. extract each column from the reader.
                row                = NewRow( );
                row.LoadId         = reader.GetString(0);
                row.SessionId      = reader.GetString(1);
                row.Seqn           = reader.GetInt32(2);
                row.PageName       = reader.GetString(3);
                row.PageFileName   = reader.GetString(4);
                row.PageDirPath    = reader.GetString(5);
                row.LoadTs         = reader.GetDateTime(6);
                row.LastPostbackTs = reader.GetDateTime(7);
                row.PostbackCx     = reader.GetInt32(8);
                row.ReferrerLoadId = reader.GetString(9);
                row.RawUrl         = reader.GetString(10);
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close( );
                }
                if (reader != null)
                {
                    reader.Close( );
                }
            }
            return(row);
        }
Example #3
0
        // ------------------------- AcAccountMaster.Chain ----------------------------
        // chain to row by OnlineId key
        public virtual AcAccountMasterRow Chain(Web.AcPage InPage, string InAccountNbr)
        {
            AcAccountMasterRow row  = null;
            SqlConnection      conn = null;
            SqlCommand         cmd;
            SqlDataReader      reader = null;
            bool rc;

            try
            {
                conn = InPage.GetDatabaseConnection( );

                cmd             = new SqlCommand( );
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new SqlParameter("@AccountNbr", InAccountNbr));
                cmd.CommandText =
                    "SELECT *" +
                    " FROM " + TableName +
                    " WHERE AccountNbr = @AccountNbr";

                reader = cmd.ExecuteReader();
                rc     = reader.Read();

                // no rows
                if (rc == false)
                {
                    throw (new AccountMasterException("AccountNbr " + InAccountNbr +
                                                      " is not found in AcAccountMaster table"));
                }

                // got a row. extract each column from the reader.
                row              = NewRow( );
                row.AccountNbr   = reader.GetString(0);
                row.AccountName  = reader.GetString(1);
                row.Password     = reader.GetString(2);
                row.EmailAddress = reader.GetString(3);
                row.CreateTs     = reader.GetDateTime(4);
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close( );
                }
                if (reader != null)
                {
                    reader.Close( );
                }
            }
            return(row);
        }
Example #4
0
        // ------------------------- AcVisitorMaster.Chain ----------------------------
        // chain to row by OnlineId key
        public virtual AcVisitorMasterRow Chain(Web.AcPage InPage, string InVisitorId)
        {
            AcVisitorMasterRow row  = null;
            SqlConnection      conn = null;
            SqlCommand         cmd;
            SqlDataReader      reader = null;
            bool rc;

            try
            {
                conn = InPage.GetDatabaseConnection( );

                cmd             = new SqlCommand( );
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new SqlParameter("@VisitorId", InVisitorId));
                cmd.CommandText =
                    "SELECT *" +
                    " FROM " + TableName +
                    " WHERE VisitorId = @VisitorId";

                reader = cmd.ExecuteReader();
                rc     = reader.Read();

                // no rows
                if (rc == false)
                {
                    throw (new VisitorMasterException("VisitorId " + InVisitorId +
                                                      " is not found in AcVisitorMaster table"));
                }

                // got a row. extract each column from the reader.
                row           = NewVisitorMasterRow( );
                row.VisitorId = reader.GetString(0);
                row.UserId    = reader.GetString(1);
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close( );
                }
                if (reader != null)
                {
                    reader.Close( );
                }
            }
            return(row);
        }
Example #5
0
        // ----------------------- AcVisitorMaster.AddNewVisitor ---------------------------
        // create a new AcVisitorMaster row.
        public virtual AcVisitorMasterRow AddNewVisitor(Web.AcPage InPage, string InUserId)
        {
            SqlConnection conn = null;
            SqlCommand    cmd;

            // build the row.
            AcVisitorMasterRow row = NewVisitorMasterRow( );

            row.VisitorId = System.Guid.NewGuid( ).ToString( );
            row.UserId    = InUserId;

            try
            {
                conn = InPage.GetDatabaseConnection();

                cmd             = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new SqlParameter("@VisitorId", row.VisitorId));
                cmd.Parameters.Add(new SqlParameter("@UserId", row.UserId));
                cmd.CommandText =
                    "INSERT " + TableName +
                    " ( VisitorId, UserId ) " +
                    "VALUES( @VisitorId, @UserId )";
                cmd.ExecuteNonQuery();
            }
            catch (SqlException excp)
            {
                if (SqlCore.TableExists(conn, TableName) == false)
                {
                    throw new AutoCoder.Sql.TableNotFound(TableName);
                }
                else
                {
                    throw excp;
                }
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }

            return(row);
        }
        // ----------------------- AcVisitorMaster.AddNewVisitor ---------------------------
        // create a new AcVisitorMaster row.
        public virtual AcVisitorMasterRow AddNewVisitor(Web.AcPage InPage, string InUserId)
        {
            SqlConnection conn = null;
            SqlCommand    cmd;

            // build the row.
            AcVisitorMasterRow row = NewVisitorMasterRow( );

            row.VisitorId = System.Guid.NewGuid( ).ToString( );
            row.UserId    = InUserId;

            try
            {
                conn = InPage.GetDatabaseConnection( );

                cmd             = new SqlCommand( );
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new SqlParameter("@VisitorId", row.VisitorId));
                cmd.Parameters.Add(new SqlParameter("@UserId", row.UserId));
                cmd.CommandText =
                    "INSERT " + TableName +
                    " ( VisitorId, UserId ) " +
                    "VALUES( @VisitorId, @UserId )";
                cmd.ExecuteNonQuery();
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }

            return(row);
        }