Esempio n. 1
0
        private void AddChildrenExportAllBlocksExportTable(ExportTable.AllBlocksExportTableDataTable exportTable, Dictionary<String, Block> AllBlocks)
        {
            foreach (string key in AllBlocks.Keys)
            {
                Block blk = AllBlocks[key];
                // Fill block parameters
                if (blk.Name.ToLower().StartsWith("db"))
                {
                    S7DataBlock lblk = (S7DataBlock)blk.BlockContents;
                    ExportTable.AllBlocksExportTableRow newRow = exportTable.NewAllBlocksExportTableRow();

                    newRow.Number = "\"" + blk.Name + "\"";
                    newRow.Name = "\"" + blk.SymbolicName + "\"";
                    newRow.Path = "\"" + key + "\"";
                    newRow.Type = "\"" + "DB" + "\"";
                    newRow.Language = "\"" + "STL" + "\"";

                    newRow.Comment = "\"";
                    if (lblk.Title != null && lblk.Title != "")
                    {
                        newRow.Comment = "\"" + ClearString(lblk.Title) + "\"";
                    }
                    newRow.Comment = newRow.Comment + "\"";

                    newRow.Size = "\"" + blk.Size.ToString() + "\"";

                    if (lblk.Version != null)
                    {
                        newRow.Version = "\"" + lblk.Version + "\"";
                    }
                    else
                    {
                        newRow.Version = "\"0.0\"";
                    }

                    newRow.LastModified = "\"" + blk.Modified.ToString("yyyy-MM-dd HH:mm:ss") + "\"";
                    exportTable.AddAllBlocksExportTableRow(newRow);
                }
                else if ( blk.Name.ToLower().StartsWith("fb") || blk.Name.ToLower().StartsWith("fc") || blk.Name.ToLower().StartsWith("ob") )
                {
                    S7FunctionBlock lblk = (S7FunctionBlock)blk.BlockContents;
                    ExportTable.AllBlocksExportTableRow newRow = exportTable.NewAllBlocksExportTableRow();

                    newRow.Number = "\"" + blk.Name + "\"";
                    newRow.Name = "\"" + blk.SymbolicName + "\"";
                    newRow.Path = "\"" + key + "\"";
                    newRow.Type = "\"" + lblk.BlockType.ToString() + "\"";
                    newRow.Language = "\"" + lblk.BlockLanguage.ToString() + "\"";

                    newRow.Comment = "\"";
                    if (lblk.Title != null && lblk.Title != "")
                    {
                        newRow.Comment = newRow.Comment + ClearString(lblk.Title);
                    }
                    if (lblk.Description != null && lblk.Description != "")
                    {
                        newRow.Comment = newRow.Comment + ". " + ClearString(lblk.Description);
                    }
                    newRow.Comment = newRow.Comment + "\"";

                    newRow.Size = "\"" + blk.Size + "\"";

                    if (lblk.Version != null)
                    {
                        newRow.Version = "\"" + lblk.Version + "\"";
                    }
                    else
                    {
                        newRow.Version = "\"0.0\"";
                    }

                    newRow.LastModified = "\"" + blk.Modified.ToString("yyyy-MM-dd HH:mm:ss") + "\"";
                    exportTable.AddAllBlocksExportTableRow(newRow);
                }
            }
        }