Ejemplo n.º 1
0
        public override IList <IDataObject> Get(string objectType, DataFilter filter, int pageSize, int startIndex)
        {
            List <IDataObject> page = new List <IDataObject>();

            try
            {
                //This is in the base class
                //loads the current object definition into _dataObjectDefinition.
                //needed by FormFilterList
                LoadDataDictionary(objectType);

                List <Filter> filterList = null;
                if (filter != null)
                {
                    filterList = FormFilterList(filter);
                }

                _dataObjects = new List <IDataObject>();

                switch (objectType.ToUpper())
                {
                case "WIDGET":

                    List <Widget> widgets = _widgetProvider.ReadWidgets(filterList);

                    foreach (Widget widget in widgets)
                    {
                        IDataObject dataObject = FormDataObject(widget);

                        _dataObjects.Add(dataObject);
                    }
                    break;

                default:
                    throw new Exception("Invalid object type provided");
                }

                long count = _dataObjects.Count();
                if (pageSize > count)
                {
                    pageSize = (int)count;
                }

                page = _dataObjects.GetRange(startIndex, pageSize);
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("Error while getting a filtered page of data objects of type [{0}]: {1}", objectType, ex);
                throw new Exception("Error while getting a filtered page of data objects of type [" + objectType + "].", ex);
            }

            return(page);
        }
Ejemplo n.º 2
0
 public Widgets GetAll()
 {
     return(_widgetProvider.ReadWidgets(null));
 }