⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ajax.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 3 页
字号:
                if ((DataConverter.CLng(str4) % DataConverter.CLng(str5)) > 0)
                {
                    num++;
                }
                iPage.PageNum = num;
                iPage.PageSize = DataConverter.CLng(str5);
                iPage.CurrentPage = DataConverter.CLng(input);
                iPage.TotalPub = DataConverter.CLng(str4);
                iPage.IsDynamicPage = true;
                iPage.PageName = "ajaxpage";
                XmlTextWriter writer = new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8);
                writer.Formatting = Formatting.Indented;
                writer.Indentation = 4;
                writer.WriteStartDocument();
                writer.WriteStartElement("root", "");
                writer.WriteElementString("status", "ok");
                writer.WriteElementString("body", LabelTransform.GetPage(str, iPage, unitname));
                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Close();
            }
        }

        private void PutSystemLabel(string labelname, XmlNodeList bnode)
        {
            string labelName = labelname;
            foreach (XmlNode node in bnode)
            {
                if (node.FirstChild != null)
                {
                    string str2 = labelName;
                    labelName = str2 + " " + node.FirstChild.Name.Trim() + "=\"" + node.FirstChild.InnerText.Trim() + "\"";
                }
            }
            XmlTextWriter writer = new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8);
            writer.Formatting = Formatting.Indented;
            writer.Indentation = 4;
            writer.WriteStartDocument();
            writer.WriteStartElement("root", "");
            writer.WriteElementString("status", "ok");
            writer.WriteElementString("body", LabelTransform.GetSiteConfigLabel(labelName).ToString());
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
        }

        private void ResponseContentSigninStatus(int generalId)
        {
            string signinStatus = this.GetSigninStatus(generalId);
            XmlTextWriter writer = new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8);
            writer.Formatting = Formatting.Indented;
            writer.Indentation = 4;
            writer.WriteStartDocument();
            writer.WriteStartElement("root", "");
            if (signinStatus == "NotSignin")
            {
                if (SiteConfig.SiteOption.IsAutoSignin)
                {
                    writer.WriteElementString("status", "AutoSignin");
                    writer.WriteElementString("time", SiteConfig.SiteOption.AutoSigninTime.ToString());
                }
                else
                {
                    writer.WriteElementString("status", "NormalSignin");
                }
            }
            else
            {
                writer.WriteElementString("status", signinStatus);
            }
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
        }

        private void SigninContent(int generalId)
        {
            string str = "NotSignined";
            if (PEContext.Current.User.Identity.IsAuthenticated && SigninLog.Signin(generalId, PEContext.Current.User.UserName, true, PEContext.Current.UserHostAddress))
            {
                str = "Signined";
            }
            XmlTextWriter writer = new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8);
            writer.Formatting = Formatting.Indented;
            writer.Indentation = 4;
            writer.WriteStartDocument();
            writer.WriteStartElement("root", "");
            writer.WriteElementString("status", str);
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
        }

        private void UserCheck(string username)
        {
            XmlTextWriter writer = new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8);
            writer.Formatting = Formatting.Indented;
            writer.Indentation = 4;
            writer.WriteStartDocument();
            writer.WriteStartElement("root", "");
            if (Users.Exists(username))
            {
                writer.WriteElementString("status", "err");
            }
            else
            {
                writer.WriteElementString("status", "ok");
            }
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
        }

        private void UserLogin(XmlDocument ixml)
        {
            UserPrincipal principal;
            string str = (ixml.DocumentElement.SelectSingleNode("//username") == null) ? "" : ixml.DocumentElement.SelectSingleNode("//username").InnerText.Trim();
            string str2 = (ixml.DocumentElement.SelectSingleNode("//password") == null) ? "" : ixml.DocumentElement.SelectSingleNode("//password").InnerText.Trim();
            string str3 = (ixml.DocumentElement.SelectSingleNode("//checkcode") == null) ? "" : ixml.DocumentElement.SelectSingleNode("//checkcode").InnerText.Trim();
            string str4 = (ixml.DocumentElement.SelectSingleNode("//expiration") == null) ? "None" : ixml.DocumentElement.SelectSingleNode("//expiration").InnerText.Trim();
            if (string.IsNullOrEmpty(str))
            {
                this.PutErrMessage("用户名不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(str2))
            {
                this.PutErrMessage("密码不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(str3))
            {
                this.PutErrMessage("验证码不能为空!");
                return;
            }
            UserInfo userInfo = new UserInfo();
            userInfo.UserName = str;
            userInfo.UserPassword = str2;
            string strB = (this.Session["CheckCode"] == null) ? "" : this.Session["CheckCode"].ToString();
            if (string.Compare(str3, strB, true) > 0)
            {
                this.PutErrMessage("您输入的验证码错误!");
                return;
            }
            if (Users.ValidateUser(userInfo) != UserStatus.None)
            {
                this.PutErrMessage("用户登录名称或用户密码不对!");
                return;
            }
            bool isPersistent = false;
            DateTime now = DateTime.Now;
            DateTime expiration = DateTime.Now;
            string str7 = str4;
            if (str7 != null)
            {
                if (!(str7 == "None"))
                {
                    if (str7 == "Day")
                    {
                        isPersistent = true;
                        expiration = now.AddDays(1.0);
                        goto Label_0230;
                    }
                    if (str7 == "Month")
                    {
                        isPersistent = true;
                        expiration = now.AddMonths(1);
                        goto Label_0230;
                    }
                    if (str7 == "Year")
                    {
                        isPersistent = true;
                        expiration = now.AddYears(1);
                        goto Label_0230;
                    }
                }
                else
                {
                    isPersistent = false;
                    expiration = now.AddMinutes(20.0);
                    goto Label_0230;
                }
            }
            isPersistent = false;
            expiration = now.AddMinutes(20.0);
        Label_0230:
            principal = new UserPrincipal();
            principal.UserName = userInfo.UserName;
            principal.LastPassword = userInfo.LastPassword;
            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, userInfo.UserName, now, expiration, isPersistent, principal.SerializeToString());
            string str6 = FormsAuthentication.Encrypt(ticket);
            HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str6);
            if (isPersistent)
            {
                cookie.Expires = expiration;
            }
            base.Response.Cookies.Add(cookie);
            HttpCookie cookie2 = new HttpCookie(FormsAuthentication.FormsCookieName + "IsUserLogOut", "false");
            cookie2.HttpOnly = true;
            cookie2.Path = FormsAuthentication.FormsCookiePath;
            cookie2.Secure = FormsAuthentication.RequireSSL;
            base.Response.Cookies.Add(cookie2);
            this.Session["UserName"] = userInfo.UserName;
            XmlTextWriter writer = new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8);
            writer.Formatting = Formatting.Indented;
            writer.Indentation = 4;
            writer.WriteStartDocument();
            writer.WriteStartElement("root", "");
            writer.WriteElementString("status", "ok");
            writer.WriteElementString("username", userInfo.UserName);
            writer.WriteElementString("usergroup", userInfo.GroupName);
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
        }

        private void UserLogout()
        {
            FormsAuthentication.SignOut();
            HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName + "IsUserLogOut", "true");
            cookie.HttpOnly = true;
            cookie.Path = FormsAuthentication.FormsCookiePath;
            cookie.Secure = FormsAuthentication.RequireSSL;
            base.Response.Cookies.Add(cookie);
            XmlTextWriter writer = new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8);
            writer.Formatting = Formatting.Indented;
            writer.Indentation = 4;
            writer.WriteStartDocument();
            writer.WriteStartElement("root", "");
            writer.WriteElementString("status", "ok");
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -