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


C# DB.Apply方法代码示例

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


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

示例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);

        }
开发者ID:dvgamer,项目名称:Touno.Sentinel-II,代码行数:101,代码来源:Secretary.cs


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