예제 #1
0
        // 重设置代理帐户密码
        int ResetManageUserPassword(out string strError)
        {
            strError = "";
            if (this.comboBox_url.Text == "")
            {
                strError = "尚未指定 dp2Library 服务器 URL";
                return(-1);
            }

            if (this.textBox_manageUserName.Text == "")
            {
                strError = "尚未指定代理帐户的用户名";
                return(-1);
            }

            if (this.textBox_managePassword.Text != this.textBox_confirmManagePassword.Text)
            {
                strError = "代理帐户 密码 和 再次输入密码 不一致。请重新输入。";
                return(-1);
            }

            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;
                    return(-1);
                }

                if (StringUtil.IsInList("changeuserpassword", channel.Rights) == false)
                {
                    strError = "您所使用的超级用户 '" + this.SupervisorUserName + "' 不具备 changeuserpassword 权限,无法进行(为代理帐户 '" + this.textBox_manageUserName.Text + "' )重设密码的操作";
                    return(-1);
                }

                UserInfo user = new UserInfo();
                user.UserName = this.textBox_manageUserName.Text;
                user.Password = this.textBox_managePassword.Text;

                long lRet = channel.SetUser(
                    "resetpassword",
                    user,
                    out strError);
                if (lRet == -1)
                {
                    strError = "重设密码时发生错误: " + strError;
                    return(-1);
                }

                channel.Logout(out strError);
                return(0);
            }
        }
예제 #2
0
        // 从 dp2library 服务器获得 outgoingQueue 字符串
        int GetQueuePath(out string strError)
        {
            strError = "";
            if (this.comboBox_url.Text == "")
            {
                strError = "尚未指定 dp2Library 服务器 URL";
                return(-1);
            }

            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;
                    return(-1);
                }

                // 2.81
                // 检查 dp2library 版本
                // return:
                //      -1  出错
                //      0   dp2library 版本太低
                //      1   成功
                nRet = CheckVersion(channel,
                                    ProductUtil.dp2library_base_version,
                                    out strError);
                if (nRet == -1 || nRet == 0)
                {
                    return(-1);
                }

                string strValue = "";
                long   lRet     = channel.GetSystemParameter(
                    "system",
                    "outgoingQueue",
                    out strValue,
                    out strError);
                if (lRet != 1)
                {
                    strError = "从 dp2library 服务器获得配置信息时发生错误: " + strError;
                    return(-1);
                }

                this.comboBox_msmqPath.Text = strValue;
                channel.Logout(out strError);
                return(0);
            }
        }
예제 #3
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);
        }
예제 #4
0
        // 获得 dp2Library 数据目录
        int GetLibraryDataDir(out string strDataDir, out string strError)
        {
            strError = "";
            strDataDir = "";

            if (this.textBox_dp2LibraryUrl.Text == "")
            {
                strError = "尚未指定 dp2Library 服务器 URL";
                return -1;
            }

            if (this.textBox_manageUserName.Text == "")
            {
                strError = "尚未指定代理帐户的用户名";
                return -1;
            }

            if (this.textBox_managePassword.Text != this.textBox_confirmManagePassword.Text)
            {
                strError = "代理帐户 密码 和 再次输入密码 不一致。请重新输入。";
                return -1;
            }

            using (LibraryChannel channel = new LibraryChannel())
            {
                channel.Url = this.textBox_dp2LibraryUrl.Text;

                // Debug.Assert(false, "");
                string strParameters = "location=#setup,type=worker,client=dp2OPAC|0.01";  // 2016/4/26 加上 0.01 部分
                long nRet = channel.Login(this.textBox_manageUserName.Text,
                    this.textBox_managePassword.Text,
                    strParameters,
                    out strError);
                if (nRet == -1)
                {
                    strError = "以用户名 '" + this.textBox_manageUserName.Text + "' 和密码登录失败: " + strError;
                    return -1;
                }

                try
                {
                    if (nRet == 0 || StringUtil.IsInList("getsystemparameter", channel.Rights) == false)
                    {
                        channel.BeforeLogin -= new BeforeLoginEventHandle(channel_BeforeLogin);
                        channel.BeforeLogin += new BeforeLoginEventHandle(channel_BeforeLogin);

                        strError = "为获取 dp2Library 数据目录配置信息, 请用超级用户身份登录。";
                        nRet = channel.DoNotLogin(ref strError);
                        if (nRet == -1 || nRet == 0)
                        {
                            strError = "以超级用户身份登录失败: " + strError + "\r\n\r\n因此无法获取 dp2Library 数据目录配置信息";
                            return -1;
                        }
                    }

                    nRet = channel.GetSystemParameter(
            null,
            "cfgs",
            "getDataDir",
            out strDataDir,
            out strError);
                    if (nRet == -1)
                        return -1;
                }
                finally
                {
                    channel.Logout(out strError);
                }

                return 0;
            }
        }
