Exemplo n.º 1
0
        /// <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);
                        }
                    }
                }
            }
        }