Exemplo n.º 1
0
        // 根据已有的配置,填充InstanceList
        int FillInstanceList(out string strError)
        {
            strError = "";

            this.listView_instance.Items.Clear();

            int nErrorCount = 0;
            for (int i = 0; ; i++)
            {
                string strInstanceName = "";
                string strDataDir = "";
                string strCertSN = "";
                string[] existing_urls = null;

                bool bRet = InstallHelper.GetInstanceInfo("dp2Kernel",
                    i,
                    out strInstanceName,
                    out strDataDir,
                    out existing_urls,
                    out strCertSN);
                if (bRet == false)
                    break;

                ListViewItem item = new ListViewItem();
                ListViewUtil.ChangeItemText(item, COLUMN_NAME, strInstanceName);
                ListViewUtil.ChangeItemText(item, COLUMN_DATADIR, strDataDir);
                ListViewUtil.ChangeItemText(item, COLUMN_BINDINGS, string.Join(";", existing_urls));
                this.listView_instance.Items.Add(item);
                LineInfo info = new LineInfo();
                item.Tag = info;
                info.CertificateSN = strCertSN;
                // return:
                //      -1  error
                //      0   file not found
                //      1   succeed
                int nRet = info.Build(strDataDir,
                    out strError);
                if (nRet == -1)
                {
                    ListViewUtil.ChangeItemText(item, COLUMN_ERRORINFO, strError);
                    item.BackColor = Color.Red;
                    item.ForeColor = Color.White;

                    nErrorCount++;
                }

                if (nRet == 1)
                {
                    string strRootUserName = "";
                    string strRootUserRights = "";
                            // 获得root用户信息
        // return:
        //      -1  error
        //      0   succeed
                    nRet = GetRootUserInfo(strDataDir,
            out strRootUserName,
            out strRootUserRights,
            out strError);
                    if (nRet == -1)
                    {
                        ListViewUtil.ChangeItemText(item, COLUMN_ERRORINFO, strError);
                        item.BackColor = Color.Red;
                        item.ForeColor = Color.White;
                        nErrorCount++;
                    }
                    else
                    {
                        info.RootUserName = strRootUserName;
                        info.RootUserRights = strRootUserRights;
                    }

                }
            }

            if (nErrorCount > 0)
                this.listView_instance.Columns[COLUMN_ERRORINFO].Width = 200;
            else
                this.listView_instance.Columns[COLUMN_ERRORINFO].Width = 0;

            return 0;
        }
Exemplo n.º 2
0
        void modify_instance_dlg_LoadXmlFileInfo(object sender, LoadXmlFileInfoEventArgs e)
        {
            Debug.Assert(String.IsNullOrEmpty(e.DataDir) == false, "");

            string strError = "";
            LineInfo info = new LineInfo();
            // return:
            //      -1  error
            //      0   file not found
            //      1   succeed
            int nRet = info.Build(e.DataDir,
                out strError);
            if (nRet == -1)
            {
                e.ErrorInfo = strError;
                return;
            }

            Debug.Assert(nRet == 1, "");

            if (nRet == 1)
            {
                string strRootUserName = "";
                string strRootUserRights = "";
                // 获得root用户信息
                // return:
                //      -1  error
                //      0   succeed
                nRet = GetRootUserInfo(e.DataDir,
        out strRootUserName,
        out strRootUserRights,
        out strError);
                if (nRet == -1)
                {
                    e.ErrorInfo = strError;
                    return;
                }
                else
                {
                    info.RootUserName = strRootUserName;
                    info.RootUserRights = strRootUserRights;
                }
            }

            e.LineInfo = info;
        }