protected void Page_Load(object sender, EventArgs e) { // Login OP string sTokenEx = ""; if (this.Context.Request.Cookies["USSUserID"] == null) { this.Context.Response.Redirect("index.aspx?showlogin=1"); } else { sTokenEx = this.Context.Request.Cookies["USSToken"].Value + "@" + this.Context.Request.UserHostAddress; try { DLLUserService.User USSUser = new DLLUserService.User(); USSUser.Authenticate(sTokenEx, 0); } catch (Exception ex) { Context.Response.Redirect("index.aspx"); } } //Login ED if (string.IsNullOrEmpty(Request.QueryString["ID"])) { return; } string sArticleGUID = Request.QueryString["ID"]; string indexPath = new DAL.Article().GetArticlePath(sArticleGUID); string strFilePath = System.Configuration.ConfigurationManager.AppSettings["FileRootPath"]; string[] pathList = strFilePath.Split('|'); for (int i = 0; i < pathList.Length; i++) { if (string.IsNullOrEmpty(pathList[i])) { continue; } string sPath = pathList[i]; if (!sPath.EndsWith("\\")) { sPath = sPath + "\\"; } if (File.Exists(sPath.Split(',')[1] + indexPath)) { indexPath = sPath.Split(',')[0] + "/" + indexPath; break; } } if (string.IsNullOrEmpty(indexPath)) { vframe.InnerHtml = "很抱歉,视频文件不存在!"; } else { this.VideoShowFrame.Attributes["src"] = indexPath; //Response.Redirect(indexPath); } }
private bool IsLogin(Page pag) { DLLUserService.User usr = new DLLUserService.User(); PageBase pb; try { pb = new PageBase(pag); } catch (Exception ex) { HttpCookie cookie; cookie = pag.Request.Cookies["USSUserID"]; if (cookie != null) { cookie.Expires = DateTime.Now.AddDays(-1); pag.Response.SetCookie(cookie); } cookie = pag.Request.Cookies["USSToken"]; if (cookie != null) { cookie.Expires = DateTime.Now.AddDays(-1); pag.Response.SetCookie(cookie); } cookie = pag.Request.Cookies["USSUserInfo"]; if (cookie != null) { cookie.Expires = DateTime.Now.AddDays(-1); pag.Response.SetCookie(cookie); } cookie = pag.Request.Cookies["USSDocInfo"]; if (cookie != null) { cookie.Expires = DateTime.Now.AddDays(-1); pag.Response.SetCookie(cookie); } pb = new PageBase(pag); } try { usr.Authenticate(pb.TokenEx, 0); } catch (Exception ex) { return(false); } pb.UserActiveTime = System.DateTime.Now; return(true); }
protected void btnExit_Click(object sender, EventArgs e) { PageBase myPage = new PageBase(Page); DLLUserService.User myUser = new DLLUserService.User(); try { myUser.Logout(myPage.TokenEx); } catch (Exception ex) { } //清空cookie myPage.set_UserID(true, ""); ShowLogin(); }
protected void btnOK_Click(object sender, EventArgs e) { string sUid; string sPwd; string sToken = ""; bool isSession = true; PageBase myPage = new PageBase(Page); DLLUserService.User myUser = new DLLUserService.User(); sUid = txtUid.Text.Trim(); sPwd = txtPwd.Text.Trim(); if (Request.Form["chLogAuto"] == "1") { isSession = false; } try { //sToken = myUser.Login(ref sUid, sPwd, "192.168.194.105"); sToken = myUser.Login(ref sUid, sPwd, Request.UserHostAddress); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "onekey", "alert('" + GetSoapError(ex) + "');", true); return; } try { myUser.Logout(myPage.TokenEx); } catch (Exception ex) { } //写cookie myPage.set_UserID(true, sUid); myPage.set_Token(isSession, sToken); GotoPage(); }
// protected void Page_Load(object sender, EventArgs e) { PageBase myPage; try { myPage = new PageBase(this.Page); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "onekey", "alert('WebService地址或访问权限配置不正确!');", true); trLogin.Visible = false; trExit.Visible = false; return; } lblWelcome.Text = "已登录"; if (!IsPostBack) { if (IsLogin(Page)) { ShowExit(myPage.get_UserID(true)); } else { try { DLLUserService.User usr = new DLLUserService.User(); string sUserID = ""; string sToken; sToken = usr.Login(ref sUserID, "", Request.UserHostAddress); //sToken = usr.Login(ref sUserID, "", "192.168.194.105"); myPage.set_UserID(true, sUserID); myPage.set_Token(true, sToken); if (sToken != "") { ShowExit(sUserID); } else { ShowLogin(); } } catch (Exception ex) { if (ex.Message.ToString().IndexOf(" 404 失败") > 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "onekey", "alert('WebService地址或访问权限配置不正确!');", true); trLogin.Visible = false; trExit.Visible = false; return; } else { ShowLogin(); } } } } }