/// <summary> /// Gets the connection enumerator with the given sorting. /// </summary> /// <returns></returns> public Enumerator GetEnumerator(DefaultSorting sorting) { if (_sorting == null) { throw new InvalidOperationException("Cannot get sorted enumerator, db is not sorted."); } if (_sorting == sorting) { return(this.GetEnumerator()); } return(this.GetOrderEnumerator()); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param> protected void Page_Load(System.Object sender, System.EventArgs e) { try { if (ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.XMLHTTP) && ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.XML)) { SupportsClientAPI = true; ClientAPI.RegisterClientReference(this.Page, ClientAPI.ClientNamespaceReferences.dnn_xml); ClientAPI.RegisterClientReference(this.Page, ClientAPI.ClientNamespaceReferences.dnn_xmlhttp); if (this.Page.ClientScript.IsClientScriptBlockRegistered("AjaxFaq.js") == false) { this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "AjaxFaq.js", "<script language=javascript src=\"" + this.ControlPath + "scripts/AjaxFaq.js\"></script>"); } } if (!IsPostBack) { //Fill the categories panel BindCategories(); //Bind the FAQ data BindData(); //Is the user allowed to sort the questions ? if (Settings["UserSort"] != null && Convert.ToBoolean(Settings["UserSort"]) && RequestFaqId < 0) { //Set default sort order pnlSortbox.Visible = true; drpSort.SelectedValue = DefaultSorting.ToString(); } else { pnlSortbox.Visible = false; } } } catch (Exception exc) //Module failed to load { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// Gets the connection enumerator with the given sorting. /// </summary> /// <returns></returns> public ConnectionsDb.Enumerator GetConnectionsEnumerator(DefaultSorting sorting) { return(_connectionsDb.GetEnumerator(sorting)); }
/// <summary> /// Sorts the connections. /// </summary> public void SortConnections(DefaultSorting sorting, Action <uint, uint> switchConnections) { _connectionsDb.Sort(sorting, switchConnections); }
/// <summary> /// Sorts the connections. /// </summary> public void Sort(DefaultSorting sorting, Action <uint, uint> switchConnections) { _sorting = sorting; if (_nextConnectionId > 0) { _connectionsOrder.Resize(_nextConnectionId); for (uint i = 0; i < _nextConnectionId; i++) { _connectionsOrder[i] = i; } QuickSort.Sort((connection) => { uint departureTime, duration; ConnectionsDb.DecodeDepartureTimeAndDuration( _connections[connection * CONNECTION_SIZE + 3], out departureTime, out duration); uint tripId = _connections[connection * CONNECTION_SIZE + 2]; if (sorting == DefaultSorting.DepartureTime) { return((long)departureTime * int.MaxValue + tripId); } return((long)(departureTime + duration) * int.MaxValue + tripId); }, (connection1, connection2) => { var value0 = _connections[connection1 * CONNECTION_SIZE + 0]; var value1 = _connections[connection1 * CONNECTION_SIZE + 1]; var value2 = _connections[connection1 * CONNECTION_SIZE + 2]; var value3 = _connections[connection1 * CONNECTION_SIZE + 3]; _connections[connection1 * CONNECTION_SIZE + 0] = _connections[connection2 * CONNECTION_SIZE + 0]; _connections[connection1 * CONNECTION_SIZE + 1] = _connections[connection2 * CONNECTION_SIZE + 1]; _connections[connection1 * CONNECTION_SIZE + 2] = _connections[connection2 * CONNECTION_SIZE + 2]; _connections[connection1 * CONNECTION_SIZE + 3] = _connections[connection2 * CONNECTION_SIZE + 3]; _connections[connection2 * CONNECTION_SIZE + 0] = value0; _connections[connection2 * CONNECTION_SIZE + 1] = value1; _connections[connection2 * CONNECTION_SIZE + 2] = value2; _connections[connection2 * CONNECTION_SIZE + 3] = value3; if (switchConnections != null) { switchConnections((uint)connection1, (uint)connection2); } }, 0, _nextConnectionId - 1); QuickSort.Sort((connection) => { uint departureTime, duration; ConnectionsDb.DecodeDepartureTimeAndDuration( _connections[_connectionsOrder[connection] * CONNECTION_SIZE + 3], out departureTime, out duration); uint tripId = _connections[_connectionsOrder[connection] * CONNECTION_SIZE + 2]; if (sorting != DefaultSorting.DepartureTime) { return((long)departureTime * int.MaxValue + tripId); } return((long)(departureTime + duration) * int.MaxValue + tripId); }, (connection1, connection2) => { var value = _connectionsOrder[connection1]; _connectionsOrder[connection1] = _connectionsOrder[connection2]; _connectionsOrder[connection2] = value; }, 0, _nextConnectionId - 1); } }