本文整理汇总了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();
}
示例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();
}