private void LoginCMS()
 {
     try
     {
         string result = SimulationHelper.PostLogin(SiteUrl + modelLogin.LoginUrl,
                                                    LoginPostData,
                                                    SiteUrl + modelLogin.LoginRefUrl,
                                                    modelLogin.PageEncode,
                                                    ref LoginedCookies);
         foreach (string str in modelLogin.LoginErrorResult.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
         {
             if (result.IndexOf(str) > -1)
             {
                 this.txtLogView.Clear();
                 this.txtLogView.AppendText("登录失败!值为:" + str);
                 return;
             }
         }
         if (modelLogin.LoginSuccessResult.Trim() != "")
         {
             if (result.IndexOf(modelLogin.LoginSuccessResult) > -1)
             {
                 GetClassList();
                 //this.txtLogView.Clear();
                 //this.txtLogView.AppendText("登录成功!Cookies值为:" + LoginedCookies);
             }
             else
             {
                 this.txtLogView.Clear();
                 this.txtLogView.AppendText("登录失败!没找到成功的值为:" + modelLogin.LoginSuccessResult);
             }
         }
         else
         {
             GetClassList();
             //this.txtLogView.Clear();
             //this.txtLogView.AppendText("登录成功!Cookies值为:" + LoginedCookies);
         }
     }
     catch (Exception ex)
     {
         this.txtLogView.Clear();
         this.txtLogView.AppendText(ex.Message);
     }
 }
        /// <summary>
        /// 用户登陆
        /// </summary>
        public void Publish_Login()
        {
            CacheManageHelper cache = CacheManageHelper.Instance;

            if (cache.Contains(this.WebSiteUrl))
            {
                cookieHeader = cache.Get(this.WebSiteUrl) as string;
                Load_RandomList("登陆");
                if (Publish_Type == PublishType.Login)
                {
                    if (Out != null)
                    {
                        Out(this, PublishType.LoginOver, true, "登陆成功!", null);
                    }
                }
            }
            else
            {
                string postData = Publish_Model.LoginPostData;
                Load_RandomList("登陆");
                postData = ReplacePostData(postData);
                string htmlContent = SimulationHelper.PostLogin(this.StrLoginDir + Publish_Model.LoginUrl, postData, string.Empty, Publish_Model.PageEncode, ref cookieHeader);
                if (htmlContent.IndexOf(Publish_Model.LoginSuccessResult) > -1)
                {
                    cache.Add(this.WebSiteUrl, cookieHeader);
                    if (Publish_Type == PublishType.Login)
                    {
                        if (Out != null)
                        {
                            Out(this, PublishType.LoginOver, true, "登陆成功!", null);
                        }
                    }
                }
                else
                {
                    if (Publish_Type == PublishType.Login)
                    {
                        if (Out != null)
                        {
                            Out(this, PublishType.LoginOver, false, "登陆失败!", null);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 测试登陆数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnTestLogin_Click(object sender, EventArgs e)
        {
            this.txtHtmlView.Clear();
            model = this.GetModelXml(this.cmbModuleList.Text);
            Encoding ed       = Encoding.GetEncoding(model.PageEncode);
            string   PostData = model.LoginPostData;

            PostData = PostData.Replace("[用户名]", this.txtTestUserName.Text);
            PostData = PostData.Replace("[密码]", this.txtTestUserPwd.Text);
            //加载随机值
            this.Load_RandomLabel("登陆");
            //替换随机值
            foreach (KeyValuePair <string, string> item in dic)
            {
                PostData = PostData.Replace("[" + item.Key + "]", item.Value);
            }
            string result = SimulationHelper.PostLogin(this.txtTestSiteAdminUrl.Text + model.LoginChkrl,
                                                       PostData,
                                                       model.LoginRefUrl,
                                                       model.PageEncode,
                                                       ref LoginedCookies);

            this.txtHtmlView.Text = result;
            foreach (string str in model.LoginErrorResult.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (result.IndexOf(str) > -1)
                {
                    this.txtResultView.Clear();
                    this.txtResultView.AppendText("登录失败!值为:" + str);
                    return;
                }
            }
            if (result.IndexOf(model.LoginSuccessResult) > -1)
            {
                IsLogin = true;
                this.txtResultView.Clear();
                this.txtResultView.AppendText("登录成功!Cookies值为:" + LoginedCookies);
            }
            else
            {
                this.txtResultView.Clear();
                this.txtResultView.Text = result;
            }
        }