예제 #5
0
        // 重设置代理帐户密码
        int ResetManageUserPassword(out string strError)
        {
            strError = "";
            if (this.textBox_dp2LibraryUrl.Text == "")
            {
                strError = "尚未指定dp2Library服务器URL";
                return -1;
            }

            if (this.textBox_manageUserName.Text == "")
            {
                strError = "尚未指定代理帐户的用户名";
                return -1;
            }

            if (this.textBox_managePassword.Text != this.textBox_confirmManagePassword.Text)
            {
                strError = "代理帐户 密码 和 再次输入密码 不一致。请重新输入。";
                return -1;
            }

            using (LibraryChannel channel = new LibraryChannel())
            {
                channel.Url = this.textBox_dp2LibraryUrl.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;
                    return -1;
                }

                if (StringUtil.IsInList("changeuserpassword", channel.Rights) == false)
                {
                    strError = "您所使用的超级用户 '" + this.SupervisorUserName + "' 不具备 changeuserpassword 权限,无法进行(为代理帐户 '" + this.textBox_manageUserName.Text + "' )重设密码的操作";
                    return -1;
                }

                UserInfo user = new UserInfo();
                user.UserName = this.textBox_manageUserName.Text;
                user.Password = this.textBox_managePassword.Text;

                long lRet = channel.SetUser(
                    null,
                    "resetpassword",
                    user,
                    out strError);
                if (lRet == -1)
                {
                    strError = "重设密码时发生错误: " + strError;
                    return -1;
                }

                channel.Logout(out strError);
                return 0;
            }
        }
예제 #6
0
        // 创建代理帐户
        int CreateManageUser(out string strError)
        {
            strError = "";
            if (this.textBox_dp2LibraryUrl.Text == "")
            {
                strError = "尚未指定dp2Library服务器URL";
                return -1;
            }

            if (this.textBox_manageUserName.Text == "")
            {
                strError = "尚未指定代理帐户的用户名";
                return -1;
            }

            if (this.textBox_manageUserName.Text == "reader"
                || this.textBox_manageUserName.Text == "public"
                || this.textBox_manageUserName.Text == "图书馆")
            {
                strError = "代理帐户的用户名不能为 'reader' 'public' '图书馆' 之一,因为这些都是 dp2Library 系统内具有特定用途的保留帐户名";
                return -1;
            }

            if (this.textBox_managePassword.Text != this.textBox_confirmManagePassword.Text)
            {
                strError = "代理帐 密码 和 再次输入密码 不一致。请重新输入。";
                return -1;
            }

            using (LibraryChannel channel = new LibraryChannel())
            {
                channel.Url = this.textBox_dp2LibraryUrl.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;
                    return -1;
                }
                UserInfo user = new UserInfo();
                user.UserName = this.textBox_manageUserName.Text;
                user.Password = this.textBox_managePassword.Text;
                user.SetPassword = true;
                // default_opac_rights
                user.Rights = "getsystemparameter,getres,search,getbiblioinfo,setbiblioinfo,getreaderinfo,writeobject,getbibliosummary,listdbfroms,simulatereader,simulateworker"
                    + ",getiteminfo,getorderinfo,getissueinfo,getcommentinfo";  // 2016/1/27

                /*
    代理帐户:
    getsystemparameter
    getres
    search
    getbiblioinfo
    getreaderinfo
    writeobject * */

                long lRet = channel.SetUser(
        null,
        "new",
        user,
        out strError);
                if (lRet == -1)
                {
                    strError = "创建代理帐户时发生错误: " + strError;
                    return -1;
                }

                channel.Logout(out strError);
                return 0;
            }
        }
