Esempio n. 1
0
        private void button_resetPassword_Click(object sender, System.EventArgs e)
        {
            ResetPasswordDlg dlg = new ResetPasswordDlg();

            dlg.Font = GuiUtil.GetDefaultFont();

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

            DomUtil.SetElementText(UserRecDom.DocumentElement,
                                   "password",
                                   Cryptography.GetSHA1(dlg.textBox_password.Text));

            UpdateXmlTextDisplay();
        }
Esempio n. 2
0
        void menu_modify_Click(object sender, System.EventArgs e)
        {
            Debug.Assert(this.LinkInfos != null, "");


            if (this.listView_linkInfo.SelectedIndices.Count == 0)
            {
                MessageBox.Show(this, "尚未选定要修改的事项");
                return;
            }

            OneLinkInfoDlg dlg = new OneLinkInfoDlg();

            dlg.Font = GuiUtil.GetDefaultFont();

            dlg.Text = "修改一个连接关系";
            dlg.textBox_serverPath.Text = this.listView_linkInfo.SelectedItems[0].Text;
            dlg.textBox_localPath.Text  = this.listView_linkInfo.SelectedItems[0].SubItems[1].Text;

            dlg.ShowDialog(this);

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

            LinkInfo info = (LinkInfo)LinkInfos[this.listView_linkInfo.SelectedIndices[0]];

            info.ServerPath = dlg.textBox_serverPath.Text;
            info.LocalPath  = dlg.textBox_localPath.Text;

            this.LinkInfos.Changed = true;

            FillList();

            int    nRet     = 0;
            string strError = "";

            nRet = info.Link(out strError);
            if (nRet == -1)
            {
                MessageBox.Show(this, strError);
            }
        }
Esempio n. 3
0
        private void button_import_Click(object sender, System.EventArgs e)
        {
            OpenCfgFileDlg dlg = new OpenCfgFileDlg();

            dlg.Font = GuiUtil.GetDefaultFont();

            dlg.ShowDialog(this);

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

            this.Mime      = dlg.textBox_mime.Text;
            this.LocalPath = dlg.textBox_localPath.Text;
            using (Stream s = File.OpenRead(this.LocalPath))
            {
                if (s.Length > 1024 * 1024)
                {
                    MessageBox.Show(this, "配置文件尺寸不能大于1M");
                    return;
                }

                byte[] buffer = new byte[s.Length];
                s.Read(buffer, 0, (int)s.Length);

                this.Stream = new MemoryStream(buffer);
            }

            //
            if (this.IsText == true)
            {
                if (this.Stream != null)
                {
                    this.Stream.Seek(0, SeekOrigin.Begin);
                    using (StreamReader sr = new StreamReader(this.Stream, Encoding.UTF8))
                    {
                        this.textBox_content.Text = sr.ReadToEnd();
                    }
                }
            }

            button_OK.Enabled = true;
        }
Esempio n. 4
0
        // parameters:
        //      strLastModified 最后修改时间。RFC1123格式。只下载这个时间以后的文件。如果为空,表示不限制时间
        // return:
        //      -1  出错
        //      0   没有更新
        //      1   已经下载
        public static int DownloadWebFile(
            IWin32Window owner,
            string strUrl,
            string strLocalFileName,
            string strTempFilename,
            string strIfModifySince,
            out string strLastModified,
            out string strError)
        {
            strError        = "";
            strLastModified = "";

            WebFileDownloadDialog dlg = new WebFileDownloadDialog();

            if (GuiUtil.GetDefaultFont() != null)
            {
                dlg.Font = GuiUtil.GetDefaultFont();
            }

            dlg.Url            = strUrl;
            dlg.OutputFilename = strLocalFileName;
            dlg.TempFielname   = strTempFilename;
            dlg.IfModifySince  = strIfModifySince;
            dlg.MessageText    = "正在下载Web文件 " + strUrl;
            dlg.StartPosition  = FormStartPosition.CenterScreen;
            dlg.ShowDialog(owner);

            if (dlg.NotModified == true)
            {
                return(0);
            }

            if (string.IsNullOrEmpty(dlg.ErrorInfo) == false)
            {
                strError = dlg.ErrorInfo;
                return(-1);
            }

            strLastModified = dlg.LastModified;

            return(1);
        }
