예제 #1
0
파일: MainForm.cs 프로젝트: renyh1013/dp2
        // 导出模板
        void menuItem_exportTemplate_Click(object sender, System.EventArgs e)
        {
            if (treeView_res.SelectedNode == null)
            {
                MessageBox.Show("请选择一个节点");
                return;
            }

            if (treeView_res.SelectedNode.ImageIndex != ResTree.RESTYPE_DB
                && treeView_res.SelectedNode.ImageIndex != ResTree.RESTYPE_SERVER)
            {
                MessageBox.Show("请选择一个服务器或数据库类型节点");
                return;
            }

            treeView_res.Refresh(ResTree.RefreshStyle.Selected);

            ExportTemplateDlg dlg = new ExportTemplateDlg();
            MainForm.SetControlFont(dlg, this.DefaultFont);

            dlg.Objects = new List<ObjectInfo>();

            if (treeView_res.SelectedNode.ImageIndex == ResTree.RESTYPE_SERVER)
            {
                for (int i = 0; i < treeView_res.SelectedNode.Nodes.Count; i++)
                {
                    ObjectInfo objectinfo = new ObjectInfo();

                    ResPath respath = new ResPath(treeView_res.SelectedNode.Nodes[i]);

                    objectinfo.Path = respath.Path;
                    objectinfo.Url = respath.Url;
                    objectinfo.ImageIndex = treeView_res.SelectedNode.Nodes[i].ImageIndex;
                    dlg.Objects.Add(objectinfo);
                }
            }
            else
            {
                ObjectInfo objectinfo = new ObjectInfo();

                ResPath respath = new ResPath(treeView_res.SelectedNode);

                objectinfo.Path = respath.Path;
                objectinfo.Url = respath.Url;
                objectinfo.ImageIndex = treeView_res.SelectedNode.ImageIndex;
                dlg.Objects.Add(objectinfo);
            }

            dlg.MainForm = this;
            dlg.ShowDialog(this);
        }
예제 #2
0
        void menu_quickSetRights_Click(object sender, EventArgs e)
        {
            /*
            // 兑现本次树上修改
            if (treeView_resRightTree.Changed == true)
                treeView_resRightTree.FinishRightsParam();
            */

            TreeNode node = this.treeView_resRightTree.SelectedNode;
            if (node == null)
                node = this.treeView_resRightTree.Nodes[0];

            QuickSetDatabaseRightsDlg dlg = new QuickSetDatabaseRightsDlg();
            dlg.Font = GuiUtil.GetDefaultFont();

            dlg.CfgFileName = "quickrights.xml";
            dlg.AllObjectNames = new List<ObjectInfo>();

            // 根
            ObjectInfo objectinfo = new ObjectInfo();
            objectinfo.Path = "服务器";
            objectinfo.ImageIndex = ResTree.RESTYPE_SERVER;
            dlg.AllObjectNames.Add(objectinfo);

            for (int i = 0; i < treeView_resRightTree.Nodes[0].Nodes.Count; i++)
            {
                objectinfo = new ObjectInfo();
                objectinfo.Path = treeView_resRightTree.Nodes[0].Nodes[i].Text;
                objectinfo.ImageIndex = treeView_resRightTree.Nodes[0].Nodes[i].ImageIndex;
                dlg.AllObjectNames.Add(objectinfo);
            }

            dlg.SelectedObjectNames = new List<ObjectInfo>();
            if (node.ImageIndex == ResTree.RESTYPE_DB)
            {
                objectinfo = new ObjectInfo();
                objectinfo.Path = node.Text;
                objectinfo.ImageIndex = node.ImageIndex;

                // 如果选定的是数据库节点
                dlg.SelectedObjectNames.Add(objectinfo);
            }
            else if (node.ImageIndex == ResTree.RESTYPE_SERVER)
            {
                // 如果选定的是服务器节点
                dlg.SelectedObjectNames.AddRange(dlg.AllObjectNames);
            }
            else
            {
                // 如果选定的是其他类型节点
                // 得到路径
                string strPath = "";
                TreeNode nodeCur = node;
                while(nodeCur != null)
                {
                    if (nodeCur.ImageIndex == ResTree.RESTYPE_SERVER)
                        break;
                    if (strPath != "")
                        strPath = "/" + strPath;
                    strPath = nodeCur.Text + strPath;
                    nodeCur = nodeCur.Parent;
                }

                objectinfo = new ObjectInfo();
                objectinfo.Path = strPath;
                objectinfo.ImageIndex = node.ImageIndex;


                dlg.SelectedObjectNames.Add(objectinfo);
            }

    
            this.MainForm.AppInfo.LinkFormState(dlg, "QuickSetDatabaseRightsDlg_state");
            dlg.ShowDialog(this);
            this.MainForm.AppInfo.UnlinkFormState(dlg);

            if (dlg.DialogResult != DialogResult.OK)
                return;


            // 兑现修改
            ModiRights(dlg.SelectedObjectNames,
                dlg.QuickRights);

            this.listView_resRightList.RefreshList();

            this.textBox_objectRights_rights.Text = ResRightTree.GetNodeRights(treeView_resRightTree.SelectedNode);

        }