예제 #7
0
        // 检测管理用户是否已经存在?
        // return:
        //       -1  出错
        //      0   不存在
        //      1   存在, 且密码一致
        //      2   存在, 但密码不一致
        int DetectManageUser(out string strError)
        {
            strError = "";
            if (this.textBox_dp2LibraryUrl.Text == "")
            {
                strError = "尚未指定 dp2Library 服务器 URL";
                return -1;
            }

            if (this.textBox_manageUserName.Text == "")
            {
                strError = "尚未指定代理帐户的用户名";
                return -1;
            }

            if (this.textBox_managePassword.Text != this.textBox_confirmManagePassword.Text)
            {
                strError = "代理帐户 密码 和 再次输入密码 不一致。请重新输入。";
                return -1;
            }

            using (LibraryChannel channel = new LibraryChannel())
            {
                channel.Url = this.textBox_dp2LibraryUrl.Text;

                // Debug.Assert(false, "");
                string strParameters = "location=#setup,type=worker,client=dp2OPAC|0.01";   // 2016/4/26 加上 0.01 部分
                long nRet = channel.Login(this.textBox_manageUserName.Text,
                    this.textBox_managePassword.Text,
                    strParameters,
                    out strError);
                if (nRet == -1)
                {
                    strError = "以用户名 '" + this.textBox_manageUserName.Text + "' 和密码登录失败: " + strError;
                    return -1;
                }

                if (nRet == 1)
                    this.ManageAccountRights = channel.Rights;

                channel.Logout(out strError);

                if (nRet == 0)
                {
                    channel.BeforeLogin -= new BeforeLoginEventHandle(channel_BeforeLogin);
                    channel.BeforeLogin += new BeforeLoginEventHandle(channel_BeforeLogin);

                    strError = "为确认代理帐户是否存在, 请用超级用户身份登录。";
                    nRet = channel.DoNotLogin(ref strError);
                    if (nRet == -1 || nRet == 0)
                    {
                        strError = "以超级用户身份登录失败: " + strError + "\r\n\r\n因此无法确定代理帐户是否存在";
                        return -1;
                    }

                    UserInfo[] users = null;
                    nRet = channel.GetUser(
                        null,
                        "list",
                        this.textBox_manageUserName.Text,
                        0,
                        -1,
                        out users,
                        out strError);
                    if (nRet == -1)
                    {
                        strError = "获取用户 '" + this.textBox_manageUserName.Text + "' 信息时发生错误: " + strError + "\r\n\r\n因此无法确定代理帐户是否存在。";
                        return -1;
                    }
                    if (nRet == 1)
                    {
                        Debug.Assert(users != null, "");
                        strError = "代理帐户 '" + this.textBox_manageUserName.Text + "' 已经存在, 但其密码和当前面板拟设置的密码不一致。";
                        return 2;
                    }
                    if (nRet >= 1)
                    {
                        Debug.Assert(users != null, "");
                        strError = "以 '" + this.textBox_manageUserName.Text + "' 为用户名 的用户记录存在多条,这是一个严重错误,请系统管理员启用dp2circulation尽快修正此错误。";
                        return -1;
                    }

                    return 0;
                }

                return 1;
            }
        }