Esempio n. 5
0
        void menu_new(object sender, EventArgs e)
        {
            DbNameMapItemDlg dlg = new DbNameMapItemDlg();

            dlg.Font = GuiUtil.GetDefaultFont();

            dlg.SearchPanel = this.SearchPanel;
            dlg.ShowDialog(this);

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

            ListViewItem item = new ListViewItem(ResPath.GetReverseRecordPath(dlg.Origin), 0);

            item.SubItems.Add(ResPath.GetReverseRecordPath(dlg.Target));
            item.SubItems.Add(dlg.WriteMode);

            this.listView_map.Items.Add(item);
        }
Esempio n. 6
0
        public static DialogResult Show(IWin32Window owner,
                                        string strText,
                                        string strCaption,
                                        MessageBoxButtons buttons,
                                        MessageBoxDefaultButton defaultButton,
                                        ref bool bChecked,
                                        string [] button_texts = null,
                                        string strCheckBoxText = "")
        {
            MessageDlg dlg  = new MessageDlg();
            Font       font = GuiUtil.GetDefaultFont();

            if (font != null)
            {
                dlg.Font = font;
            }
            if (string.IsNullOrEmpty(strCheckBoxText) == false)
            {
                dlg.checkBox_noAsk.Text = strCheckBoxText;
            }
            else
            {
                dlg.CheckBoxVisible = false;
            }
            dlg.checkBox_noAsk.Checked = bChecked;
            dlg.buttons       = buttons;
            dlg.defaultButton = defaultButton;
            dlg.Message       = strText;
            dlg.Text          = strCaption;
            dlg.ButtonTexts   = button_texts;
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(owner);

            bChecked = dlg.checkBox_noAsk.Checked;

            return(dlg.DialogResult);
        }
Esempio n. 7
0
        private void button_findOrigin_Click(object sender, System.EventArgs e)
        {
            OpenResDlg dlg = new OpenResDlg();

            dlg.Font = GuiUtil.GetDefaultFont();

            dlg.Text           = "请选择源数据库";
            dlg.EnabledIndices = new int[] { ResTree.RESTYPE_DB };
            dlg.ap             = this.AppInfo;
            dlg.ApCfgTitle     = "dbnamemapitemdlg_origin";
            dlg.MultiSelect    = false;
            dlg.Path           = this.textBox_origin.Text;
            dlg.Initial(this.Servers,
                        this.Channels);
            // dlg.StartPositon = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

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

            textBox_origin.Text = dlg.Path;
        }
Esempio n. 8
0
        void NewItem(string strServerPath)
        {
            Debug.Assert(this.LinkInfos != null, "");

            OneLinkInfoDlg dlg = new OneLinkInfoDlg();

            dlg.Font = GuiUtil.GetDefaultFont();

            dlg.Text = "指定一个新的连接关系";
            dlg.textBox_serverPath.Text = strServerPath;
            dlg.ShowDialog(this);

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

            LinkInfo info = new LinkInfo();

            info.ServerPath = dlg.textBox_serverPath.Text;
            info.LocalPath  = dlg.textBox_localPath.Text;

            this.LinkInfos.Add(info);
            this.LinkInfos.Changed = true;

            FillList();

            int    nRet     = 0;
            string strError = "";

            nRet = info.Link(out strError);
            if (nRet == -1)
            {
                MessageBox.Show(this, strError);
            }
        }