예제 #3
0
        void menu_quickSetRights_Click(object sender, EventArgs e)
        {
            /*
             * // 兑现本次树上修改
             * if (treeView_resRightTree.Changed == true)
             *  treeView_resRightTree.FinishRightsParam();
             */

            TreeNode node = this.treeView_resRightTree.SelectedNode;

            if (node == null)
            {
                node = this.treeView_resRightTree.Nodes[0];
            }

            QuickSetDatabaseRightsDlg dlg = new QuickSetDatabaseRightsDlg();

            dlg.Font = GuiUtil.GetDefaultFont();

            dlg.CfgFileName    = "quickrights.xml";
            dlg.AllObjectNames = new List <ObjectInfo>();

            // 根
            ObjectInfo objectinfo = new ObjectInfo();

            objectinfo.Path       = "服务器";
            objectinfo.ImageIndex = ResTree.RESTYPE_SERVER;
            dlg.AllObjectNames.Add(objectinfo);

            for (int i = 0; i < treeView_resRightTree.Nodes[0].Nodes.Count; i++)
            {
                objectinfo            = new ObjectInfo();
                objectinfo.Path       = treeView_resRightTree.Nodes[0].Nodes[i].Text;
                objectinfo.ImageIndex = treeView_resRightTree.Nodes[0].Nodes[i].ImageIndex;
                dlg.AllObjectNames.Add(objectinfo);
            }

            dlg.SelectedObjectNames = new List <ObjectInfo>();
            if (node.ImageIndex == ResTree.RESTYPE_DB)
            {
                objectinfo            = new ObjectInfo();
                objectinfo.Path       = node.Text;
                objectinfo.ImageIndex = node.ImageIndex;

                // 如果选定的是数据库节点
                dlg.SelectedObjectNames.Add(objectinfo);
            }
            else if (node.ImageIndex == ResTree.RESTYPE_SERVER)
            {
                // 如果选定的是服务器节点
                dlg.SelectedObjectNames.AddRange(dlg.AllObjectNames);
            }
            else
            {
                // 如果选定的是其他类型节点
                // 得到路径
                string   strPath = "";
                TreeNode nodeCur = node;
                while (nodeCur != null)
                {
                    if (nodeCur.ImageIndex == ResTree.RESTYPE_SERVER)
                    {
                        break;
                    }
                    if (strPath != "")
                    {
                        strPath = "/" + strPath;
                    }
                    strPath = nodeCur.Text + strPath;
                    nodeCur = nodeCur.Parent;
                }

                objectinfo            = new ObjectInfo();
                objectinfo.Path       = strPath;
                objectinfo.ImageIndex = node.ImageIndex;


                dlg.SelectedObjectNames.Add(objectinfo);
            }


            this.MainForm.AppInfo.LinkFormState(dlg, "QuickSetDatabaseRightsDlg_state");
            dlg.ShowDialog(this);
            this.MainForm.AppInfo.UnlinkFormState(dlg);

            if (dlg.DialogResult != DialogResult.OK)
            {
                return;
            }


            // 兑现修改
            ModiRights(dlg.SelectedObjectNames,
                       dlg.QuickRights);

            this.listView_resRightList.RefreshList();

            this.textBox_objectRights_rights.Text = ResRightTree.GetNodeRights(treeView_resRightTree.SelectedNode);
        }
