public void FormalizeWithStrictTest() { var rules = PricesValidator.LoadFormRules(_testPrice.Costs[0].PriceItem.Id); var row = rules.NewRow(); row[FormRules.colFirmCode] = 0; row[FormRules.colPriceCode] = _testPrice.Id; row[FormRules.colFormByCode] = 0; row[FormRules.colCostType] = _testPrice.CostType; row[FormRules.colPriceType] = _testPrice.PriceType; row[FormRules.colPriceItemId] = _testPrice.Costs[0].PriceItem.Id; row[FormRules.colParentSynonym] = 0; row["BuyingMatrix"] = 0; row["PriceEncode"] = _testPrice.Costs[0].PriceItem.Format.PriceEncode; rules.Rows.Add(row); var price = session.Query <Price>().FirstOrDefault(p => p.Id == _testPrice.Id); price.IsStrict = false; session.Save(price); Reopen(); var info = new PriceFormalizationInfo(row, price); var parser = new PriceDbfParser(@"..\..\Data\BadTestFile.dbf", info); parser.Formalize(); Assert.AreEqual(info.CodePage, 1251); }
public IList <string> GetAllNames() { var names = new List <string>(); using (var reader = new FarmaimpeksReader(_fileName)) { foreach (var parsedPrice in reader.Prices()) { var priceInfo = _data.Rows[0]; var supplierId = Convert.ToUInt32(priceInfo["FirmCode"]); PriceCost cost; using (new SessionScope(FlushAction.Never)) { cost = PriceCost.Queryable.FirstOrDefault( c => c.Price.Supplier.Id == supplierId && c.CostName == parsedPrice.Id); } if (cost == null) { _log.WarnFormat( "Не смог найти прайс лист у поставщика {0} с именем '{1}', пропуская этот прайс", Info.FirmShortName, parsedPrice.Id); continue; } var info = new PriceFormalizationInfo(priceInfo, cost.Price); var parser = new BasePriceParser(reader, info); parser.Downloaded = Downloaded; names.AddRange(reader.Read() .Where(x => !String.IsNullOrWhiteSpace(x.PositionName)).Select(x => x.PositionName)); } } return(names); }
private IPriceFormalizer CreateFormalizer() { var table = PricesValidator.LoadFormRules(priceItem.Id); var row = table.Rows[0]; var localPrice = session.Load <Price>(price.Id); var info = new PriceFormalizationInfo(row, localPrice); return(new BufferFormalizer(file, info)); }
public void Base_buffer_formalize_fixture() { var info = new PriceFormalizationInfo(); var formalizer = new TestFormalizer("test", info); Assert.AreEqual(formalizer.CodePage.CodePage, 1251); info.CodePage = 866; formalizer = new TestFormalizer("test", info); Assert.AreEqual(formalizer.CodePage.CodePage, 866); }
public static IPriceFormalizer CreateFormalizer(string fileName, DataRow dataRow, Type parserClass) { PriceFormalizationInfo priceInfo = null; SessionHelper.StartSession(s => { var price = s.Load <Price>(Convert.ToUInt32(dataRow[FormRules.colPriceCode])); NHibernateUtil.Initialize(price); priceInfo = new PriceFormalizationInfo(dataRow, price); }); return(With.Connection(c => (IPriceFormalizer)Activator.CreateInstance(parserClass, new object[] { fileName, priceInfo }))); }
public void Price_formalizer_info() { var row = GetFormRuleRow(); row[FormRules.colPriceEncode] = 866; var info = new PriceFormalizationInfo(row, new Price()); Assert.AreEqual(info.CodePage, 866); row[FormRules.colPriceEncode] = DBNull.Value; info = new PriceFormalizationInfo(row, new Price()); Assert.AreEqual(info.CodePage, 0); }
public static string InsertOfferSql(PriceFormalizationInfo info, NewOffer offer) { var command = new StringBuilder(); command.Append("insert into farm.Core0(PriceCode,") .Append(Mapping.OfferMapping.Select(m => m.Name).Implode()) .Append(") values (") .Append(info.PriceCode + ",") .Append(Mapping.OfferMapping.Select(m => ToSql(m.GetValue(offer))).Implode()) .Append(");") .Append("set @LastCoreID = last_insert_id();"); return(command.ToString()); }
public void Setup() { costDescriptions = new List <CostDescription>(); table = new DataTable(); table.Columns.Add("F1"); table.Columns.Add("F2"); var row = table.NewRow(); row["F1"] = "Папаверин"; row["F2"] = "50"; table.Rows.Add(row); info = PriceFormalizationInfoFixture.FakeInfo(); info.FormRulesData.Rows[0]["FName1"] = "F1"; }
public FormLog(PriceFormalizationInfo priceInfo) { Host = Environment.MachineName; PriceItemId = (uint?)priceInfo.PriceItemId; InsertCoreCount = 0; UpdateCoreCount = 0; DeleteCoreCount = 0; InsertCostCount = 0; UpdateCostCount = 0; DeleteCostCount = 0; Form = 0; Zero = 0; UnForm = 0; Forb = 0; }
public static PriceFormalizationInfo FakeInfo() { var table = new DataTable(); table.Columns.Add("region"); table.Columns.Add("CostName"); table.Columns.Add("SelfPriceName"); table.Columns.Add("FirmShortName"); table.Columns.Add("FirmCode"); table.Columns.Add("CostCode"); table.Columns.Add("PriceCode"); table.Columns.Add("FormByCode"); table.Columns.Add("CostType"); table.Columns.Add("PriceType"); table.Columns.Add("PriceItemId"); table.Columns.Add("ParentSynonym"); table.Columns.Add("RowCount"); var field = typeof(FormRules).GetFields(BindingFlags.Static | BindingFlags.Public); foreach (var fieldInfo in field) { var value = (String)fieldInfo.GetValue(null); if (!table.Columns.Contains(value)) { table.Columns.Add(value); } } foreach (PriceFields pf in Enum.GetValues(typeof(PriceFields))) { var name = (PriceFields.OriginalName == pf) ? "FName1" : "F" + pf; if (!table.Columns.Contains(name)) { table.Columns.Add(name); } } var row = table.Rows.Add("1", "", "", "", "1", "1", "1", false, 0, 1, 2, 1, 0); var info = new PriceFormalizationInfo(row, new Price { IsUpdate = true }); return(info); }
private void FakeParserSynonymTest(bool automatic, int automaticProducerSynonyms) { if (session.Transaction.IsActive) { session.Transaction.Commit(); } var table = PricesValidator.LoadFormRules(priceItem.Id); var row = table.Rows[0]; var info = new PriceFormalizationInfo(row, session.Load <Price>(price.Id)); var parser = new FakeParser(new FakeReader(), info); if (parser.Connection.State != ConnectionState.Open) { parser.Connection.Open(); } FillDaSynonymFirmCr2(parser, (MySqlConnection)session.Connection, automatic); parser.Connection.Close(); var counter = session.Connection.CreateCommand(); counter.CommandText = "select count(*) from AutomaticProducerSynonyms"; Assert.That(Convert.ToInt32(counter.ExecuteScalar()), Is.EqualTo(automaticProducerSynonyms)); }
public FarmaimpeksOKPFormalizer(string filename, PriceFormalizationInfo data) : base(filename, data) { }
public PositionSlicer(DataTable table, PriceFormalizationInfo info) { _table = table; _info = info; }
public UniversalFormalizer(string filename, PriceFormalizationInfo data) : base(filename, data) { }
private void GetBody(string mSubjPref, ref string add, ref string subj, ref string body, PriceFormalizationInfo info) { if (info == null) { subj = mSubjPref; body = $@"Файл : {Path.GetFileName(_processItem.FilePath)} Дата события : {DateTime.Now} Ошибка : {add}"; add = body; } else { var name = $"{info.FirmShortName} ({info.PriceName})"; subj = $"{mSubjPref} {info.PriceCode}"; body = $@"Код фирмы : {info.FirmCode} Код прайса : {info.PriceCode} Название прайса : {name} Дата события : {DateTime.Now} Ошибка : {add}"; } }
public TestTextParser(string filename, PriceFormalizationInfo data) : base(filename, data) { }
public BaseFormalizer(string filename, PriceFormalizationInfo data) { Info = data; _fileName = filename; _data = data.FormRulesData; }
public FakeParser(IReader reader, PriceFormalizationInfo priceInfo) : base(reader, priceInfo) { }