示例#1
0
        public virtual ActionResult HistoryFilter(string viewName, FormCollection collection, string guid)
        {
            try
            {
                if (string.IsNullOrEmpty(viewName))
                {
                    if (Map.Database.DefaultLast && Map.Database.FirstView != null)
                    {
                        return(RedirectToAction("Index", new { viewName = Map.Database.FirstView.Name, page = 1, guid = guid }));
                    }
                    else
                    {
                        return(RedirectToAction("Default"));
                    }
                }

                HandleFilter(collection);

                ViewHelper.SetSessionState(guid + "Filter", collection);
                ViewHelper.SetSessionState(viewName + "Filter", collection);

                Durados.Web.Mvc.View view = GetView(viewName, "Filter");
                //ViewData["Styler"] = GetNewStyler();
                //ViewData["TableViewer"] = GetNewTableViewer();

                string sortColumn    = SortHelper.GetSortColumn(view);
                string sortDirection = SortHelper.GetSortDirection(view);

                if (string.IsNullOrEmpty(sortColumn) && !string.IsNullOrEmpty(view.DefaultSort) || (view.DisplayType != DisplayType.Table && !string.IsNullOrEmpty(view.GroupingFields)))
                {
                    string[] defaultSort = view.GetDefaultSortColumnsAndOrder();
                    string   defaultSortColumnAndOrder = defaultSort[0];
                    sortColumn    = view.GetDefaultSortColumn(defaultSortColumnAndOrder);
                    sortDirection = view.GetDefaultSortColumnOrder(defaultSortColumnAndOrder);
                }

                ViewData["SortColumn"] = sortColumn;
                ViewData["direction"]  = sortDirection;

                return(RedirectToAction("Index", new { viewName = viewName, guid = guid, firstTime = true }));
            }
            catch (Exception exception)
            {
                Map.Logger.Log(GetControllerNameForLog(this.ControllerContext), this.ControllerContext.RouteData.Values["action"].ToString(), exception.Source, exception, 1, null);
                return(PartialView("~/Views/Shared/Controls/ErrorMessage.ascx", (object)exception.Message));
            }
            //DataView dataView = GetDataTable(viewName, 1, collection, search, sortColumn, sortDirection, guid);
            //dataView.Table.ExtendedProperties.Add("guid", guid);
            //return PartialView("~/Views/Shared/Controls/DataTableView.ascx", dataView);
        }