Exemple #1
0
        public bool Check()
        {
            var logger = new TextLogger(LogSeverity.Warning);

            logger.PutLine("*** Control d’intégrité ***");
            logger.PutLine($"Table: {AppContext.TableManager.Countries.Name}");
            logger.PutLine("Les élemnets suivants ont un numerà de géneration invalide:");

            using (IDatumProvider dp = AppContext.TableManager.TablesGeneration.DataProvider)
            {
                dp.Connect();

                bool anyErr = false;

                if (dp.Count > 0)
                {
                    foreach (FileGeneration d in dp.Enumerate())
                    {
                        if (d.Generation == 0)
                        {
                            logger.PutLine(d.ToString());
                            anyErr = true;
                        }
                    }
                }

                if (anyErr)
                {
                    logger.Flush();
                }

                return(!anyErr);
            }
        }
Exemple #2
0
        bool CheckConstraint17()
        {
            //∀m ∈ ProductMapping  ∃c ∈ ValueContext : c.ID = m.ContextID

            var logger = new TextLogger(LogSeverity.Warning);

            logger.PutLine("*** Control d’intégrité ***");
            logger.PutLine($"Table: {AppContext.TableManager.TRProductsMapping.Name}");

            bool err = false;

            if (m_ndxerMapProdNber.Source.Count > 0)
            {
                foreach (ProductMapping pm in m_ndxerMapProdNber.Source.Enumerate())
                {
                    if (m_ndxerContext.Get(pm.ContextID) == null)
                    {
                        logger.PutLine("La contrainte d’intégrité n° 17 est violée par l'élément suivant :");
                        logger.PutLine(pm);
                        logger.PutLine();

                        err = true;
                    }
                }
            }
            if (err)
            {
                logger.Flush();
            }

            return(!err);
        }
Exemple #3
0
        public bool Check()
        {
            var logger = new TextLogger(LogSeverity.Warning);

            logger.PutLine("*** Control d’intégrité ***");
            logger.PutLine($"Table: {AppContext.TableManager.Incoterms.Name}");
            logger.PutLine("La contrainte d’intégrité n° 16 est violée par les éléments suivants :");

            bool err = false;

            foreach (uint prodID in m_ndxerLabelProdNbers.Attributes)
            {
                if (m_ndxerMappingProdNbers.Get(prodID).Any())
                {
                    logger.PutLine(m_ndxerLabelProdNbers.Get(prodID).First().ToString());

                    logger.PutLine();
                    err = true;
                }
            }


            if (err)
            {
                logger.Flush();
            }

            return(!err);
        }
Exemple #4
0
        bool CheckConstraint20()
        {
            //∀v1, v2 ∈ TRSpotValueTable (v1.ProductMappingId, v1.Time) = (v2.ProductMappingId, v2.Time) <=> v1=v2

            var logger = new TextLogger(LogSeverity.Warning);

            logger.PutLine("*** Control d’intégrité ***");
            logger.PutLine($"Table: {AppContext.TableManager.TRSpotValues.Name}");


            Func <IDatum, Pair <uint, DateTime> > selector = d =>
            {
                var sv = d as SpotValue;
                return(Pair.Create(sv.ProductMappingID, sv.Time));
            };

            bool err = false;

            using (var ndxer = new AttrIndexer <Pair <uint, DateTime> >(m_srcSpotValues, selector))
            {
                ndxer.Connect();

                foreach (var pair in ndxer.Attributes)
                {
                    if (ndxer.Get(pair).Count() != 1)
                    {
                        {
                            logger.PutLine("La contrainte d’intégrité n° 20 est violée par les éléments suivants :");

                            foreach (var datum in ndxer.Get(pair))
                            {
                                logger.PutLine(datum);
                            }

                            logger.PutLine();

                            err = true;
                        }
                    }
                }
            }


            if (err)
            {
                logger.Flush();
            }

            return(!err);
        }
Exemple #5
0
        bool CheckConstraint11()
        {
            //∀ p1, p2 ∈ TRProductMapping (p1.ProductID, p1.ContextID) = (p2.ProductID, p2.ContextID) <=> p1 = p2

            var logger = new TextLogger(LogSeverity.Warning);

            logger.PutLine("*** Control d’intégrité ***");
            logger.PutLine($"Table: {AppContext.TableManager.TRProductsMapping.Name}");

            Func <IDatum, Pair <uint, uint> > selctor = d =>
            {
                var p = d as ProductMapping;
                return(Pair.Create(p.ProductID, p.ContextID));
            };


            bool err = false;

            using (var ndxer = new AttrIndexer <Pair <uint, uint> >(m_ndxerMapProdNber.Source, selctor))
            {
                ndxer.Connect();

                foreach (Pair <uint, uint> item in ndxer.Attributes)
                {
                    var seq = ndxer.Get(item);

                    if (seq.Count() != 1)
                    {
                        logger.PutLine("La contrainte d’intégrité n° 11 est violée par les éléments suivants :");
                        foreach (ProductMapping mapping in seq)
                        {
                            logger.PutLine(mapping);
                        }

                        logger.PutLine();
                        err = true;
                    }
                }
            }


            if (err)
            {
                logger.Flush();
            }

            return(!err);
        }
Exemple #6
0
        public void Run()
        {
            Assert(!IsDisposed);


            m_pendingData.Clear();
            m_ignoredRows.Clear();

            foreach (List <IDataRow> lst in m_importedData.Values)
            {
                lst.Clear();
            }

            SetupSupplier();

            var logger = new TextLogger(LogSeverity.Error);

            for (int i = 0; i < m_srcData.Length; ++i)
            {
                if (ParseSpotValue(i) == null)
                {
                    m_ignoredRows.Add(i);
                    logger.PutLine($"La ligne N° {i + 1} a été ignorée.");
                }
                else
                {
                    foreach (uint idTable in m_pendingData.Keys)
                    {
                        m_importedData[idTable].Add(m_pendingData[idTable]);
                    }
                }

                m_pendingData.Clear();
            }
        }
Exemple #7
0
        void Save()
        {
            Assert(!InvokeRequired);

            var      price  = (double)m_nudPrice.Value;
            DateTime dtSpot = m_dtpSpotTime.Value;

            if (m_spotValue.Price == price && m_spotValue.SpotTime == dtSpot)
            {
                TextLogger.Info("Aucune modification détectée, enregistrement non-nécessaire.");
                Close();

                return;
            }


            //verification contrainte 8
            using (var ndxer = new AttrIndexer <DateTime>(m_ndxerValues.Source, d => (d as SpotValue).SpotTime))
            {
                ndxer.Connect();

                IEnumerable <SpotValue> values = from SpotValue sv in ndxer.Get(dtSpot)
                                                 where sv.ProductID == m_spotValue.ProductID &&
                                                 sv.SupplierID == m_spotValue.SupplierID &&
                                                 sv.ValueContextID == m_spotValue.ValueContextID
                                                 select sv;

                if (values.Count() > 1 || (values.Count() == 1 && values.Single().ID != m_spotValue.ID))
                {
                    var logger = new TextLogger(LogSeverity.Warning);
                    logger.Put("Duplication de données détectée.");
                    logger.Put("Elément trouvé:\n");

                    foreach (SpotValue sv in values)
                    {
                        logger.PutLine(sv);
                    }

                    logger.Flush();

                    MessageBox.Show("La validation de  données a échouée. " +
                                    "Consultez le journal des événements pour plus d’informations.",
                                    null,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);

                    return;
                }


                var newValue = new SpotValue(m_spotValue.ID, price, dtSpot, m_spotValue.ProductID,
                                             m_spotValue.ValueContextID, m_spotValue.SupplierID, 0);
                m_ndxerValues.Source.Replace(m_ndxerValues.IndexOf(m_spotValue.ID), newValue);

                TextLogger.Info("Enregistrement réussi.");
                Close();
            }
        }