Esempio n. 9
0
        // 修改名字和注释
        void menu_Modify(object sender, System.EventArgs e)
        {
            if (listView1.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未选择拟修改的模板记录事项...");
                return;
            }
            TemplateRecordDlg dlg = new TemplateRecordDlg();

            dlg.Font = GuiUtil.GetDefaultFont();

            string strOldName = ListViewUtil.GetItemText(listView1.SelectedItems[0], 0);

            dlg.textBox_name.Text    = ListViewUtil.GetItemText(listView1.SelectedItems[0], 0);
            dlg.textBox_comment.Text = ListViewUtil.GetItemText(listView1.SelectedItems[0], 1);

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

            string strError = "";
            int    nRet     = ChangeRecordProperty(strOldName,
                                                   dlg.textBox_name.Text,
                                                   dlg.textBox_comment.Text,
                                                   out strError);

            if (nRet == -1)
            {
                MessageBox.Show(this, strError);
                return;
            }

            FillList(false);
        }
Esempio n. 10
0
        private void button_findPinyinDbPath_Click(object sender, EventArgs e)
        {
            // 选择目标数据库
            OpenResDlg dlg = new OpenResDlg();

            dlg.Font = GuiUtil.GetDefaultFont();

            dlg.Text           = "请选择拼音库";
            dlg.EnabledIndices = new int[] { ResTree.RESTYPE_DB };
            dlg.ap             = this.MainForm.AppInfo;
            dlg.ApCfgTitle     = "preferencedlg_findpinyinpathdlg";
            dlg.Path           = this.textBox_pinyin_pinyinDbPath.Text;
            dlg.Initial(MainForm.Servers,
                        MainForm.SearchPanel.Channels);
            // dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

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

            this.textBox_pinyin_pinyinDbPath.Text = dlg.Path;
        }