예제 #8
0
        int CreateDpUser(out string strError)
        {
            strError = "";
            if (this.comboBox_url.Text == "")
            {
                strError = "尚未指定 dp2Library 服务器 URL";
                return(-1);
            }

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

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

                strError = "请用超级用户身份登录,以便创建 dp 帐户。";
                int nRet = channel.DoNotLogin(ref strError);
                if (nRet == -1 || nRet == 0)
                {
                    strError = "以超级用户身份登录失败: " + strError;
                    return(-1);
                }

                // 2.81
                // 检查 dp2library 版本
                // return:
                //      -1  出错
                //      0   dp2library 版本太低
                //      1   成功
                nRet = CheckVersion(channel,
                                    ProductUtil.dp2library_base_version,
                                    out strError);
                if (nRet == -1 || nRet == 0)
                {
                    return(-1);
                }

                CreateDpUserDialog dlg = new CreateDpUserDialog();
                dlg.UserName      = "******";
                dlg.StartPosition = FormStartPosition.CenterScreen;
                dlg.ShowDialog(this);
                if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                {
                    strError = "放弃创建 dp 用户";
                    return(-1);
                }

                UserInfo user = new UserInfo();
                user.UserName    = dlg.UserName;
                user.Password    = dlg.Password;
                user.SetPassword = true;
                user.Binding     = "ip:[current]" // 自动绑定当前请求者的 IP
                                   + ",router_ip:" + StringUtil.MakePathList(dlg.IpList, "|");
                user.Rights  = "changeuser,getcalendar,getchannelinfo,getoperlog,getreaderinfo,getres,getsystemparameter,getuser,listbibliodbfroms,listdbfroms,managedatabase,order,searchreader,setsystemparameter,writeres,managechannel";
                user.Comment = "数字平台远程维护用账号";

                long lRet = channel.SetUser(
                    "new",
                    user,
                    out strError);
                if (lRet == -1)
                {
                    strError = "创建代理帐户时发生错误: " + strError;
                    return(-1);
                }

                channel.Logout(out strError);
                return(0);
            }
        }
예제 #9
0
        // 创建代理帐户
        // 安装成功后,dp2Capo 运行中,点对点 API 实际上是使用这个账户对 dp2library 进行操作的
        int CreateManageUser(out string strError)
        {
            strError = "";
            if (this.comboBox_url.Text == "")
            {
                strError = "尚未指定 dp2Library 服务器 URL";
                return(-1);
            }

            if (this.textBox_manageUserName.Text == "")
            {
                strError = "尚未指定代理帐户的用户名";
                return(-1);
            }

            if (this.textBox_manageUserName.Text == "reader" ||
                this.textBox_manageUserName.Text == "public" ||
                this.textBox_manageUserName.Text == "opac" ||
                this.textBox_manageUserName.Text == "图书馆")
            {
                strError = "代理帐户的用户名不能为 'reader' 'public' 'opac' '图书馆' 之一,因为这些都是 dp2Library 系统内具有特定用途的保留帐户名";
                return(-1);
            }

            if (this.textBox_managePassword.Text != this.textBox_confirmManagePassword.Text)
            {
                strError = "代理帐 密码 和 再次输入密码 不一致。请重新输入。";
                return(-1);
            }

            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;
                    return(-1);
                }

                // 2.81
                // 检查 dp2library 版本
                // return:
                //      -1  出错
                //      0   dp2library 版本太低
                //      1   成功
                nRet = CheckVersion(channel,
                                    ProductUtil.dp2library_base_version,
                                    out strError);
                if (nRet == -1 || nRet == 0)
                {
                    return(-1);
                }

                UserInfo user = new UserInfo();
                user.UserName    = this.textBox_manageUserName.Text;
                user.Password    = this.textBox_managePassword.Text;
                user.SetPassword = true;
                user.Binding     = "ip:[current]"; // 自动绑定当前请求者的 IP
                // default_capo_rights
                user.Rights = "getsystemparameter,getres,search,getbiblioinfo,setbiblioinfo,getreaderinfo,writeobject,getbibliosummary,listdbfroms,simulatereader,simulateworker"
                              + ",getiteminfo,getorderinfo,getissueinfo,getcommentinfo"
                              + ",borrow,return,getmsmqmessage"
                              + ",bindpatron,searchbiblio,getpatrontempid,resetpasswordreturnmessage,getuser,changereaderpassword,renew,reservation";

                long lRet = channel.SetUser(
                    "new",
                    user,
                    out strError);
                if (lRet == -1)
                {
                    strError = "创建代理帐户时发生错误: " + strError;
                    return(-1);
                }

                channel.Logout(out strError);
                return(0);
            }
        }