예제 #4
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.listView_style.SelectedItems.Count == 0)
            {
                strError = "尚未选定风格名";
                goto ERROR1;
            }

            if (this.listView_objectNames.SelectedItems.Count == 0)
            {
                strError = "尚未选定要针对的用户名";
                goto ERROR1;
            }

            string strName = this.listView_style.SelectedItems[0].Text;

            int nRet = QuickRights.Build(this.cfgDom,
                strName,
                out this.QuickRights,
                out strError);
            if (nRet == -1)
                goto ERROR1;


            /*
            string strXPath = "//style[@name='" + strName + "']";
            XmlNode parent = this.cfgDom.DocumentElement.SelectSingleNode(strXPath);
            if (parent == null)
            {
                MessageBox.Show(this, "dom出错");
                return;
            }

            this.QuickRights = new QuickRights();

            XmlNodeList nodes = parent.SelectNodes("rights");
            for (int i = 0; i < nodes.Count; i++)
            {
                XmlNode node = nodes[i];

                QuickRightsItem item = new QuickRightsItem();
                item.Type = DomUtil.GetAttr(node, "type");
                item.Name = DomUtil.GetAttr(node, "name");
                item.Rights = DomUtil.GetNodeText(node);
                item.Style = QuickRights.GetStyleInt(DomUtil.GetAttr(node, "style"));

                this.QuickRights.Add(item);

            }
             */

            /*
            this.QuickRights.ServerRights = DomUtil.GetElementText(parent, "rights[@name='server']");
            this.QuickRights.DatabaseRights = DomUtil.GetElementText(parent, "rights[@name='database']");
            this.QuickRights.DirectoryRights = DomUtil.GetElementText(parent, "rights[@name='directory']");
            this.QuickRights.FileRights = DomUtil.GetElementText(parent, "rights[@name='file']");
             */


            // 收集已经选择的数据库名
            this.SelectedObjectNames.Clear();
            for (int i = 0; i < this.listView_objectNames.SelectedItems.Count; i++)
            {
                ObjectInfo objectinfo = new ObjectInfo();
                objectinfo.Path = this.listView_objectNames.SelectedItems[i].Text;
                objectinfo.ImageIndex = this.listView_objectNames.SelectedItems[i].ImageIndex;
                this.SelectedObjectNames.Add(objectinfo);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
예제 #5
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.listView_style.SelectedItems.Count == 0)
            {
                strError = "尚未选定风格名";
                goto ERROR1;
            }

            if (this.listView_objectNames.SelectedItems.Count == 0)
            {
                strError = "尚未选定要针对的用户名";
                goto ERROR1;
            }

            string strName = this.listView_style.SelectedItems[0].Text;

            int nRet = QuickRights.Build(this.cfgDom,
                                         strName,
                                         out this.QuickRights,
                                         out strError);

            if (nRet == -1)
            {
                goto ERROR1;
            }


            /*
             * string strXPath = "//style[@name='" + strName + "']";
             * XmlNode parent = this.cfgDom.DocumentElement.SelectSingleNode(strXPath);
             * if (parent == null)
             * {
             *  MessageBox.Show(this, "dom出错");
             *  return;
             * }
             *
             * this.QuickRights = new QuickRights();
             *
             * XmlNodeList nodes = parent.SelectNodes("rights");
             * for (int i = 0; i < nodes.Count; i++)
             * {
             *  XmlNode node = nodes[i];
             *
             *  QuickRightsItem item = new QuickRightsItem();
             *  item.Type = DomUtil.GetAttr(node, "type");
             *  item.Name = DomUtil.GetAttr(node, "name");
             *  item.Rights = DomUtil.GetNodeText(node);
             *  item.Style = QuickRights.GetStyleInt(DomUtil.GetAttr(node, "style"));
             *
             *  this.QuickRights.Add(item);
             *
             * }
             */

            /*
             * this.QuickRights.ServerRights = DomUtil.GetElementText(parent, "rights[@name='server']");
             * this.QuickRights.DatabaseRights = DomUtil.GetElementText(parent, "rights[@name='database']");
             * this.QuickRights.DirectoryRights = DomUtil.GetElementText(parent, "rights[@name='directory']");
             * this.QuickRights.FileRights = DomUtil.GetElementText(parent, "rights[@name='file']");
             */


            // 收集已经选择的数据库名
            this.SelectedObjectNames.Clear();
            for (int i = 0; i < this.listView_objectNames.SelectedItems.Count; i++)
            {
                ObjectInfo objectinfo = new ObjectInfo();
                objectinfo.Path       = this.listView_objectNames.SelectedItems[i].Text;
                objectinfo.ImageIndex = this.listView_objectNames.SelectedItems[i].ImageIndex;
                this.SelectedObjectNames.Add(objectinfo);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }