Beispiel #1
0
        // 全局参数配置
        private void button_globalConfig_Click(object sender, EventArgs e)
        {
            bool bStopped = false;

            if (GetGlobalRunningState() == true)
            {
                StartOrStopGlobalInstance("stop");
                bStopped = true;
            }

            try
            {
                GlobalConfigDialog dlg = new GlobalConfigDialog();
                FontUtil.AutoSetDefaultFont(dlg);

                dlg.DataDir       = this.textBox_dataDir.Text;
                dlg.StartPosition = FormStartPosition.CenterScreen;
                dlg.ShowDialog(this);
            }
            finally
            {
                if (bStopped)
                {
                    StartOrStopGlobalInstance("start");
                }
            }
        }
Beispiel #2
0
        private void button_modifyInstance_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.listView_instance.SelectedItems.Count == 0)
            {
                strError = "尚未选择要修改的实例";
                goto ERROR1;
            }

            ListViewItem item = this.listView_instance.SelectedItems[0];

            InstanceDialog dlg = new InstanceDialog();

            FontUtil.AutoSetDefaultFont(dlg);

            dlg.ParentDialog = this;
            dlg.Index        = this.listView_instance.Items.IndexOf(item);
            dlg.InstanceName = ListViewUtil.GetItemText(item, COLUMN_NAME);
            dlg.DataDir      = ListViewUtil.GetItemText(item, COLUMN_DATADIR);

            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

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

            RefreshItemLine(item, dlg.DataDir);
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Beispiel #3
0
        private void button_newInstance_Click(object sender, EventArgs e)
        {
            InstanceDialog dlg = new InstanceDialog();

            FontUtil.AutoSetDefaultFont(dlg);

            dlg.ParentDialog = this;
            dlg.Index        = this.listView_instance.Items.Count;
            dlg.InstanceName = "?";
            // 找到一个没有用过的目录名字
            dlg.DataDir       = GetNewDirectoryName(this.DataDir);
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

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

            ListViewItem item = new ListViewItem(dlg.InstanceName);

            RefreshItemLine(item, dlg.DataDir);
            this.listView_instance.Items.Add(item);

            if (dlg.InstanceName.IndexOf("?") != -1)
            {
                RefreshInstanceName(item);
            }
        }
Beispiel #4
0
        void channel_BeforeLogin(object sender, BeforeLoginEventArgs e)
        {
            if (e.FirstTry == true &&
                string.IsNullOrEmpty(this.SupervisorUserName) == false)
            {
                e.UserName = this.SupervisorUserName;
                e.Password = this.SupervisorPassword;

                e.Parameters = "location=#setup,type=worker,client=dp2CapoInstall|0.01";   // 2016/5/6 加上 0.01 部分

                if (String.IsNullOrEmpty(e.UserName) == false)
                {
                    return; // 立即返回, 以便作第一次 不出现 对话框的自动登录
                }
            }

            //
            IWin32Window owner = null;

            if (sender is IWin32Window)
            {
                owner = (IWin32Window)sender;
            }
            else
            {
                owner = this;
            }

            ConfirmSupervisorDialog dlg = new ConfirmSupervisorDialog();

            FontUtil.AutoSetDefaultFont(dlg);
            // dlg.Text = "";
            dlg.ServerUrl     = this.comboBox_url.Text;
            dlg.Comment       = e.ErrorInfo;
            dlg.UserName      = e.UserName;
            dlg.Password      = e.Password;
            dlg.StartPosition = FormStartPosition.CenterScreen;

            dlg.ShowDialog(owner);

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

            e.UserName          = dlg.UserName;
            e.Password          = dlg.Password;
            e.SavePasswordShort = true;
            e.Parameters        = "location=#setup,type=worker,client=dp2CapoInstall|0.01";

            e.SavePasswordLong = true;
            e.LibraryServerUrl = dlg.ServerUrl;

            this.SupervisorUserName = e.UserName;
            this.SupervisorPassword = e.Password;
        }
Beispiel #5
0
        // 全局参数配置
        private void button_globalConfig_Click(object sender, EventArgs e)
        {
            GlobalConfigDialog dlg = new GlobalConfigDialog();

            FontUtil.AutoSetDefaultFont(dlg);

            dlg.DataDir       = this.textBox_dataDir.Text;
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);
        }
Beispiel #6
0
        private void button_edit_dp2mserver_Click(object sender, EventArgs e)
        {
            dp2MServerDialog dlg = new dp2MServerDialog();

            FontUtil.AutoSetDefaultFont(dlg);

            dlg.CfgDom        = this.CfgDom;
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

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

            this.Changed = true;
            // 刷新显示
            this.DisplayDp2mserverInfo();
        }
Beispiel #7
0
        private void button_newInstance_Click(object sender, EventArgs e)
        {
            InstanceDialog new_instance_dlg = new InstanceDialog();

            FontUtil.AutoSetDefaultFont(new_instance_dlg);

            new_instance_dlg.ParentDialog = this;
            new_instance_dlg.Index        = this.listView_instance.Items.Count;
            new_instance_dlg.InstanceName = "?";
            // 找到一个没有用过的目录名字
            new_instance_dlg.DataDir       = GetNewDirectoryName(this.DataDir);
            new_instance_dlg.StartPosition = FormStartPosition.CenterScreen;
            new_instance_dlg.ShowDialog(this);

            if (new_instance_dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            this.Enabled = false;
            try
            {
                ListViewItem item = new ListViewItem(new_instance_dlg.InstanceName);

                RefreshItemLine(item, new_instance_dlg.DataDir);
                this.listView_instance.Items.Add(item);

                if (new_instance_dlg.InstanceName.IndexOf("?") != -1)
                {
                    RefreshInstanceName(item);
                }

                if (IsDp2CapoRunning())
                {
                    StartOrStopOneInstance(new_instance_dlg.InstanceName, "start");
                }
            }
            finally
            {
                this.Enabled = true;
            }
        }
Beispiel #8
0
        // 为工作人员添加管理公众号的权限
        private void button_workerRights_Click(object sender, EventArgs e)
        {
            string strError = "";

            this.EnableControls(false);
            try
            {
                using (LibraryChannel channel = new LibraryChannel())
                {
                    channel.Url = this.comboBox_url.Text;

                    channel.BeforeLogin -= new BeforeLoginEventHandle(channel_BeforeLogin);
                    channel.BeforeLogin += new BeforeLoginEventHandle(channel_BeforeLogin);

                    strError = "请用超级用户身份登录,以便为工作人员添加管理公众号的权限。";
                    int nRet = channel.DoNotLogin(ref strError);
                    if (nRet == -1 || nRet == 0)
                    {
                        strError = "以超级用户身份登录失败: " + strError;
                        goto ERROR1;
                    }

                    WorkerRightsDialog dlg = new WorkerRightsDialog();
                    FontUtil.AutoSetDefaultFont(dlg);
                    dlg.Channel         = channel;
                    dlg.ManagerUserName = this.textBox_manageUserName.Text;
                    dlg.StartPosition   = FormStartPosition.CenterScreen;
                    dlg.ShowDialog(this);

                    channel.Logout(out strError);
                }
            }
            finally
            {
                this.EnableControls(true);
            }
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Beispiel #9
0
        // 用 supervisor 用户名进行登录
        void _channels_LoginSupervisor(object sender, LoginEventArgs e)
        {
            MessageConnection connection = sender as MessageConnection;

            if (string.IsNullOrEmpty(this.ManagerUserName) == false)
            {
                e.UserName   = this.ManagerUserName;
                e.Password   = this.ManagerPassword;
                e.Parameters = "propertyList=biblio_search,libraryUID=install";
                return;
            }

            ConfirmSupervisorDialog dlg = new ConfirmSupervisorDialog();

            FontUtil.AutoSetDefaultFont(dlg);
            // dlg.Text = "";
            dlg.ServerUrl     = this.textBox_url.Text;
            dlg.Comment       = "为在 dp2mserver 服务器上创建图书馆账户,请使用超级用户登录";
            dlg.UserName      = e.UserName;
            dlg.Password      = e.Password;
            dlg.StartPosition = FormStartPosition.CenterScreen;

            dlg.ShowDialog(this);

            if (dlg.DialogResult == DialogResult.Cancel)
            {
                e.ErrorInfo = "放弃登录";
                return;
            }

            e.UserName = dlg.UserName;
            if (string.IsNullOrEmpty(e.UserName) == true)
            {
                throw new Exception("尚未指定用户名,无法进行登录");
            }

            e.Password   = dlg.Password;
            e.Parameters = "propertyList=biblio_search,libraryUID=install";
        }
Beispiel #10
0
        private void button_newInstance_Click(object sender, EventArgs e)
        {
            InstanceDialog dlg = new InstanceDialog();

            FontUtil.AutoSetDefaultFont(dlg);

            dlg.InstanceName = "?";
            // 找到一个没有用过的目录名字
            dlg.DataDir       = GetNewDirectoryName(this.DataDir);
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

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

            ListViewItem item = new ListViewItem((this.listView_instance.Items.Count + 1).ToString());

            ListViewUtil.ChangeItemText(item, COLUMN_DATADIR, dlg.DataDir);
            this.listView_instance.Items.Add(item);
        }
Beispiel #11
0
        private void button_modifyInstance_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.listView_instance.SelectedItems.Count == 0)
            {
                strError = "尚未选择要修改的实例";
                goto ERROR1;
            }

            ListViewItem item = this.listView_instance.SelectedItems[0];

            string strInstanceName = ListViewUtil.GetItemText(item, COLUMN_NAME);

            if (IsLocking(strInstanceName))
            {
                strError = "实例 '" + strInstanceName + "' 当前处于被锁定状态,无法进行修改操作";
                goto ERROR1;
            }

            bool bStopped = false;

            if (item.ImageIndex == IMAGEINDEX_RUNNING)
            {
                // 只对正在 running 状态的实例做停止处理
                StartOrStopOneInstance(strInstanceName,
                                       "stop");
                bStopped = true;
            }
            try
            {
                InstanceDialog dlg = new InstanceDialog();
                FontUtil.AutoSetDefaultFont(dlg);

                dlg.ParentDialog = this;
                dlg.Index        = this.listView_instance.Items.IndexOf(item);
                dlg.InstanceName = strInstanceName;
                dlg.DataDir      = ListViewUtil.GetItemText(item, COLUMN_DATADIR);

                dlg.StartPosition = FormStartPosition.CenterScreen;
                dlg.ShowDialog(this);

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

                RefreshItemLine(item, dlg.DataDir);
            }
            finally
            {
                if (bStopped)
                {
                    StartOrStopOneInstance(strInstanceName,
                                           "start");
                }
            }
            return;

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