public static string ToHtmlString(this PagingMgr pagingMgr, Controller mvcController) { // Get the pagingState and pagingDirection var route = mvcController.RouteData; var controllerName = route.GetRequiredString("controller"); var actionName = route.GetRequiredString("action"); string pagingState = mvcController.Request.Params["pagingState"]; string pagingDirection = mvcController.Request.Params["pagingDirection"] ?? "first"; // Set the pagingState before getting the intended page pagingMgr.RestorePagingState(pagingState); // Set the paging option and get the next page PagingMgr.PagingDbCmdEnum pagingOption = pagingDirection == "first" ? PagingMgr.PagingDbCmdEnum.First : pagingDirection == "next" ? PagingMgr.PagingDbCmdEnum.Next : pagingDirection == "prev" ? PagingMgr.PagingDbCmdEnum.Previous : PagingMgr.PagingDbCmdEnum.Last; DataTable pageTable = pagingMgr.GetPage(pagingOption); IEnumerable <dynamic> pageData = DataTableToEnumerable(pageTable); // Realize the loop WebGrid webGrid = new WebGrid(pageData, rowsPerPage: pagingMgr.PageSize); // Get the new paging state for next and previous link string newPagingState = pagingMgr.GetPagingState(); string html = string.Format("<a href=\"/OurAdminWeb/Grid/TestSequences?pagingState={0}&pagingDirection={1}\">Previous</a>", newPagingState, "prev") + " | " + string.Format("<a href=\"/OurAdminWeb/Grid/TestSequences?pagingState={0}&pagingDirection={1}\">Next</a><br />", newPagingState, "next"); return(html + webGrid.Table().ToHtmlString()); }
public static string PagingMgrGrid(this HtmlHelper htmlHelper, PagingMgr pagingMgr) { // Get the pagingState and pagingDirection var route = htmlHelper.ViewContext.RouteData; var controllerName = route.GetRequiredString("controller"); var actionName = route.GetRequiredString("action"); string pagingState = htmlHelper.ViewContext.HttpContext.Request.Params["pagingState"]; string pagingDirection = htmlHelper.ViewContext.HttpContext.Request.Params["pagingDirection"]; PagingMgr.PagingDbCmdEnum pagingOption = string.IsNullOrWhiteSpace(pagingDirection) ? PagingMgr.PagingDbCmdEnum.First : (PagingMgr.PagingDbCmdEnum)Enum.Parse(typeof(PagingMgr.PagingDbCmdEnum), pagingDirection); if (!string.IsNullOrWhiteSpace(pagingState)) { // Set the pagingState before getting the intended page pagingMgr.RestorePagingState(pagingState); // string initHtml = @" // //function showPage(action, data) {{ // $.ajax({{ // url: action, // type: ""get"", // format: ""html"", // cache: false, // data: data, // success: function (result) {{ // // alert(result); // $(""#gridContainer"").html(result); // }}, // error: function (xhr, status, error) {{ // // //?? CALL the client side error handling function which may be provided by the client // // alert(xhr.responseText); // //?? showModalDialog(xhr.statusText, xhr.responseText); // }} // }}); //}} // //"; } // Set the paging option and get the next page DataTable pageTable = pagingMgr.GetPage(pagingOption); IEnumerable <dynamic> pageData = DataTableToEnumerable(pageTable); // Realize the loop WebGrid webGrid = new WebGrid(pageData, rowsPerPage: pagingMgr.PageSize); // Get the new paging state for next and previous link string newPagingState = pagingMgr.GetPagingState(); string html = string.Format("<a href=\"/OurAdminWeb/Grid/TestSequences?pagingState={0}&pagingDirection={1}\">Previous</a>", newPagingState, "prev") + " | " + string.Format("<a href=\"/OurAdminWeb/Grid/TestSequences?pagingState={0}&pagingDirection={1}\">Next</a><br />", newPagingState, "next"); return(html + webGrid.Table().ToHtmlString()); }
public static IHtmlString ToHtmlString <T>(this PagingMgr pagingMgr, PagingMgr.PagingDbCmdEnum pagingDirection) where T : new() { IEnumerable <dynamic> pageData = (IEnumerable <dynamic>)pagingMgr.GetPage <T>(pagingDirection); WebGrid webGrid = new WebGrid(pageData); return(webGrid.Table()); }
public ActionResult Users2() { DataAccessMgr daMgr = Global.GetDataAccessMgr(this.HttpContext); B1SampleEntities entities = new B1SampleEntities(); var query = from a in entities.UserMasters select new { a.UserCode, a.UserId, a.FirstName, "Edit" }; PagingMgr testSequenceMgr = new PagingMgr(daMgr, query, DataAccess.Constants.PageSize, 5); return(PartialView(Constants._Page_PagingMgrView, testSequenceMgr)); }
public string TestSequences() { DataAccessMgr daMgr = Global.GetDataAccessMgr(this.HttpContext); B1SampleEntities entities = new B1SampleEntities(); var query = from a in entities.TestSequences orderby new { a.AppSequenceName, a.AppSequenceId } select new { a.AppSequenceId, a.AppSequenceName, a.DbSequenceId }; PagingMgr testSequenceMgr = new PagingMgr(daMgr, query, DataAccess.Constants.PageSize, 20); return(testSequenceMgr.ToHtmlString(this)); }
public ActionResult TestSequences2() { DataAccessMgr daMgr = Global.GetDataAccessMgr(this.HttpContext); B1SampleEntities entities = new B1SampleEntities(); var query = from a in entities.TestSequences orderby new { a.AppSequenceName, a.AppSequenceId } select new { a.AppSequenceId, a.AppSequenceName, a.DbSequenceId }; PagingMgr testSequenceMgr = new PagingMgr(daMgr, query, DataAccess.Constants.PageSize, 10); return(PartialView(Constants._Page_PagingMgrView, testSequenceMgr)); }
/// <summary> /// Main Window for Application /// </summary> public MainWindow() { try { InitializeComponent(); _configSettings = LoadConfigurationSettings(); _loggingMgr = new LoggingMgr(_loggingKey); _loggingMgr.TraceToWindow = true; _daMgr = new DataAccessMgr(_connectionKey, _loggingMgr); // This host requires an app session object _appSession = new AppSession(_daMgr , _engineId , _assemblyVersion , _assemblyName , Status); // create paging manager for task processing queue PagingMgr tpq = new PagingMgr(_daMgr , string.Format("{0}.{1}", DataAccess.Constants.SCHEMA_CORE, TaskProcessing.Constants.TaskProcessingQueue) , null, 1, null); // pass paging manager to paging controll pagingTableTPQ.Source = tpq; pagingTableTPQ.Title = "Task Processing Queue"; // set the status control for the local TPE localTpeStatus.SetContext(this, null, OnPlusMinusClick); // pass in the configuration settings localTpeStatus.Display(TraceLevelChanged , MaxTasksChanged , _connectionKey , _loggingKey , _configId , _engineId , _taskAssemblyPath , _hostEndpointAddress , _maxTasks , _loggingMgr.TraceLevel); // right now we cannot connect to any remote host remoteTpeStatus.IsEnabled = false; } catch (Exception e) { string errorFileName = "TaskProcessingEngine.Exception.txt"; string msg = "Will attempt to write exception details to file: " + errorFileName + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine; MessageBox.Show(msg, "Fatal Error - Look for file: " + errorFileName); FileManagement.FileMgr.WriteTextToFile(errorFileName, msg, false, true); Exit(); } }
//?? public ActionResult AppSessions() public string AppSessions() { B1SampleEntities entities = new B1SampleEntities(); DataAccessMgr daMgr = Global.GetDataAccessMgr(this.HttpContext); var query = from a in entities.AppSessions orderby new { a.AppCode, a.MultipleSessionCode } select new { a.AppCode, a.AppId, a.MultipleSessionCode }; PagingMgr testSequenceMgr = new PagingMgr(daMgr, query, DataAccess.Constants.PageSize, 20); return(testSequenceMgr.ToHtmlString <AppSession>(PagingMgr.PagingDbCmdEnum.First).ToHtmlString()); //DbCommand dbCmd = daMgr.BuildSelectDbCommand(query, null); //return PartialView("_AppSessions", daMgr.ExecuteCollection<AppSession>(dbCmd, null)); }
/// <summary> /// Sets the grid to contain the page of data of given direction for the given page size /// using the given pagingMgr. /// </summary> /// <param name="pagingMgr">PagingMgr object instance</param> /// <param name="pageDirection">Paging enumeration: First, Last, Next, Previou</param> /// <param name="pageSize">Number of records to be loaded in a page</param> /// <returns>Bool indicator of whether there was data loaded into grid</returns> private bool SetPage(PagingMgr pagingMgr, PagingMgr.PagingDbCmdEnum?pageDirection, short pageSize) { if (pagingMgr == null) { throw new ILoggingManagement.ExceptionEvent(ILoggingManagement.enumExceptionEventCodes.NullOrEmptyParameter , "pagingMgr cannot be null"); } DataTable page = pageDirection.HasValue ? pagingMgr.GetPage(pageDirection.Value, pageSize) : pagingMgr.RefreshPage(pageSize); if (page != null && page.Rows.Count > 0) { dataGridPaging.ItemsSource = page.DefaultView; lblPagingGridMsg.Content = string.Empty; return(true); } lblPagingGridMsg.Content = "No more data found."; return(false); }
/// <summary> /// Function which handles the response to when a user clicks on the paging control. /// <para>It determines if the click was on the paging control of remote TPE hosts. /// If it was on remote TPE and the row contains a host with an endpoint address, then it activates /// the Connect button.</para> /// </summary> /// <param name="source">The paging manager source to be compared to pagingMgr of remote hosts</param> /// <param name="currentRow">The current row clicked on.</param> private void RemoteHostSelection(PagingMgr source, DataRow currentRow) { // we need to distinguish a click on the local host tab from a // click on the remote hosts tabl. // There were two different pagingMgr instances; we compare the hash. // do we have data and is it a remoteHost source if (currentRow != null && source.GetHashCode() == pagingTableRemoteHosts.Source.GetHashCode()) { // do we have an endpoint address to connect to? if (currentRow[SessionManagement.Constants.TpeEndpointAddress] != null && currentRow[SessionManagement.Constants.TpeEndpointAddress] != DBNull.Value) { remoteTpeStatus.SetContext(this , currentRow[SessionManagement.Constants.TpeEndpointAddress] , OnPlusMinusClick , "Connect" , "Disconnect"); remoteTpeStatus.IsEnabled = true; } } }