示例#1
0
        } // end ds2login

//
//-------------------------------------------------------------------------------------------------
//
        public bool ds2newcustomer(string username_in, string password_in, string firstname_in,
                                   string lastname_in, string address1_in, string address2_in, string city_in, string state_in,
                                   string zip_in, string country_in, string email_in, string phone_in, int creditcardtype_in,
                                   string creditcard_in, int ccexpmon_in, int ccexpyr_in, int age_in, int income_in,
                                   string gender_in, ref int customerid_out, ref double rt)
        {
            int    region_in = (country_in == "US") ? 1:2;
            string creditcardexpiration_in = String.Format("{0:D4}/{1:D2}", ccexpyr_in, ccexpmon_in);

#if (USE_WIN32_TIMER)
            long ctr0 = 0, ctr = 0, freq = 0;
#else
            TimeSpan TS = new TimeSpan();
            DateTime DT0;
#endif
            New_Customer.Parameters["username_in"].Value             = username_in;
            New_Customer.Parameters["password_in"].Value             = password_in;
            New_Customer.Parameters["firstname_in"].Value            = firstname_in;
            New_Customer.Parameters["lastname_in"].Value             = lastname_in;
            New_Customer.Parameters["address1_in"].Value             = address1_in;
            New_Customer.Parameters["address2_in"].Value             = address2_in;
            New_Customer.Parameters["city_in"].Value                 = city_in;
            New_Customer.Parameters["state_in"].Value                = state_in;
            New_Customer.Parameters["zip_in"].Value                  = (zip_in == "") ? 0 : Convert.ToInt32(zip_in);
            New_Customer.Parameters["country_in"].Value              = country_in;
            New_Customer.Parameters["region_in"].Value               = region_in;
            New_Customer.Parameters["email_in"].Value                = email_in;
            New_Customer.Parameters["phone_in"].Value                = phone_in;
            New_Customer.Parameters["creditcardtype_in"].Value       = creditcardtype_in;
            New_Customer.Parameters["creditcard_in"].Value           = creditcard_in;
            New_Customer.Parameters["creditcardexpiration_in"].Value = creditcardexpiration_in;
            New_Customer.Parameters["age_in"].Value                  = age_in;
            New_Customer.Parameters["income_in"].Value               = income_in;
            New_Customer.Parameters["gender_in"].Value               = gender_in;

//    Console.WriteLine("Thread {0}: Calling New_Customer w/username_in= {1}  region={2}  ccexp={3}",
//      Thread.CurrentThread.Name, username_in, region_in, creditcardexpiration_in);

#if (USE_WIN32_TIMER)
            QueryPerformanceFrequency(ref freq); // obtain system freq (ticks/sec)
            QueryPerformanceCounter(ref ctr0);   // Start response time clock
#else
            DT0 = DateTime.Now;
#endif

            bool deadlocked;
            do
            {
                try
                {
                    deadlocked = false;
                    New_Customer.ExecuteNonQuery();
                }
                catch (MySqlException e)
                {
                    if (e.Number == 1205)
                    {
                        deadlocked = true;
                        Random r    = new Random(DateTime.Now.Millisecond);
                        int    wait = r.Next(1000);
                        Console.WriteLine("Thread {0}: New_Customer deadlocked...waiting {1} msec, then will retry",
                                          Thread.CurrentThread.Name, wait);
                        Thread.Sleep(wait); // Wait up to 1 sec, then try again
                    }
                    else
                    {
                        Console.WriteLine("Thread {0}: MySql Error {1} in New_Customer: {2}",
                                          Thread.CurrentThread.Name, e.Number, e.Message);
                        return(false);
                    }
                }
            } while (deadlocked);

            customerid_out = (int)cust_out_param.Value;

#if (USE_WIN32_TIMER)
            QueryPerformanceCounter(ref ctr); // Stop response time clock
            rt = (ctr - ctr0) / (double)freq; // Calculate response time
#else
            TS = DateTime.Now - DT0;
            rt = TS.TotalSeconds; // Calculate response time
#endif
            return(true);
        } // end ds2newcustomer()
示例#2
0
        } // end ds2login

//
//-------------------------------------------------------------------------------------------------
//
        public bool ds2newcustomer(string username_in, string password_in, string firstname_in,
                                   string lastname_in, string address1_in, string address2_in, string city_in, string state_in,
                                   string zip_in, string country_in, string email_in, string phone_in, int creditcardtype_in,
                                   string creditcard_in, int ccexpmon_in, int ccexpyr_in, int age_in, int income_in,
                                   string gender_in, ref int customerid_out, ref double rt)
        {
            int    region_in = (country_in == "US") ? 1:2;
            string creditcardexpiration_in = String.Format("{0:D4}/{1:D2}", ccexpyr_in, ccexpmon_in);

#if (USE_WIN32_TIMER)
            long ctr0 = 0, ctr = 0, freq = 0;
#else
            TimeSpan TS = new TimeSpan();
            DateTime DT0;
#endif

            New_Customer_prm[0].Value  = firstname_in;
            New_Customer_prm[1].Value  = lastname_in;
            New_Customer_prm[2].Value  = address1_in;
            New_Customer_prm[3].Value  = address2_in;
            New_Customer_prm[4].Value  = city_in;
            New_Customer_prm[5].Value  = state_in;
            New_Customer_prm[6].Value  = (zip_in == "") ? 0 : Convert.ToInt32(zip_in);
            New_Customer_prm[7].Value  = country_in;
            New_Customer_prm[8].Value  = region_in;
            New_Customer_prm[9].Value  = email_in;
            New_Customer_prm[10].Value = phone_in;
            New_Customer_prm[11].Value = creditcardtype_in;
            New_Customer_prm[12].Value = creditcard_in;
            New_Customer_prm[13].Value = creditcardexpiration_in;
            New_Customer_prm[14].Value = username_in;
            New_Customer_prm[15].Value = password_in;
            New_Customer_prm[16].Value = age_in;
            New_Customer_prm[17].Value = income_in;
            New_Customer_prm[18].Value = gender_in;


#if (USE_WIN32_TIMER)
            QueryPerformanceFrequency(ref freq); // obtain system freq (ticks/sec)
            QueryPerformanceCounter(ref ctr0);   // Start response time clock
#else
            DT0 = DateTime.Now;
#endif

            try
            {
                New_Customer.ExecuteNonQuery();
                customerid_out = (int)New_Customer_prm[19].Value;
            }
            catch (System.Exception e)
            {
                Console.WriteLine("Thread {0}: ERROR in New_Customer.ExecuteNonQuery(): {1}",
                                  Thread.CurrentThread.Name, e.Message);
            }


#if (USE_WIN32_TIMER)
            QueryPerformanceCounter(ref ctr); // Stop response time clock
            rt = (ctr - ctr0) / (double)freq; // Calculate response time
#else
            TS = DateTime.Now - DT0;
            rt = TS.TotalSeconds; // Calculate response time
#endif

//    Console.WriteLine("Thread {0}: New_Customer created w/username_in= {1}  region={2}  customerid={3}",
//      Thread.CurrentThread.Name, username_in, region_in, customerid_out);

            return(true);
        } // end ds2newcustomer()