Esempio n. 11
0
        // 编辑配置文件
        void menu_editCfgFile(object sender, System.EventArgs e)
        {
            string strError = "";

            if (this.SelectedNode == null)
            {
                strError = "尚未选择要编辑的配置文件节点";
                goto ERROR1;
            }

            if (this.SelectedNode.ImageIndex != RESTYPE_FILE)
            {
                strError = "所选择的节点不是配置文件类型。请选择要编辑的配置文件节点";
                goto ERROR1;
            }

            string strPath = GetNodePath(this.SelectedNode);

            // 获得配置文件内容
            ConfigInfo info = null;

            LibraryChannel channel     = null;
            TimeSpan       old_timeout = new TimeSpan(0);

            channel = this.CallGetChannel(true);

            old_timeout     = channel.Timeout;
            channel.Timeout = new TimeSpan(0, 5, 0);

            try
            {
                int nRet = GetConfigFile(
                    channel,
                    strPath,
                    out info,
                    out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }

                // 编辑配置文件
                KernelCfgFileDialog dlg = new KernelCfgFileDialog();
                dlg.Font       = GuiUtil.GetDefaultFont();
                dlg.ActivePage = "content";
                dlg.Content    = info.Content;
                dlg.MIME       = info.MIME;
                dlg.ServerUrl  = channel.Url;
                dlg.Path       = strPath;
                if (this.AppInfo != null)
                {
                    this.AppInfo.LinkFormState(dlg, "CfgFileEditDlg_state");
                }
                else
                {
                    dlg.StartPosition = FormStartPosition.CenterScreen;
                }

                dlg.ShowDialog(this);

                if (dlg.DialogResult == DialogResult.Cancel)
                {
                    return;
                }

                info.Content = dlg.Content;
                info.MIME    = dlg.MIME;

                nRet = SaveConfigFile(channel,
                                      strPath,
                                      info,
                                      out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }
            }
            finally
            {
                channel.Timeout = old_timeout;

                this.CallReturnChannel(channel, true);
            }
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Esempio n. 12
0
        // 获得缺省帐户信息
        // return:
        //		2	already login succeed
        //		1	dialog return OK
        //		0	dialog return Cancel
        //		-1	other error
        public void OnAskAccountInfo(object sender,
                                     AskAccountInfoEventArgs e)
        {
            bool bFirst = true;

            bool bAutoLogin   = (e.LoginStyle & LoginStyle.AutoLogin) == LoginStyle.AutoLogin;
            bool bFillDefault = (e.LoginStyle & LoginStyle.FillDefaultInfo) == LoginStyle.FillDefaultInfo;

            e.Owner    = this.ownerForm;
            e.UserName = "";
            e.Password = "";

            LoginDlg dlg = new LoginDlg();

            dlg.Font = GuiUtil.GetDefaultFont();

            Server server = this[e.Url];

            dlg.textBox_serverAddr.Text = e.Url;
            if (bFillDefault == true)
            {
                if (server != null)
                {
                    dlg.textBox_userName.Text         = (server.DefaultUserName == "" ? "public" : server.DefaultUserName);
                    dlg.textBox_password.Text         = server.DefaultPassword;
                    dlg.checkBox_savePassword.Checked = server.SavePassword;
                }
                else
                {
                    dlg.textBox_userName.Text         = "public";
                    dlg.textBox_password.Text         = "";
                    dlg.checkBox_savePassword.Checked = false;
                }
            }

            if (e.Comment != null)
            {
                dlg.textBox_comment.Text = e.Comment;
            }

DOLOGIN:
            if (e.Channels != null)
            {
                if (bAutoLogin == false && bFirst == true)
                {
                    goto REDOINPUT;
                }

                // 找到Channel
                RmsChannel channel = e.Channel; // 2013/2/14
                if (channel == null)
                {
                    channel = e.Channels.GetChannel(dlg.textBox_serverAddr.Text);
                }

                Debug.Assert(channel != null, "Channels.GetChannel()异常...");

                string strError;
                // 登录
                int nRet = channel.Login(dlg.textBox_userName.Text,
                                         dlg.textBox_password.Text,
                                         out strError);

                if (nRet != 1)
                {
                    strError = "以用户名 '" + dlg.textBox_userName.Text + "' 登录到 '" + dlg.textBox_serverAddr.Text + "' 失败: " + strError;

                    if (this.ownerForm != null)
                    {
                        MessageBox.Show(this.ownerForm, strError);
                    }
                    else
                    {
                        e.ErrorInfo = strError;
                        e.Result    = -1;
                    }

                    goto REDOINPUT;
                }
                else // 登录成功
                {
                    if (String.Compare(e.Url, dlg.textBox_serverAddr.Text, true) != 0)
                    {
                        // 创建一个新的Server对象
                        // return:
                        //		-1	出错
                        //		0	加入了
                        //		1	发现重复,没有加入
                        nRet = this.NewServer(dlg.textBox_serverAddr.Text, -1);
                        if (nRet == 0)
                        {
                            e.Url = channel.Url;
                        }
                    }

                    server = this[dlg.textBox_serverAddr.Text];

                    if (server == null) // 2006/8/19 add
                    {
                        // 创建一个新的Server对象
                        // return:
                        //		-1	出错
                        //		0	加入了
                        //		1	发现重复,没有加入
                        nRet = this.NewServer(dlg.textBox_serverAddr.Text, -1);
                        if (nRet == 0)
                        {
                            e.Url = channel.Url;
                        }

                        server = this[dlg.textBox_serverAddr.Text];
                    }

                    Debug.Assert(server != null, "此时server不可能为null");

                    server.DefaultUserName = dlg.textBox_userName.Text;
                    server.DefaultPassword = dlg.textBox_password.Text;
                    server.SavePassword    = dlg.checkBox_savePassword.Checked;
                    this.m_bChanged        = true;

                    e.Result = 2;
                    return;
                }
            }


REDOINPUT:
            bFirst = false;

            dlg.ShowDialog(ownerForm);

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

            if (e.Channels == null)
            {
                e.UserName = dlg.textBox_userName.Text;
                e.Password = dlg.textBox_password.Text;

                e.Result = 1;
                return;
            }


            goto DOLOGIN;
        }
Esempio n. 13
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);
        }