123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- 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<string, string> getParamsSource()
- {
- Dictionary<string, string> dicparams = new Dictionary<string, string>();
- 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 List<ConfiguretView> getConditions()
- {
- var queryParams = this.getParamsSource();
- List<ConfiguretView> configuretViews = new List<ConfiguretView>();
- foreach (var item in queryParams)
- {
- if (item.Key != "Attribute" && item.Key != "ConditionValue" && item.Key != "Condition" && !item.Key.Contains("_QueryTextBox"))
- {
- if (!string.IsNullOrEmpty(item.Value) && item.Value != "-1")
- {
- configuretViews.Add(new ConfiguretView()
- {
- Attribute = item.Key,
- Condition = "=",
- ConditionValue = item.Value
- });
- }
- }
- }
- return configuretViews;
- }
- 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<int> redata = new Nullable<int>();
- 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<DateTime> redata = new Nullable<DateTime>();
- 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<Guid> redata = new Nullable<Guid>();
- if (datas.ContainsKey(QueryparameName))
- {
- Guid idata = Guid.Empty;
- if (Guid.TryParse(datas[QueryparameName], out idata))
- {
- redata = idata;
- }
- }
- return redata;
- }
- }
- }
|