Example #1
0
        // return:
        //      -1  error
        //      0   canceled
        //      1   succeed
        public int GetNumber(
            Stop stop,
            System.Windows.Forms.IWin32Window parent,
            string strUrl,
            string strAuthor,
            bool bSelectPinyin,
            bool bSelectEntry,
            bool bOutputDebugInfo,
            BeforeLoginEventHandle e,
            out string strNumber,
            out string strDebugInfo,
            out string strError)
        {
            strError = "";
            strDebugInfo = "";

            Channel channel = this;

            // this.parent = parent;

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

            channel.BeforeLogin -= e;
            channel.BeforeLogin += e;

            channel.Url = strUrl;

            strNumber = "";

            int nRet = 0;

            try
            {
                channel.Clear();
            }
            catch (Exception ex)
            {
                strError = ExceptionUtil.GetAutoText(ex);
                return -1;
            }

            for (; ; )
            {
                // 这个函数具有catch 通讯中 exeption的能力
                nRet = channel.GetNumber(
                    stop,
                    strAuthor,
                    bSelectPinyin,
                    bSelectEntry,
                    bOutputDebugInfo,
                    out strNumber,
                    out strDebugInfo,
                    out strError);
                if (nRet != -3)
                    break;

                Debug.Assert(nRet == -3, "");

                string strTitle = strError;

                string strQuestion = "";

                nRet = channel.GetQuestion(out strQuestion,
                    out strError);
                if (nRet != 1)
                {
                    nRet = -1;
                    break;
                }

                QuestionDlg dlg = new QuestionDlg();
                GuiUtil.AutoSetDefaultFont(dlg);    // 2015/5/28
                dlg.StartPosition = FormStartPosition.CenterScreen;
                dlg.label_messageTitle.Text = strTitle;
                dlg.textBox_question.Text = strQuestion.Replace("\n", "\r\n");
                dlg.ShowDialog(parent);

                if (dlg.DialogResult != DialogResult.OK)
                {
                    nRet = 0;
                    break;
                }

                nRet = channel.Answer(strQuestion,
                    dlg.textBox_result.Text,
                    out strError);
                if (nRet != 1)
                {
                    nRet = -1;
                    break;
                }
            }

            if (nRet == -1)
                return -1;

            return 1;
        }
Example #2
0
        // return:
        //      -1  error
        //      0   canceled
        //      1   succeed
        public int GetNumber(
            Stop stop,
            System.Windows.Forms.IWin32Window parent,
            string strUrl,
            string strAuthor,
            bool bSelectPinyin,
            bool bSelectEntry,
            bool bOutputDebugInfo,
            BeforeLoginEventHandle e,
            out string strNumber,
            out string strDebugInfo,
            out string strError)
        {
            strError     = "";
            strDebugInfo = "";

            Channel channel = this;

            // this.parent = parent;

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

            channel.BeforeLogin -= e;
            channel.BeforeLogin += e;

            channel.Url = strUrl;

            strNumber = "";

            int nRet = 0;

            try
            {
                channel.Clear();
            }
            catch (Exception ex)
            {
                strError = ExceptionUtil.GetAutoText(ex);
                return(-1);
            }

            for (; ;)
            {
                // 这个函数具有catch 通讯中 exeption的能力
                nRet = channel.GetNumber(
                    stop,
                    strAuthor,
                    bSelectPinyin,
                    bSelectEntry,
                    bOutputDebugInfo,
                    out strNumber,
                    out strDebugInfo,
                    out strError);
                if (nRet != -3)
                {
                    break;
                }

                Debug.Assert(nRet == -3, "");

                string strTitle = strError;

                string strQuestion = "";

                nRet = channel.GetQuestion(out strQuestion,
                                           out strError);
                if (nRet != 1)
                {
                    nRet = -1;
                    break;
                }

                QuestionDlg dlg = new QuestionDlg();
                GuiUtil.AutoSetDefaultFont(dlg);    // 2015/5/28
                dlg.StartPosition           = FormStartPosition.CenterScreen;
                dlg.label_messageTitle.Text = strTitle;
                dlg.textBox_question.Text   = strQuestion.Replace("\n", "\r\n");
                dlg.ShowDialog(parent);

                if (dlg.DialogResult != DialogResult.OK)
                {
                    nRet = 0;
                    break;
                }

                nRet = channel.Answer(strQuestion,
                                      dlg.textBox_result.Text,
                                      out strError);
                if (nRet != 1)
                {
                    nRet = -1;
                    break;
                }
            }

            if (nRet == -1)
            {
                return(-1);
            }

            return(1);
        }
