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


C# DB.Rollback方法代码示例

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


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

示例1: Update

        public override void Update()
        {
            DB db = new DB("travox_global"); 

            RequestBuilder doExchange = new RequestBuilder("127.0.0.1:3000/API-v3/exchange-rate/");
            doExchange.By = RequestBuilder.Method.POST;
            doExchange.ContentType = "application/x-www-form-urlencoded";
            doExchange.AddHeader("Token-Auth", "ZHNnc2RmaCxrZXIgbmFsZ25zIGRmZ2RzZmc");

            doExchange.AddBody("from", db.GetField("SELECT ISNULL(currency,'') FROM currency FOR XML PATH('')"));
            doExchange.AddBody("to", "THB");
            doExchange.AddBody("amt", "1");

            XHR rate = new XHR().AsyncSend(doExchange).Wait();

            try
            {
                foreach (RateAPI item in JsonConvert.DeserializeObject<List<RateAPI>>(rate.ToString()))
                {
                    SQLCollection param = new SQLCollection();
                    param.Add("@to", DbType.String, item.currency);
                    param.Add("@rate", DbType.Decimal, item.rate);
                    param.Add("@date", DbType.DateTime, DateTime.Parse(item.updated).ToString("dd-MM-yyyy HH:mm:ss"));

                    db.Execute("UPDATE currency SET [email protected], [email protected] WHERE currency = @to", param);
                }
                db.Apply();
            }
            catch (Exception e)
            {
                db.Rollback();
                throw e;
            }
            base.Update();
        }
开发者ID:dvgamer,项目名称:Touno.Sentinel-II,代码行数:35,代码来源:ExchangeRate.cs

示例2: Update

        public override void Update()
        {
            String PatturnRate = @"<item><title>(?<from_desc>.*?)\((?<from>\w{3})\)/(?<to_desc>.*?)\((?<to>\w{3})\).*?</title>.*?";
            PatturnRate += @"<pubDate>(?<date>.*?)</pubDate>.*?<description>.*?=.*?(?<rate>[\d|.]+).*?</description>.*?</item>";

            String RateRSS = XHR.Connect("thb.fxexchangerate.com/rss.xml");

            DB db = new DB("travox_global");

            try
            {
                foreach (Match item in Regex.Matches(RateRSS.ToString(), PatturnRate, RegexOptions.Singleline))
                {
                    String UpdateDate = Regex.Replace(item.Groups["date"].Value, "\r\n", " ");
                    CultureInfo culture = CultureInfo.CurrentCulture;
                    DateTimeStyles style = DateTimeStyles.AssumeUniversal;
                    DateTime date = DateTime.ParseExact(UpdateDate.Trim(), "ddd MMM d yyyy H:m:s UTC", culture, style);

                    SQLCollection param = new SQLCollection();
                    param.Add("@to", DbType.String, item.Groups["to"].Value.Trim());
                    param.Add("@to_desc", DbType.String, item.Groups["to_desc"].Value.Trim());
                    param.Add("@rate", DbType.Decimal, item.Groups["rate"].Value.Trim());
                    param.Add("@date", DbType.DateTime, date.ToString("dd-MM-yyyy HH:mm:ss"));

                    db.Execute("UPDATE currency SET [email protected], [email protected] WHERE currency = @to", param);
                }
                db.Apply();
            }
            catch (Exception e)
            {
                db.Rollback();
                throw new Exception(e.Message, new Exception(RateRSS.ToString()));
            }

            RateRSS = null;
            base.Update();
        }
开发者ID:dvgamer,项目名称:Touno.Sentinel-II,代码行数:37,代码来源:ExchangeRate.cs


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