protected override IEnumerable <StandardRoute> ReadComponents(RecordRefModel model, string componentFolderPath)
        {
            var route = new StandardRoute
            {
                Name  = model.Code,
                Title = model.Name
            };
            var stateReq = model.Requisites
                           .FirstOrDefault(r => r.Name == StateReqName);

            if (stateReq != null)
            {
                route.State = stateReq.Value == StateActiveRequisiteValue ? ComponentState.Active : ComponentState.Closed;
            }
            var descriptionFile = Path.Combine(componentFolderPath, "Properties.xml");

            if (File.Exists(descriptionFile))
            {
                var descriptionData = File.ReadAllText(descriptionFile, Encoding.GetEncoding(1251));
                route.WorkflowDescription = WorkflowDescriptionParser.Parse(descriptionData);
                ReadActions(route.WorkflowDescription, componentFolderPath);
                ReadBlocks(route.WorkflowDescription, componentFolderPath);
                ReadEvents(route.WorkflowDescription, componentFolderPath);
            }
            else
            {
                log.Warn($"File not found {descriptionFile}");
            }

            yield return(route);
        }
Ejemplo n.º 2
0
        public IEnumerable <RouteBlock> Read(SqlConnection connection, Version platformVersion)
        {
            var components = new List <RouteBlock>();

            var query = this.GetRouteBlockQuery(platformVersion);

            if (string.IsNullOrEmpty(query))
            {
                return(components);
            }

            var command = new SqlCommand(query, connection);

            using (var reader = command.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        var routeBlock = new RouteBlock
                        {
                            Name  = reader["Name"] as string,
                            Title = reader["Title"] as string
                        };
                        if (ActiveValue.Equals(reader["State"] as string))
                        {
                            routeBlock.State = ComponentState.Active;
                        }
                        else
                        {
                            routeBlock.State = ComponentState.Closed;
                        }
                        if (Enum.TryParse(reader["BaseBlockType"] as string, out RouteBlockType blockType))
                        {
                            routeBlock.BaseBlockType = blockType;
                        }
                        else
                        {
                            routeBlock.BaseBlockType = RouteBlockType.Unknown;
                        }
                        if (reader["Properties"] is byte[] blockDescriptionRawData)
                        {
                            var blockDescription = Encoding.GetEncoding(1251).GetString(blockDescriptionRawData);
                            if (!string.IsNullOrWhiteSpace(blockDescription))
                            {
                                var description = WorkflowDescriptionParser.Parse(blockDescription);
                                routeBlock.WorkflowBlock = description.Blocks.FirstOrDefault();
                            }
                        }
                        components.Add(routeBlock);
                    }
                }
            }
            return(components);
        }
Ejemplo n.º 3
0
        protected override IEnumerable <RouteBlock> ReadComponents(ComponentModel model, string componentFolderPath)
        {
            var entity = PackageHandlerUtils.CreateEntity <RouteBlock>(model);

            var stateReq = model.Card.Requisites
                           .FirstOrDefault(r => r.Code == StateReqName);

            if (stateReq != null)
            {
                entity.State = stateReq.ValueLocalizeID == Active ? ComponentState.Active : ComponentState.Closed;
            }

            var baseBlockTypeReq = model.Card.Requisites
                                   .FirstOrDefault(r => r.Code == BaseBlockTypeReqName);

            if (baseBlockTypeReq != null)
            {
                entity.BaseBlockType = RouteBlockUtils.GetBaseBlockType(baseBlockTypeReq.ValueLocalizeID);
            }
            else
            {
                entity.BaseBlockType = RouteBlockType.Unknown;
            }

            var blockPropertiesFile = Path.Combine(componentFolderPath, "Properties.xml");

            if (File.Exists(blockPropertiesFile))
            {
                var blockProperties = File.ReadAllText(blockPropertiesFile, Encoding.GetEncoding(1251));
                var description     = WorkflowDescriptionParser.Parse(blockProperties);
                entity.WorkflowBlock = description.Blocks.FirstOrDefault();
                if (entity.WorkflowBlock != null)
                {
                    ReadActions(entity.WorkflowBlock, componentFolderPath);
                    ReadEvents(entity.WorkflowBlock, componentFolderPath);
                    ReadProperties(entity.WorkflowBlock, componentFolderPath);
                }
                else
                {
                    log.Warn($"Cannot read properties for block {entity.Name}");
                }
            }
            else
            {
                log.Warn($"File not found {blockPropertiesFile}");
            }

            yield return(entity);
        }
Ejemplo n.º 4
0
        public IEnumerable <StandardRoute> Read(SqlConnection connection, Version platformVersion)
        {
            var components = new List <StandardRoute>();

            var query = this.GetStandardRouteQuery(platformVersion);

            if (string.IsNullOrEmpty(query))
            {
                return(components);
            }

            var command = new SqlCommand(query, connection);

            using (var reader = command.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        var standardRoute = new StandardRoute
                        {
                            Name  = (reader["Name"] as string).Trim(),
                            Title = (reader["Title"] as string).Trim()
                        };
                        if (ActiveValue.Equals(reader["State"] as string))
                        {
                            standardRoute.State = ComponentState.Active;
                        }
                        else
                        {
                            standardRoute.State = ComponentState.Closed;
                        }
                        if (reader["WorkflowDescription"] is byte[] workflowDescriptionRawData)
                        {
                            var workflowDescription = Encoding.GetEncoding(1251).GetString(workflowDescriptionRawData);
                            if (!string.IsNullOrWhiteSpace(workflowDescription))
                            {
                                standardRoute.WorkflowDescription = WorkflowDescriptionParser.Parse(workflowDescription);
                            }
                        }
                        components.Add(standardRoute);
                    }
                }
            }
            return(components);
        }
Ejemplo n.º 5
0
        public IEnumerable <RouteBlock> Read(ComponentsModel packageModel)
        {
            foreach (var model in packageModel.RouteBlocks)
            {
                var entity = PackageHandlerUtils.CreateEntity <RouteBlock>(model);

                var stateReq = model.Card.Requisites
                               .FirstOrDefault(r => r.Code == StateReqName);
                if (stateReq != null)
                {
                    entity.State = stateReq.ValueLocalizeID == Active ? ComponentState.Active : ComponentState.Closed;
                }

                var baseBlockTypeReq = model.Card.Requisites
                                       .FirstOrDefault(r => r.Code == BaseBlockTypeReqName);
                if (baseBlockTypeReq != null)
                {
                    entity.BaseBlockType = RouteBlockUtils.GetBaseBlockType(baseBlockTypeReq.ValueLocalizeID);
                }
                else
                {
                    entity.BaseBlockType = RouteBlockType.Unknown;
                }

                var blockPropertiesReq = model.Card.Requisites
                                         .FirstOrDefault(r => r.Code == BlockPropertiesReqName);
                if (blockPropertiesReq != null)
                {
                    var blockProperties = blockPropertiesReq.DecodedText;
                    if (!string.IsNullOrWhiteSpace(blockProperties))
                    {
                        var description = WorkflowDescriptionParser.Parse(blockProperties);
                        entity.WorkflowBlock = description.Blocks.FirstOrDefault();
                    }
                }

                yield return(entity);
            }
        }