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


C# SqlBulkCopy.WriteToServerAdv方法代码示例

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


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

示例1: WriteData

        protected void WriteData(List<Jdp> jdps)
        {
            try
            {
                //List<TradeFullinfoGetResponse> trdf = jdps.Select(k => TopUtils.ParseResponse<TradeFullinfoGetResponse>(k.jdp_response))
                //    .Where(j => !string.IsNullOrEmpty(j.Trade.PayTime)).ToList();
                List<TradeFullinfoGetResponse> trdf = jdps.Select(k => TopUtils.ParseResponse<TradeFullinfoGetResponse>(k.jdp_response)).ToList();
                if (null == trdf || trdf.Count < 1) return;
                var trdpayed = trdf.Select(k => k.Trade).ToList();
                if (null == trdpayed || trdpayed.Count < 1) return;
                var trdpay = Caster.CastTrades(trdpayed);
                if (null == trdpay || trdpay.Count < 1) return;
                using (var blk = new SqlBulkCopy(_con))
                {
                    blk.DestinationTableName = "T_ERP_TaoBaoATS_Trade";
                    blk.WriteToServerAdv<T_ERP_TaoBao_Trade>(trdpay, Exclude);

                    blk.DestinationTableName = "T_ERP_TaoBaoATS_Order";
                    var ords = trdpay.SelectMany(k => k.OrderList).ToList();
                    blk.WriteToServerAdv<T_ERP_TaoBao_Order>(ords, Exclude);

                    blk.DestinationTableName = "T_ERP_TaoBaoATS_PromotionDetail";
                    var kpromt = trdpay.Where(j => j.PromotList != null).SelectMany(k => k.PromotList);
                    if (null != kpromt)
                    {
                        try
                        {
                            var promots = kpromt.ToList();
                            if (null != promots && promots.Count > 0)
                                blk.WriteToServerAdv<T_ERP_TaoBao_PromotionDetail>(promots, Exclude);
                        }
                        catch (Exception ex) { throw; }
                    }

                    blk.DestinationTableName = "T_ERP_TaobaoATS_ServiceOrder";
                    var ksvcs = trdpay.Where(j => j.ServiceOrderList != null).SelectMany(k => k.ServiceOrderList);
                    if (null != ksvcs)
                    {
                        try
                        {
                            var svcs = ksvcs.ToList();
                            if (null != svcs && svcs.Count > 0)
                                blk.WriteToServerAdv<T_ERP_Taobao_ServiceOrder>(svcs, Exclude);
                        }
                        catch (Exception ex) { throw; }
                    }
                }

            }
            catch (Exception ex)
            {
                _applog.DebugException(ex);
#if DEBUG
                throw;
#else
#endif
            }

        }
开发者ID:MasterGao,项目名称:DevWinFormFrame,代码行数:59,代码来源:Run.cs

