using System;
|
using System.Collections.Generic;
|
using System.IO;
|
using System.Linq;
|
using System.Text;
|
using System.Web;
|
using System.Web.Mvc;
|
using System.Web.Mvc.Html;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Converters;
|
using HH.AutoBom.Core;
|
using HH.WMS.Common;
|
|
namespace HH.WMS.WebUI
|
{
|
/// <summary>
|
/// htmlhelper拓展
|
/// </summary>
|
public static class WmsUiExpands
|
{
|
/// <summary>
|
/// 将此路径razor视图转成字符串
|
/// </summary>
|
/// <param name="htmlHelper"></param>
|
/// <param name="path"></param>
|
/// <returns></returns>
|
public static IHtmlString GetVueTemplate(this HtmlHelper htmlHelper, string path)
|
{
|
MvcHtmlString mvcHtmlString = htmlHelper.Partial(path);
|
string result = Escape(mvcHtmlString.ToString().Replace("\r", "").Replace("\n", ""));
|
return htmlHelper.Raw(result);
|
}
|
|
public static string Escape(string str)
|
{
|
StringBuilder sb = new StringBuilder();
|
foreach (char c in str)
|
{
|
sb.Append((Char.IsLetterOrDigit(c)
|
|| c == '-' || c == '_' || c == '\\'
|
|| c == '/' || c == '.') ? c.ToString() : Uri.HexEscape(c));
|
}
|
return sb.ToString();
|
}
|
|
public static IsoDateTimeConverter DateFormatter(this HtmlHelper htmlHelper)
|
{
|
IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
|
timeFormat.DateTimeFormat = "yyyy-MM-dd";
|
return timeFormat;
|
}
|
|
}
|
|
public static class ViewConstants
|
{
|
#region 登陆信息
|
/// <summary>
|
/// 登陆信息
|
/// </summary>
|
public static LoginerBase UserData
|
{
|
get
|
{
|
var loginer = FormsAuth.GetUserData<LoginerBase>();
|
if (loginer == null)
|
return new LoginerBase();
|
return loginer;
|
}
|
}
|
#endregion
|
|
#region TokenId
|
/// <summary>
|
/// TokenId
|
/// </summary>
|
public static string TokenId
|
{
|
get
|
{
|
return UserData.Extend1;
|
}
|
}
|
#endregion
|
|
#region 当前应用
|
/// <summary>
|
/// 当前应用
|
/// </summary>
|
public static string AppCode
|
{
|
get
|
{
|
return Constants.appCode;
|
}
|
}
|
#endregion
|
}
|
}
|