private void HandleFilter(FormCollection collection) { string jsonFilter = collection["jsonFilter"]; Durados.Web.Mvc.UI.Json.Filter filter = Durados.Web.Mvc.UI.Json.JsonSerializer.Deserialize <Durados.Web.Mvc.UI.Json.Filter>(jsonFilter); if (filter.Fields.ContainsKey("ViewName")) { string viewName = filter.Fields["ViewName"].Value.ToString(); if (Map.Database.Views.ContainsKey(viewName)) { View view = (View)Map.Database.Views[viewName]; if (!IsAllow(view) || !ViewOwnerAllow(view)) { throw new DuradosAccessViolationException(Map.Database.Localizer.Translate("You are trying to view history of an unpermitted Table/View")); } if (!string.IsNullOrEmpty(view.BaseName)) { if (view.Base != null) { viewName = view.Base.Name; filter.Fields["ViewName"].Value = viewName; jsonFilter = Durados.Web.Mvc.UI.Json.JsonSerializer.Serialize <Durados.Web.Mvc.UI.Json.Filter>(filter); collection["jsonFilter"] = jsonFilter; } } } } }
public DataView FillPage(View view, int page, int pageSize, Json.Filter jsonFilter, bool search, string sortColumn, SortDirection direction, out int rowCount, BeforeSelectEventHandler beforeSelectCallback, AfterSelectEventHandler afterSelectCallback) { Dictionary <string, object> values = new Dictionary <string, object>(); if (jsonFilter != null) { foreach (Json.Field jsonField in jsonFilter.Fields.Values) { if (jsonField.Value != null && !string.IsNullOrEmpty(jsonField.Value.ToString())) { values.Add(jsonField.Name, jsonField.Value); } //else //{ // values.Add(jsonField.Name, null); //} } } Dictionary <string, SortDirection> sortColumns = new Dictionary <string, SortDirection>(); if (!string.IsNullOrEmpty(sortColumn)) { sortColumns.Add(sortColumn, direction); } return(view.FillPage(page, pageSize, values, search, sortColumns, out rowCount, beforeSelectCallback, afterSelectCallback)); }
private int?GetMemRequestID() { Durados.Web.Mvc.UI.Json.Filter jsonFilter = ViewHelper.ConvertQueryStringToJsonFilter(currentGuid); if (jsonFilter == null) { return(null); } string fkFieldName = "MemoryRequestId"; if (!jsonFilter.Fields.ContainsKey(fkFieldName)) { return(null); } object value = jsonFilter.Fields[fkFieldName].Value; if (value == null || value.ToString() == string.Empty) { return(null); } return(Convert.ToInt32(jsonFilter.Fields[fkFieldName].Value)); }
public virtual void HandleFilter(Json.Filter jsonFilter) { }
public Json.Filter GetJsonFilter(View view, string guid) { Json.Filter jsonFilter = new Json.Filter(); //foreach (Field field in view.VisibleFieldsForFilter) foreach (Field field in view.Fields.Values) { string type = (field.FieldType == FieldType.Children) ? "Children" : field.GetHtmlControlType().ToString(); jsonFilter.Fields.Add(field.Name, new Json.Field() { Name = field.Name, Type = type, Searchable = field.IsSearchable(), Permanent = false }); } Durados.Web.Mvc.UI.Json.Filter pageFilter = view.GetPageFilter(guid); string parentFieldName = pageFilter.GetParentFiterFieldName(); if (!string.IsNullOrEmpty(parentFieldName)) { if (jsonFilter.Fields.ContainsKey(parentFieldName)) { Field field = view.Fields[parentFieldName]; string fieldVal = string.Empty; foreach (string s in field.DatabaseNames.Split(',')) { fieldVal += string.Format("{0},", ViewHelper.GetSessionState(guid + "PageFilterState")[s]); } jsonFilter.Fields[parentFieldName].Value = fieldVal.TrimEnd(','); if (field.FieldType == FieldType.Parent) { ParentField parentField = (ParentField)field; //if (parentField.ParentHtmlControlType == ParentHtmlControlType.Autocomplete) //{ string pk = jsonFilter.Fields[parentFieldName].Value.ToString(); jsonFilter.Fields[parentFieldName].Default = parentField.GetDisplayValue(pk); //} } else if (field.FieldType == FieldType.Column) { } jsonFilter.Fields[parentFieldName].Permanent = true; } else { if (view.IsDerived) { string derivedFieldName = view.GetDerivedParentField(parentFieldName).Name; if (jsonFilter.Fields.ContainsKey(derivedFieldName)) { jsonFilter.Fields[derivedFieldName].Value = ViewHelper.GetSessionState(guid + "PageFilterState")[0]; jsonFilter.Fields[derivedFieldName].Permanent = true; } } } } return(jsonFilter); }