예제 #1
0
        // 获得著者号
        // return:
        //      -1  error
        //      0   canceled
        //      1   succeed
        public int GetGcatAuthorNumber(string strGcatWebServiceUrl,
                                       string strAuthor,
                                       out string strAuthorNumber,
                                       out string strError)
        {
            strError        = "";
            strAuthorNumber = "";

            if (String.IsNullOrEmpty(strGcatWebServiceUrl) == true)
            {
                strGcatWebServiceUrl = "http://dp2003.com/gcatserver/";  //  "http://dp2003.com/dp2libraryws/gcat.asmx";
            }
            if (strGcatWebServiceUrl.IndexOf(".asmx") != -1)
            {
                if (this.GcatChannel == null)
                {
                    this.GcatChannel = new DigitalPlatform.GcatClient.Channel();
                }

                string strDebugInfo = "";

                BeginGcatLoop("正在获取 '" + strAuthor + "' 的著者号,从 " + strGcatWebServiceUrl + " ...");
                try
                {
                    // return:
                    //      -1  error
                    //      0   canceled
                    //      1   succeed
                    int nRet = this.GcatChannel.GetNumber(
                        this.DetailForm.stop,
                        this.DetailForm,
                        strGcatWebServiceUrl,
                        strAuthor,
                        true,   // bSelectPinyin
                        true,   // bSelectEntry
                        true,   // bOutputDebugInfo
                        new DigitalPlatform.GcatClient.BeforeLoginEventHandle(gcat_channel_BeforeLogin),
                        out strAuthorNumber,
                        out strDebugInfo,
                        out strError);
                    if (nRet == -1)
                    {
                        strError = "取 著者 '" + strAuthor + "' 之号码时出错 : " + strError;
                        return(-1);
                    }

                    return(nRet);
                }
                finally
                {
                    EndGcatLoop();
                }
            }
            else if (strGcatWebServiceUrl.Contains("gcat"))
            {
                // 新的WebService

                string strID   = this.DetailForm.MainForm.AppInfo.GetString("DetailHost", "gcat_id", "");
                bool   bSaveID = this.DetailForm.MainForm.AppInfo.GetBoolean("DetailHost", "gcat_saveid", false);

                Hashtable question_table = (Hashtable)this.DetailForm.MainForm.ParamTable["question_table"];
                if (question_table == null)
                {
                    question_table = new Hashtable();
                }

REDO_GETNUMBER:
                string strDebugInfo = "";

                BeginGcatLoop("正在获取 '" + strAuthor + "' 的著者号,从 " + strGcatWebServiceUrl + " ...");
                try
                {
                    // return:
                    //      -1  error
                    //      0   canceled
                    //      1   succeed
                    int nRet = GcatNew.GetNumber(
                        ref question_table,
                        this.DetailForm.stop,
                        this.DetailForm,
                        strGcatWebServiceUrl,
                        strID, // ID
                        strAuthor,
                        true,  // bSelectPinyin
                        true,  // bSelectEntry
                        true,  // bOutputDebugInfo
                        out strAuthorNumber,
                        out strDebugInfo,
                        out strError);
                    if (nRet == -1)
                    {
                        strError = "取 著者 '" + strAuthor + "' 之号码时出错 : " + strError;
                        return(-1);
                    }
                    if (nRet == -2)
                    {
                        IdLoginDialog login_dlg = new IdLoginDialog();
                        GuiUtil.AutoSetDefaultFont(login_dlg);
                        login_dlg.Text = "获得著者号 -- "
                                         + ((string.IsNullOrEmpty(strID) == true) ? "请输入ID" : strError);
                        login_dlg.ID            = strID;
                        login_dlg.SaveID        = bSaveID;
                        login_dlg.StartPosition = FormStartPosition.CenterScreen;
                        if (login_dlg.ShowDialog(this.DetailForm) == DialogResult.Cancel)
                        {
                            return(-1);
                        }

                        strID   = login_dlg.ID;
                        bSaveID = login_dlg.SaveID;
                        if (login_dlg.SaveID == true)
                        {
                            this.DetailForm.MainForm.AppInfo.SetString("DetailHost", "gcat_id", strID);
                        }
                        else
                        {
                            this.DetailForm.MainForm.AppInfo.SetString("DetailHost", "gcat_id", "");
                        }
                        this.DetailForm.MainForm.AppInfo.SetBoolean("DetailHost", "gcat_saveid", bSaveID);
                        goto REDO_GETNUMBER;
                    }

                    this.DetailForm.MainForm.ParamTable["question_table"] = question_table;

                    return(nRet);
                }
                finally
                {
                    EndGcatLoop();
                }
            }
            else // dp2library 服务器
            {
                Hashtable question_table = (Hashtable)Program.MainForm.ParamTable["question_table"];
                if (question_table == null)
                {
                    question_table = new Hashtable();
                }

                string strDebugInfo = "";

                BeginGcatLoop("正在获取 '" + strAuthor + "' 的著者号,从 " + strGcatWebServiceUrl + " ...");
                try
                {
                    // return:
                    //      -1  error
                    //      0   canceled
                    //      1   succeed
                    long nRet = GetAuthorNumber(
                        ref question_table,
                        this.DetailForm.stop,
                        this.DetailForm,
                        strGcatWebServiceUrl,
                        strAuthor,
                        true,   // bSelectPinyin
                        true,   // bSelectEntry
                        true,   // bOutputDebugInfo
                        out strAuthorNumber,
                        out strDebugInfo,
                        out strError);
                    if (nRet == -1)
                    {
                        strError = "取 著者 '" + strAuthor + "' 之号码时出错 : " + strError;
                        return(-1);
                    }
                    Program.MainForm.ParamTable["question_table"] = question_table;
                    return((int)nRet);
                }
                finally
                {
                    EndGcatLoop();
                }
            }
        }
