当前位置: 首页>>代码示例>>C#>>正文


C# MySqlCommand.GetInt32方法代码示例

本文整理汇总了C#中MySql.Data.MySqlClient.MySqlCommand.GetInt32方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlCommand.GetInt32方法的具体用法?C# MySqlCommand.GetInt32怎么用?C# MySqlCommand.GetInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MySql.Data.MySqlClient.MySqlCommand的用法示例。


在下文中一共展示了MySqlCommand.GetInt32方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckAndAddProducts

        private static IEnumerable<int> CheckAndAddProducts(IList<string> productSubNumbers, string productMainDescr, IList<string> productSubDescriptions)
        {
            var productIds = new List<int>();
            var productAttributes = new List<string>();

            if (productSubNumbers.Count > 1)
            {
                var attributes = "Rozmiar";

                var productNumberLength = productSubNumbers[0].Length - 2;
                string productNumber = productSubNumbers[0].Substring(0, productNumberLength);

                const string attributesRegex = "((rozm\\.)|(Rozmiar)|(rozmiar))\\s*\\w*";
                foreach (var productSubDescription in productSubDescriptions)
                {
                    var temp = new Regex(attributesRegex).Match(productSubDescription).Value;
                    try
                    {
                        productAttributes.Add(temp.Split(' ')[1]);
                    }
                    catch(Exception)
                    {
                        try
                        {
                            productAttributes.Add(temp.Split('.')[1]);
                        }
                        catch(Exception)
                        {
                            var tempSubDescr = productSubDescription.Split(' ');
                            productAttributes.Add(tempSubDescr[tempSubDescr.Length - 1]);
                        }
                    }
                }

                var productTemp = new Regex(attributesRegex).Match(productSubDescriptions[0]).Value;
                string productName = "";
                try
                {
                    productName = productSubDescriptions[0].Replace(productTemp, "");
                }
                catch(Exception)
                {
                    var tempProductNameAll = productSubDescriptions[0].Split(' ');
                    var tempProductName = "";
                    for (var i = 0; i < tempProductNameAll.Length - 1; i++)
                    {
                        tempProductName += tempProductNameAll[i] + " ";
                    }

                    productName = tempProductName;
                }

                for (var i = 0; i < productSubNumbers.Count; i++)
                {
                    attributes += String.Format(",({0}) {1}", productSubNumbers[i], productAttributes[i]);
                }

                var selectQuery = "select * from jos_vm_product where product_sku = " + productNumber;
                selectQuery = productSubNumbers.Aggregate(selectQuery, (current, productSubNumber) => current + (" or attribute like \"%" + productSubNumber + "%\""));

                var selectCommand = new MySqlCommand(selectQuery, _mySqlConnect).ExecuteReader();

                if (!selectCommand.Read())
                {
                    selectCommand.Close();

                    var insertQuery = String.Format("insert into jos_vm_product (vendor_id, product_parent_id, product_sku, product_s_desc, product_desc, product_thumb_image, product_full_image, product_publish, product_weight, product_weight_uom, product_length, product_width, product_height, product_lwh_uom, product_url, product_in_stock, product_available_date, product_availability, product_special, product_discount_id, ship_code_id, cdate, mdate, product_name, product_sales, attribute, custom_attribute, product_tax_id, product_unit, product_packaging, child_options, quantity_options, child_option_ids, product_order_levels) VALUES (1, 0, {0}, '', '{1}', '', '', 'Y', '0.0000', 'kg', '0.0000', '0.0000', '0.0000', 'cm', '', 0, 1279843200, '', 'N', 0, NULL, 1279922325, 1279922577, '{2}', 0, '{3}', '', 3, 'szt.', 0, 'N,N,N,N,N,Y,20%,10%,', 'none,0,0,1', '', '0,0')", productNumber, productMainDescr, productName, attributes);
                    var insertCommand = new MySqlCommand(insertQuery, _mySqlConnect);
                    insertCommand.ExecuteNonQuery();
                    productIds.Add((int)insertCommand.LastInsertedId);
                }
                else
                {
                    productIds.Add(selectCommand.GetInt32("product_id"));
                    selectCommand.Close();
                }
            }
            else
            {
                for (var j = 0; j < productSubNumbers.Count; j++)
                {
                    var selectQuery = "select * from jos_vm_product where product_sku = " + productSubNumbers[j];
                    selectQuery = productSubNumbers.Aggregate(selectQuery, (current, productSubNumber) => current + (" or attribute like \"%" + productSubNumber + "%\""));

                    var selectCommand = new MySqlCommand(selectQuery, _mySqlConnect).ExecuteReader();

                    if (!selectCommand.Read())
                    {
                        selectCommand.Close();

                        var insertQuery = String.Format("insert into jos_vm_product (vendor_id, product_parent_id, product_sku, product_s_desc, product_desc, product_thumb_image, product_full_image, product_publish, product_weight, product_weight_uom, product_length, product_width, product_height, product_lwh_uom, product_url, product_in_stock, product_available_date, product_availability, product_special, product_discount_id, ship_code_id, cdate, mdate, product_name, product_sales, attribute, custom_attribute, product_tax_id, product_unit, product_packaging, child_options, quantity_options, child_option_ids, product_order_levels) VALUES (1, 0, {0}, '', '{1}', '', '', 'Y', '0.0000', 'kg', '0.0000', '0.0000', '0.0000', 'cm', '', 0, 1279843200, '', 'N', 0, NULL, 1279922325, 1279922577, '{2}', 0, '', '', 3, 'szt.', 0, 'N,N,N,N,N,Y,20%,10%,', 'none,0,0,1', '', '0,0')", productSubNumbers[j], productMainDescr, productSubDescriptions[j]);
                        var insertCommand = new MySqlCommand(insertQuery, _mySqlConnect);
                        insertCommand.ExecuteNonQuery();
                        productIds.Add((int)insertCommand.LastInsertedId);
                    }
                    else
                    {
                        productIds.Add(selectCommand.GetInt32("product_id"));
                        selectCommand.Close();
                        continue;
//.........这里部分代码省略.........
开发者ID:dev4s,项目名称:2010-moto-akcesoria-web-crawler,代码行数:101,代码来源:Program.cs

示例2: CheckForProduct

        private int CheckForProduct(int articleNr)
        {
            var selectQuery = String.Format("select product_id from jos_vm_product where product_sku = \"{0}\" or attribute like \"%{0}%\"", articleNr);
            var selectCommand = new MySqlCommand(selectQuery, _mySqlConnect).ExecuteReader();

            if (!selectCommand.Read())
            {
                selectCommand.Close();
                return 0;
            }

            var temp = selectCommand.GetInt32("product_id");
            selectCommand.Close();
            return temp;
        }
开发者ID:dev4s,项目名称:2010-database-excel-updater,代码行数:15,代码来源:ExcelDatabaseConnector.cs

示例3: getTencentNews


//.........这里部分代码省略.........
                //matches3 获取 matches 中的新闻网址
                MatchCollection matches3 = Regex.Matches(match.Value.ToString(), "href=\"([^\"]*?)\"", RegexOptions.IgnoreCase);
                foreach (Match match3 in matches3)
                {
                    string filecontent = "";
                    picimgPos = 0;
                    pictxtPos = 0;
                    string newshtml = match3.Value.ToString().Substring(5).Replace("\"", "");   //newshtml 是新闻网址
                    HttpWebRequest httpRequest2 = (HttpWebRequest)WebRequest.Create(newshtml);
                    HttpWebResponse httpResponse2;
                    try
                    {
                        httpResponse2 = (HttpWebResponse)httpRequest2.GetResponse();
                    }
                    catch (WebException ex)
                    {
                        httpResponse2 = (HttpWebResponse)ex.Response;
                    }
                    Stream receiveStream2 = httpResponse2.GetResponseStream();
                    StreamReader streamReader2 = new StreamReader(receiveStream2, Encoding.Default);
                    string htmlstr2 = streamReader2.ReadToEnd();    //htmlstr2是新闻详情页的源代码
                    streamReader2.Close();

                    //matches5 获取新闻内的图片
                    MatchCollection matches5 = Regex.Matches(htmlstr2, "<img alt=(.*?) src=\"(.*?)\">", RegexOptions.IgnoreCase);
                    foreach (Match match5 in matches5)
                    {
                        picimg[picimgPos] = match5.Value.ToString();
                        picimgPos++;
                    }
                    //matches6 获取新闻内图片的说明
                    MatchCollection matches6 = Regex.Matches(htmlstr2, "<p class=pictext align=center>(.*?)</p>", RegexOptions.IgnoreCase);
                    foreach (Match match6 in matches6)
                    {
                        pictxt[pictxtPos] = match6.Value.ToString();
                        pictxtPos++;
                    }

                    //matches7 获取新闻发布时间
                    MatchCollection matches7 = Regex.Matches(htmlstr2, "<span class=\"article-time\">(.*?)</span>", RegexOptions.IgnoreCase);
                    foreach (Match match7 in matches7)
                    {
                        MatchCollection matches8 = Regex.Matches(match7.Value.ToString(), ">(.*?)</span>", RegexOptions.IgnoreCase);
                        foreach (Match match8 in matches8)
                        {
                            publishdate = match8.Value.ToString().Substring(1).Replace("</span>", "");
                        }
                    }

                    //matches9 获取新闻类型
                    MatchCollection matches9 = Regex.Matches(htmlstr2, "<a target=\"_blank\" accesskey=\"5\" href=\"(.*?)\" title=\"(.*?)\">(.*?)</a>", RegexOptions.IgnoreCase);
                    foreach (Match match9 in matches9)
                    {
                        MatchCollection matches10 = Regex.Matches(match9.Value.ToString(), ">(.*?)</a>", RegexOptions.IgnoreCase);
                        foreach (Match match10 in matches10)
                        {
                            typename = match10.Value.ToString().Substring(1).Replace("</a>", "");
                        }
                    }

                    for (int i = 0; i < (picimgPos > pictxtPos ? pictxtPos : picimgPos); i++)
                        filecontent = filecontent + picimg[i] + pictxt[i];
                    MatchCollection matches4 = Regex.Matches(htmlstr2, "<P style=\"TEXT-INDENT: 2em\">(.*?)</P>", RegexOptions.IgnoreCase);
                    foreach (Match match4 in matches4)
                    {
                        filecontent = filecontent + match4.Value.ToString().Replace("'", "\\'");
                    }
                    conn.Open();
                    MySqlDataReader reader_select_typeid = new MySqlCommand("select typeid from type where typename='" + typename + "'", conn).ExecuteReader();
                    int typeid = 99;
                    while (reader_select_typeid.Read())
                    {
                        if (reader_select_typeid.HasRows)
                            typeid = reader_select_typeid.GetInt32(0);
                        else
                            new MySqlCommand("insert into type(typename) values('" + typename + "')", conn).ExecuteNonQuery();
                    }
                    reader_select_typeid.Close();
                    MySqlDataReader reader_typeid = new MySqlCommand("select typeid from type where typename='" + typename + "'", conn).ExecuteReader();
                    if (reader_typeid.Read())
                        typeid = reader_typeid.GetInt32(0);
                    reader_typeid.Close();
                    sql += "'" + typename + "'," + typeid + ",'" + filecontent + "','UM','" + publishdate + "','" + newshtml + "')";

                    MySqlDataReader reader_filename = new MySqlCommand("select filename from files where filename='" + filename + "'", conn).ExecuteReader();
                    if (reader_filename.HasRows || filecontent.Equals("") || filecontent.Length < 300)
                    {
                        reader_filename.Close();
                    }
                    else
                    {
                        reader_filename.Close();
                        new MySqlCommand(sql, conn).ExecuteNonQuery();
                    }
                    conn.Close();
                }
            }
        }
        catch (Exception msg) { }
    }
开发者ID:RoyalBob,项目名称:Git,代码行数:101,代码来源:GetNews.cs

示例4: getItem

        public static Request getItem()
        {
            Request r = new Request();
            try
            {
                MySqlDataReader rdr = new MySqlCommand("SELECT `id`,`steam_id`,`type`,`priority` FROM `queue` WHERE `id` IN (SELECT `queue_id` FROM `queue_status` WHERE `active`=1 AND `status`=" + (int)RequestStatus.Waiting + ") ORDER BY `priority` DESC, `id` ASC LIMIT 1", QueueConnection).ExecuteReader();
                while (rdr.Read())
                {
                    r.ID = rdr.GetInt32(0);
                    r.User = rdr.GetUInt64(1);
                    r.TradeType = (Bot.TradeTypes)rdr.GetInt32(2);
                    r.Priority = rdr.GetInt32(3);
                }
                rdr.Close();
                r.Data = new string[Int32.Parse((new MySqlCommand("SELECT COUNT(`data`) FROM `queue_items` WHERE `queue_id`=" + r.ID, conn)).ExecuteScalar().ToString())];
                rdr = (new MySqlCommand("SELECT `data` FROM `queue_items` WHERE `queue_id`=" + r.ID, conn)).ExecuteReader();
                int i = 0;
                while (rdr.Read())
                    r.Data[i++] = rdr.GetString(0);
                rdr.Close();
            }
            catch (Exception e)
            {
                log.Error("Error getting new request: " + e.Message);
            }

            return r;
        }
开发者ID:norgalyn,项目名称:SteamBot,代码行数:28,代码来源:MySQL.cs


注:本文中的MySql.Data.MySqlClient.MySqlCommand.GetInt32方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。