private static void ReadCardRequisites(ComponentModel model, Dialog entity, string componentFolderPath) { if (model.DetailDataSets?.DetailDataSet1 == null) return; foreach (var row in model.DetailDataSets.DetailDataSet1.Rows) { var cardRequisite = new CardRequisite(); var numberReq = row.Requisites .FirstOrDefault(r => r.Code == ReqNumberReqName); if (!string.IsNullOrEmpty(numberReq?.Value)) cardRequisite.Number = int.Parse(numberReq.Value); var sectionReq = row.Requisites .FirstOrDefault(r => r.Code == ReqSectionReqName); if (sectionReq != null) cardRequisite.Section = RequisiteHandlerUtils.GetRequisiteSection(sectionReq.ValueLocalizeID); var nameReq = row.Requisites .FirstOrDefault(r => r.Code == ReqNameReqName); if (nameReq != null) cardRequisite.Name = nameReq.Value; var isRequiredReq = row.Requisites .FirstOrDefault(r => r.Code == ReqIsRequiredReqName); if (isRequiredReq != null) cardRequisite.IsRequired = isRequiredReq.ValueLocalizeID == YesValue; var isLastValueSavedReq = row.Requisites .FirstOrDefault(r => r.Code == ReqIsLastValueSavedReqName); if (isLastValueSavedReq != null) cardRequisite.IsLastValueSaved = isLastValueSavedReq.ValueLocalizeID == YesValue; var isSelectionConstrainedReq = row.Requisites .FirstOrDefault(r => r.Code == ReqIsSelectionConstrainedReqName); if (isSelectionConstrainedReq != null) cardRequisite.IsSelectionConstrained = isSelectionConstrainedReq.ValueLocalizeID == YesValue; var requisiteEventsFolder = Path.Combine(componentFolderPath, "Requisites", cardRequisite.Name); if (Directory.Exists(requisiteEventsFolder)) { foreach (var eventFile in Directory.EnumerateFiles(requisiteEventsFolder, "*.isbl")) { var eventName = Path.GetFileNameWithoutExtension(eventFile); var eventType = EventTypeResolver.GetExportedEventType(eventName); var calculationText = File.ReadAllText(eventFile, Encoding.GetEncoding(1251)); cardRequisite.Events.Add(new Event { EventType = eventType, CalculationText = calculationText }); } } entity.Requisites.Add(cardRequisite); } }
protected override IEnumerable <DocumentRequisite> ReadComponents(ComponentModel model, string componentFolderPath) { var entity = PackageHandlerUtils.CreateEntity <DocumentRequisite>(model); var fieldReq = model.Card.Requisites .FirstOrDefault(r => r.Code == FieldReqName); if (fieldReq != null) { entity.Field = fieldReq.Value; } var sectionReq = model.Card.Requisites .FirstOrDefault(r => r.Code == SectionReqName); if (sectionReq != null) { entity.Section = RequisiteHandlerUtils.GetRequisiteSection(sectionReq.ValueLocalizeID); } var typeReq = model.Card.Requisites .FirstOrDefault(r => r.Code == TypeReqName); if (typeReq != null) { entity.Type = RequisiteHandlerUtils.GetRequisiteType(typeReq.ValueLocalizeID); } var formatReq = model.Card.Requisites .FirstOrDefault(r => r.Code == FormatReqName); if (formatReq != null) { entity.Format = RequisiteHandlerUtils.GetRequisiteFormat(formatReq.ValueLocalizeID); } var lengthReq = model.Card.Requisites .FirstOrDefault(r => r.Code == LengthReqName); if (!string.IsNullOrEmpty(lengthReq?.Value)) { entity.Length = int.Parse(lengthReq.Value); } var precissionReq = model.Card.Requisites .FirstOrDefault(r => r.Code == PrecissionReqName); if (!string.IsNullOrEmpty(precissionReq?.Value)) { entity.Precission = int.Parse(precissionReq.Value); } var referenceTypeReq = model.Card.Requisites .FirstOrDefault(r => r.Code == ReferenceTypeReqName); if (referenceTypeReq != null) { entity.ReferenceType = referenceTypeReq.Value; } var referenceViewReq = model.Card.Requisites .FirstOrDefault(r => r.Code == ReferenceViewReqName); if (referenceViewReq != null) { entity.ReferenceView = referenceViewReq.Value; } var pickValuesReq = model.Card.Requisites .FirstOrDefault(r => r.Code == PickValuesReqName); if (!string.IsNullOrEmpty(pickValuesReq?.Value)) { var pickValues = pickValuesReq.Value.Split(';'); foreach (var pickValue in pickValues) { var pickValueParts = pickValue.Split('=', '|'); var reqPickValue = new RequisitePickValue { Id = pickValueParts[0][0], Value = pickValueParts[1] }; entity.PickValues.Add(reqPickValue); } } var isStoredReq = model.Card.Requisites .FirstOrDefault(r => r.Code == IsStoredReqName); if (isStoredReq != null) { entity.IsStored = isStoredReq.ValueLocalizeID == Stored; } var isGeneratedReq = model.Card.Requisites .FirstOrDefault(r => r.Code == IsGeneratedReqName); if (isGeneratedReq != null) { entity.IsGenerated = isGeneratedReq.ValueLocalizeID == Generated; } yield return(entity); }