예제 #2
0
        // 获得著者号
        // return:
        //      -1  error
        //      0   canceled
        //      1   succeed
        public int GetGcatAuthorNumber(string strGcatWebServiceUrl,
            string strAuthor,
            out string strAuthorNumber,
            out string strError)
        {
            strError = "";
            strAuthorNumber = "";

            if (String.IsNullOrEmpty(strGcatWebServiceUrl) == true)
                strGcatWebServiceUrl = "http://dp2003.com/gcatserver/";  //  "http://dp2003.com/dp2libraryws/gcat.asmx";

            if (strGcatWebServiceUrl.IndexOf(".asmx") != -1)
            {

                if (this.GcatChannel == null)
                    this.GcatChannel = new DigitalPlatform.GcatClient.Channel();

                string strDebugInfo = "";

                BeginGcatLoop("正在获取 '" + strAuthor + "' 的著者号,从 " + strGcatWebServiceUrl + " ...");
                try
                {
                    // return:
                    //      -1  error
                    //      0   canceled
                    //      1   succeed
                    int nRet = this.GcatChannel.GetNumber(
                        this.DetailForm.stop,
                        this.DetailForm,
                        strGcatWebServiceUrl,
                        strAuthor,
                        true,	// bSelectPinyin
                        true,	// bSelectEntry
                        true,	// bOutputDebugInfo
                        new DigitalPlatform.GcatClient.BeforeLoginEventHandle(gcat_channel_BeforeLogin),
                        out strAuthorNumber,
                        out strDebugInfo,
                        out strError);
                    if (nRet == -1)
                    {
                        strError = "取 著者 '" + strAuthor + "' 之号码时出错 : " + strError;
                        return -1;
                    }

                    return nRet;
                }
                finally
                {
                    EndGcatLoop();
                }
            }
            else
            {
                // 新的WebService

                string strID = this.DetailForm.MainForm.AppInfo.GetString("DetailHost", "gcat_id", "");
                bool bSaveID = this.DetailForm.MainForm.AppInfo.GetBoolean("DetailHost", "gcat_saveid", false);

                Hashtable question_table = (Hashtable)this.DetailForm.MainForm.ParamTable["question_table"];
                if (question_table == null)
                    question_table = new Hashtable();

            REDO_GETNUMBER:
                string strDebugInfo = "";

                BeginGcatLoop("正在获取 '" + strAuthor + "' 的著者号,从 " + strGcatWebServiceUrl + " ...");
                try
                {
                    // return:
                    //      -1  error
                    //      0   canceled
                    //      1   succeed
                    int nRet = GcatNew.GetNumber(
                        ref question_table,
                        this.DetailForm.stop,
                        this.DetailForm,
                        strGcatWebServiceUrl,
                        strID, // ID
                        strAuthor,
                        true,	// bSelectPinyin
                        true,	// bSelectEntry
                        true,	// bOutputDebugInfo
                        out strAuthorNumber,
                        out strDebugInfo,
                        out strError);
                    if (nRet == -1)
                    {
                        strError = "取 著者 '" + strAuthor + "' 之号码时出错 : " + strError;
                        return -1;
                    }
                    if (nRet == -2)
                    {
                        IdLoginDialog login_dlg = new IdLoginDialog();
                        GuiUtil.AutoSetDefaultFont(login_dlg);
                        login_dlg.Text = "获得著者号 -- "
                            + ((string.IsNullOrEmpty(strID) == true) ? "请输入ID" : strError);
                        login_dlg.ID = strID;
                        login_dlg.SaveID = bSaveID;
                        login_dlg.StartPosition = FormStartPosition.CenterScreen;
                        if (login_dlg.ShowDialog(this.DetailForm) == DialogResult.Cancel)
                        {
                            return -1;
                        }

                        strID = login_dlg.ID;
                        bSaveID = login_dlg.SaveID;
                        if (login_dlg.SaveID == true)
                        {
                            this.DetailForm.MainForm.AppInfo.SetString("DetailHost", "gcat_id", strID);
                        }
                        else
                        {
                            this.DetailForm.MainForm.AppInfo.SetString("DetailHost", "gcat_id", "");
                        }
                        this.DetailForm.MainForm.AppInfo.SetBoolean("DetailHost", "gcat_saveid", bSaveID);
                        goto REDO_GETNUMBER;
                    }

                    this.DetailForm.MainForm.ParamTable["question_table"] = question_table;

                    return nRet;
                }
                finally
                {
                    EndGcatLoop();
                }
            }
        }