Beispiel #1
0
    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);
      }
    }
Beispiel #2
0
    private static void ReadEvents(Dialog entity, string componentFolderPath)
    {
      var eventsTextsFolder = Path.Combine(componentFolderPath, "Events");
      if (!Directory.Exists(eventsTextsFolder))
        return;

      foreach (var eventFile in Directory.EnumerateFiles(eventsTextsFolder, "*.isbl"))
      {
        var eventName = Path.GetFileNameWithoutExtension(eventFile);
        var eventType = EventTypeResolver.GetExportedEventType(eventName);
        var calculationText = File.ReadAllText(eventFile, Encoding.GetEncoding(1251));
        entity.Events.Add(new Event
        {
          EventType = eventType,
          CalculationText = calculationText
        });
      }
    }