コード例 #1
0
        private void wordAddCfgObjectTable <TCfgObj>(
            string[] queries, string[] headers,
            ICollection <TCfgObj> cfgObjects)
            where TCfgObj : ICfgObject
        {
            Word.Table   table         = wordAddTable(cfgObjects.Count + 1, queries.Length);
            Word.Shading headerShading = table.Rows[1].Shading;
            headerShading.Texture = Word.WdTextureIndex.wdTextureSolid;

            bool moveRight = false;

            foreach (string header in headers)
            {
                if (moveRight)
                {
                    wordMoveToCellRight();
                }
                else
                {
                    moveRight = true;
                }

                word.Selection.TypeText(header);
            }

            foreach (ICfgObject cfgObject in cfgObjects)
            {
                foreach (string query in queries)
                {
                    wordMoveToCellRight();
                    word.Selection.TypeText(
                        CfgObjectUtil.Query(cfgObject, query).ToString());
                }
            }

            table.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
        }
コード例 #2
0
        public void Generate(CfgSystem system)
        {
            createFile(FilePath, CfgDoc.Properties.Resources.WordRunBookTemplate);

            word         = new Word.Application();
            word.Visible = true;
            doc          = wordOpen(FilePath);

            ICollection <CfgHost> hosts = system.Hosts;

            string[] headers;
            string[] queries;

            wordGotoBookmark("HostsList");

            headers = new string[] {
                "DBID", "Name", "IP Address", "OS", "OS version", "LCA Port"
            };
            queries = new string[] {
                "dbid", "name", "ip_address", "(enum)os_type", "os_version", "lca_port"
            };

            wordAddCfgObjectTable(queries, headers, system.Hosts);

            wordGotoBookmark("ServersList");

            headers = new string[] {
                "Host name", "App name"
            };
            queries = new string[] {
                "host_dbid.name", "app_dbid.name"
            };

            wordAddCfgObjectTable(queries, headers, system.Servers);

            wordGotoBookmark("DapsList");

            headers = new string[] {
                "Host name", "App name"
            };
            queries = new string[] {
                "host_dbid.name", "app_dbid.name"
            };

            wordAddCfgObjectTable(queries, headers, system.Servers);

            wordGotoBookmark("DNsList");

            foreach (var switch_ in system.Switches)
            {
                wordSetStyleHeading(2);
                word.Selection.TypeText(switch_.Name);
                word.Selection.TypeParagraph();

                headers = new string[] {
                    "Number", "Type", "Annex options"
                };
                queries = new string[] {
                    "number_", "(enum)type", "(flexprops)cfg_flex_prop_DN"
                };

                wordAddCfgObjectTable(queries, headers, switch_.DNs);

                word.Selection.Move(Word.WdUnits.wdLine, 2);
            }

            wordGotoBookmark("TenantsList");

            foreach (var tenant in system.Tenants)
            {
                wordSetStyleHeading(2);
                word.Selection.TypeText(tenant.Name);
                word.Selection.TypeParagraph();

                wordSetStyleNormal();
                word.Selection.TypeText((string)CfgObjectUtil.Query(tenant, "(flexprops)cfg_flex_prop_Tenant"));
            }

            wordGotoBookmark("ServerOptions");

            foreach (CfgHost host in system.Hosts)
            {
                wordSetStyleHeading(2);
                word.Selection.TypeText(host.Name);
                word.Selection.TypeParagraph();

                foreach (CfgServer server in host.Servers)
                {
                    wordSetStyleHeading(3);
                    word.Selection.TypeText(server.Application.Name);
                    word.Selection.TypeParagraph();

                    wordSetStyleHeading(4);
                    word.Selection.TypeText("Options");
                    word.Selection.TypeParagraph();

                    wordSetStyleNormal();
                    word.Selection.TypeText(CfgObjectUtil.OptionsToString(server.Application.Options));

                    if (server.Application.FlexProperties.Count != 0)
                    {
                        wordSetStyleHeading(4);
                        word.Selection.TypeText("Annex options");
                        word.Selection.TypeParagraph();

                        wordSetStyleNormal();
                        word.Selection.TypeText(CfgObjectUtil.FlexPropsToString(server.Application.FlexProperties));
                    }
                }
            }

            wordGotoEnd();
        }