예제 #1
0
        private void GetNodeDirectorys()
        {
            if (!File.Exists(TempNodeFileName))
            {
                string cmdstr = " \"db2 list node directory > " + TempNodeFileName + " && exit\"";
                CCmd   cmd    = new CCmd();
                cmd.db2cmd(cmdstr);
            }

            int    LNUM          = 0;
            int    TotalEntryNum = 0;
            string snode         = "";
            string sprotocol     = "";
            string shost         = "";
            string sport         = "";

            StreamReader sRead = new StreamReader(TempNodeFileName, GetFileEncodeType(TempNodeFileName));
            string       line;

            sRead.ReadLine();
            while ((line = sRead.ReadLine()) != null)
            {
                if (line.Trim().Length < 1)
                {
                    continue;
                }
                LNUM++;
                if (1 == LNUM)
                {
                    continue;
                }
                if (2 == LNUM)
                {
                    TotalEntryNum = int.Parse(line.Split('=')[1].Trim());
                    continue;
                }
                if ((LNUM - 3) % 7 == 0)
                {
                    if (LNUM != 3)
                    {
                        for (int i = 0; i < m_conns.Count(); i++)
                        {
                            if (m_conns[i].node == snode)
                            {
                                m_conns[i].protocol = sprotocol;
                                m_conns[i].host     = shost;
                                m_conns[i].port     = sport;
                            }
                        }
                    }
                    continue;
                }
                if (line.Contains("节点名"))
                {
                    snode = line.Split('=')[1].Trim();
                }
                if (line.Contains("协议"))
                {
                    sprotocol = line.Split('=')[1].Trim();
                }
                if (line.Contains("主机名"))
                {
                    shost = line.Split('=')[1].Trim();
                }
                if (line.Contains("服务名称"))
                {
                    sport = line.Split('=')[1].Trim();
                }
            }
            for (int i = 0; i < m_conns.Count(); i++)
            {
                if (m_conns[i].node == snode)
                {
                    m_conns[i].protocol = sprotocol;
                    m_conns[i].host     = shost;
                    m_conns[i].port     = sport;
                }
            }

            sRead.Close();
            //if ((LNUM-3)/7 != TotalEntryNum)
            //{
            //    Console.WriteLine("生成的节点目录文件不完整!");
            //}
        }
예제 #2
0
        private void GetDBDirectorys()
        {
            if (!File.Exists(TempDBFileName))
            {
                string cmdstr = " \"db2 list db directory > " + TempDBFileName + " && exit \"";
                CCmd   cmd    = new CCmd();
                cmd.db2cmd(cmdstr);
            }

            int            LNUM          = 0;
            int            TotalEntryNum = 0;
            SDB2Connection db2           = new SDB2Connection();

            StreamReader sRead = new StreamReader(TempDBFileName, GetFileEncodeType(TempDBFileName));
            string       line;

            sRead.ReadLine();
            while ((line = sRead.ReadLine()) != null)
            {
                if (line.Trim().Length < 1)
                {
                    continue;
                }
                LNUM++;
                if (LNUM == 1)
                {
                    continue;
                }
                if (LNUM == 2)
                {
                    TotalEntryNum = int.Parse(line.Split('=')[1].Trim());
                    continue;
                }
                if ((LNUM - 3) % 10 == 0)
                {
                    if (3 != LNUM)
                    {
                        m_conns.Add(db2);
                        db2 = new SDB2Connection();
                    }
                    continue;
                }

                if (line.Contains("数据库别名"))
                {
                    db2.alias = line.Split('=')[1].Trim();
                    continue;
                }
                if (line.Contains("数据库名称"))
                {
                    db2.database = line.Split('=')[1].Trim();
                    continue;
                }
                if (line.Contains("节点名"))
                {
                    db2.node = line.Split('=')[1].Trim();
                    continue;
                }
                if (line.Contains("注释"))
                {
                    db2.note = line.Split('=')[1].Trim();
                    continue;
                }
            }
            m_conns.Add(db2);
            sRead.Close();
            //if ((LNUM-3)/10 != TotalEntryNum)
            //{
            //    Console.WriteLine("生成的系统数据库目录文件不完整!");
            //}
        }