public ToughMask(string mask, PriceFormalizationInfo priceInfo) { reGroupName = new string[Enum.GetNames(typeof(NameGroup)).Length]; try { re = new Regex(mask); } catch (Exception e) { throw new WarningFormalizeException(String.Format(Settings.Default.ParseMaskError, e), priceInfo); } foreach (var gname in re.GetGroupNames()) { var gnameU = gname.ToUpper(); foreach (NameGroup ng in Enum.GetValues(typeof(NameGroup))) { var sNG = ng.ToString().ToUpper(); if (gnameU.Equals(sNG)) { if (null == reGroupName[(int)ng]) { reGroupName[(int)ng] = gname; } else { throw new WarningFormalizeException(String.Format(Settings.Default.DoubleGroupMaskError, ng), priceInfo); } break; } } } }
public BasePriceParser(IReader reader, PriceFormalizationInfo priceInfo, bool saveInCore = false) { _logger = LogManager.GetLogger(GetType()); _reader = reader; _priceInfo = priceInfo; _loggingStat = new FormLog(priceInfo); _connection = new MySqlConnection(ConnectionHelper.GetConnectionString()); dsMyDB = new DataSet(); priceItemId = _priceInfo.PriceItemId; parentSynonym = _priceInfo.ParentSynonym; costType = _priceInfo.CostType; string selectCostFormRulesSQL; if (costType == CostTypes.MultiColumn) { selectCostFormRulesSQL = String.Format("select *, (exists(select * from usersettings.pricesregionaldata prd where prd.pricecode=pc.pricecode and prd.basecost=pc.costcode limit 1)) as NewBaseCost from usersettings.PricesCosts pc, farm.CostFormRules cfr where pc.PriceCode={0} and cfr.CostCode = pc.CostCode", _priceInfo.PriceCode); } else { selectCostFormRulesSQL = String.Format("select *, (exists(select * from usersettings.pricesregionaldata prd where prd.pricecode=pc.pricecode and prd.basecost=pc.costcode limit 1)) as NewBaseCost from usersettings.PricesCosts pc, farm.CostFormRules cfr where pc.PriceCode={0} and cfr.CostCode = pc.CostCode and pc.CostCode = {1}", _priceInfo.PriceCode, _priceInfo.CostCode.Value); } var daPricesCost = new MySqlDataAdapter(selectCostFormRulesSQL, _connection); var dtPricesCost = new DataTable("PricesCosts"); daPricesCost.Fill(dtPricesCost); _reader.CostDescriptions = dtPricesCost.Rows.Cast <DataRow>().Select(r => new CostDescription(r)).ToList(); _logger.DebugFormat("Загрузили цены {0}.{1}", _priceInfo.PriceCode, _priceInfo.CostCode); _saveInCore = saveInCore; }
public RollbackFormalizeException(string message, PriceFormalizationInfo priceInfo, FormLog stat) : base(message, priceInfo) { FormCount = (int)stat.Form.GetValueOrDefault(); ZeroCount = (int)stat.Zero.GetValueOrDefault(); UnformCount = (int)stat.UnForm.GetValueOrDefault(); ForbCount = (int)stat.Forb.GetValueOrDefault(); }
public FormalizeException(string message, PriceFormalizationInfo priceInfo) : base(message) { clientCode = priceInfo.FirmCode; priceCode = priceInfo.PriceCode; clientName = priceInfo.FirmShortName; priceName = priceInfo.PriceName; }
public BufferFormalizer(string filename, PriceFormalizationInfo data) : base(filename, data) { if (data.CodePage > 0) { Encoding = Encoding.GetEncoding(data.CodePage); } else { Encoding = Encoding.GetEncoding(1251); } }
public static void NotConfiguredAllert(StringBuilder sb, PriceFormalizationInfo info) { SendAlertToUserFail( sb, "PriceProcessor: В прайс-листе {0} поставщика {1} отсутствуют настроенные поля", @" Здравствуйте! В прайс-листе {0} поставщика {1} отсутствуют настроенные поля. Следующие поля отсутствуют: {2} С уважением, PriceProcessor.", info); }
public static void ToManyZeroCostAlert(StringBuilder stringBuilder, PriceFormalizationInfo info) { SendAlertToUserFail( stringBuilder, "PriceProcessor: В прайс-листе {0} поставщика {1} имеются позиции с незаполненными ценами", @" Здравствуйте! В прайс-листе {0} поставщика {1} имеются позиции с незаполненными ценами. Список ценовых колонок: {2} С уважением, PriceProcessor.", info); }
public static void ZeroCostAlert(StringBuilder stringBuilder, PriceFormalizationInfo info) { SendAlertToUserFail( stringBuilder, "PriceProcessor: В прайс-листе {0} поставщика {1} имеются ценовые колонки, полностью заполненные ценой \"0\"", @" Здравствуйте! В прайс-листе {0} поставщика {1} имеются ценовые колонки, полностью заполненные ценой '0'. Список ценовых колонок: {2} С уважением, PriceProcessor.", info); }
public ExcelParser(string filename, PriceFormalizationInfo data) : base(filename, data) { var row = data.FormRulesData.Rows[0]; Parser = new ExcelReader( row["ListName"].ToString().Replace("$", ""), row["StartLine"] is DBNull ? 0 : Convert.ToInt32(row["StartLine"])); //медицина пишет в срок годносит 1953 год если срок годности не ограничен всякие скальпели и прочее if (data.PriceItemId == 822) { ((ExcelReader)Parser).NullDate = new DateTime(1953, 01, 01); } StringDecoder.DefaultEncoding = Encoding.GetEncoding(1251); }
public PriceReader(IParser parser, string filename, PriceFormalizationInfo info) { _logger.DebugFormat("Создали класс для обработки файла {0}", filename); var priceInfo = info.FormRulesData.Rows[0]; _filename = filename; _parser = parser; _priceInfo = info; fieldNames = new string[Enum.GetNames(typeof(PriceFields)).Length]; var nameMask = priceInfo[FormRules.colNameMask] is DBNull ? String.Empty : (string)priceInfo[FormRules.colNameMask]; awaitPos = priceInfo[FormRules.colSelfAwaitPos].ToString(); junkPos = priceInfo[FormRules.colSelfJunkPos].ToString(); vitallyImportantMask = priceInfo[FormRules.colSelfVitallyImportantMask].ToString(); toughDate = new ToughDate(); if (String.Empty != nameMask) { toughMask = new ToughMask(nameMask, info); } //Производим попытку разобрать строку с "запрещенными выражениями" var forbWords = priceInfo[FormRules.colForbWords] is DBNull ? String.Empty : (string)priceInfo[FormRules.colForbWords]; forbWords = forbWords.Trim(); if (String.Empty != forbWords) { forbWordsList = forbWords.Split(new[] { ' ' }).Where(w => !String.IsNullOrWhiteSpace(w)).ToArray(); if (forbWordsList.Length == 0) { forbWordsList = null; } } foreach (PriceFields pf in Enum.GetValues(typeof(PriceFields))) { var tmpName = (PriceFields.OriginalName == pf) ? "FName1" : "F" + pf; SetFieldName(pf, priceInfo[tmpName] is DBNull ? String.Empty : (string)priceInfo[tmpName]); } }
public FixedTextParser(string filename, PriceFormalizationInfo data) : base(filename, data) { Parser = new TextParser(new PositionSlicer(data.FormRulesData, data), Encoding, -1); }
public DelimiterTextParser(string filename, PriceFormalizationInfo data) : base(filename, data) { }
public PriceDbfParser(string filename, PriceFormalizationInfo data) : base(filename, data) { Parser = new DbfReader(data.Price.IsStrict, data.CodePage); }
public WarningFormalizeException(string message, PriceFormalizationInfo info) : base(message, info) { }
public static void SendAlertToUserFail(StringBuilder stringBuilder, string subject, string body, PriceFormalizationInfo info) { if (stringBuilder.Length == 0) { return; } string fullPriceName; if (info.CostType == CostTypes.MultiColumn) { fullPriceName = info.PriceName; } else { fullPriceName = String.Format("[Колонка] {0}", info.CostName); } var fullSupplierName = String.Format("{0} - {1}", info.FirmShortName, info.Region); subject = String.Format(subject, fullPriceName, fullSupplierName); body = String.Format( body, fullPriceName, fullSupplierName, stringBuilder); _logger.DebugFormat("Сформировали предупреждение о настройках формализации прайс-листа: {0}", body); Mailer.SendUserFail(subject, body); }