public bool SaveProductInfoByPid(string pid, string cpremark, bool isAuto, string vehicleLevel) { bool result = false; try { int isAutometic = isAuto ? 1 : 0; #region 车型信息变更 则删除原有车型信息配置 bool configNotChange = DalProductVehicleInfo.IsExistProductVehicleTypeConfig(pid, vehicleLevel); bool?deleteResult = null; if (!configNotChange) { Func <SqlConnection, bool> deleteAction = (connection) => DalProductVehicleInfo.DeleteOldProductVehicleTypeConfig(connection, pid); deleteResult = dbManager.Execute(deleteAction); if (deleteResult != true) { throw new Exception("删除旧车型配置失败"); } } #endregion Func <SqlConnection, bool> action = (connection) => DalProductVehicleInfo.SaveProductInfoByPid(connection, pid, cpremark, isAutometic, vehicleLevel); result = dbManager.Execute(action); } catch (Exception e) { logger.Info($"SaveProductInfoByPid;ErrorMessage:{e.Message};ErrorStackTrace:{e.StackTrace}"); Monitor.ExceptionMonitor.AddNewMonitor("编辑页保存车型级别异常", e, "保存数据异常", MonitorLevel.Critial, MonitorModule.Other); throw e; } return(result); }
public List <string> GetVehicleBodyType() { Func <SqlConnection, List <string> > action = (connection) => DalProductVehicleInfo.GetVehicleBodyType(connection); return(dbManager.Execute(action)); }
public List <ProductInfo> GetAllNoImportProduct(int pageIndex, int pageSize) { try { return(DalProductVehicleInfo.SelectAllNoImportProduct(pageIndex, pageSize)); } catch (Exception e) { Monitor.ExceptionMonitor.AddNewMonitor("查询已配置未导入商品异常", e, "目标检索", MonitorLevel.Critial, MonitorModule.Other); return(new List <ProductInfo>()); } }
public ProductInfo GetProductInfoByPid(string pid) { try { Func <SqlConnection, ProductInfo> action = (connection) => DalProductVehicleInfo.GetProductInfoByPid(connection, pid); return(dbManagerReadOnly.Execute(action)); } catch (Exception e) { Monitor.ExceptionMonitor.AddNewMonitor("根据PID检索产品信息异常", e, "检索异常", MonitorLevel.Critial, MonitorModule.Other); return(new ProductInfo()); } }
public bool DeleteProductVehicleTypeConfigByParams(List <ProductVehicleTypeConfigDb> deleteList) { try { Func <SqlConnection, bool> action = (connection) => DalProductVehicleInfo.DeleteProductVehicleTypeConfigByParams(connection, deleteList); return(dbManager.Execute(action)); } catch (Exception e) { Monitor.ExceptionMonitor.AddNewMonitor("根据条件删除产品车型配置异常", e, "删除异常", MonitorLevel.Critial, MonitorModule.Other); return(false); } }
public List <ProductInfo> GetProductInfoByPids(string pids) { try { Func <SqlConnection, List <ProductInfo> > action = (connection) => DalProductVehicleInfo.GetProductInfoByPids(connection, pids); return(dbManagerReadOnly.Execute(action)); } catch (Exception e) { Monitor.ExceptionMonitor.AddNewMonitor("复制配置页面根据录入PIDs查询产品信息异常", e, "检索异常", MonitorLevel.Critial, MonitorModule.Other); return(new List <ProductInfo>()); } }
public bool SaveProductVehicleExcelInfo(ProductVehicleTypeFileInfoDb entity) { try { Func <SqlConnection, bool> action = (connection) => DalProductVehicleInfo.SaveProductVehicleExcelInfo(connection, entity); return(dbManager.Execute(action)); } catch (Exception e) { Monitor.ExceptionMonitor.AddNewMonitor("保存上传Excel信息异常", e, "保存数据异常", MonitorLevel.Critial, MonitorModule.Other); return(false); } }
public bool InsertProductVehicleTypeConfigInfoByPid(string pid, string destPids, string remark, string vehicleLevel) { try { Func <SqlConnection, bool> action = (connection) => DalProductVehicleInfo.InsertProductVehicleTypeConfigInfoByPid(connection, pid, destPids, remark, vehicleLevel); return(dbManager.Execute(action)); } catch (Exception e) { Monitor.ExceptionMonitor.AddNewMonitor("批量复制产品配置异常", e, "复制数据异常", MonitorLevel.Critial, MonitorModule.Other); return(false); } }
public List <ProductInfo> SearchProductInfoByParam(string pidOrDisplayName, int pageIndex, int pageSize, int type) { List <ProductInfo> result = new List <ProductInfo>(); try { dbManagerReadOnly.Execute(conn => { if (type == 1 || type == 2) { result = DalProductVehicleInfo.SelectProductInfo(conn, pidOrDisplayName, pageIndex, pageSize, type); } else { result = DalProductVehicleInfo.SearchProductInfoByParam(conn, pidOrDisplayName, pageIndex, pageSize, type); } if (result != null && result.Any() && type != 2) { var data = DalProductVehicleInfo.SelectProductConfigInfoByPIDs(conn, result.Select(x => x.PID).ToList()); if (data != null && data.Any()) { result.ForEach(x => { x.UpdateTime = data.Where(y => y.PID == x.PID).Select(_ => _.UpdateTime).FirstOrDefault() ?? string.Empty; }); } } }); } catch (Exception e) { Monitor.ExceptionMonitor.AddNewMonitor("列表页查询产品信息异常", e, "目标检索", MonitorLevel.Critial, MonitorModule.Other); return(new List <ProductInfo>()); } return(result); }
public List <VehicleInfoExDb> GetVehicleInfoEx() { Func <SqlConnection, List <VehicleInfoExDb> > action = (connection) => DalProductVehicleInfo.GetVehicleInfoEx(connection); return(dbManager.Execute(action)); }
public List <VehicleInfoExDb> GetVehicleInfoExByPid(string pid, string level) { Func <SqlConnection, List <VehicleInfoExDb> > action = (connection) => DalProductVehicleInfo.GetVehicleInfoExByPid(connection, pid, level); return(dbManager.Execute(action)); }
public VehicleInfoExDb GetVehicleInfoExByTid(string tid) { Func <SqlConnection, VehicleInfoExDb> action = (connection) => DalProductVehicleInfo.GetVehicleInfoExByTid(connection, tid); return(dbManager.Execute(action)); }
public List <VehicleTypeInfoDb> GetVehicleTypeInfoByBrandName(string brandNames) { Func <SqlConnection, List <VehicleTypeInfoDb> > action = (connection) => DalProductVehicleInfo.GetVehicleTypeInfoByBrandName(connection, brandNames); return(dbManager.Execute(action)); }
public List <VehicleTypeInfoDb> GetVehicleTypeInfoByCharacter(string alpha) { Func <SqlConnection, List <VehicleTypeInfoDb> > action = (connection) => DalProductVehicleInfo.GetVehicleTypeInfoByCharacter(connection, alpha); return(dbManager.Execute(action)); }
public List <ProductVehicleTypeFileInfoDb> GetExcelInfoByPid(string pid) { try { Func <SqlConnection, List <ProductVehicleTypeFileInfoDb> > action = (connection) => DalProductVehicleInfo.GetExcelInfoByPid(connection, pid); return(dbManagerReadOnly.Execute(action)); } catch (Exception e) { Monitor.ExceptionMonitor.AddNewMonitor("根据PID检索产品上传的Excel配置异常", e, "检索异常", MonitorLevel.Critial, MonitorModule.Other); return(new List <ProductVehicleTypeFileInfoDb>()); } }
/// <summary> /// 添加或更新车型配置信息 /// </summary> /// <param name="pid"></param> /// <param name="table"></param> /// <param name="fileName"></param> /// <param name="cpremark"></param> /// <returns></returns> public bool InsertOrUpdateVehicleInfoByPID(string pid, DataTable table, string fileName, string cpremark) { var result = true; var vehicleIdList = new List <string>(); var insertTidList = new List <string>(); var updateTidList = new List <string>(); var deleteVehicleIdList = new List <string>(); var deleteTidList = new List <string>(); var batchCount = 1000; try { dbManager.CreateTransaction(conn => { var pidInfo = DalProductVehicleInfo.GetAllProductVehicleTypeConfigInfoByPid(conn, pid, fileName, cpremark); VerifyAndConvertData(pidInfo, table, fileName, cpremark, out vehicleIdList, out insertTidList, out updateTidList, out deleteVehicleIdList, out deleteTidList); if (deleteVehicleIdList.Any())//删除的二级车型信息 { while (deleteVehicleIdList.Any()) { if (deleteVehicleIdList.Count() < batchCount) { batchCount = deleteVehicleIdList.Count(); } DalProductVehicleInfo.BatchDeleteSecondVehicleTypeConfig(conn, deleteVehicleIdList.GetRange(0, batchCount), pid); deleteVehicleIdList.RemoveRange(0, batchCount); } } if (deleteTidList.Any())//删除的五级车型信息 { while (deleteTidList.Any()) { if (deleteTidList.Count() < batchCount) { batchCount = deleteTidList.Count(); } DalProductVehicleInfo.BatchDeleteFiveVehicleTypeConfig(conn, deleteTidList.GetRange(0, batchCount), pid); deleteTidList.RemoveRange(0, batchCount); } } if (vehicleIdList.Any())//增加的二级车型信息 { while (vehicleIdList.Any()) { if (vehicleIdList.Count() < batchCount) { batchCount = vehicleIdList.Count(); } DalProductVehicleInfo.BatchInsertSecondVehicleTypeConfig(conn, vehicleIdList.GetRange(0, batchCount), pid); vehicleIdList.RemoveRange(0, batchCount); } } if (insertTidList.Any())//增加的五级车型信息 { while (insertTidList.Any()) { if (insertTidList.Count() < batchCount) { batchCount = insertTidList.Count(); } DalProductVehicleInfo.BatchInsertFiveVehicleTypeConfig(conn, insertTidList.GetRange(0, batchCount), pid); insertTidList.RemoveRange(0, batchCount); } } if (updateTidList.Any())//需要更新的五级车型信息 { while (updateTidList.Any()) { if (updateTidList.Count() < batchCount) { batchCount = updateTidList.Count(); } DalProductVehicleInfo.BatchUpdateFiveVehicleTypeConfig(conn, updateTidList.GetRange(0, batchCount), pid); updateTidList.RemoveRange(0, batchCount); } } }); } catch (Exception ex) { result = false; logger.Error(ex); } return(result); }
public bool UpdateVehicleInfoByPid(string pid, DataTable table, string level, string vehicleLevel) { var isSuccess = true; try { dbManagerReadOnly.Execute(conn => { var resultList = DalProductVehicleInfo.GetAllProductVehicleTypeConfigInfoByPid(conn, pid, level, vehicleLevel); if (level.Contains("二级")) { for (int i = table.Rows.Count - 1; i >= 0; i--) { var vehicleId = table.Rows[i][1].ToString(); //var nian = table.Rows[i][4].ToString(); //var paiLiang = table.Rows[i][5].ToString(); if (resultList.Exists(item => item.VehicleID == vehicleId)) { table.Rows.Remove(table.Rows[i]);//找到重复的就删掉不更新 continue; } } } else if (level.Contains("四级")) { for (int i = table.Rows.Count - 1; i >= 0; i--) { var vehicleId = table.Rows[i][1].ToString(); var nian = table.Rows[i][4].ToString(); var paiLiang = table.Rows[i][5].ToString(); if (resultList.Exists(item => item.VehicleID == vehicleId && item.Nian == nian && item.PaiLiang == paiLiang)) { table.Rows.Remove(table.Rows[i]); continue; } } } else if (level.Contains("五级")) { for (int i = table.Rows.Count - 1; i >= 0; i--) { //var tid = table.Rows[i][6].ToString(); var vehicleId = table.Rows[i][1].ToString(); var paiLiang = table.Rows[i][5].ToString(); var nian = table.Rows[i][4].ToString(); var salesName = table.Rows[i][7].ToString(); if (resultList.Exists(item => item.VehicleID == vehicleId && item.PaiLiang == paiLiang && item.Nian == nian && item.SalesName == salesName)) { //如果已存在相同数据则去重 table.Rows.Remove(table.Rows[i]); continue; } } } else { } //isSuccess = DalProductVehicleInfo.BulkSaveVehicleInfoByPid(conn, table, level, cpremark); }); Func <SqlConnection, bool> action = (connection) => DalProductVehicleInfo.BulkSaveVehicleInfoByPid(connection, table, level, vehicleLevel); dbManager.Execute(action); } catch (Exception e) { isSuccess = false; Monitor.ExceptionMonitor.AddNewMonitor("编辑页保存车型配置数据异常", e, "保存异常", MonitorLevel.Critial, MonitorModule.Other); } //try //{ // //var count = table.Rows.Count; // //先去重,去数据库捞一把防止重复数据插入 // if (level.Contains("二级")) // { // Func<SqlConnection, List<ProductVehicleTypeConfigDb>> actionOne = (connection) => DalProductVehicleInfo.GetAllProductVehicleTypeConfigInfoByPid(connection, pid, level, cpremark); // var resultList = dbManager.Execute(actionOne); // try // { // for (int i = table.Rows.Count - 1; i >= 0; i--) // { // var vehicleId = table.Rows[i][1].ToString(); // //var nian = table.Rows[i][4].ToString(); // //var paiLiang = table.Rows[i][5].ToString(); // if (resultList.Exists(item => item.VehicleID == vehicleId)) // { // table.Rows.Remove(table.Rows[i]);//找到重复的就删掉不更新 // //table.Rows[i].Delete(); // continue; // } // } // //table.AcceptChanges(); // } // catch (Exception ex) // { // isSuccess = false; // } // } // else if (level.Contains("四级")) // { // Func<SqlConnection, List<ProductVehicleTypeConfigDb>> actionTwo = (connection) => DalProductVehicleInfo.GetAllProductVehicleTypeConfigInfoByPid(connection, pid, level, cpremark); // var resultList = dbManager.Execute(actionTwo); // try // { // for (int i = table.Rows.Count - 1; i >= 0; i--) // { // var vehicleId = table.Rows[i][1].ToString(); // var nian = table.Rows[i][4].ToString(); // var paiLiang = table.Rows[i][5].ToString(); // if (resultList.Exists(item => item.VehicleID == vehicleId && item.Nian == nian && item.PaiLiang == paiLiang)) // { // table.Rows.Remove(table.Rows[i]); // continue; // } // } // } // catch (Exception ex) // { // isSuccess = false; // } // } // else if (level.Contains("五级")) // { // Func<SqlConnection, List<ProductVehicleTypeConfigDb>> actionThree = (connection) => DalProductVehicleInfo.GetAllProductVehicleTypeConfigInfoByPid(connection, pid, level, cpremark); // var resultList = dbManager.Execute(actionThree); // try // { // for (int i = table.Rows.Count - 1; i >= 0; i--) // { // var tid = table.Rows[i][6].ToString(); // if (resultList.Exists(item => item.TID == tid)) // { // //如果已存在相同数据则去重 // table.Rows.Remove(table.Rows[i]); // continue; // } // } // } // catch (Exception ex) // { // isSuccess = false; // } // } // Func<SqlConnection, bool> action = (connection) => DalProductVehicleInfo.BulkSaveVehicleInfoByPid(connection, table, level, cpremark); // dbManager.Execute(action); //} //catch (Exception e) //{ // isSuccess = false; //} return(isSuccess); }