public GuidesIdsCollection GetGuidesIds() { GuidesConfiguration guidesConfiguration = _guidesConfigManager.Get(); GuidesIdsCollection guides = LoadGuidesIds(guidesConfiguration); return(guides); }
private GuidesIdsCollection CreateGuidesIdsCollecion(HashSet <int> mnnGuideIds, HashSet <int> tradeNameGuideIds) { var guidesIdsCollection = new GuidesIdsCollection() { MnnGuideIs = mnnGuideIds, TradeNamesGudeIds = tradeNameGuideIds }; return(guidesIdsCollection); }
//*** SIMPLIFY THIS METHOD /** * public void CheckGuidesForUpdate(FtpClient ftpClient) * { * if (ftpClient == null) * { * throw new ArgumentNullException(nameof(ftpClient)); * } * * var guidesConfiguration = _guidesConfigurationManager.Get(); * * var latestEntity = GetLatestFileMetadata(ftpClient); * * var lastUpdateDate = guidesConfiguration.LastUpdateDate; * if (latestEntity != null && !string.Equals(latestEntity.Date, lastUpdateDate)) * { * try * { * var localPath = guidesConfiguration.Path; * var fileName = latestEntity.Name; * * ftpClient.DownloadFile(fileName, localPath); * * UnZip(latestEntity.Name, guidesConfiguration.Path, true); * DeleteFile(guidesConfiguration.Path, latestEntity.Name); * * guidesConfiguration.LastUpdateDate = latestEntity.Date; * _guidesConfigurationManager.Update(guidesConfiguration); * } * catch (IOException ex) * { * throw new FileSaveException(ex.Message, ex); * } * catch (AggregateException ae) * { * // This is where you can choose which exceptions to handle. * foreach (var ex in ae.InnerExceptions) * { * if (ex is System.Net.WebException) * { * throw new RemoteServerException( * "Guides service not respond" + Environment.NewLine + ex.Message, ex); * } * * if (ex is System.IO.DirectoryNotFoundException) * { * throw new FileSaveException( * "Guides folder not found" + Environment.NewLine + ex.Message, ex); * } * * throw ex; * } * } * } * } */ public GuidesIdsCollection GetGuidesIds() { var mnnGuideIds = _mnnGuideRepository.GetIds("sp_mnn.dbf"); var tradeNameIds = _tradeNameGuideRepository.GetIds("sp_trn.dbf"); var drugIds = _drugGuideRepository.GetIds("sp_tov.dbf"); var drugformIds = _drugformGuideRepository.GetIds("sp_lf.dbf"); var guidesIdsCollection = new GuidesIdsCollection() { MnnGuideIs = mnnGuideIds, TradeNamesGudeIds = tradeNameIds, DrugGuideIds = drugIds, DrugformIds = drugformIds }; return(guidesIdsCollection); }
private async Task SendRecipes(string clientId, List <RecipeRow> recipesList, GuidesIdsCollection guidesIdsCollection) { _log.Info("Checking recipes in guides"); var isRemainsFieldsValid = _recipeService.CheckRequiredFields(recipesList, guidesIdsCollection); if (!isRemainsFieldsValid) { _log.Info("Recipes check failed"); _log.Info("Recipes send failed"); return; } //*** _remainService move to function parameters await SendEntitiesAsync(clientId, _recipeService, recipesList); }
private async Task ProcessRemains(string clientId, List <RemainRow> remainsCollection, GuidesIdsCollection guidesIdsCollection) { /** *** get test data * * var isRequiredFieldsValid = * _remainService.CheckRequiredFields(remainsCollection, guidesIdsCollection); * * if (isRequiredFieldsValid) * { * await SendEntitiesAsync(clientId, _remainService, remainsCollection); * } * else * { * _log.Info("Записи из выгрузки остатков отсутствуют в справочнике"); * } */ await SendEntitiesAsync(clientId, _remainService, remainsCollection); }
public async Task <GuidesIdsCollection> GetGuidesIdsAsync() { var mnnGuideIds = await _mnnGuideRepository.GetIdsAsync("sp_mnn.dbf"); var tradeNameIds = await _tradeNameGuideRepository.GetIdsAsync("sp_trn.dbf"); var drugIds = await _drugGuideRepository.GetIdsAsync("sp_tov.dbf"); var drugformIds = await _drugformGuideRepository.GetIdsAsync("sp_lf.dbf"); var guidesIdsCollection = new GuidesIdsCollection() { MnnGuideIs = mnnGuideIds, TradeNamesGudeIds = tradeNameIds, DrugGuideIds = drugIds, DrugformIds = drugformIds }; return(guidesIdsCollection); }
// PUBLIC INTERFACE METHODS SECTION //--------------------------------------------------------------------- public override bool CheckRequiredFields(IEnumerable <RemainRow> entitiesList, GuidesIdsCollection guidesIds) { /** LINQ equvalent * * return entitiesList.All(entity => * guidesIds.TradeNamesGudeIds.Contains(int.Parse(entity.ProductCode))); */ foreach (var entity in entitiesList) { if (!guidesIds.TradeNamesGudeIds.Contains(int.Parse(entity.ProductCode))) { return(false); } } return(true); }
// PUBLIC INTERFACE METHODS SECTION //--------------------------------------------------------------------- //*** or return check state public abstract bool CheckRequiredFields(IEnumerable <TEntity> entitiesList, GuidesIdsCollection guidesIds);
// PUBLIC INTERFACE METHODS SECTION //--------------------------------------------------------------------- public override bool CheckRequiredFields(IEnumerable <RecipeRow> entitiesList, GuidesIdsCollection guidesIds) { throw new NotImplementedException(); }