using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using Bowin.Common.Linq.Entity; namespace EMIS.ViewModel { public class QueryParamsModel { public int? page { get; set; } public int? rows { get; set; } public string QueryParamsDatas { get; set; } /// /// /// public string OrderBy { get { var orderby = (OrderByStatementView)HttpContext.Current.Session["Bowin_Common_Linq_Entity_CurOrderby"]; if (orderby == null) { return null; } else { return orderby.OrderBy; } } set { if (value == null) { HttpContext.Current.Session["Bowin_Common_Linq_Entity_CurOrderby"] = null; return; } var orderby = (OrderByStatementView)HttpContext.Current.Session["Bowin_Common_Linq_Entity_CurOrderby"]; if (orderby == null) { orderby = new OrderByStatementView() { OrderBy = value }; } else { orderby.OrderBy = value; } HttpContext.Current.Session["Bowin_Common_Linq_Entity_CurOrderby"] = orderby; } } /// /// /// public bool? IsAsc { get { var orderby = (OrderByStatementView)HttpContext.Current.Session["Bowin_Common_Linq_Entity_CurOrderby"]; if (orderby == null) { return null; } else { return orderby.isAsc; } } set { if (value == null) { HttpContext.Current.Session["Bowin_Common_Linq_Entity_CurOrderby"] = null; return; } var orderby = (OrderByStatementView)HttpContext.Current.Session["Bowin_Common_Linq_Entity_CurOrderby"]; if (orderby == null) { orderby = new OrderByStatementView() { isAsc = value.Value }; } else { orderby.isAsc = value.Value; } HttpContext.Current.Session["Bowin_Common_Linq_Entity_CurOrderby"] = orderby; } } /// /// /// /// protected Dictionary getParamsSource() { Dictionary dicparams = new Dictionary(); if (!string.IsNullOrEmpty(QueryParamsDatas)) { var arrayQueryParams = QueryParamsDatas.Split(new string[] { "|@|" }, StringSplitOptions.RemoveEmptyEntries); arrayQueryParams.ToList().ForEach(it => { var arraydata = it.Split(new string[] { "|*|" }, StringSplitOptions.None); dicparams.Add(arraydata[0], arraydata[1]); }); } return dicparams; } /// /// /// /// /// public String getExtraString(string QueryparameName) { var datas = getParamsSource(); string redata = ""; if (datas.ContainsKey(QueryparameName)) { redata = datas[QueryparameName]; } return redata; } /// /// /// /// /// public int? getExtraInt(string QueryparameName) { var datas = getParamsSource(); Nullable redata = new Nullable(); if (datas.ContainsKey(QueryparameName)) { int idata = 0; if (int.TryParse(datas[QueryparameName], out idata)) { redata = idata; } } return redata; } /// /// /// /// /// public bool? getExtraBool(string QueryparameName) { var datas = getParamsSource(); if (datas.ContainsKey(QueryparameName)) { if (datas[QueryparameName].ToLower().Contains("true")) { return true; } else { return false; } } else { return null; } } /// /// /// /// /// public DateTime? getExtraDateTime(string QueryparameName) { var datas = getParamsSource(); Nullable redata = new Nullable(); if (datas.ContainsKey(QueryparameName)) { DateTime idata = DateTime.MinValue; if (DateTime.TryParse(datas[QueryparameName], out idata)) { redata = idata; } } return redata; } /// /// /// /// /// public Guid? getExtraGuid(string QueryparameName) { var datas = getParamsSource(); Nullable redata = new Nullable(); if (datas.ContainsKey(QueryparameName)) { Guid idata = Guid.Empty; if (Guid.TryParse(datas[QueryparameName], out idata)) { redata = idata; } } return redata; } } }