private static void ReadActions(WorkflowBlock block, string blocksFolderPath)
 {
     foreach (var action in block.Actions)
     {
         var actionFile = Path.Combine(blocksFolderPath, "Actions", $"{action.Name}.isbl");
         if (File.Exists(actionFile))
         {
             action.CalculationText = File.ReadAllText(actionFile, Encoding.GetEncoding(1251));
         }
         else
         {
             log.Warn($"File not found {actionFile}");
         }
     }
 }
 private static void ReadProperties(WorkflowBlock block, string blocksFolderPath)
 {
     foreach (var property in block.IsblProperties)
     {
         if (blockEventFileNames.TryGetValue(property.Name, out string propertyFileName))
         {
             var propertyCalculationFile = Path.Combine(blocksFolderPath, "Events", propertyFileName);
             if (File.Exists(propertyCalculationFile))
             {
                 property.CalculationText = File.ReadAllText(propertyCalculationFile, Encoding.GetEncoding(1251));
             }
             //else
             //  log.Warn($"File not found {propertyCalculationFile}");
         }
         else
         {
             log.Warn($"Unknown block ISBL property {property.Name}");
         }
     }
 }
 private static void ReadEvents(WorkflowBlock block, string blocksFolderPath)
 {
     foreach (var @event in block.Events)
     {
         if (blockEventFileNames.TryGetValue(@event.Name, out string eventFileName))
         {
             var eventFile = Path.Combine(blocksFolderPath, "Events", eventFileName);
             if (File.Exists(eventFile))
             {
                 @event.CalculationText = File.ReadAllText(eventFile, Encoding.GetEncoding(1251));
             }
             //else
             //  log.Warn($"File not found {eventFile}");
         }
         else
         {
             log.Warn($"Unknown event {@event.Name}");
         }
     }
 }
        private static WorkflowBlock ParseBlock(XElement blockElement)
        {
            var block = new WorkflowBlock {
                Id = blockElement.Attribute("ID")?.Value ?? string.Empty
            };

            if (!Enum.TryParse(blockElement.Attribute("SystemType")?.Value, out RouteBlockType baseBlockType))
            {
                baseBlockType = RouteBlockType.Unknown;
            }
            block.BaseBlockType = baseBlockType;

            var properties = blockElement.Element("Properties")?.Elements("Property");

            if (properties != null)
            {
                var nameProperty = properties.FirstOrDefault(p => p.Attribute("Name")?.Value == "Name");
                if (nameProperty != null)
                {
                    block.Name = GetTextPropertyValue(nameProperty) ?? string.Empty;
                }
                else
                {
                    block.Name = string.Empty;
                }

                foreach (var p in properties.Where(p => p.Attribute("ValueType")?.Value == "2"))
                {
                    var propName        = p.Attribute("Name").Value;
                    var propTitle       = p.Attribute("Description").Value;
                    var calculationText = GetTextPropertyValue(p) ?? string.Empty;
                    if (IsBlockEvent(propName, baseBlockType))
                    {
                        block.Events.Add(new WorkflowEvent
                        {
                            Name            = propName,
                            Title           = propTitle,
                            CalculationText = calculationText
                        });
                    }
                    else
                    {
                        block.IsblProperties.Add(new WorklflowIsblProperty
                        {
                            Name            = propName,
                            Title           = propTitle,
                            CalculationText = calculationText
                        });
                    }
                }
            }

            var actions = blockElement.Element("Actions")?.Elements("Action");

            if (actions != null)
            {
                foreach (var action in actions)
                {
                    block.Actions.Add(ParseAction(action));
                }
            }

            return(block);
        }