日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

 

關于應用模塊頁面的生成

應用模塊頁面函數

如:

public partial class userblog : BaseJsonMode{

[ModeMethod("{CanNoLogin:true,CanEnable:true}")]

static public ReturnJson index(HttpContext ctx, Object m_Parame)

{

ReturnJson m_ReturnJson = new ReturnJson();

try

{

Hashtable m_PageHH = new Hashtable();

//獲得頁面參數

JsonHelper.OBJToHashTable(m_Parame, m_PageHH);

m_ReturnJson.bOK=true;

//獲得渲染頁面的內容,傳遞頁面數據m_PageHH

m_ReturnJson.m_ReturnOBJ = RenderPageView(ctx, m_JsonModePath, "index", m_PageHH);

}

catch(Exception)

{

m_ReturnJson.bOK=false;

m_ReturnJson.sMsg="渲染頁面異常";

}

return m_ReturnJson;

}

通過瀏覽器訪問該頁面

http://../userblog/index.aspx?a=a

其中m_PageHH將獲得參數

string a=m_PageHH["a"].ToString();

渲染頁面函數

static protected string RenderPageView(HttpContext m_ctx, string m_ModePath, string m_TamplateCTL, Object m_Model)

m_ModePath:頁面文件所在位置一般為m_JsonModePath

如是渲染PC端頁面一般為Viewamazeuizh-CNindex.aspx

如是渲染手機端頁面一般為Viewdeviceamazeuizh-CNindex.aspx

我們也可以自己再加自己的路徑

如m_ModePath設置為m_JsonModePath+“/xn”;

那么找到的頁面路徑則為

如是渲染PC端頁面一般為Viewamazeuizh-CNxnindex.aspx

如是渲染手機端頁面一般為Viewdeviceamazeuizh-CNixnndex.aspx

路徑分解

對于PC端:View+UI庫名+語言+添加路徑+頁面文件

對于手機端:View+device+UI庫名+語言+添加路徑+頁面文件

我們采用aspx作為頁面模板的原因,因為ASP.NET開發人員對于aspx頁面嵌套服務端邏輯代碼是比較熟悉的,便于很快上手

對于aspx模板頁面派生自
XNWebEngine.JsonBase.MyBasePageView

典型代碼如下:

<%@ Page Language="C#" AutoEventWireup="true" Inherits="XNWebEngine.JsonBase.MyBasePageView" %>

<%@ Assembly Name="CoreSYS" %>

<%@ Import Namespace="XNWebEngine.JsonBase" %>

<%@ Import Namespace="System" %>

<%@ Import Namespace="CoreSYS" %>

<%@ Import Namespace="System.Collections.Generic" %>

<%@ Import Namespace="XNWebEngine" %>

<script language="C# " runat="server">

public Object getModel()

{

return this.Model;

}

</script>

其中getModel()獲得RenderPageView傳過來的頁面數據

如:

<%

Hashtable m_PageHH=(Hashtable)getModel();

string a="";

try

{

if(m_PageHH.ContainsKey("a"))

{

a=m_PageHH["a"].ToString();

}

}

catch

{

}

%>

后續的代碼和正常的aspx頁面寫法一致

MyBasePageView的類函數可在頁面使用的可見之前的章節

MyBasePageView常用函數和參數

獲得文件上傳參數

static public OneUpFileWEB GetUpFileURL(HttpContext ctx)

讀取cookie

static protected string ReadCookie(HttpContext ctx, string name)

static protected HttpCookie GetCookie(HttpContext ctx, string sKey)

獲得當前登錄信息

protected SessionLink GetSessionLink()

判斷當前用戶權限

public bool HavePower(string ClassFullName, string FunctionName, bool bClient, out string sError)

判斷指定角色權限

public bool HavePower(string sys_js_uuid, string username, string ClassFullName, string FunctionName, bool bClient, out string sError)

調用指定應用模塊函數

public bool CallModeFunction(string classfullname, string functionname, object m_InParame, out object m_OutParame, out string sError)

執行指定模塊的函數返回html

public string RenderModeHTML(string classfullname, string functionname, object m_InParame)

保存cookie

protected bool SaveCookie(string name, string value)

讀取cookie

protected string ReadCookie( string name)

#region 讀寫Cache

protected bool SaveCache<T>(string sKey, T m_T,bool bSlidTime=true)

 

protected bool ReadCache<T>(string sKey, out T m_T, int nDelayMinute = -1)

 

protected bool SaveCache<T>(string sKey, T m_T, TimeSpan m_nOverTime, bool bSlidTime=true)

 

protected bool ClearCache(string sKey)

 

#endregion

#region 清除cookie

protected void ClearCookie(string sKey)

#endregion

其他

protected bool SaveCookie( string name, string value, TimeSpan m_T)

 

protected bool SaveUserShareCache<T>(string sKey, T m_T, bool bSlidTime=true)

 

protected bool SaveUserShareCache<T>(string sKey, T m_T, TimeSpan m_nOverTime, bool bSlidTime=true)

 

protected bool ReadUserShareCache<T>(string sKey, out T m_T, int nDelayMinute = -1)

 

protected bool ClearUserShareCache<T>( string sKey)

 

protected bool SaveUserCache<T>(string sKey, T m_T, bool bSlidTime=true)

 

protected bool SaveUserCache<T>(string sKey, T m_T, TimeSpan m_nOverTime, bool bSlidTime=true)

 

protected bool ReadUserCache<T>(string sKey, out T m_T, int nDelayMinute = -1)

 

protected bool ClearUserCache<T>(string sKey)

讀取key

static protected string GetConfigKeyString(string sKeyName)

獲得資源url

static protected string GetResourceUrl(HttpContext ctx)

獲得頁面前綴

static protected string GetUrlBefore(HttpContext ctx)

protected static string GetUrlHead(HttpContext ctx)

判斷是否是PC端

protected bool IsPCClient()

判斷是否HTTPS

protected bool IsHTTPS()

 

以上函數在頁面里都可調用

常用功能及函數為

1.獲得頁面數據

<script language="C# " runat="server">

public Object getModel()

{

return this.Model;

}

</script>

<%

Hashtable m_HH=(Hashtable)getModel();

%>

2.權限判斷

<%

string sError;

if (HavePower("CodeFactory_0_base", "Addcode_adcodes", false, out sError))

{

}

%>

3.獲得當前登錄信息

<%

SessionLink m_SessionLink = GetSessionLink();

%>

 

4.獲得應用模塊的view Url路徑

<%

string ModeUrl = urlBefore + MainViewPath;

%>

<script src="<%=ModeUrl%>amazeui/public/js/clipboard.min.js" type="text/JAVAscript"></script>

 

5.獲得資源的URL路徑

<%

GetResourceUrl(HttpContext.Current);

%>

//應用例子

<script src="<%=GetResourceUrl(HttpContext.Current)%>/public/amazeui/amazeui/js/jquery.min.js"></script>

 

6.獲得頁面前綴

<%

GetHeadUrl(HttpContext.Current);

%>

//應用例子

ar options = {

iniUrl: "<%=GetUrlHead(HttpContext.Current)%>
weixin/initLayUI_RawJson.ajax", // 初始化接口

clearUrl: "<%=GetUrlHead(HttpContext.Current)%>
weixin/clearLayUI_RawJson.ajax", // 緩存清理接口

renderPageVersion: true, // 初始化頁面是否加版本號

bgColorDefault: false, // 主題默認配置

multiModule: true, // 是否開啟多模塊

menuChildOpen: false, // 是否默認展開菜單

loadingTime: 0, // 初始化加載時間

pageAnim: true, // 切換菜單動畫

};

 

頁面渲染函數的內部實現

static protected string RenderPageView(HttpContext m_ctx, string m_ModePath, string m_TamplateCTL, Object m_Model)

該頁面渲染函數支持對aspx的渲染和shtml采用開源JNTemplate渲染

aspx頁面渲染核心代碼

//構建Page pageVirtualPath:aspx文件路徑

Page handler = BuildManager.CreateInstanceFromVirtualPath(pageVirtualPath, typeof(System.Web.UI.Page)) as Page;

//設置頁面數據

SetPageModel(handler, m_Model, ViewPath);

StringWriter output = new StringWriter();

//執行輸出頁面

m_ctx.Server.Execute(handler, output, false);

//返回頁面字符串

return output.ToString();

 

shtml頁面JNTemplate渲染核心代碼

string output="";

using (JNTemplateEngine m_JNTemplateEngine = new JNTemplateEngine(m_ctx, m_ModePath, FName, m_Model, true))

{

m_JNTemplateEngine.Render(out output);

}

對于開源JNTemplate的使用可查閱相關資料

其中JNTemplateEngine封裝的渲染引擎代碼如下

class JNTemplateEngine: IDisposable

{

JinianNet.JNTemplate.ITemplate ITemplate = null;

HttpContext ctx = null;

PageEngine m_PageEngine = null;

public JNTemplateEngine(HttpContext ctx, string m_ModePath, string src, Object m_Model, bool bFile = true)

{

this.ctx = ctx;

if (bFile)

ITemplate = Engine.LoadTemplate(src);

else

{

ITemplate = Engine.CreateTemplate(src);

}

ITemplate.Set("model", m_Model);

m_PageEngine = new PageEngine(ctx, m_ModePath);

ITemplate.Set("engine", m_PageEngine);

 

}

public JNTemplateEngine(HttpContext ctx, string m_ModePath, string src, Object m_Model, Type m_Type,bool bFile = true)

{

this.ctx = ctx;

if (bFile)

ITemplate = Engine.LoadTemplate(src);

else

{

ITemplate = Engine.CreateTemplate(src);

}

ITemplate.Set("model", m_Model);

m_PageEngine = new PageEngine(ctx, m_ModePath);

ITemplate.Set("engine", m_PageEngine);

ITemplate.SetStaticType("insertClass", m_Type);

}

 

public void Dispose()

{

if(ITemplate!=null)

{

ITemplate=null;

}

if(m_PageEngine!=null)

{

m_PageEngine = null;

}

}

 

public bool Render(out string sText)

{

sText = "";

try

{

sText = ITemplate.Render();

return true;

}

catch (Exception e)

{

sText = e.ToString();

return false;

}

}

}

public class PageEngine : BaseJsonMode

{

HttpContext ctx = null;

string m_ModePath,ModeUrl="";

public PageEngine(HttpContext ctx, string m_ModePath)

{

this.ctx = ctx;

this.m_ModePath = m_ModePath;

string ViewPath = "~\" + m_ModePath + "\View\";

ViewPath = ViewPath.Replace("\", "/");

int nPos = ViewPath.IndexOf("View/");

string MainViewPath = "";

if (nPos != -1)

{

MainViewPath = ViewPath.Substring(1, nPos + 4);

}

ModeUrl = GetResourceUrl() + MainViewPath;

 

}

public SessionLink GetSessionLink()

{

return BaseJsonMode.GetSessionLink(ctx);

//SessionLink m_SessionLink = new SessionLink();

//m_SessionLink.username = "xuneng";

//return m_SessionLink;

}

public bool HavePower(string FullClassName, string FunctionName)

{

return BaseJsonMode.HavePower(ctx, FullClassName, FunctionName, true).bOK;

//return true;

}

public bool SaveCookie(string name, string value)

{

return BaseJsonMode.SaveCookie(ctx, name, value);

//return false;

}

public string ReadCookie(string name)

{

return BaseJsonMode.ReadCookie(ctx, name);

//return "";

}

public void ClearCookie(string name)

{

BaseJsonMode.ClearCookie(ctx, name);

//return;

}

public ReturnJson CallJsonModeFunction(string ClassFullName, string FunctionName, Object m_InParame)

{

ReturnJson m_ReturnJson = new ReturnJson();

//return m_ReturnJson;

 

if (BaseJsonMode.CallJsonModeFunction(ctx, ClassFullName, FunctionName, m_InParame, true, out m_ReturnJson.m_ReturnOBJ, out m_ReturnJson.sMsg))

{

m_ReturnJson.bOK = true;

return m_ReturnJson;

}

else

{

m_ReturnJson.bOK = false;

return m_ReturnJson;

}

 

}

public string RenderModeHTML(string classfullname, string functionname, object m_InParame)

{

//return "";

ReturnJson m_ReturnJson = CallJsonModeFunction(classfullname, functionname, m_InParame);

if (m_ReturnJson.bOK)

{

return m_ReturnJson.m_ReturnOBJ.ToString();

}

else

{

return m_ReturnJson.sMsg;

}

}

public string GetResourceUrl()

{

return BaseJsonMode.GetResourceUrl(ctx);

}

public OneUpFileWEB GetUpFileURL()

{

return BaseJsonMode.GetUpFileURL(ctx);

}

public bool HaveCrossPower(string sClassFullName, string sFunctionName, string sys_companys_nodeuuid)

{

return BaseJsonMode.HaveCrossPower(ctx, sClassFullName, sFunctionName, sys_companys_nodeuuid, true).bOK;

}

protected List<string> GetUrlDotListString()

{

if (ctx.Items.Contains("headDot"))

{

return (List<string>)ctx.Items["headDot"];

}

string[] sDotArray = ctx.Request.FilePath.Split('/');

int nCnt = sDotArray.Length;

List<string> m_List = new List<string>();

if (nCnt >= 3)

{

if (nCnt == 3)

{

ctx.Items["headDot"] = m_List;

return m_List;

}

else

{

//string[] m_ReturnDotArray = new string[nCnt - 3];

for (int i = 1; i < 1 + nCnt - 3; i++)

{

m_List.Add(sDotArray[i]);

}

ctx.Items["headDot"] = m_List;

return m_List;

}

}

else

{

ctx.Items["headDot"] = m_List;

return m_List;

}

}

public string GetUrlHead()

{

List<string> m_HeadList = GetUrlDotListString(ctx);

if (m_HeadList.Count > 0)

{

string str = "";

for (int i = 0; i < m_HeadList.Count; i++)

{

str += "/" + m_HeadList[i];

}

str += "/";

return str;

}

else

{

return "/";

}

}

public string GetModeUrl()

{

return ModeUrl;

}

public bool IsPCClient()

{

return BaseJsonMode.IsPCClient(ctx);

}

public bool isHTTPS()

{

return ctx.Request.IsSecureConnection;

}

public Hashtable OBJToHashTable(Object m_Parame)

{

/*

Hashtable m_HH = new Hashtable();

JsonHelper.OBJToHashTable(m_Parame, m_HH);

return m_HH;

*/

try

{

return JsonHelper.OBJToType<Hashtable>(m_Parame);

}

catch

{

return new Hashtable();

}

}

 

public List<Hashtable>OBJToListHashtable(Object m_Parame)

{

return JsonHelper.OBJToType<List<Hashtable>>(m_Parame);

}

public Hashtable JsonToHashtable(string jsonString)

{

/*

Hashtable m_HH = new Hashtable();

JsonHelper.JsonToHashtable(jsonString, m_HH);

return m_HH;

*/

return JsonHelper.JsonStrToOBJ<Hashtable>(jsonString);

}

}

 

使用JNTemplate的頁面例子

頁面函數:

static public ReturnJson uniAppTestPage(HttpContext ctx, Object m_Parame)

{

Hashtable m_HH = new Hashtable();

JsonHelper.OBJToHashTable(m_Parame, m_HH);

 

ReturnJson m_ReturnJson = new ReturnJson();

try

{

string type = "";

if (KeyIsOK(m_HH, "type"))

{

type = m_HH["type"].ToString();

}

m_ReturnJson.bOK = true;

oneData m_oneData = new oneData();

m_oneData.m_HH = new Hashtable();

m_oneData.A = "1";

m_oneData.B = 2;

m_oneData.m_HH["A"] = type;

m_oneData.m_oneData = new oneData();

m_oneData.m_oneData.m_HH = new Hashtable();

m_oneData.m_oneData.A = "11";

m_oneData.m_oneData.B = 22;

m_oneData.m_oneData.m_HH["A"] = "下級測試數據";

oneData m_oneData0 = new oneData();

m_oneData0.A = "c1";

m_oneData.m_HH["m_oneData"] = m_oneData0;//錯誤Hashtable內只能包含基本數據類型如int string float double 不能包含對象否則模板訪問失敗

int i;

List<Hashtable> m_HHList = new List<Hashtable>();

for (i = 0; i < 10; i++)

{

Hashtable m_oneHH = new Hashtable();

m_oneHH["pos"] = i;

m_HHList.Add(m_oneHH);

}

m_oneData.m_oneData.m_HHList = m_HHList;

List<oneRow> m_RowArray = new List<oneRow>();

for (i = 0; i < 10; i++)

{

oneRow m_oneRow = new oneRow();

m_oneRow.pos = i;

m_RowArray.Add(m_oneRow);

}

m_oneData.m_oneData.m_HH["array"] = m_RowArray.ToArray();

m_oneData.m_oneData.m_HH["array2"] = m_HHList;

m_oneData.m_oneData.m_RowArray = m_RowArray;

m_ReturnJson.m_ReturnOBJ = RenderPageView(ctx, m_JsonModePath, "uniappTestPage.shtml", m_oneData,typeof(menuClass));

}

catch

{

m_ReturnJson.bOK = false;

m_ReturnJson.sMsg = "渲染uniappTestPage失敗";

}

return m_ReturnJson;

}

uniappTestPage.shtml的頁面內容純測試模板語法所以里面未出現html標簽

m_oneData.A:${model.A},m_oneData.B:${model.B},m_oneData.m_HH["A"]:${model.m_HH["A"]},m_oneData.m_oneData.A:${model.m_oneData.A},m_oneData.m_oneData.B:${model.m_oneData.B},m_oneData.m_oneData.m_HH["A"]:${model.m_oneData.m_HH["A"]},m_SessionLink.username:${engine.GetSessionLink().username}

權限判斷:CoreSYS.SYS/AddCompany:${if(engine.HavePower("CoreSYS.SYS","AddCompany"))}有權限執行${else}無權限執行${end}

對象列表數據:${foreach(one in
model.m_oneData.m_RowArray)}序號-${one.pos} ${end}<br />

Hashtable的List列表數據:${foreach(one in model.m_oneData.m_HHList)}序號-${one["pos"]} ${end}</br>

Hashtable中對象${model.m_HH["m_oneData"]}</br>

引號內</br>

Hashtable的List列表數據:"${foreach(one in model.m_oneData.m_HHList)}序號-${one["pos"]} ${end}"</br>

模板頁內變量使用<br />

${set(a=123)}<br />

輸出:${a}

<br />

<ul>

定義ii變量

${set(ii=0)}

${for(ii=1;ii<4;ii++)}

<li>${ii}</li>

${end}

</ul>

</br>

復雜語法測試<br />

${set(m_SessionLink=engine.GetSessionLink())}

${if(model.m_oneData.m_HH.ContainsKey("BB"))}

有BB

${else}

無BB

${end}

<br />

復雜測試

Hashtable對象${set(m_oneData=model.m_HH["m_oneData"])}

${set(hh=engine.OBJToHashTable(m_oneData))}

${hh["A"]}

<br />

Hashtable對象

${engine.OBJToHashTable(model.m_HH["m_oneData"])["A"]}

<br />

Hashtable包含Hashtable數組

${set(m_List=model.m_oneData.m_HH["array2"])}

${set(m_HHList=engine.OBJToListHashtable(m_List))}

${foreach(rr in m_HHList)}

${rr["pos"]},

${end}

<br />

Hashtable包含Hashtable數組

${foreach(rr2 in engine.OBJToListHashtable(model.m_oneData.m_HH["array2"]))}

${rr2["pos"]},

${end}

下集將針對應用模塊開發頁面UI常用代碼總結

分享到:
標簽:NET
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定