Example #1
0
        /// <summary>
        /// Retrieves customers from the database and gets a set of results.
        /// </summary>
        /// <remarks>
        /// NOTE: You must first build the database using the provided scripts.
        /// See the Database project for the scripts.
        /// </remarks>
        /// <returns></returns>
        public static Customers Retrieve()
        {
            Customers customerList = new Customers();

            // Retrieve the data using the data access component
            DataTable dt = Dac.ExecuteDataTable("CustomerRetrieve");

            // Process each row in the table
            foreach (DataRow dr in dt.Rows)
            {
                Customer customerInstance = new Customer {
                    CustomerId   = (int)dr["CustomerId"],
                    LastName     = dr["LastName"].ToString(),
                    FirstName    = dr["FirstName"].ToString(),
                    EmailAddress = dr["EmailAddress"].ToString(),
                    CustomerType = (CustomerTypeOption)dr["CustomerType"]
                };

                // Retrieve the invoices for this customer
                customerInstance.InvoiceList = Invoices.Retrieve(customerInstance.CustomerId);

                customerList.Add(customerInstance);
            }

            return(customerList);
        }
        public void RefreshList()
        {
            if (this.userId == 0)
            {
                return;
            }

            Dac dac = new Dac();

            MethodResult <DataTable> result = dac.ExecuteDataTable(" SELECT CreatedAt, Text, RetweetCount, FavoriteCount, IsRetweet FROM Tweet WHERE CreatedByUserId=" + this.userId.ToString());

            if (result.IsSuccessful)
            {
                MainDataGridView.DataSource = result.Result;
            }
            else
            {
                MessageBox.Show("List Error :-(" + Environment.NewLine + result.Exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #3
0
        private void DownloadButton_Click(object sender, EventArgs e)
        {
            Dac       dac           = new Dac();
            DataTable userDataTable = dac.ExecuteDataTable("SELECT * FROM User").Result;
            decimal   progress      = 0;

            foreach (DataRow dr in userDataTable.Rows)
            {
                IUser user = TwitterEngine.User.FindUserFromUserName((string)dr["UserName"]).Result;
                if (user == null)
                {
                    continue;
                }

                progress++;
                ProgressbarDescriptionLabel.Text = user.Name;
                ProgressBar.Value = (int)((progress / userDataTable.Rows.Count) * 100);

                MethodResult <int> result = DbHelper.SaveTweetList(user.GetUserTimeline((int)TweetCountNumericUpDown.Value).ToList <ITweet>());
                if (result.IsSuccessful)
                {
                    //ProgressbarDescriptionLabel.Text = user.Name + " : " + result.Result.ToString() + " Tweets Saved :-)";
                    ResultsTextBox.Text += Environment.NewLine + user.Name + " : " + result.Result.ToString() + " Tweets Saved :-)";
                    //MessageBox.Show(user.Name + " : " + result.Result.ToString() + " Tweets Saved :-)", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    ProgressbarDescriptionLabel.Text = user.Name + " : " + "Save Error :-(";
                    ResultsTextBox.Text += Environment.NewLine + user.Name + " : " + "Save Error :-(";
                    ProgressBar.Value    = 0;
                    MessageBox.Show(user.Name + " : " + "Save Error :-(" + Environment.NewLine + result.Exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }
            }

            ProgressbarDescriptionLabel.Text = "Finished";
            ResultsTextBox.Text += Environment.NewLine + "Finished";
            ProgressBar.Value    = 100;
        }