public override List <AccountStatementImportFile> ImportFile(StreamReader reader, AccountStatementImport accountStatementImport, User user) { reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); List <AccountStatementImportFile> accountStatementImportFiles = new List <AccountStatementImportFile>(); int currentLineNumber = 0; while (!reader.EndOfStream) { var line = reader.ReadLine(); var values = line.Split(';'); AccountStatementImportFile asif = _asifService.InitForImport(user.IdUserGroup); asif.Id = currentLineNumber; asif.IdImport = accountStatementImport.Id; asif.DateImport = DateTime.Now; asif.Reference = null; asif.LabelOperation = values[2].ToString(); asif.LabelOperationWork = _asifService.GetOperationLabelWork(asif.LabelOperation); //asif.LabelOperationWork = asif.LabelOperationWork.ToString().Replace(" ", ""); if (values[3].ToString() != string.Empty) { asif.AmountOperation = -double.Parse(values[3].Replace(",", ".").ToString(), CultureInfo.InvariantCulture); asif.IdMovement = (int)EnumMovement.Debit; } else if (values[4].ToString() != string.Empty) { asif.AmountOperation = double.Parse(values[4].Replace(",", ".").ToString(), CultureInfo.InvariantCulture); asif.IdMovement = (int)EnumMovement.Credit; } asif.DateIntegration = Convert.ToDateTime(values[1].ToString()); asif.Account = _referentialService.AccountService.GetByNumber(values[0].ToString()); asif.IdAccount = asif.Account.Id; OperationMethod operationMethod = _referentialService.OperationMethodService.GetOperationMethodByFileLabel(asif.LabelOperationWork, EnumBankFamily.CreditAgricole); asif.IdOperationMethod = operationMethod.Id; //Date Operation switch (asif.IdOperationMethod) { case (int)EnumOperationMethod.PaiementCarte: asif.DateOperation = GetDateOperationByFileLabel(asif.LabelOperationWork, asif.DateIntegration.Value, EnumOperationMethod.PaiementCarte); break; case (int)EnumOperationMethod.RetraitCarte: asif.DateOperation = GetDateOperationByFileLabel(asif.LabelOperationWork, asif.DateIntegration.Value, EnumOperationMethod.RetraitCarte); break; } //Determination de operationDetail (operation+addresse) à partir des keywords OperationDetail operationDetail = _asifService.GetOperationDetail(user.Id, asif); if (operationDetail != null) { asif.IdOperation = operationDetail.Operation.Id; asif.IdOperationType = operationDetail.Operation.IdOperationType; asif.IdOperationTypeFamily = operationDetail.Operation.OperationType.IdOperationTypeFamily; asif.IdOperationDetail = operationDetail.Id; asif.OperationLabelTemp = operationDetail.Operation.Label; asif.OperationKeywordTemp = operationDetail.KeywordOperation; asif.PlaceLabelTemp = operationDetail.KeywordPlace; asif.PlaceKeywordTemp = operationDetail.KeywordPlace; } else { //Determination de operationDetail (operation+addresse) à partir du label brut OperationType operationType = _referentialService.OperationTypeService.GetUnknown(user.IdUserGroup); asif.IdOperationType = operationType.Id; asif.IdOperationTypeFamily = operationType.IdOperationTypeFamily; //rechercher les labels et keyword sur libellé brut OperationInformation operationInformation = GetOperationInformationByParsingLabel(user.Id, asif.LabelOperation, asif.LabelOperationWork, operationMethod); if (operationInformation != null) { //asif.IdOperation = operationInformation.IdOperation; asif.OperationLabelTemp = operationInformation.OperationLabel; asif.OperationKeywordTemp = operationInformation.OperationKeyword; asif.PlaceKeywordTemp = operationInformation.PlaceKeyword; asif.PlaceLabelTemp = operationInformation.PlaceLabel; } } accountStatementImportFiles.Add(asif); } return(accountStatementImportFiles); }