protected override bool AddItemsToDb(List <Jc_McInfo> addItems) { try { System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); IEnumerable <IGrouping <string, Jc_McInfo> > groupYYYYMMDD = addItems.GroupBy(p => p.Timer.ToString("yyyyMMdd")); foreach (IGrouping <string, Jc_McInfo> info in groupYYYYMMDD) { var initialinfolist = info.ToList(); var initialModels = ObjectConverter.CopyList <Jc_McInfo, Jc_McModel>(initialinfolist); //if (!runLogRepositoty.BulkCopy("KJ_DataDetail" + info.Key, initialModels, BuildDataColumn(columns))) if (!runLogRepositoty.BulkCopy("KJ_DataDetail" + info.Key, initialModels, null)) //2017.9.16 by 解决入库时间带毫秒问题 { //数据库连接失败则缓存数据至本地文件 int isconn = runLogRepositoty.GetTotalRecord("DataToDb_GetDbServerIsNormal"); if (isconn <= 0) { AddDataToLocal(initialinfolist); } } } sw.Stop(); LogHelper.Info(string.Format("密采批量入库:{0} 条,耗时:{1}", addItems.Count, sw.ElapsedMilliseconds)); return(true); } catch (Exception ex) { LogHelper.Error("密采数据入库失败:" + "\r\n" + ex.Message); return(false); } }
protected override void AddItemsToDb(List <Jc_McInfo> addItems) { try { IEnumerable <IGrouping <string, Jc_McInfo> > groupYYYYMMDD = addItems.GroupBy(p => p.Timer.ToString("yyyyMMdd")); foreach (IGrouping <string, Jc_McInfo> info in groupYYYYMMDD) { var initialinfolist = info.ToList(); var initialModels = ObjectConverter.CopyList <Jc_McInfo, Jc_McModel>(initialinfolist); if (!runLogRepositoty.BulkCopy("KJ_DataDetail" + info.Key, initialModels, BuildDataColumn(columns))) { //数据库连接失败则缓存数据至本地文件 int isconn = runLogRepositoty.GetTotalRecord("DataToDb_GetDbServerIsNormal"); if (isconn <= 0) { AddDataToLocal(initialinfolist); } } } } catch (Exception ex) { LogHelper.Error("密采数据入库失败:" + "\r\n" + ex.Message); } }