本文整理汇总了C#中DB.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# DB.Execute方法的具体用法?C# DB.Execute怎么用?C# DB.Execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB.Execute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例3: Update
//.........这里部分代码省略.........
}
if ((!MBOS.Null(OutputEmailType) || MBOS.Bool(OutputPrinter)) && Period != SecretaryEvent.Unknow)
{
RequestBuilder ReportViewer = new RequestBuilder((!App.DebugMode) ? "mos.travox.com/mos_v2/report_viewer/default.aspx" : "localhost:8026/Default.aspx");
ReportViewer.By = RequestBuilder.Method.POST;
ReportViewer.SetCookie("ASP.NET_SessionId", "xxxxxxxxxxxxxxxxxxxxxxxx");
ReportViewer.SetCookie("COMPANY_ACCESS", base.State.CompanyCode);
ReportViewer.SetCookie("ID", "-4");
ReportViewer.SetCookie("Code", "TX");
ReportViewer.SetCookie("Name", "Travox Sentinel");
//ReportViewer.POST("ItemType", JSON.Serialize<ItemType>(new ItemType { ExportType = OutputEmailType }));
//ReportViewer.POST("Report", JSON.Serialize<ItemReport>(new ItemReport { Name = Row["report_key"].ToString(), Filename = Row["report_key"].ToString() + ".rpt" }));
ReportViewer.AddBody("period_begin", SystemDate.From.ToString("dd-MM-yyyy"));
ReportViewer.AddBody("period_end", SystemDate.To.ToString("dd-MM-yyyy"));
param.Add("@s_id", DbType.Int32, Row["secretary_id"].ToString());
param.Add("@name", DbType.String, Row["report_name"].ToString());
param.Add("@email", DbType.String, Row["email"].ToString());
param.Add("@code", DbType.String, base.State.CompanyCode);
param.Add("@file", DbType.String, null);
String[] ArgsString = { Row["period"].ToString(), PeriodDate, Row["report_name"].ToString() };
HandlerItem Item = new HandlerItem();
Item.Subject = String.Format("Secretary({0} {1}) Report of \"{2}\"", ArgsString);
Item.OnEmail = !MBOS.Null(OutputEmailType);
Item.OnPrinter = MBOS.Bool(OutputPrinter);
Item.Mail = Row["email"].ToString();
Item.Ajax = ReportViewer;
EventEmail.Add(Item);
}
}
foreach (HandlerItem Item in EventEmail)
{
//CallbackException data = JSON.Deserialize<CallbackException>(XHR.Connect(Item.Ajax));
CallbackException data = new CallbackException();
String getItems = Regex.Match(data.getItems, @"[\\|/]Temp[\\|/](?<path>.*)").Groups["path"].Value;
String AttachFile = null;
if (!data.onError)
{
String FolderName = Path.GetDirectoryName(CrawlerPath + getItems) + "\\";
String FileName = Path.GetFileName(getItems);
if (!App.DebugMode)
{
if (Directory.Exists(FolderName)) Directory.CreateDirectory(FolderName);
File.Copy(ViewerPath + data.getItems, FolderName + FileName);
File.Delete(ViewerPath + data.getItems);
AttachFile = FolderName + FileName;
}
else
{
AttachFile = @"D:\Travox Mid-Back\TravoxViewer\TravoxViewer\Temp\" + getItems;
}
}
if (Item.OnEmail)
{
DB db = new DB("travox_system");
NameValueCollection MailParam = new NameValueCollection();
TypeMAIL ReportSecretary = new TypeMAIL("[email protected]", Item.Subject, false);
ReportSecretary.Add(Item.Mail);
ReportSecretary.Body(base.GetResource("MailTemplate.html"));
String SQL = db.Execute("INSERT INTO crawler.secretary_email (secretary_id, company_code, report_name, email) VALUES (@s_id, @code, @name, @email)", param);
MailParam.Add("message_email", data.exMessage);
MailParam.Add("print_date", DateTime.Now.Date.ToString("dd-MM-yyyy"));
if (!data.onError && data.exTitle != "ManualException")
{
ReportSecretary.Attach(AttachFile);
param["@file"].DefaultValue = getItems;
}
else
{
param["@file"].DefaultValue = data.exMessage;
}
param.Add("@e_id", DbType.Int32, SQL);
db.Execute("UPDATE crawler.secretary_email SET [email protected] WHERE [email protected]_id", param);
ReportSecretary.DataSource(MailParam);
if (!ReportSecretary.Sending())
{
param["@file"].DefaultValue = ReportSecretary.ErrorMessage;
db.Execute("UPDATE crawler.secretary_email SET [email protected] WHERE [email protected]_id", param);
}
db.Apply();
}
if (Item.OnPrinter)
{
}
}
param = null;
EventEmail = null;
Console.WriteLine("{0} Updated", base.State.DatabaseName);
}
示例4: GetPNR
private void GetPNR(object item)
{
String StartMonth = DateTime.Now.AddDays(DateTime.Now.Day * -1).ToString("dd-MM-yyyy");
StateTask State = (StateTask)item;
SQLCollection param = new SQLCollection("@code", DbType.String, State.DB);
param.ANDBetween("TICKET_DATE", "ticket_date", StartMonth, null, DbType.Date);
switch(State.Type)
{
case Business.B2C:
State.DB = new DB("travoxb2b_global", State.DNS, "travox").GetField("SELECT name FROM db_initial WHERE wholesale_code = @code ", param);
break;
case Business.B2B: State.DB = "travoxb2b"; break;
}
DB GD = new DB(State.DB, State.DNS, "travox");
foreach (DataRow PNR in GD.GetTable(base.GetResource("GetPNR(view_header).sql"), param).Rows)
{
param.Add("@booking_info_id", DbType.String ,PNR["ref_id"].ToString());
String booking_pnr_id = GD.Execute("", WithBookingPNR(PNR));
param.Add("@booking_pnr_id", DbType.String, booking_pnr_id);
// PR_view_header_Item.airline_code = PNR["airline_code"].ToString();
// PR_view_header_Item.airline_name = PNR["airline_name"].ToString();
// PR_view_header_Item.gds = PNR["gds"].ToString();
// PR_view_header_Item.client_deadline = PNR["client_deadline"].ToString();
// PR_view_header_Item.airline_deadline = PNR["airline_deadline"].ToString();
// PR_view_header_Item.ticket_date = PNR["ticket_date"].ToString();
// PR_view_header_Item.operate_by_code = PNR["operate_by_code"].ToString();
// PR_view_header_Item.pnr = PNR["pnr"].ToString();
// PR_view_header_Item.ad_cost = PNR["ad_cost")
// PR_view_header_Item.ch_cost = PNR["ch_cost")
// PR_view_header_Item.inf_cost = loopHeader
// PR_view_header_Item.ad_price = PNR["ad_price")
// PR_view_header_Item.ch_price = PNR["ch_price")
// PR_view_header_Item.inf_price = loopHeader
// PR_view_header_Item.ad_tax = PNR["ad_tax")
// PR_view_header_Item.ch_tax = PNR["ch_tax")
// PR_view_header_Item.inf_tax = loopHeader
// PR_view_header_Item.currency = PNR["currency"].ToString();
// PR_view_header_Item.credit_card_success = PNR["credit_card_success"].ToString();
// PR_view_header_Item.service_charge = PNR["service_charge")
// PR_view_header_Item.invoice_name = PNR["invoice_name"].ToString();
// PR_view_header_Item.invoice_address = PNR["invoice_address"].ToString();
// PR_view_header_Item.invoice_district = PNR["invoice_district"].ToString();
// PR_view_header_Item.invoice_province = PNR["invoice_province"].ToString();
// PR_view_header_Item.invoice_postcode = PNR["invoice_postcode"].ToString();
// PR_view_header_Item.invoice_country = PNR["invoice_country"].ToString();
// PR_view_header_Item.invoice_tel = PNR["invoice_tel"].ToString();
// PR_view_header_Item.invoice_fax = PNR["invoice_fax"].ToString();
// PR_view_header_Item.invoice_email = PNR["invoice_email"].ToString();
// PR_view_header_Item.payment_type = PNR["payment_type"]
// PR_view_header_Item.agent_name = PNR["agent_name"].ToString();
// PR_view_header_Item.agent_address = PNR["agent_address"].ToString();
// PR_view_header_Item.insurance_code = PNR["insurance_code"].ToString();
// PR_view_header_Item.insurance_price = PNR["insurance_price"].ToString();
// PR_view_header_Item.import_by = schema_name.ToString()
// 'PR_view_header.Add(PR_view_header_Item)
// iReturn = dtReturn.Rows(0)("ref_id")
}
mres[State.ID].Set();
}