Exemple #1
0
        private IDictionary <string, string> ProcessSendHeaders()
        {
            int Row = 1;
            IDictionary <string, string> SendHeaders = new Dictionary <string, string>()
            {
            };

            foreach (Control item in gbHeaders.Controls)
            {
                if (item is TextBox && item.Name.IndexOf("txtHeaderN") > -1)
                {
                    if (WinFun.FindControl(gbHeaders, "txtHeaderN" + Row.ToString()) is TextBox CtTbKey && CtTbKey.Text.Trim().Length > 0 &&
                        WinFun.FindControl(gbHeaders, "txtHeaderV" + Row.ToString()) is TextBox CtTbValue && CtTbValue.Text.Trim().Length > 0)
                    {
                        SendHeaders.Add(CtTbKey.Text.Trim(), CtTbValue.Text.Trim());
                    }
                    Row++;
                }
            }
            if (txtUserAgent.Text.Trim().Length > 0)
            {
                SendHeaders.Add("User-Agent", txtUserAgent.Text.Trim());
            }

            return(SendHeaders);
        }
Exemple #2
0
        private void picVerifyCode_Click(object sender, EventArgs e)
        {
            _Thread_GetVerifyCode = new Thread(() =>
            {
                #region Parameters/Headers
                IDictionary <string, string> SendParams = new Dictionary <string, string>()
                {
                };
                IDictionary <string, string> SendHeaders = ProcessSendHeaders();
                #endregion

                string GetURL = GetHTTPSendURL((int)APIActionType.GetVerifyCode);

                #region Process & Results
                bool IsSucceed = ProcessHTTPSend(GetURL, SendParams, SendHeaders, out string OutMessages, out string OutHtmlSource);
                if (IsSucceed && OutHtmlSource.Length > 0)
                {
                    var VerifyCode = JsonConvert.DeserializeObject <VerifyCodeInfo>(OutHtmlSource);
                    if (VerifyCode.StateCode.Equals(1) && VerifyCode.Info.VerifyImage.Length > 0)
                    {
                        txtVerifyKey.Text   = VerifyCode.Info.VerifyKey;
                        picVerifyCode.Image = WinFun.Base64ToImage(VerifyCode.Info.VerifyImage);
                    }
                    else
                    {
                        WinFun.ShowMessageBox("获取验证码失败:" + VerifyCode.StateMessage);
                    }
                }
                #endregion
            });
            _Thread_GetVerifyCode.Start();
        }
Exemple #3
0
        public void Demo3_Window_Function()
        {
            using (var context = DbContextFactory.GetDbContext())
            {
                try
                {
                    var winFun = new WinFun <Student>()
                                 .ORDERBY(a => a.Age)
                                 .ROW_NUMBER();

                    var student1 = context.From <Student>()
                                   .Select(s => new
                    {
                        s.Id,
                        s.Name,
                        s.Age,
                        RowNum = (ulong)winFun
                    });
                }
                catch (Exception e)
                {
                    throw;
                }
            }
        }
Exemple #4
0
        private void btnHtppSend_Click(object sender, EventArgs e)
        {
            _Thread_WebGetting = new Thread(() =>
            {
                btnHtppSend.Enabled = false;

                #region Parameters/Headers
                IDictionary <string, string> SendParams = new Dictionary <string, string>()
                {
                };
                IDictionary <string, string> SendHeaders = ProcessSendHeaders();

                int Row = 1;
                foreach (Control item in gbParameters.Controls)
                {
                    if (item is TextBox && item.Name.IndexOf("txtParamN") > -1)
                    {
                        if (WinFun.FindControl(gbParameters, "txtParamN" + Row.ToString()) is TextBox CtTbKey && CtTbKey.Text.Trim().Length > 0 &&
                            WinFun.FindControl(gbParameters, "txtParamV" + Row.ToString()) is TextBox CtTbValue && CtTbValue.Text.Trim().Length > 0)
                        {
                            SendParams.Add(CtTbKey.Text.Trim(), CtTbValue.Text.Trim());
                        }
                        Row++;
                    }
                }
                #endregion

                #region Process & Results
                switch (cmbAPIAction.SelectedIndex)
                {
                case (int)APIActionType.GetVerifyCode: picVerifyCode_Click(new object(), new EventArgs()); break;

                case (int)APIActionType.GetSMS: btnGetLoginSMS_Click(new object(), new EventArgs()); break;

                case (int)APIActionType.UserLogin: btnUserLogin_Click(new object(), new EventArgs()); break;

                case (int)APIActionType.UserRegister: btnGetRegisterSMS_Click(new object(), new EventArgs()); break;

                default:
                    ProcessHTTPSend(GetHTTPSendURL(cmbAPIAction.SelectedIndex), SendParams, SendHeaders, out string OutMessages, out string OutHtmlSource);
                    break;
                }
                #endregion

                btnHtppSend.Enabled = true;
            });
            _Thread_WebGetting.Start();
        }