예제 #10
0
        // 检测管理用户是否已经存在?
        // return:
        //       -1  出错
        //      0   不存在
        //      1   存在, 且密码一致
        //      2   存在, 但密码不一致
        int DetectManageUser(out string strError)
        {
            strError = "";
            if (this.comboBox_url.Text == "")
            {
                strError = "尚未指定 dp2Library 服务器 URL";
                return(-1);
            }

            if (this.textBox_manageUserName.Text == "")
            {
                strError = "尚未指定代理帐户的用户名";
                return(-1);
            }

            if (this.textBox_managePassword.Text != this.textBox_confirmManagePassword.Text)
            {
                strError = "代理帐户 密码 和 再次输入密码 不一致。请重新输入。";
                return(-1);
            }

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

                // Debug.Assert(false, "");
                string strParameters = "location=#setup,type=worker,client=dp2CapoInstall|0.01";
                long   nRet          = channel.Login(this.textBox_manageUserName.Text,
                                                     this.textBox_managePassword.Text,
                                                     strParameters,
                                                     out strError);
                if (nRet == -1)
                {
                    strError = "以用户名 '" + this.textBox_manageUserName.Text + "' 和密码登录失败: " + strError;
                    return(-1);
                }

                if (nRet == 1)
                {
                    this.ManageAccountRights = channel.Rights;
                }

                channel.Logout(out strError);

                if (nRet == 0)
                {
                    channel.BeforeLogin -= new BeforeLoginEventHandle(channel_BeforeLogin);
                    channel.BeforeLogin += new BeforeLoginEventHandle(channel_BeforeLogin);

                    strError = "为确认代理帐户是否存在, 请用超级用户身份登录。";
                    nRet     = channel.DoNotLogin(ref strError);
                    if (nRet == -1 || nRet == 0)
                    {
                        strError = "以超级用户身份登录失败: " + strError + "\r\n\r\n因此无法确定代理帐户是否存在";
                        return(-1);
                    }

                    UserInfo[] users = null;
                    nRet = channel.GetUser(
                        "list",
                        this.textBox_manageUserName.Text,
                        0,
                        -1,
                        out users,
                        out strError);
                    if (nRet == -1)
                    {
                        strError = "获取用户 '" + this.textBox_manageUserName.Text + "' 信息时发生错误: " + strError + "\r\n\r\n因此无法确定代理帐户是否存在。";
                        return(-1);
                    }
                    if (nRet == 1)
                    {
                        Debug.Assert(users != null, "");
                        strError = "代理帐户 '" + this.textBox_manageUserName.Text + "' 已经存在, 但其密码和当前面板拟设置的密码不一致。";
                        return(2);
                    }
                    if (nRet >= 1)
                    {
                        Debug.Assert(users != null, "");
                        strError = "以 '" + this.textBox_manageUserName.Text + "' 为用户名 的用户记录存在多条,这是一个严重错误,请系统管理员启用dp2circulation尽快修正此错误。";
                        return(-1);
                    }

                    return(0);
                }

                return(1);
            }
        }
