Пример #1
0
        /// <summary>
        /// BindData fetches the data from the database and updates the controls
        /// </summary>
        /// <history>
        ///     [cnurse]	9/28/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        private void BindData()
        {
            CreateLetterSearch();
            string strQuerystring = Null.NullString;

            if (Filter != "")
            {
                strQuerystring += "filter=" + Filter;
            }

            if (Filter == Localization.GetString("Expired", LocalResourceFile))
            {
                PortalList = PortalController.GetExpiredPortals();
                ctlPagingControl.Visible = false;
            }
            else
            {
                PortalList = PortalController.GetPortalsByName(Filter + "%", CurrentPage - 1, PageSize, ref TotalRecords);
            }
            grdPortals.DataSource = PortalList;
            grdPortals.DataBind();
            ctlPagingControl.TotalRecords = TotalRecords;
            ctlPagingControl.PageSize     = PageSize;
            ctlPagingControl.CurrentPage  = CurrentPage;

            ctlPagingControl.QuerystringParams = strQuerystring;
            ctlPagingControl.TabID             = TabId;

            if (SuppressPager & ctlPagingControl.Visible)
            {
                ctlPagingControl.Visible = (PageSize < TotalRecords);
            }
        }
Пример #2
0
        public HttpResponseMessage GetPortals(int portalGroupId, string filter, int pageIndex, int pageSize)
        {
            try
            {
                var totalRecords = 0;
                IEnumerable <PortalInfo> portals;

                if (portalGroupId > Null.NullInteger)
                {
                    portals = PortalGroupController.Instance.GetPortalsByGroup(portalGroupId)
                              .Where(p => string.IsNullOrEmpty(filter) ||
                                     p.PortalName.ToLowerInvariant().Contains(filter.ToLowerInvariant()))
                              .ToList();
                    totalRecords = portals.Count();
                    portals      = portals.Skip(pageIndex * pageSize).Take(pageSize);
                }
                else
                {
                    portals = PortalController.GetPortalsByName($"%{filter}%", pageIndex, pageSize,
                                                                ref totalRecords).Cast <PortalInfo>();
                }
                var response = new
                {
                    Results      = portals.Select(GetPortalDto).ToList(),
                    TotalResults = totalRecords
                };

                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Пример #3
0
        /// <summary>
        /// BindData fetches the data from the database and updates the controls
        /// </summary>
        private void BindData()
        {
            CreateLetterSearch();

            int       totalRecords = 0;
            ArrayList portals;

            if (Filter.Equals(Localization.GetString("Expired", LocalResourceFile), StringComparison.InvariantCultureIgnoreCase))
            {
                portals      = PortalController.GetExpiredPortals();
                totalRecords = portals.Count;
            }
            else
            {
                portals = PortalController.GetPortalsByName(Filter + "%", grdPortals.CurrentPageIndex, grdPortals.PageSize, ref totalRecords);
            }
            grdPortals.VirtualItemCount = totalRecords;
            grdPortals.DataSource       = portals;
        }
Пример #4
0
        public static ActionResult GetAllPortals(int PortalID, string filter, int pageIndex, int pageSize)
        {
            ActionResult    actionResult   = new ActionResult();
            SitesController sitecontroller = new SitesController();
            dynamic         Result         = new ExpandoObject();
            List <dynamic>  PortalsInfo    = new List <dynamic>();

            try
            {
                int totalRecords = 0;
                IEnumerable <PortalInfo> portals = PortalController.GetPortalsByName($"%{filter}%", pageIndex, pageSize,
                                                                                     ref totalRecords).Cast <PortalInfo>();

                foreach (PortalInfo pinfo in portals.ToList())
                {
                    var portalInfo = new
                    {
                        pinfo.PortalID,
                        pinfo.PortalName,
                        PortalAliases = sitecontroller.FormatPortalAliases(pinfo.PortalID),
                        allowDelete   = (pinfo.PortalID != PortalID && !PortalController.IsMemberOfPortalGroup(pinfo.PortalID))
                    };
                    PortalsInfo.Add(portalInfo);
                }

                Result.Items = PortalsInfo;
                double NumberOfPages = (double)totalRecords / pageSize;
                if ((int)NumberOfPages > 0)
                {
                    NumberOfPages = Math.Ceiling(NumberOfPages);
                }

                Result.NumberOfPages   = NumberOfPages;
                actionResult.IsSuccess = true;
                actionResult.Data      = Result;
            }
            catch (Exception ex)
            {
                actionResult.AddError("exceptions", ex.Message);
            }
            return(actionResult);
        }
Пример #5
0
        protected void loadSitesDataGrid()
        {
            int totalRecords = 0;

            ArrayList _Portals = new ArrayList();

            _Portals = PortalController.GetPortalsByName("%", 0, 100, ref totalRecords);

            gvSites.DataSource          = _Portals;
            gvSites.AutoGenerateColumns = false;
            gvSites.AllowPaging         = true;
            gvSites.AllowSorting        = true;
            gvSites.PageSize            = 20;

            //gvSites.Columns.Clear();

            BoundField contentName = new BoundField();

            contentName.DataField            = "PortalName";
            contentName.HeaderText           = "Micro Site";
            contentName.HeaderStyle.Width    = Unit.Pixel(200);
            contentName.HeaderStyle.CssClass = "Abstracts_gvHeaderStyle";
            gvSites.Columns.Add(contentName);

            TemplateField includeSite = new TemplateField();

            includeSite.HeaderText = "Available?";
            includeSite.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
            includeSite.HeaderStyle.Width           = Unit.Pixel(150);
            includeSite.HeaderStyle.CssClass        = "Abstracts_gvHeaderStyle";
            gvSites.Columns.Add(includeSite);

            gvSites.DataKeyNames = new string[] { "PortalId", "PortalName" };

            gvSites.DataBind();
        }