当前位置: 首页>>代码示例>>C#>>正文


C# LibraryChannel.Logout方法代码示例

本文整理汇总了C#中LibraryChannel.Logout方法的典型用法代码示例。如果您正苦于以下问题:C# LibraryChannel.Logout方法的具体用法?C# LibraryChannel.Logout怎么用?C# LibraryChannel.Logout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LibraryChannel的用法示例。


在下文中一共展示了LibraryChannel.Logout方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetLibraryDataDir

        // 获得 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;
            }
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:73,代码来源:InstallOpacParamDlg.cs

示例2: ResetManageUserPassword

        // 重设置代理帐户密码
        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;
            }
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:62,代码来源:InstallOpacParamDlg.cs

示例3: DetectManageUser

        // 检测管理用户是否已经存在?
        // 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;
            }
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:94,代码来源:InstallOpacParamDlg.cs

示例4: CreateManageUser

        // 创建代理帐户
        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;
            }
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:76,代码来源:InstallOpacParamDlg.cs

示例5: button_dp2library_changePassword_Click

        private void button_dp2library_changePassword_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.textBox_dp2library_userName.Text == "")
            {
                MessageBox.Show(this, "尚未输入用户名。");
                this.textBox_dp2library_userName.Focus();
                return;
            }

            if (this.textBox_dp2library_newPassword.Text != this.textBox_dp2library_confirmNewPassword.Text)
            {
                MessageBox.Show(this, "新密码 和 确认新密码不一致。请重新输入。");
                this.textBox_dp2library_newPassword.Focus();
                return;
            }

            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在修改 dp2library 用户密码 ...");
            stop.BeginLoop();

            this.EnableControls(false);

            this.Update();
            this.MainForm.Update();


            try
            {
                long lRet = 0;

                // 获得server url
                if (String.IsNullOrEmpty(this.LibraryServerName) == true)
                {
                    strError = "尚未指定服务器名";
                    goto ERROR1;
                }
                dp2Server server = this.MainForm.Servers.GetServerByName(this.LibraryServerName);
                if (server == null)
                {
                    strError = "服务器名为 '" + this.LibraryServerName + "' 的服务器不存在...";
                    goto ERROR1;
                }

                string strServerUrl = server.Url;

                this.Channel = this.Channels.GetChannel(strServerUrl);


                // 非强制修改密码,即本人修改
                if (this.checkBox_dp2library_force.Checked == false)
                {

                    // return:
                    //      -1  error
                    //      0   登录未成功
                    //      1   登录成功
                    lRet = Channel.Login(this.textBox_dp2library_userName.Text,
                        this.textBox_dp2library_oldPassword.Text,
                        "location=dp2Catalog,type=worker",
                        /*
                        "",
                        false,
                         * */
                        out strError);
                    if (lRet == -1)
                    {
                        goto ERROR1;
                    }

                    if (lRet == 0)
                    {
                        strError = "旧密码不正确";
                        goto ERROR1;
                    }

                    try
                    {

                        lRet = Channel.ChangeUserPassword(
                            stop,
                            this.textBox_dp2library_userName.Text,
                            this.textBox_dp2library_oldPassword.Text,
                            this.textBox_dp2library_newPassword.Text,
                            out strError);
                        if (lRet == -1)
                            goto ERROR1;
                    }
                    finally
                    {
                        string strError_1 = "";
                        Channel.Logout(out strError_1);
                    }
                }

                // 强制修改密码
                if (this.checkBox_dp2library_force.Checked == true)
                {
                    UserInfo info = new UserInfo();
//.........这里部分代码省略.........
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:ChangePasswordForm.cs


注:本文中的LibraryChannel.Logout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。