using BLL;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Policy;
using System.Text;
using System.Threading;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Xml;
using AspNet = System.Web.UI.WebControls;
namespace FineUIPro.Web
{
public class PageBase : System.Web.UI.Page
{
///
/// 当前登录人信息。
///
public Model.Sys_User CurrUser
{
get
{
if (Session["CurrUser"] == null)
{
string account = string.Empty;
string password = string.Empty;
if (Request.Cookies["u"] != null)
{
account = HttpUtility.UrlDecode(Request.Cookies["u"].Value);
}
if (Request.Cookies["p"] != null)
{
password = Request.Cookies["p"].Value;
}
Session["CurrUser"] = BLL.Funs.DB.Sys_User.FirstOrDefault(x => x.Account == account && x.Password == Funs.EncryptionPassword(password));
}
return (Model.Sys_User)Session["CurrUser"];
}
}
public string SysType
{
get
{
return (string)Session["SysType"];
}
set
{
Session["SysType"] = value;
}
}
//#region OnInit
// protected override void OnInit(EventArgs e)
//{
// if (Session["CurrUser"] == null && !Request.Path.Contains("/Login.aspx") && !Request.Path.Contains("DataShow"))
// {
// string ticket = Request.Params["ticket"];
// if (!string.IsNullOrEmpty(ticket))
// {
// string jsonCameras = APIGetHttpService.Http("https://cas.china-tcc.com/cas/serviceValidate?service=https://tccsg.cntcc.cn:17001/sggl/indexProject.aspx&ticket=" + ticket);
// XmlDocument xml = new XmlDocument();
// xml.LoadXml(jsonCameras);
// XmlElement root = xml.DocumentElement;
// XmlNode node = root.ChildNodes[0];//遍历输出.
// if (node.LocalName == "authenticationSuccess")
// {
// string user = node.ChildNodes[0].InnerText;//InnerText节点包合的所有文本内容
// //if ("zyk" == user)
// //{
// // user = "hfnbd";
// //}
// Model.Sys_User sysUser = (from y in Funs.DB.Sys_User
// where (y.DomainAccount == user || y.Account ==user) && y.IsPost == true
// select y).FirstOrDefault();
// if (user != null)
// {
// string accValue = HttpUtility.UrlEncode(user);
// FormsAuthentication.SetAuthCookie(accValue, false);
// Page.Session[SessionName.CurrUser] = sysUser;
// string url = "";
// this.CurrUser.RoleType = RoleService.GetRoleTypeByRoleId(this.CurrUser.RoleId);
// if (!this.CurrUser.LastIsOffice.HasValue)
// {
// this.CurrUser.LastIsOffice = this.CurrUser.IsOffice;
// }
// if (this.CurrUser.LastIsOffice == true)
// {
// this.CurrUser.LoginProjectId = null;
// ////本部菜单
// url = "index.aspx";
// }
// else
// {
// this.CurrUser.LoginProjectId = this.CurrUser.LastProjectId;
// //// 项目菜单
// url = "indexProject.aspx?projectId=" + this.CurrUser.LastProjectId;
// }
// this.SysType = "GONGCHENG";
// Response.Redirect(url);
// }
// else
// {
// Response.Redirect("Login.aspx");
// }
// }
// }
// else
// {
// Response.Redirect("https://cas.china-tcc.com/cas/login?service=https://tccsg.cntcc.cn:17001/sggl/indexProject.aspx");
// }
// }
// var pm = PageManager.Instance;
// if (pm != null)
// {
// HttpCookie themeCookie = Request.Cookies["Theme"];
// if (themeCookie != null)
// {
// string themeValue = themeCookie.Value;
// if (themeValue != "Cupertino")
// {
// themeValue = "Cupertino";
// Response.Cookies.Remove("Theme");
// HttpCookie cookie = new HttpCookie("Theme", themeValue)
// {
// Expires = DateTime.Now.AddYears(1)
// };
// Response.Cookies.Add(cookie);
// }
// // 是否为内置主题
// if (IsSystemTheme(themeValue))
// {
// pm.CustomTheme = String.Empty;
// pm.Theme = (Theme)Enum.Parse(typeof(Theme), themeValue, true);
// }
// else
// {
// pm.CustomTheme = themeValue;
// }
// }
// HttpCookie langCookie = Request.Cookies["Language"];
// if (langCookie != null)
// {
// string langValue = langCookie.Value;
// try
// {
// // 是否为内置语言
// pm.Language = (Language)Enum.Parse(typeof(Language), langValue, true);
// }
// catch (Exception)
// {
// pm.CustomLanguage = langValue;
// }
// }
// // 1. 仅显示基础版示例, 2. 基础版
// // 上述两种情况都要禁用EnableAnimation、DisplayMode、MobileAdaption
// bool showOnlyBase = false;
// HttpCookie menuShowOnlyBase = Request.Cookies["ShowOnlyBase"];
// if (menuShowOnlyBase != null)
// {
// showOnlyBase = Convert.ToBoolean(menuShowOnlyBase.Value);
// }
// if (showOnlyBase || Constants.IS_BASE)
// {
// pm.EnableAnimation = false;
// pm.DisplayMode = DisplayMode.Normal;
// pm.MobileAdaption = false;
// }
// else
// {
// HttpCookie modeCookie = Request.Cookies["DisplayMode"];
// if (modeCookie != null)
// {
// string modeValue = modeCookie.Value;
// try
// {
// pm.DisplayMode = (DisplayMode)Enum.Parse(typeof(DisplayMode), modeValue, true);
// }
// catch (Exception)
// {
// pm.DisplayMode = DisplayMode.Normal;
// }
// }
// }
// HttpCookie loadingCookie = Request.Cookies["Loading"];
// if (loadingCookie != null)
// {
// int loadingNumber = Convert.ToInt32(loadingCookie.Value);
// pm.LoadingImageNumber = loadingNumber;
// }
// // SaveFStateToServer是页面上自定义的一个属性
// if (SaveFStateToServer)
// {
// //// FState保存到服务器文件
// //pm.EnableFStatePersistence = true;
// //pm.LoadFStateFromPersistenceMedium = LoadFStateFromPersistenceMedium;
// //pm.SaveFStateToPersistenceMedium = SaveFStateToPersistenceMedium;
// //FState保存到服务器缓存
// pm.EnableFStatePersistence = true;
// pm.LoadFStateFromPersistenceMedium = LoadFStateFromPersistenceMedium_Cache;
// pm.SaveFStateToPersistenceMedium = SaveFStateToPersistenceMedium_Cache;
// }
// // 为所有页面添加公共CSS:
// System.Web.UI.HtmlControls.HtmlGenericControl linkCtrl = new System.Web.UI.HtmlControls.HtmlGenericControl("link");
// linkCtrl.Attributes["rel"] = "stylesheet";
// linkCtrl.Attributes["type"] = "text/css";
// linkCtrl.Attributes["href"] = ResolveClientUrl("~/res/css/common.css?v" + GlobalConfig.ProductVersion);
// Header.Controls.AddAt(GetHeadStyleCSSIndex(), linkCtrl);
// // 为所有页面添加公共JS:
// var commonJSPath = String.Format("", ResolveClientUrl("~/res/js/common.js?v" + GlobalConfig.ProductVersion));
// PageContext.RegisterStartupScript("FineUIPro_Examples_common_js", commonJSPath, false);
// //var jqueryMigrateJSPath = String.Format("", ResolveClientUrl("~/res/js/jquery-migrate-3.0.1.js?v" + GlobalConfig.ProductVersion));
// //PageContext.RegisterPreStartupScript("FineUIPro_Examples_jquery-migrate_js", jqueryMigrateJSPath, false);
// // 禁用表单的自动完成功能
// // v5.4.0 - 无需手工设置,每个表单字段的autoComplete默认为false
// //Form.Attributes["autocomplete"] = "off";
// }
// this.Load += new EventHandler(this.PageBase_Load);
// this.Unload += new EventHandler(this.PageBase_UNLoad);
// //base.OnInit(e);
// }
// ///
// /// 页面登录成功
// ///
// ///
// ///
// protected void PageBase_Load(object sender, EventArgs e)
// {
// //这是后置式的权限管理策略.
// //页面装载完成以后才检查是否有权限打开此页....
// //anyway,its ok.
// this.Title = BLL.Funs.SystemName;
// //if (CurrUser == null)
// //{
// // if (this.Page.Request.AppRelativeCurrentExecutionFilePath != "~/Login.aspx")
// // Response.Redirect("~/Login.aspx");
// //}
// }
// ///
// /// UNLOAD事件,发生在页面装载顺序的最后。
// /// 在这里处理的是DBLIST,数据库连接字典。
// ///
// /// S
// /// E
// protected void PageBase_UNLoad(object sender, EventArgs e)
// {
// if (BLL.Funs.DBList.ContainsKey(System.Threading.Thread.CurrentThread.ManagedThreadId))
// {
// BLL.Funs.DBList.Remove(System.Threading.Thread.CurrentThread.ManagedThreadId);
// }
// }
// private bool IsSystemTheme(string themeName)
// {
// themeName = themeName.ToLower();
// string[] themes = Enum.GetNames(typeof(Theme));
// foreach (string theme in themes)
// {
// if (theme.ToLower() == themeName)
// {
// return true;
// }
// }
// return false;
// }
// private int GetHeadStyleCSSIndex()
// {
// var theIndex = 0;
// for (var i = 0; i < Header.Controls.Count; i++)
// {
// var ctrl = Header.Controls[i];
// if (ctrl is LiteralControl)
// {
// if ((ctrl as LiteralControl).Text.Trim().ToLower().StartsWith("