//29 private static void AddGood(Dish dish) { string err = ""; int errCode = 0; if (!sh.AddGoods((int)dish.DishKitсhenGroup.SHIdToFly, dish.Name + "_ToFly", "Al_" + dish.Barcode.ToString(), (int)dish.Barcode, (int)dish.Barcode, 1, 2, UnitId, (double)dish.PriceForFlight, out errCode, out err)) { int i = 0; } }
private static bool AddNewDishToFly(Dish dish, out string ErrMesssage, out int catId) { logger.Debug($"AddNewDishToFly dish: {dish.Barcode} {dish.Name}; KithcenCat: {dish.DishKitсhenGroupId}; LogicCat: {dish.DishLogicGroupId}"); catId = Properties.Settings.Default.SHNoCatFolderToFlyId; ErrMesssage = ""; int errCode = 0; var toFlyGroups = GetToFlyGoodsTreeDic().Keys.ToList(); toFlyGroups.AddRange(GetSVOGoodsTreeDic().Keys.ToList()); var existD = GetDishesFromSH(toFlyGroups); //if (dish.IsTemporary) //{ // // if (existD.Any(a => GetBarCode(a.prCode) == dish.Barcode && GetBarCode2OpenDish(a.prCode) == dish.Id)) // { // dish.SHIdNewBase = existD.FirstOrDefault(a => GetBarCode(a.prCode) == dish.Barcode && GetBarCode2OpenDish(a.prCode) == dish.Id).Rid; // //catId = -1; // DBProvider.Client.UpdateDish(dish); // return true; // } // /* // if (DataExtension.DataCatalogsSingleton.Instance.Dishes.Any(a => a.Barcode == dish.Barcode && !a.IsTemporary)) // { // dish.SHIdNewBase = DataExtension.DataCatalogsSingleton.Instance.Dishes.SingleOrDefault(a => a.Barcode == dish.Barcode && !a.IsTemporary).SHIdNewBase; // return true; // } // */ //} //else { if (existD.Any(a => GetBarCode(a.prCode, dish.IsDop()) == dish.Barcode || GetBarCode(a.prCode, dish.IsDop()) == dish.Barcode + 10000)) { dish.SHIdNewBase = existD.FirstOrDefault(a => GetBarCode(a.prCode, dish.IsDop()) == dish.Barcode || GetBarCode(a.prCode, dish.IsDop()) == dish.Barcode + 10000).Rid; //catId = -1; DBProvider.Client.UpdateDish(dish); return(true); } } try { bool res = false; if (dish.Name == null) { logger.Error($"Error dish.Name == null Id: {dish.Id}"); } string dName = dish.Name.Length > ShMaxNameLenght?dish.Name.Substring(0, ShMaxNameLenght) : dish.Name; /* * if (dish.IsTemporary) * { * catId = Properties.Settings.Default.SHOpenDishFolderToFly; * res = sh.AddGoods(catId, dName + "_ToFly", "Al_Op_" + dish.Barcode.ToString() + "_" + dish.Id.ToString(), (int)dish.Barcode, (int)dish.Barcode, 1, 2, Properties.Settings.Default.SHUnitId, (double)dish.PriceForFlight, out errCode, out ErrMesssage); * * } * * else */ { string prefixDop = dish.DishLogicGroupId == MainClass.DopLogikCatId ? "dop_" : ""; if (dish.DishLogicGroupId == null || (int)dish.DishLogicGroupId != 1) { if (dish.DishKitсhenGroup != null && dish.DishKitсhenGroup.SHIdToFly != 0) { catId = (int)dish.DishKitсhenGroup.SHIdToFly; } res = sh.AddGoods(catId, dName + "_" + prefixDop + "ToFly", "Al_" + prefixDop + dish.Barcode.ToString(), (int)dish.Barcode, (int)dish.Barcode, 1, 2, Properties.Settings.Default.SHUnitId, (double)dish.PriceForFlight, out errCode, out ErrMesssage); } else { catId = Properties.Settings.Default.SHSharFolderId; res = sh.AddGoods(catId, dName + "_ToFly", "Al_" + prefixDop + dish.Barcode.ToString(), (int)dish.Barcode, (int)dish.Barcode, 1, 2, Properties.Settings.Default.SHUnitId, (double)dish.PriceForFlight, out errCode, out ErrMesssage); } } if (res) { int shId = 0; /* * if (dish.IsTemporary) * { * shId = GetOpenDishShId(catId, (int)dish.Barcode, (int)dish.Id); * } * else */ { shId = GetDishShId(catId, (int)dish.Barcode, dish.IsDop()); } if (shId != 0) { logger.Debug($"shId = {shId}"); dish.SHIdNewBase = shId; DBProvider.Client.UpdateDish(dish); return(true); } else { logger.Debug($"TExpenceDocument create Shid=0 return false"); return(false); } } else { return(false); } } catch (Exception e) { logger.Error($"AddNewDishToFly error: " + e.Message); return(false); } finally { logger.Debug($"AddNewDishToFly end. Errcode {errCode}; ErrMesssage: {ErrMesssage}"); } }