Exemple #5
0
        private void btnUserRegister_Click(object sender, EventArgs e)
        {
            _Thread_UserRegister = new Thread(() =>
            {
                btnUserRegister.Enabled = false;

                #region Parameters/Headers
                IDictionary <string, string> SendParams = new Dictionary <string, string>()
                {
                };
                IDictionary <string, string> SendHeaders = ProcessSendHeaders();

                SendParams.Add("UserName", txtLoginUser.Text.Trim());
                SendParams.Add("Password", WinFun.StringToBase64(txtLoginPassword.Text.Trim()));
                SendParams.Add("MobileCode", txtLoginMobileCode.Text.Trim());
                SendParams.Add("VerifyKey", txtVerifyKey.Text.Trim());
                SendParams.Add("VerifyCode", txtLoginVerifyCode.Text.Trim());
                #endregion

                #region Process & Results
                bool IsSucceed = ProcessHTTPSend(GetHTTPSendURL((int)APIActionType.UserRegister), SendParams, SendHeaders, out string OutMessages, out string OutHtmlSource);
                if (IsSucceed && OutHtmlSource.Length > 0)
                {
                    UserTokenResult ResultInfo           = null;
                    UserTokenResultError ResultInfoError = null;

                    try { ResultInfo = JsonConvert.DeserializeObject <UserTokenResult>(OutHtmlSource); }
                    catch { }

                    try { ResultInfoError = JsonConvert.DeserializeObject <UserTokenResultError>(OutHtmlSource); }
                    catch { }

                    if (ResultInfo != null)
                    {
                        if (ResultInfo.StateCode.Equals(1))
                        {
                            //txtParamV1.Text = ResultInfo.Info.Token;
                            //txtHeaderV1.Text = ResultInfo.Info.Token;
                            WinFun.ShowMessageBox("注册成功");
                        }
                        else
                        {
                            WinFun.ShowMessageBox("注册失败," + ResultInfo.StateMessage);
                        }
                    }
                    else
                    {
                        if (ResultInfoError != null)
                        {
                            StringBuilder SbResults = new StringBuilder();
                            foreach (var item in ResultInfoError.Info)
                            {
                                SbResults.Append(item.Code.ToString() + ":" + item.Message + "\r");
                            }

                            WinFun.ShowMessageBox("注册失败,\r" + SbResults.ToString());
                        }
                        else
                        {
                            WinFun.ShowMessageBox("注册失败,远程返回状态不正确");
                        }
                    }
                }
                else
                {
                    WinFun.ShowMessageBox(OutMessages);
                }
                #endregion

                btnUserRegister.Enabled = true;
            });
            _Thread_UserRegister.Start();
        }
Exemple #6
0
 private int FormatGetTimeout()
 {
     txtHttpTimeOut.Text = WinFun.RemoveSpace(txtHttpTimeOut.Text).Trim();
     return(WinFun.GetInt32(txtHttpTimeOut.Text.Replace("毫秒", "")));
 }
Exemple #7
0
        private bool ProcessHTTPSend(string GetURL,
                                     IDictionary <string, string> SendParams,
                                     IDictionary <string, string> SendHeaders,
                                     out string OutMessages,
                                     out string OutHtmlSource)
        {
            txtOptionTips.Text    = "";
            txtHtmlSource.Text    = "";
            txtResultHeaders.Text = "";

            bool IsSucceed = false;
            bool IsPost    = cmbHttpType.SelectedIndex == 1 ? true : false;

            OutMessages   = "";
            OutHtmlSource = "";

            IDictionary <string, string> OutSendHeaders = new Dictionary <string, string>()
            {
            };
            IDictionary <string, string> OutResultHeaders = new Dictionary <string, string>()
            {
            };

            if (WinFun.CheckIsUrl(GetURL))
            {
                txtOptionTips.AppendText(FormatResultData("请求:" + GetURL + "\r\n"));
                if (IsPost)
                {
                    IsSucceed = HttpFun.DoWebPost(
                        GetURL,
                        "",
                        FormatGetTimeout(),
                        _Array_EncodingList[cmbEncoding.SelectedIndex],
                        SendParams,
                        SendHeaders,
                        out OutSendHeaders,
                        out OutResultHeaders,
                        out OutHtmlSource,
                        out OutMessages
                        );
                }
                else
                {
                    IsSucceed = HttpFun.DoWebGet(
                        GetURL,
                        FormatGetTimeout(),
                        _Array_EncodingList[cmbEncoding.SelectedIndex],
                        SendParams,
                        SendHeaders,
                        out OutSendHeaders,
                        out OutResultHeaders,
                        out OutHtmlSource,
                        out OutMessages
                        );
                }

                txtOptionTips.AppendText(FormatResultData("URL:" + OutMessages + "\r\n"));
                if (IsSucceed)
                {
                    txtOptionTips.AppendText(FormatResultData("结果:成功。\r\n"));
                    txtOptionTips.AppendText(FormatResultData("字数:" + OutHtmlSource.Length.ToString() + "\r\n"));
                    txtHtmlSource.Text = OutHtmlSource;
                }
                else
                {
                    txtOptionTips.AppendText("结果:失败。" + OutMessages + "\r\n");
                }

                #region Headers Show
                txtResultHeaders.AppendText("请求Headers:\r\n");
                foreach (var item in OutSendHeaders)
                {
                    txtResultHeaders.AppendText(item.Key + ": " + item.Value + "\r\n");
                }

                txtResultHeaders.AppendText("\r\n返回Headers:\r\n");

                foreach (var item in OutResultHeaders)
                {
                    txtResultHeaders.AppendText(item.Key + ": " + item.Value + "\r\n");
                }
                #endregion
            }
            else
            {
                WinFun.ShowMessageBox("请求URL无效。");
            }

            return(IsSucceed);
        }