Exemple #8
0
        public bool Check()
        {
            //contrainte 14

            var logger = new TextLogger(LogSeverity.Warning);

            logger.PutLine("*** Control d’intégrité ***");
            logger.PutLine($"Table: {AppContext.TableManager.ValuesContext.Name}");


            Func <IDatum, Tuple <uint, uint, uint, uint, uint> > selector = delegate(IDatum d)
            {
                var vc = d as ValueContext;
                return(Tuple.Create(vc.CurrencyID, vc.IncotermID, vc.OriginID, vc.PlaceID, vc.UnitID));
            };

            bool err = false;

            using (var ndxer = new AttrIndexer <Tuple <uint, uint, uint, uint, uint> >(m_srcContext, selector))
            {
                ndxer.Connect();

                foreach (var tpl in ndxer.Attributes)
                {
                    if (ndxer.Get(tpl).Count() > 1)
                    {
                        logger.PutLine("La contrainte d’intégrité n° 14 est violée par les éléments suivants :");
                        foreach (IDatum d in ndxer.Get(tpl))
                        {
                            logger.PutLine(d);
                        }

                        logger.PutLine();
                        err = true;
                    }
                }

                if (err)
                {
                    logger.Flush();
                }

                return(!err);
            }
        }
Exemple #9
0
        public bool Check()
        {
            var logger = new TextLogger(LogSeverity.Warning);

            logger.PutLine("*** Control d’intégrité ***");
            logger.PutLine($"Table: {AppContext.TableManager.Suppiers.Name}");
            logger.PutLine("La contrainte d’intégrité n° 6 est violée par les éléments suivants :");


            bool anyErr = false;

            using (var ndxer = new AttrIndexer <string>(m_srcSuppmiers, d => (d as DataSupplier).Name,
                                                        StringComparer.CurrentCultureIgnoreCase))
            {
                ndxer.Connect();

                foreach (string name in ndxer.Attributes)
                {
                    if (ndxer.Get(name).Count() != 1)
                    {
                        logger.PutLine("Les éléments suivant sont identiques:");
                        foreach (var item in ndxer.Get(name))
                        {
                            logger.PutLine(item);
                        }

                        logger.PutLine();
                        anyErr = true;
                    }
                }
            }

            return(!anyErr);
        }
Exemple #10
0
        bool AddDatum(string name, ProfilePrivilege_t privilege)
        {
            var seq = from UserProfile p in m_ndxProfiles.Source.Enumerate()
                      where string.Compare(p.Name, name, true) == 0
                      select p;

            if (seq.Count() > 0)
            {
                var logger = new TextLogger(LogSeverity.Warning);
                logger.PutLine("Duplication de données détectée.");
                logger.PutLine(seq.Single().ToString());
                logger.Flush();

                MessageBox.Show("La validation de  données a échouée. " +
                                "Consultez le journal des événements pour plus d’informations.",
                                null,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);

                return(false);
            }

            var profile = new UserProfile(AppContext.TableManager.Profiles.CreateUniqID(), name, privilege);

            //ajouter gestion des profils
            var mgmntMode = new ProfileManagementMode(profile.ID);

            using (IDatumProvider dp = AppContext.TableManager.ProfileManagementMode.DataProvider)
            {
                dp.Connect();
                dp.Insert(mgmntMode);
            }

            //ajouer le profil
            m_ndxProfiles.Source.Insert(profile);


            return(true);
        }
Exemple #11
0
        public bool Check()
        {
            //contrainte no 10 = Name et unique
            var logger = new TextLogger(LogSeverity.Warning);

            logger.PutLine("*** Control d’intégrité ***");
            logger.PutLine($"Table: {AppContext.TableManager.Suppiers.Name}");


            bool err = false;

            using (var ndxer = new AttrIndexer <string>(m_srcUnits, d => (d as Unit).Name, StringComparer.CurrentCultureIgnoreCase))
            {
                ndxer.Connect();

                foreach (string name in ndxer.Attributes)
                {
                    if (ndxer.Get(name).Count() > 1)
                    {
                        logger.PutLine("La contrainte d’intégrité n° 10 est violée par les éléments suivants :");
                        foreach (IDatum d in ndxer.Get(name))
                        {
                            logger.PutLine(d);
                        }

                        logger.PutLine();
                        err = true;
                    }
                }
            }

            if (err)
            {
                logger.Flush();
            }

            return(!err);
        }