Example #3
0
		// 供脚本调用
        // return:
        //      -1  error
        //      0   canceled
        //      1   succeed
        public int GetNumber(
			System.Windows.Forms.IWin32Window parent,
			string strUrl,
			string strAuthor,
			bool bSelectPinyin,
			bool bSelectEntry,
			bool bOutputDebugInfo,
			BeforeLoginEventHandle e,
			out string strNumber,
			out string strDebugInfo,
			out string strError)
		{
			strError = "";
			strDebugInfo = "";

			Channel channel = this;

			// this.parent = parent;

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

			channel.BeforeLogin -= e;
			channel.BeforeLogin += e;


			channel.Url = strUrl;

			strNumber = "";

			int nRet = 0;

			channel.Clear();

			for(;;) 
			{
                // return:
                //		-3	需要回答问题
                //      -2  尚未登录(info.UserID为空)
                //      -1  出错
                //      0   成功
				nRet = channel.GetNumber(strAuthor,
					bSelectPinyin,
					bSelectEntry,
					bOutputDebugInfo,
					out strNumber,
					out strDebugInfo,
					out strError);
                if (nRet == 0)
                    return 1;
                if (nRet == -2)
                    return -1;
                if (nRet != -3)
                {
                    return -1;
                    //break;
                }

				Debug.Assert(nRet == -3, "");

				string strTitle = strError;

				string strQuestion = "";

				nRet = channel.GetQuestion(out strQuestion,
					out strError);
				if (nRet != 1)
				{
                    return -1;
                    /*
					nRet = -1;
					break;
                     * */
				}

				QuestionDlg dlg = new QuestionDlg();
                GuiUtil.AutoSetDefaultFont(dlg);    // 2015/5/28
                dlg.StartPosition = FormStartPosition.CenterScreen;
				dlg.label_messageTitle.Text = strTitle;
				dlg.textBox_question.Text = strQuestion.Replace("\n","\r\n");
				dlg.ShowDialog(parent);

				if (dlg.DialogResult != DialogResult.OK)
				{
                    return 0;   // 表示被放弃(放弃回答问题)
                    /*
					nRet = 0;
					break;
                     * */
				}

				nRet = channel.Answer(strQuestion,
					dlg.textBox_result.Text,
					out strError);
				if (nRet != 1) 
				{
                    /*
					nRet = -1;
					break;
                     * */
                    return -1;
				}
			}

            /*
			if (nRet == -1)
				return -1;
	
			return 1;
             * */
		}
Example #4
0
        // 供脚本调用
        // return:
        //      -1  error
        //      0   canceled
        //      1   succeed
        public int GetNumber(
            System.Windows.Forms.IWin32Window parent,
            string strUrl,
            string strAuthor,
            bool bSelectPinyin,
            bool bSelectEntry,
            bool bOutputDebugInfo,
            BeforeLoginEventHandle e,
            out string strNumber,
            out string strDebugInfo,
            out string strError)
        {
            strError     = "";
            strDebugInfo = "";

            Channel channel = this;

            // this.parent = parent;

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

            channel.BeforeLogin -= e;
            channel.BeforeLogin += e;


            channel.Url = strUrl;

            strNumber = "";

            int nRet = 0;

            channel.Clear();

            for (;;)
            {
                // return:
                //		-3	需要回答问题
                //      -2  尚未登录(info.UserID为空)
                //      -1  出错
                //      0   成功
                nRet = channel.GetNumber(strAuthor,
                                         bSelectPinyin,
                                         bSelectEntry,
                                         bOutputDebugInfo,
                                         out strNumber,
                                         out strDebugInfo,
                                         out strError);
                if (nRet == 0)
                {
                    return(1);
                }
                if (nRet == -2)
                {
                    return(-1);
                }
                if (nRet != -3)
                {
                    return(-1);
                    //break;
                }

                Debug.Assert(nRet == -3, "");

                string strTitle = strError;

                string strQuestion = "";

                nRet = channel.GetQuestion(out strQuestion,
                                           out strError);
                if (nRet != 1)
                {
                    return(-1);

                    /*
                     *                  nRet = -1;
                     *                  break;
                     * */
                }

                QuestionDlg dlg = new QuestionDlg();
                GuiUtil.AutoSetDefaultFont(dlg);    // 2015/5/28
                dlg.StartPosition           = FormStartPosition.CenterScreen;
                dlg.label_messageTitle.Text = strTitle;
                dlg.textBox_question.Text   = strQuestion.Replace("\n", "\r\n");
                dlg.ShowDialog(parent);

                if (dlg.DialogResult != DialogResult.OK)
                {
                    return(0);   // 表示被放弃(放弃回答问题)

                    /*
                     *                  nRet = 0;
                     *                  break;
                     * */
                }

                nRet = channel.Answer(strQuestion,
                                      dlg.textBox_result.Text,
                                      out strError);
                if (nRet != 1)
                {
                    /*
                     *                  nRet = -1;
                     *                  break;
                     * */
                    return(-1);
                }
            }

            /*
             *          if (nRet == -1)
             *                  return -1;
             *
             *          return 1;
             * */
        }