示例#1
0
 public void FormateDateToCodeLotTest()
 {
     dataFormater = serviceProvider.GetService <IDateFormater>();
     string[] months = { "JV", "FV", "MR", "AV", "MI", "JN", "JL", "AO", "SP", "OC", "NV", "DC" };
     Assert.AreEqual("JV/18/1", dataFormater.FormateDateToCodeLot(new DateTime(2018, 1, 1), months));
     Assert.AreEqual("FV/18/10", dataFormater.FormateDateToCodeLot(new DateTime(2018, 2, 10), months));
     Assert.AreEqual("MR/22/28", dataFormater.FormateDateToCodeLot(new DateTime(2022, 3, 28), months));
 }
示例#2
0
        public void FormateDateToCodeLotTestExceptions()
        {
            dataFormater = serviceProvider.GetService <IDateFormater>();
            DateTime date = new DateTime();

            Assert.ThrowsException <Exception>(() => dataFormater.FormateDateToCodeLot(date, null));
            string[] months = { "JV", "FV", "MR", "AV", "MI", "JN", "JL", "AO" };
            Assert.ThrowsException <Exception>(() => dataFormater.FormateDateToCodeLot(new DateTime(2018, 1, 1), months));
        }
示例#3
0
        public (bool processOk, List <string> errors) SyncLotFromRef(DateTime minDate, string[] monthsNames)
        {
            List <string> errors = new List <string>();

            try
            {
                var refOffices = _refContext.Offices.Where(p => p.Office > minDate && p.Office != null);
                _logger.LogInformation($"Nombre d'office dans la base réf avec office > minDate : {refOffices.Count()}");
                int counter = 0;

                foreach (var office in refOffices)
                {
                    try
                    {
                        Lot lot = _fabContext.Lot.FirstOrDefault(p => p.FkOffices == office.PkOffices);
                        if (lot == null)
                        {
                            lot = new Lot();
                            lot.FkParamDetailProc = (int)ProcessusEnum.Nouveaute;
                            lot.EnCours           = false;
                            lot.FkOffices         = office.PkOffices;
                            lot.DateMiseEnVente   = office.MiseEnVente;
                            lot.CodeLot           = _dateFormater.FormateDateToCodeLot(office.Office.Value, monthsNames);
                            lot.NomLot            = _dateFormater.FormatDateToNomLot(office.Office.Value);
                            _fabContext.Add(lot);
                            _fabContext.SaveChanges();
                            counter++;
                            //throw new Exception("test erreur sur un lot");
                        }
                    }
                    catch (Exception ex)
                    {
                        errors.Add($"Erreur lors de la sauvegarde du lot [{office?.Nom}] dans LMG_FAB : {ex.ToString()}");
                        continue;
                    }
                }

                _logger.LogInformation($"Nombre d'office intégrés dans la base LMG_FAB.Lot : {counter.ToString()}");
            }
            catch (Exception ex)
            {
                errors.Add($"Erreur lors de la sauvegarde des lots dans LMG_FAB : {ex.ToString()}");
            }

            return(errors.Count == 0, errors);
        }