示例#1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            SqlConnection conn = null;
            SqlDataReader dr = null;

            try
            {
                UserRepository ur = new UserRepository();
                conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DataServices"].ConnectionString);
                conn.Open();

                SqlCommand cmd = new SqlCommand("Select * from [dbo].[User]", conn);
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    UserData user = new UserData();
                    user.emailAddress = dr.GetString(1);
                    user.lastLogin = dr.GetDateTime(2);
                    user.createdDate = user.lastLogin.AddDays(-10);
                    user.locale = dr.GetString(3);
                    user.firstName = dr.GetString(4);
                    user.lastName = dr.GetString(5);
                    user.timezoneFromUTC = dr.GetInt32(6);
                    user.name = dr.GetString(7);
                    if (dr.GetValue(8) != DBNull.Value)
                        user.gender = dr.GetString(8);
                    if (dr.GetValue(9) != DBNull.Value && dr.GetString(9).Trim().Length > 0)
                        user.location = dr.GetString(9);
                    if (dr.GetValue(10) != DBNull.Value && dr.GetString(10).Trim().Length > 0)
                        user.fBUsername = dr.GetString(10);
                    if (dr.GetValue(11) != DBNull.Value && dr.GetString(11).Trim().Length > 0)
                        user.fBLink = dr.GetString(11);
                    if (dr.GetValue(12) != DBNull.Value && dr.GetString(12).Trim().Length > 0)
                        user.oauthId = dr.GetString(12);

                    user = (UserData)ur.Add(user);
                    string fbstuff = user.fBLink;
                }

            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }
示例#2
0
        protected void Button4_Click(object sender, EventArgs e)
        {
            SqlConnection conn = null;
            SqlDataReader dr = null;

            try
            {
                ReviewRepository pr = new ReviewRepository();
                ReviewableRepository rr = new ReviewableRepository();
                UserRepository ur = new UserRepository();

                conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DataServices"].ConnectionString);
                conn.Open();

                SqlCommand cmd = new SqlCommand("SELECT * from vCurrentProductReviews", conn);

                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    ReviewData prod = new ReviewData();
                    //prod.name = dr.GetString(4);
                    //if (dr.GetValue(5) != DBNull.Value)
                    //    prod.description = dr.GetString(5);
                    if (dr.GetValue(6) != DBNull.Value)
                        prod.createdDate = dr.GetDateTime(6);
                    if (dr.GetValue(7) != DBNull.Value)
                        prod.lastModified = dr.GetDateTime(7);
                    if (dr.GetValue(8) != DBNull.Value)
                        prod.text = dr.GetString(8);
                    if (dr.GetValue(9) != DBNull.Value)
                        prod.rating = dr.GetDouble(9);
                    if (dr.GetValue(10) != DBNull.Value)
                    {
                        prod.userName = dr.GetString(10);
                        prod.user = ur.GetByName(prod.userName).id;
                    }
                    if (dr.GetValue(14) != DBNull.Value)
                        prod.fBFeedPostId = dr.GetString(14);
                    if (dr.GetValue(15) != DBNull.Value)
                        prod.fBTimelinePostId = dr.GetString(15);

                    if (dr.GetValue(4) != DBNull.Value)
                    {
                        ReviewableData x = rr.GetByName(dr.GetString(4), Guid.Empty).First();
                        prod.parentReviewableId = x.id;
                        prod.parentName = x.name;

                        //prod.outsideCode = x.outsideCode;
                        //prod.outsideCodeType = x.outsideCodeType;
                        //prod.issuerCountryCode = x.issuerCountryCode;
                        //prod.issuerCountry = x.issuerCountry;
                        //prod.providedByBizId = x.parentReviewableId;
                        //prod.providedByBizName = x.parentName;

                    }
                    prod.reviewableType = "product";

                    pr.Add(prod);

                }
                dr.Close();
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }