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


C# DBHelper.Update方法代码示例

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


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

示例1: QueryTest

        public void QueryTest()
        {
            // arrange
            DBHelper.Sqldb dbType = DBHelper.Sqldb.OrderWrite;
            DBHelper db = new DBHelper();

            string sql = "SELECT * FROM DealerServiceLog  ";

            var list = db.Query(sql).ToList();

            var log = db.Query<DealerServiceLog>(21);

            log.Description = "新增测试用例!!!";

            db.Update(log);

            // act
            int count = list.Count;
            // assert
            Assert.AreEqual(7, count);
        }
开发者ID:AllenSteve,项目名称:Instance,代码行数:21,代码来源:DapperHelperTest.cs

示例2: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack && Request.QueryString["v"] != null)
            {
                string id;
                id = Request.QueryString["v"].ToString();
                try
                {
                    string appCode = Request["AppCode"];
                    if (string.IsNullOrEmpty(appCode))
                        appCode = "APP_01";
                    DBHelper hlp = new DBHelper(new BSD.FW.DBHelper.DBHelperConnection(this.ConnectionString, this.FactoryName));
                    if (hlp.GetDataSet("select * from vod_youtube where v_id='" + id + "'", "youtube").Tables[0].Rows.Count == 0)
                    {

                        string link = "http://www.youtube.com/watch?v=";
                        link += id;

                        /*
                         * Get the available video formats.
                         * We'll work with them in the video and audio download examples.
                         */
                        WebProxy proxy = this.proxy();
                        IEnumerable<VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link ,proxy,System.Text.Encoding.UTF8 );

                        VideoInfo video = videoInfos.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360);

                        WebClient client = new WebClient();
                        client.Proxy = proxy;
                        Response.Write(Server.MapPath("ffmpeg/ffmpeg.exe") + "<br>");
                        client.DownloadFile(video.DownloadUrl, Server.MapPath(id + ".mp4"));

                        System.Diagnostics.ProcessStartInfo p;
                        p = new System.Diagnostics.ProcessStartInfo(Server.MapPath("ffmpeg/ffmpeg.exe"), "-i \"" + Server.MapPath(id + ".mp4") + "\" -vcodec copy -acodec copy -vbsf h264_mp4toannexb \"" + Server.MapPath(id + ".ts") + "\"");
                        p.CreateNoWindow = true;
                        Process _p = new Process();
                        _p.StartInfo = p;
                        _p.Start();

                        _p.WaitForExit();

                        //Response.Clear();
                        //Response.TransmitFile(Server.MapPath(id + ".ts"));
                        _p.Close();
                        _p.Dispose();

            //                        string sql = @"INSERT INTO VOD_YOUTUBE(V_ID,TITLE,PUBLISH_DATE,APP_CODE,THUMNAIL_URL,CREATED_DATE,CREATED_BY)VALUES
            //                                ('" + id + "','" + video.Title + "',sysdate,'" + appCode + "','',sysdate,'VOD')";
            //                        hlp.ExecuteNonQuery(sql);
                        string sql = "select * from VOD_YOUTUBE where 1<>1";
                        System.Data.DataTable dt = hlp.GetDataSet(sql, "VOD_YOUTUBE").Tables[0];
                        System.Data.DataRow dr = dt.NewRow();
                        dr["V_ID"] = id;
                        dr["TITLE"] = video.Title;
                        dr["PUBLISH_DATE"] = DateTime.Now ;
                        dr["THUMNAIL_URL"] = video.ThumnailUrl;
                        dr["APP_CODE"] = appCode;
                        dr["CREATED_DATE"] = DateTime.Now;
                        dr["CREATED_BY"] = "VOD";

                        dt.Rows.Add(dr);
                        hlp.Update(dt.DataSet);

                        string fName = Server.MapPath(id + ".mp4");
                        //Delete mp4 file (temp file)
                        if (System.IO.File.Exists(fName))
                            System.IO.File.Delete(fName);

                        Response.Write("{ \"status\":200, \"description\":\"Success\"}");
                    }
                }
                catch (Exception ex)
                {
                    string fName = Server.MapPath(id + ".mp4");
                    //Delete mp4 file
                    if (System.IO.File.Exists(fName))
                        System.IO.File.Delete(fName);
                    //Delete ts file
                    fName = Server.MapPath(id + ".ts");
                    if (System.IO.File.Exists(fName))
                        System.IO.File.Delete(fName);

                    Response.Write(ex.Message);
                }
            }
        }
开发者ID:remy22,项目名称:Youtube_downloader,代码行数:86,代码来源:Default.aspx.cs


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