示例2: btnImp_Click

        private void btnImp_Click(object sender, EventArgs e)
        {
            if (MsgBox.ShowYesNoMessage("确定要导入吗?") == System.Windows.Forms.DialogResult.No) return;
            var dlg = new DevExpress.Utils.WaitDialogForm("正在导入,请稍候...","导入");
            try {
                var ds = GridControl.GetDataSource<T_ERP_ProduceDosageIpt>();
                if (null == ds || ds.Count < 1) return;
                var session = Guid.NewGuid();
                List<T_ERP_ProduceDosageIptTemp> ipts = new List<T_ERP_ProduceDosageIptTemp>();
                ds.ForEach(j => {
                    var ipt = new T_ERP_ProduceDosageIptTemp
                    {
                        Session = session,
                        OuterIid = j.OuterIid,
                        OuterSkuId = j.OuterSkuId,
                        ProcedureName = j.ProcedureName,
                        MaterialNo = j.MaterialNo,
                        MaterialName = j.MaterialName,
                        Dosage = j.Dosage,
                        Unit = j.Unit
                    };
                    ipts.Add(ipt);
                });

                using (SqlConnection destinationConnection = new SqlConnection(this.ConnString))
                {
                    destinationConnection.Open();
                    using (SqlBulkCopy bulkCopy =
                               new SqlBulkCopy(destinationConnection))
                    {
                        bulkCopy.DestinationTableName = "T_ERP_ProduceDosageIpt";
                        try
                        {
                            bulkCopy.WriteToServerAdv(ipts);
                        }
                        catch (Exception ex)
                        {
                            MsgBox.ShowErrMsg("导入失败;错误信息:" + ex.Message);
                            return;
                        }
                    }
                }

                //导入成功,调用迁移过程
                var prms = new SqlParameter[]{
                            new SqlParameter("@session", session),
                            new SqlParameter("@user", this.CurUser)
                        };
                SqlHelper.ExecuteNonQuery(this.ConnString, CommandType.StoredProcedure, "P_FAS_ProduceDosageImpt", prms);
            } catch (Exception) {
                throw;
            } finally {
                dlg.Close();
            }
            MsgBox.ShowMessage("导入已完成!");
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
开发者ID:ZixiangBoy,项目名称:FAS,代码行数:58,代码来源:MaterialsImptView.cs

示例3: btnImp_Click

        private void btnImp_Click(object sender, EventArgs e)
        {
            var dt = gridControlEx1.DataSource as DataTable;
            List<T_ERP_IptPriceTemp> ipts = new List<T_ERP_IptPriceTemp>();
            var session = Guid.NewGuid();
            using (var db = new Database(this.ConnString))
            {
                try{

                    var pros = db.Fetch<UltraDbEntity.T_ERP_Procedure>(" where isnull(IsUsing,0) = 1 ");
                    foreach (DataRow dr in dt.Rows)
                    {
                        pros.ForEach(j => {
                            var ipt = new T_ERP_IptPriceTemp
                            {
                                //Guid = Guid.NewGuid(),
                                //Creator = CurUser,
                                //Updator = CurUser,
                                //Remark = string.Empty,
                                //Reserved1 = 0,
                                //Reserved2 = string.Empty,
                                //Reserved3 = false,

                                Session = session,
                                OuterIid = dr["商品编码"].ToString(),
                                OuterSkuId = dr["规格编码"].ToString(),
                                ProcedureName = j.ProcedureName,
                                ProcedureGuid = j.Guid,
                                CostPrice = string.IsNullOrEmpty(dr[j.ProcedureName] == null
                                            ? "" : dr[j.ProcedureName].ToString())
                                            ? 0 : Convert.ToDecimal(dr[j.ProcedureName])
                            };
                            if (ipt.CostPrice!=0)
                                ipts.Add(ipt);
                        });
                    }
                }catch (Exception ex){
                    MsgBox.ShowErrMsg("导入失败;错误信息:" + ex.Message);
                    return;
                }
            }
            //var excludes = new string[] { "Id", "Guid", "CreateDate", "UpdateDate", "IsDel", "UISelected", "IsDynamicAdd", "TimeStamp" };
            using (SqlConnection destinationConnection = new SqlConnection(this.ConnString))
            {

                destinationConnection.Open();
                using (SqlBulkCopy bulkCopy =
                           new SqlBulkCopy(destinationConnection))
                {
                    bulkCopy.DestinationTableName = "T_ERP_IptPrice";
                    try
                    {
                        bulkCopy.WriteToServerAdv(ipts);
                    }
                    catch (Exception ex)
                    {
                        MsgBox.ShowErrMsg("导入失败;错误信息:" + ex.Message);
                        return;
                    }
                }
            }

            //导入成功,调用迁移过程
            var prms = new SqlParameter[]{
                            new SqlParameter("@session ", session)
                        };
            SqlHelper.ExecuteNonQuery(this.ConnString, CommandType.StoredProcedure, "P_ERP_ProPriceImport", prms);
            MsgBox.ShowMessage("导入完成");
            fileBrowser1.Text = string.Empty;
            gridControlEx1.DataSource = null;
            btnImp.Enabled = false;
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
开发者ID:ZixiangBoy,项目名称:FAS,代码行数:74,代码来源:ProPriceIptView.cs

示例4: WriteData

        protected void WriteData(List<Jdp> jdps, ShopData shp, DateTime begin, DateTime end, string remark = "同步") {
            try {
                List<TradeFullinfoGetResponse> trdf = jdps.Select(k => TopUtils.ParseResponse<TradeFullinfoGetResponse>(k.jdp_response))
                    .Where(j => !string.IsNullOrEmpty(j.Trade.PayTime)).ToList();
                if (null == trdf || trdf.Count < 1) return;

                using (var blk = new SqlBulkCopy(_con)) {
                    blk.DestinationTableName = "T_ERP_SyncLog";
                    blk.WriteToServerAdv<T_ERP_SyncLog>(new List<T_ERP_SyncLog> { new T_ERP_SyncLog{
                        SellerNick=shp.SellerNick,MinDateTime=begin,MaxDateTime=end,Remark=remark,JdpCounts=jdps.Count,JdpResCounts=trdf.Count
                    }}, Exclude);
                }

                var trdpayed = trdf.Select(k => k.Trade).ToList();
                if (null == trdpayed || trdpayed.Count < 1) return;
                var trdpay = Caster.CastTrades(trdpayed);
                if (null == trdpay || trdpay.Count < 1) return;
                using (var blk = new SqlBulkCopy(_con)) {
                    blk.DestinationTableName = "T_ERP_TaoBaoATS_Trade";
                    blk.WriteToServerAdv<T_ERP_TaoBao_Trade>(trdpay, Exclude);

                    blk.DestinationTableName = "T_ERP_TaoBaoATS_Order";
                    var ords = trdpay.SelectMany(k => k.OrderList).ToList();
                    blk.WriteToServerAdv<T_ERP_TaoBao_Order>(ords, Exclude);

                    blk.DestinationTableName = "T_ERP_TaoBaoATS_PromotionDetail";
                    var kpromt = trdpay.Where(j => j.PromotList != null).SelectMany(k => k.PromotList);
                    if (null != kpromt) {
                        try {
                            var promots = kpromt.ToList();
                            if (null != promots && promots.Count > 0)
                                blk.WriteToServerAdv<T_ERP_TaoBao_PromotionDetail>(promots, Exclude);
                        } catch (Exception ex) { _applog.DebugException(new Exception(string.Format("SHOP:{0} Promot Error:{1}", shp.SellerNick, ex.Message))); }
                    }

                    blk.DestinationTableName = "T_ERP_TaobaoATS_ServiceOrder";
                    var ksvcs = trdpay.Where(j => j.ServiceOrderList != null).SelectMany(k => k.ServiceOrderList);
                    if (null != ksvcs) {
                        try {
                            var svcs = ksvcs.ToList();
                            if (null != svcs && svcs.Count > 0)
                                blk.WriteToServerAdv<T_ERP_Taobao_ServiceOrder>(svcs, Exclude);
                        } catch (Exception ex) { _applog.DebugException(new Exception(string.Format("SHOP:{0} SvcOrder Error:{1}", shp.SellerNick, ex.Message))); }
                    }
                }
                //登记同步时间
                if (remark != "重试")
                    _applog.DebugException(new Exception(string.Format("SHOP:{0} Begin:{1} End:{2} Count:{3}", shp.SellerNick, begin.ToDefaultStr(), end.ToDefaultStr(), jdps.Count)));
                else
                    _applog.DebugException(new Exception(string.Format("RETRY\tSHOP:{1}\tCOUNT:{0}\tBegin:{2}\tEnd:{3}\tFor Retry Sync.", jdps.Count, shp.SellerNick,
                    begin.ToDefaultStr(), end.ToDefaultStr())));
            } catch (Exception ex) {
                _applog.DebugException(new Exception(string.Format("Shop:{0} Begin:{2} End:{3} Ex:{1}", shp.SellerNick, ex.Message,
                    begin.ToDefaultStr(), end.ToDefaultStr())));
                lock (objLock)//加入失败队列重新操作
                {
                    QueFail.Enqueue(new T_ERP_SyncLog {
                        SellerNick = shp.SellerNick,
                        MinDateTime = begin,
                        MaxDateTime = end
                    });
                }
#if DEBUG
                throw;
#else
#endif
            }

        }
开发者ID:MasterGao,项目名称:DevWinFormFrame,代码行数:69,代码来源:RunToDb.cs

示例5: WriteRefundData

        protected void WriteRefundData(List<Jdp> jds) {
            List<RefundGetResponse> jdprefs = jds.Select(k => TopUtils.ParseResponse<RefundGetResponse>(k.jdp_response))
                                .ToList();
            var refs = jdprefs.Select(k => k.Refund).ToList();

            try {
                var trdpay = Caster.CastRefund(refs);
                using (var blk = new SqlBulkCopy(_con)) {
                    blk.DestinationTableName = "T_ERP_TaoBao_Refund";
                    blk.WriteToServerAdv<T_ERP_TaoBao_Refund>(trdpay, new string[] { "Id", "CreateTime" });
                }

            } catch (Exception ex) {
                _applog.DebugException(ex);
#if DEBUG
                throw;
#else
#endif
            }
        }
开发者ID:MasterGao,项目名称:DevWinFormFrame,代码行数:20,代码来源:RunToDb.cs

示例6: WriteRefundData

        protected void WriteRefundData(List<Refund> refs)
        {
            try
            {
                var trdpay = Caster.CastRefund(refs);
                using (var blk = new SqlBulkCopy(_con))
                {
                    blk.DestinationTableName = "T_ERP_TaoBao_Refund";
                    blk.WriteToServerAdv<T_ERP_TaoBao_Refund>(trdpay,new string[]{"Id","CreateTime"});
                }

            }
            catch (Exception ex)
            {
                _applog.DebugException(ex);
#if DEBUG
                throw;
#else
#endif
            }
        }
开发者ID:MasterGao,项目名称:DevWinFormFrame,代码行数:21,代码来源:Run.cs


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