예제 #11
0
        // 获得 dp2Library 数据目录
        int GetLibraryDataDir(out string strDataDir, out string strError)
        {
            strError   = "";
            strDataDir = "";

            if (this.textBox_dp2LibraryUrl.Text == "")
            {
                strError = "尚未指定 dp2Library 服务器 URL";
                return(-1);
            }

            if (this.textBox_manageUserName.Text == "")
            {
                strError = "尚未指定代理帐户的用户名";
                return(-1);
            }

            if (this.textBox_managePassword.Text != this.textBox_confirmManagePassword.Text)
            {
                strError = "代理帐户 密码 和 再次输入密码 不一致。请重新输入。";
                return(-1);
            }

            using (LibraryChannel channel = new LibraryChannel())
            {
                channel.Url = this.textBox_dp2LibraryUrl.Text;

                // Debug.Assert(false, "");
                string strParameters = "location=#setup,type=worker,client=dp2OPAC|0.01";  // 2016/4/26 加上 0.01 部分
                long   nRet          = channel.Login(this.textBox_manageUserName.Text,
                                                     this.textBox_managePassword.Text,
                                                     strParameters,
                                                     out strError);
                if (nRet == -1)
                {
                    strError = "以用户名 '" + this.textBox_manageUserName.Text + "' 和密码登录失败: " + strError;
                    return(-1);
                }

                try
                {
                    if (nRet == 0 || StringUtil.IsInList("getsystemparameter", channel.Rights) == false)
                    {
                        channel.BeforeLogin -= new BeforeLoginEventHandle(channel_BeforeLogin);
                        channel.BeforeLogin += new BeforeLoginEventHandle(channel_BeforeLogin);

                        strError = "为获取 dp2Library 数据目录配置信息, 请用超级用户身份登录。";
                        nRet     = channel.DoNotLogin(ref strError);
                        if (nRet == -1 || nRet == 0)
                        {
                            strError = "以超级用户身份登录失败: " + strError + "\r\n\r\n因此无法获取 dp2Library 数据目录配置信息";
                            return(-1);
                        }
                    }

                    nRet = channel.GetSystemParameter(
                        null,
                        "cfgs",
                        "getDataDir",
                        out strDataDir,
                        out strError);
                    if (nRet == -1)
                    {
                        return(-1);
                    }
                }
                finally
                {
                    channel.Logout(out strError);
                }

                return(0);
            }
        }
예제 #12
0
        // 创建代理帐户
        int CreateManageUser(out string strError)
        {
            strError = "";
            if (this.textBox_dp2LibraryUrl.Text == "")
            {
                strError = "尚未指定dp2Library服务器URL";
                return(-1);
            }

            if (this.textBox_manageUserName.Text == "")
            {
                strError = "尚未指定代理帐户的用户名";
                return(-1);
            }

            if (this.textBox_manageUserName.Text == "reader" ||
                this.textBox_manageUserName.Text == "public" ||
                this.textBox_manageUserName.Text == "图书馆")
            {
                strError = "代理帐户的用户名不能为 'reader' 'public' '图书馆' 之一,因为这些都是 dp2Library 系统内具有特定用途的保留帐户名";
                return(-1);
            }

            if (this.textBox_managePassword.Text != this.textBox_confirmManagePassword.Text)
            {
                strError = "代理帐 密码 和 再次输入密码 不一致。请重新输入。";
                return(-1);
            }

            using (LibraryChannel channel = new LibraryChannel())
            {
                channel.Url = this.textBox_dp2LibraryUrl.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;
                    return(-1);
                }
                UserInfo user = new UserInfo();
                user.UserName    = this.textBox_manageUserName.Text;
                user.Password    = this.textBox_managePassword.Text;
                user.SetPassword = true;
                // default_opac_rights
                user.Rights = "getsystemparameter,getres,search,getbiblioinfo,setbiblioinfo,getreaderinfo,writeobject,getbibliosummary,listdbfroms,simulatereader,simulateworker"
                              + ",getiteminfo,getorderinfo,getissueinfo,getcommentinfo"; // 2016/1/27

                /*
                 * 代理帐户:
                 * getsystemparameter
                 * getres
                 * search
                 * getbiblioinfo
                 * getreaderinfo
                 * writeobject * */

                long lRet = channel.SetUser(
                    null,
                    "new",
                    user,
                    out strError);
                if (lRet == -1)
                {
                    strError = "创建代理帐户时发生错误: " + strError;
                    return(-1);
                }

                channel.Logout(out strError);
                return(0);
            }
        }