Exemple #12
0
        bool CheckConstraint19()
        {
            // ∀v ∈ TRSpotValueTable ∃m ∈ TRProductMappingTable: v.ProductMappingID = m.ID;

            var logger = new TextLogger(LogSeverity.Warning);

            logger.PutLine("*** Control d’intégrité ***");
            logger.PutLine($"Table: {AppContext.TableManager.TRSpotValues.Name}");

            bool err = false;

            using (var ndxer = new AttrIndexer <uint>(m_srcSpotValues, d => (d as SpotValue).ProductMappingID))
            {
                ndxer.Connect();

                foreach (uint idMapping in ndxer.Attributes)
                {
                    if (m_ProductMappings.Get(idMapping) == null)
                    {
                        logger.PutLine("La contrainte d’intégrité n° 19 est violée par l'élément suivant :");
                        logger.PutLine(ndxer.Get(idMapping));

                        logger.PutLine();

                        err = true;
                    }
                }
            }


            if (err)
            {
                logger.Flush();
            }

            return(!err);
        }
Exemple #13
0
        //private:
        bool CheckConstraint5()
        {
            //∀ p1, P2 ∈ TRProductMapping, p1.ProductNumber = p2.ProductNumber <=> p1 = p2;

            var logger = new TextLogger(LogSeverity.Warning);

            logger.PutLine("*** Control d’intégrité ***");
            logger.PutLine($"Table: {AppContext.TableManager.TRProductsMapping.Name}");

            bool err = false;

            foreach (uint prodNber in m_ndxerMapProdNber.Attributes)
            {
                if (m_ndxerMapProdNber.Get(prodNber).Count() != 1)
                {
                    logger.PutLine("La contrainte d’intégrité n° 5 est violée par les éléments suivants :");

                    foreach (IDatum d in m_ndxerMapProdNber.Get(prodNber))
                    {
                        logger.PutLine(d);
                    }

                    logger.PutLine();

                    err = true;
                }
            }


            if (err)
            {
                logger.Flush();
            }


            return(!err);
        }
Exemple #14
0
        bool UpdateDatum(string name, ProfilePrivilege_t privilege)
        {
            if (string.Compare(name, m_datum.Name) == 0 && m_datum.Privilege == privilege)
            {
                TextLogger.Info("Aucune modification détectée, enregistrement non-nécessaire.");
                return(true);
            }

            var seq = from UserProfile p in m_ndxProfiles.Source.Enumerate()
                      where string.Compare(p.Name, name, true) == 0 && p.ID != m_datum.ID
                      select p;

            if (seq.Count() > 0)
            {
                var logger = new TextLogger(LogSeverity.Warning);
                logger.PutLine("Duplication de données détectée.");
                logger.PutLine(seq.Single().ToString());
                logger.Flush();

                MessageBox.Show("La validation de  données a échouée. " +
                                "Consultez le journal des événements pour plus d’informations.",
                                null,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);


                return(false);
            }

            int ndx     = m_ndxProfiles.IndexOf(m_datum.ID);
            var profile = new UserProfile(m_datum.ID, name, privilege);

            m_ndxProfiles.Source.Replace(ndx, profile);

            return(true);
        }
