예제 #1
0
        public void ResolveProducer(DataRow item, uint producerId)
        {
            var table      = item.Table;
            var assortment = LoadAssortmentByProducer(producerId);

            var synonym = ProducerSynonym.CreateSynonym(item, producerId);

            var loadedSynonym = LoadSynonym()
                                .Where("sfc.Synonym = ?Name && sfc.CodeFirmCr = ?ProducerId", new { synonym.Name, synonym.ProducerId })
                                .SingleOrDefault(ProducerSynonym.CreateSynonym);

            if (loadedSynonym != null)
            {
                synonym = loadedSynonym;
            }
            else
            {
                synonyms.Add(synonym);
            }

            for (var i = 0; i < table.Rows.Count; i++)
            {
                var row = table.Rows[i];
                if (synonym.IsApplicable(row, assortment))
                {
                    synonym.Apply(row);
                }
            }
        }
예제 #2
0
        public void ResolveProduct(DataRow item, DataRow product, bool markAsJunk)
        {
            var  productId           = Convert.ToUInt32(product["Id"]);
            var  catalogId           = Convert.ToUInt32(product["CatalogId"]);
            var  pharmacie           = Convert.ToBoolean(product["Pharmacie"]);
            uint?monobrendProducerId = null;

            if (!(product["MonobrendProducerId"] is DBNull))
            {
                monobrendProducerId = Convert.ToUInt32(product["MonobrendProducerId"]);
            }

            var table = item.Table;
            var name  = item["UEName1"].ToString().Trim();

            var producer           = item["UEFirmCr"].ToString();
            var applicableSynonyms = GetSynonyms(producer)
                                     .Concat(synonyms.Where(s => String.Equals(s.Name, producer, StringComparison.CurrentCultureIgnoreCase)))
                                     .ToList();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                var row = table.Rows[i];
                if (String.Equals(name, GetName(row), StringComparison.CurrentCultureIgnoreCase))
                {
                    if (((FormMask)Convert.ToByte(row["UEStatus"]) & FormMask.NameForm) != FormMask.NameForm)
                    {
                        //TODO: Здесь потребуется завести дополнительный столбец в таблицу нераспознанных выражений
                        row["UEStatus"]         = (int)((FormMask)Convert.ToByte(row["UEStatus"]) | FormMask.NameForm);
                        row["UEJunk"]           = Convert.ToByte(markAsJunk);
                        row["UEPriorProductId"] = productId;
                        row["UEPriorCatalogId"] = catalogId;
                        row["Pharmacie"]        = pharmacie;

                        TryToPickProducerSynonym(row, applicableSynonyms);

                        if (monobrendProducerId != null &&
                            ((FormMask)Convert.ToByte(row["UEStatus"]) & FormMask.FirmForm) != FormMask.FirmForm)
                        {
                            var synonym = ProducerSynonym.CreateSynonym(item, monobrendProducerId.Value);
                            applicableSynonyms.Add(synonym);
                            synonyms.Add(synonym);
                            synonym.Apply(item);
                        }
                    }
                }
            }
        }
예제 #3
0
        public void CreateSynonym(DataTable synonyms, ProducerSynonym synonym)
        {
            if (synonym.Loaded)
            {
                return;
            }
            var synonymRow = synonyms.NewRow();

            UpdateSynonym(synonymRow, synonym);
            synonymRow["Synonym"] = synonym.Name;
            try {
                synonyms.Rows.Add(synonymRow);
                stat.SynonymFirmCrCount++;
            }
            catch (ConstraintException) {
            }
        }
예제 #4
0
        private void UpdateSynonym(DataRow synonym, ProducerSynonym producerSynonym)
        {
            if (!(synonym["Processed"] is DBNull) && Convert.ToBoolean(synonym["Processed"]))
            {
                CreateSynonym(synonym.Table, producerSynonym);
                return;
            }

            if (producerSynonym.ProducerId > 0)
            {
                synonym["CodeFirmCr"] = producerSynonym.ProducerId;
            }
            else
            {
                synonym["CodeFirmCr"] = DBNull.Value;
            }
            synonym["PriceCode"]    = priceId;
            synonym["SupplierCode"] = producerSynonym.SupplierCode;
            synonym["Processed"]    = true;
            if (priceId != childPriceId)
            {
                synonym["ChildPriceCode"] = childPriceId;
            }
        }