Exemple #15
0
        public bool Check()
        {
            //contrainte 4

            var logger = new TextLogger(LogSeverity.Warning);

            logger.PutLine("*** Control d’intégrité ***");
            logger.PutLine($"Table: {AppContext.TableManager.Places.Name}");
            logger.PutLine("La contrainte d’intégrité n° 4 est violée par les éléments suivants :");

            Func <IDatum, Pair <string, uint> > filter = d =>
            {
                var p = d as Place;

                return(new Pair <string, uint>(p.Name, p.CountryID));
            };


            bool anyErr = false;

            using (AttrIndexer <Pair <string, uint> > ndxer = new AttrIndexer <Pair <string, uint> >(m_srcPlaces, filter))
            {
                ndxer.Connect();

                foreach (Pair <string, uint> item in ndxer.Attributes)
                {
                    IEnumerable <IDatum> data = ndxer.Get(item);

                    if (data.Count() > 1)
                    {
                        logger.PutLine("Eléments suivant sont identiques:");

                        foreach (Place p in data)
                        {
                            logger.PutLine($"(Lieu:{p.Name}, ID Pays:{p.CountryID})");
                        }

                        logger.PutLine();
                        anyErr = true;
                    }
                }
            }

            if (anyErr)
            {
                logger.Flush();
            }

            return(!anyErr);
        }
Exemple #16
0
        public bool Check()
        {
            //contrainte 1

            var logger = new TextLogger(LogSeverity.Warning);

            logger.PutLine("*** Control d’intégrité ***");
            logger.PutLine($"Table: {AppContext.TableManager.Products.Name}");
            logger.PutLine("La contrainte d’intégrité n° 1 est violée par les éléments suivants :");

            Func <IDatum, Pair <string, SubHeading> > selector = (d) =>
            {
                var p = d as Product;
                return(Pair.Create(p.Name, p.SubHeading));
            };

            bool anyErr = false;

            using (var ndxer = new AttrIndexer <Pair <string, SubHeading> >(m_srcProducts, selector))
            {
                ndxer.Connect();

                foreach (var pair in ndxer.Attributes)
                {
                    IEnumerable <IDatum> products = ndxer.Get(pair);

                    if (products.Count() > 1)
                    {
                        logger.PutLine("Eléments suivant sont identiques:");

                        foreach (Product prod in products)
                        {
                            logger.PutLine(prod);
                        }

                        logger.PutLine();
                        anyErr = true;
                    }
                }
            }

            if (anyErr)
            {
                logger.Flush();
            }

            return(!anyErr);
        }
Exemple #17
0
        public bool Check()
        {
            var logger = new TextLogger(LogSeverity.Warning);

            logger.PutLine("*** Control d’intégrité ***");
            logger.PutLine($"Table: {AppContext.TableManager.SpotValues.Name}");
            logger.PutLine("La contrainte d’intégrité n° 8 est violée par les éléments suivants :");

            Func <IDatum, IDatum, bool> comparer = (d1, d2) =>
            {
                var sv1 = d1 as SpotValue;
                var sv2 = d2 as SpotValue;

                return(sv1.ProductID == sv2.ProductID && sv1.SpotTime == sv2.SpotTime &&
                       sv1.SupplierID == sv2.SupplierID && sv1.ValueContextID == sv2.ValueContextID);
            };

            bool anyErr = false;

            using (var ndxer = new AttrIndexer <SpotValue>(m_srcSpotValues, d => d as SpotValue))
            {
                ndxer.Connect();

                foreach (SpotValue sv in ndxer.Attributes)
                {
                    if (ndxer.IndexOf(sv).Count() > 1)
                    {
                        logger.PutLine("Les éléments suivant sont identiques:");
                        foreach (var item in ndxer.Get(sv))
                        {
                            logger.PutLine(item);
                        }

                        logger.PutLine();

                        anyErr = true;
                    }
                }
            }

            return(!anyErr);
        }
Exemple #18
0
        public bool Check()
        {
            var logger = new TextLogger(LogSeverity.Warning);

            logger.PutLine("*** Control d’intégrité ***");
            logger.PutLine($"Table: {AppContext.TableManager.Incoterms.Name}");
            logger.PutLine("La contrainte d’intégrité n° 9 est violée par les éléments suivants :");


            bool anyErr = false;

            foreach (string name in m_ndxerNames.Attributes)
            {
                IEnumerable <IDatum> icts = m_ndxerNames.Get(name);

                if (icts.Count() > 1)
                {
                    logger.PutLine($"Noms identiques ({name}):");

                    foreach (Incoterm c in icts)
                    {
                        logger.PutLine(c.ToString());
                    }

                    logger.PutLine();
                    anyErr = true;
                }
            }


            if (anyErr)
            {
                logger.Flush();
            }

            return(!anyErr);
        }
Exemple #19
0
        void Save()
        {
            Assert(!InvokeRequired);

            string ictName = m_tbName.GetInputText();

            if (string.IsNullOrWhiteSpace(ictName))
            {
                this.ShowWarning("Champs monétaire mal servi. Veuillez compléter le formulaire.");
                m_tbName.Select();

                return;
            }


            if (m_incoterm != null && m_incoterm.Name == ictName)
            {
                TextLogger.Info("Aucune modification détectée, enregistrement non-nécessaire.");

                Close();
                return;
            }


            IEnumerable <IDatum> data = m_ndxerNames.Get(ictName.ToUpper());

            int count = data.Count();

            if (count == 0 || (count == 1 && m_incoterm != null && m_incoterm.ID == data.Cast <Incoterm>().Single().ID))
            {
                uint id = m_incoterm == null?AppContext.TableManager.Incoterms.CreateUniqID() :
                              m_incoterm.ID;

                var ict = new Incoterm(id, ictName);

                if (m_incoterm == null)
                {
                    m_ndxerNames.Source.Insert(ict);
                }
                else
                {
                    m_ndxerNames.Source.Replace(m_ndxerNames.IndexOf(m_incoterm.Name.ToUpper()).Single(), ict);
                }

                TextLogger.Info("Enregistrement réussi.");
                Close();
            }
            else
            {
                var logger = new TextLogger(LogSeverity.Warning);
                logger.Put("Duplication de données détectée.");
                logger.Put("Elément trouvé:\n");

                foreach (Incoterm ict in data)
                {
                    logger.PutLine(ict);
                }

                logger.Flush();

                MessageBox.Show("La validation de  données a échouée. " +
                                "Consultez le journal des événements pour plus d’informations.",
                                null,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
            }
        }
Exemple #20
0
        public bool Check()
        {
            //contrainte 2
            var logger = new TextLogger(LogSeverity.Warning);

            logger.PutLine("*** Control d’intégrité ***");
            logger.PutLine($"Table: {AppContext.TableManager.Countries.Name}");
            logger.PutLine("La contrainte d’intégrité n° 2 est violée par les éléments suivants :");

            bool anyErr = false;

            //nom unique
            foreach (string name in m_ndxerName.Attributes)
            {
                IEnumerable <IDatum> countries = m_ndxerName.Get(name);

                if (countries.Count() > 1)
                {
                    logger.PutLine($"Noms identiques ({name}):");

                    foreach (Country c in countries)
                    {
                        logger.PutLine(c.ToString());
                    }

                    logger.PutLine();
                    anyErr = true;
                }
            }


            //code pays unique
            foreach (ushort code in m_ndxerInternalCode.Attributes)
            {
                IEnumerable <IDatum> countries = m_ndxerInternalCode.Get(code);

                if (countries.Count() > 1)
                {
                    logger.PutLine($"Codes pays identiques ({code}):");

                    foreach (Country c in countries)
                    {
                        logger.PutLine(c.ToString());
                    }

                    logger.PutLine();
                    anyErr = true;
                }
            }


            //iso code est nul ou unique
            foreach (string isoCode in  m_ndxerIsoCode.Attributes.Where(s => !string.IsNullOrWhiteSpace(s)))
            {
                IEnumerable <IDatum> countries = m_ndxerIsoCode.Get(isoCode);

                if (countries.Count() > 1)
                {
                    logger.PutLine($"Iso Codes identiques ({isoCode}):");

                    foreach (Country c in countries)
                    {
                        logger.PutLine(c.ToString());
                    }

                    logger.PutLine();
                    anyErr = true;
                }
            }


            if (anyErr)
            {
                logger.Flush();
            }

            return(!anyErr);
        }