コード例 #1
0
        /// <summary>
        /// Caricamento dati trasmissioni effettuate
        /// </summary>
        public void Fetch()
        {
            if (RicercaTrasmissioniHandler.CurrentFilter == null)
            {
                throw new ApplicationException("Filtro per la ricerca delle trasmissioni non impostato");
            }

            // Impostazione della tipologia di ricerca delle trasmissioni effettuate per:
            // documenti o fascicoli
            if (RicercaTrasmissioniHandler.CurrentFilter.TipoOggettoTrasmissione == TipiOggettiTrasmissioniEnum.Fascicoli)
            {
                this.TipoRicercaTrasmissione = TipiRicercaTrasmissioniEnum.Fascicoli;
            }
            else
            {
                this.TipoRicercaTrasmissione = TipiRicercaTrasmissioniEnum.Documenti;
            }

            PagingContext pagingContext = new PagingContext(this.GetInitPageNumber());

            this.FetchTrasmissioni(pagingContext);

            this.GetListPagingControl().RefreshPaging(pagingContext);

            this.SetPanelMessageText(pagingContext);
        }
コード例 #2
0
        internal static List <ShopItem> GetPagedShopItemByPublishDate(PagingContext pager, int publishStatus,
                                                                      DateTime sTime, DateTime eTime)
        {
            List <ShopItem> list = new List <ShopItem>(pager.RecordsPerPage);

            SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(JaneDefine.DBInstanceName),
                                               "dbo.Shop_items_GetPagedByPublishDate",
                                               delegate(IParameterSet parameters)
            {
                parameters.AddWithValue("@STime", sTime);
                parameters.AddWithValue("@ETime", eTime);
                parameters.AddWithValue("@PublishStatus", publishStatus);
                parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
            },
                                               delegate(IRecord record)
            {
                MapList(record, list);
            },
                                               delegate(IParameterSet outputParameters)
            {
                pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
            }
                                               );

            return(list);
        }
コード例 #3
0
ファイル: TagsDao.cs プロジェクト: sidny/d4d-studio
        internal static List <Tag> GetPagedTags(PagingContext pager)
        {
            List <Tag> list = new List <Tag>(pager.RecordsPerPage);

            SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(D4DDefine.DBInstanceName),
                                               "dbo.GetPagedTags",
                                               delegate(IParameterSet parameters)
            {
                parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
            },
                                               delegate(IRecord record)
            {
                Tag tag       = new Tag();
                tag.TagId     = record.GetInt32OrDefault(0, 0);
                tag.TagName   = record.GetStringOrEmpty(1);
                tag.Hits      = record.GetInt32OrDefault(2, 0);
                tag.AddUserID = record.GetInt32OrDefault(3, 0);
                tag.AddDate   = record.GetDateTime(4);

                list.Add(tag);
            },
                                               delegate(IParameterSet outputParameters)
            {
                pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
            }
                                               );

            return(list);
        }
コード例 #4
0
ファイル: SpamKeywordDao.cs プロジェクト: sidny/d4d-studio
        internal static List <SpamKeyword> GetPagedSpamKeywords(PagingContext pager)
        {
            List <SpamKeyword> list = new List <SpamKeyword>(pager.RecordsPerPage);

            SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(D4DDefine.DBInstanceName),
                                               "dbo.SpamKeywords_GetPaged",
                                               delegate(IParameterSet parameters)
            {
                //parameters.AddWithValue("@PublishStatus", publishStatus);
                parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
            },
                                               delegate(IRecord record)
            {
                MapList(record, list);
            },
                                               delegate(IParameterSet outputParameters)
            {
                pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
            }
                                               );

            return(list);
        }
コード例 #5
0
        internal static List<ShopTradelist> GetPagedTradelist(PagingContext pager, int orderid)
        {
            List<ShopTradelist> list = new List<ShopTradelist>(pager.RecordsPerPage);

            SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(JaneDefine.DBInstanceName),
               "dbo.Shop_tradelist_GetPaged",
               delegate(IParameterSet parameters)
               {
                   parameters.AddWithValue("@orderid", orderid);
                   parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                   parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                   parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
               },
               delegate(IRecord record)
               {
                   MapList(record, list);
               },
               delegate(IParameterSet outputParameters)
               {
                   pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
               }
               );

            return list;
        }
コード例 #6
0
ファイル: TagsDao.cs プロジェクト: sidny/d4d-studio
        internal static List<Tag> GetPagedTags(PagingContext pager)
        {
            List<Tag> list = new List<Tag>(pager.RecordsPerPage);

            SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(D4DDefine.DBInstanceName),
               "dbo.GetPagedTags",
               delegate(IParameterSet parameters)
               {
                   parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                   parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                   parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
               },
               delegate(IRecord record)
               {
                   Tag tag = new Tag();
                   tag.TagId = record.GetInt32OrDefault(0, 0);
                   tag.TagName = record.GetStringOrEmpty(1);
                   tag.Hits = record.GetInt32OrDefault(2, 0);
                   tag.AddUserID = record.GetInt32OrDefault(3, 0);
                   tag.AddDate = record.GetDateTime(4);

                   list.Add(tag);
               },
               delegate(IParameterSet outputParameters)
               {
                   pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
               }
               );

            return list;
        }
コード例 #7
0
ファイル: Search.razor.cs プロジェクト: ScriptBox21/Money
        protected Task OnSearchAsync()
        {
            string lastQuery = Query;
            var    lastSort  = Sort;

            FormText = Query = Navigator.FindQueryParameter("q");

            if (SortDescriptor.TryParseFromUrl <OutcomeOverviewSortType>(Navigator.FindQueryParameter("sort"), out var descriptor))
            {
                FormSort = Sort = descriptor;
            }
            else
            {
                FormSort = Sort = DefaultSort;
            }

            Console.WriteLine($"Sort: last '{lastSort.Type}+{lastSort.Direction}', current '{Sort.Type}+{Sort.Direction}'.");

            if (lastQuery == Query && lastSort.Equals(Sort))
            {
                return(Task.CompletedTask);
            }

            return(PagingContext.LoadAsync(0));
        }
コード例 #8
0
        /// <summary>
        /// <see cref="IDtoService{TEntity, TDto, TDtoKey}.Retrieve(Expression{Func{TEntity, bool}}, PagingContext, Func{IQueryable{TEntity}, IOrderedQueryable{TEntity}}, Expression{Func{TEntity, object}}[])"/>
        /// </summary>
        public virtual async Task <IEnumerable <TDto> > RetrieveAsync(
            Expression <Func <TEntity, bool> > filter = null,
            PagingContext pagingContext = null,
            Func <IQueryable <TEntity>, IOrderedQueryable <TEntity> > sortCondition = null,
            CancellationToken cancellationToken = default,
            params Expression <Func <TEntity, object> >[] includes)
        {
            try
            {
                var items = new List <TDto>();
                IEnumerable <TEntity> models = await ObjectService.RetrieveAsync(
                    filter,
                    pagingContext,
                    sortCondition,
                    cancellationToken,
                    includes);

                if (models?.Count() > 0)
                {
                    items = Mapper.Map <List <TDto> >(models);

                    if (KeyEncoder != null)
                    {
                        items.ForEach(d => d.Id = KeyEncoder.Encode(d.Id));
                    }
                }

                return(items);
            }
            catch (EncodingException e)
            {
                throw new ServiceException($"Error retrieving objects of type {typeof(TDto).Name}.", e);
            }
        }
コード例 #9
0
ファイル: JaneShopItemsDao.cs プロジェクト: sidny/d4d-studio
        internal static List<ShopItem> GetPagedShopItemByPublishDate(PagingContext pager, int publishStatus,
            DateTime sTime,DateTime eTime)
        {
            List<ShopItem> list = new List<ShopItem>(pager.RecordsPerPage);

            SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(JaneDefine.DBInstanceName),
               "dbo.Shop_items_GetPagedByPublishDate",
               delegate(IParameterSet parameters)
               {
                   parameters.AddWithValue("@STime", sTime);
                   parameters.AddWithValue("@ETime", eTime);
                   parameters.AddWithValue("@PublishStatus", publishStatus);
                   parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                   parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                   parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
               },
               delegate(IRecord record)
               {
                   MapList(record, list);
               },
               delegate(IParameterSet outputParameters)
               {
                   pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
               }
               );

            return list;
        }
コード例 #10
0
ファイル: ShowDao.cs プロジェクト: sidny/d4d-studio
        internal static List<Show> GetPagedShowByBandId(PagingContext pager, int bandId, int publishStatus)
        {
            List<Show> list = new List<Show>(pager.RecordsPerPage);

            SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(D4DDefine.DBInstanceName),
               "dbo.Show_GetPagedByBandId",
               delegate(IParameterSet parameters)
               {
                   parameters.AddWithValue("@BandId", bandId);
                   parameters.AddWithValue("@PublishStatus", publishStatus);
                   parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                   parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                   parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
               },
               delegate(IRecord record)
               {
                   MapList(record, list);
               },
               delegate(IParameterSet outputParameters)
               {
                   pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
               }
               );

            return list;
        }
コード例 #11
0
        internal static List <ShopTradelist> GetPagedTradelist(PagingContext pager, int orderid)
        {
            List <ShopTradelist> list = new List <ShopTradelist>(pager.RecordsPerPage);

            SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(JaneDefine.DBInstanceName),
                                               "dbo.Shop_tradelist_GetPaged",
                                               delegate(IParameterSet parameters)
            {
                parameters.AddWithValue("@orderid", orderid);
                parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
            },
                                               delegate(IRecord record)
            {
                MapList(record, list);
            },
                                               delegate(IParameterSet outputParameters)
            {
                pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
            }
                                               );

            return(list);
        }
コード例 #12
0
        /// <summary>
        /// The filter parameter is not used as it is not possible to query an Azure Storage Table using Linq.
        /// The sortCondition parameter has not been implemented and instead been defaulted to Timestamp (descending).
        /// The includes parameter is not applicable to Azure Storage Tables.
        /// The current paging implementation is highly inefficient.
        /// <see cref="IReadOnlyRepository{TEntity, TKey}.RetrieveAsync(Expression{Func{TEntity, bool}}, PagingContext, Func{IQueryable{TEntity}, IOrderedQueryable{TEntity}}, CancellationToken, Expression{Func{TEntity, object}}[])"/>
        /// </summary>
        /// <exception cref="ArgumentException">Not applicable.</exception>"
        public virtual async Task <IEnumerable <TEntity> > RetrieveAsync(
            Expression <Func <TEntity, bool> > filter = null,
            PagingContext pagingContext = null,
            Func <IQueryable <TEntity>, IOrderedQueryable <TEntity> > sortCondition = null,
            CancellationToken cancellationToken = default,
            params Expression <Func <TEntity, object> >[] includes)
        {
            // Construct the query operation for all objects.
            var             query = new TableQuery <TEntity>();
            IList <TEntity> items = await Table.ExecuteQueryAsync(query, cancellationToken);

            if (pagingContext?.PageSize > 0)
            {
                items = items
                        .OrderByDescending(l => l.Timestamp)
                        .Skip((int)(pagingContext.PageIndex * pagingContext.PageSize))
                        .Take((int)pagingContext.PageSize)
                        .ToList();
            }
            else
            {
                items = items.OrderByDescending(l => l.Timestamp).ToList();
            }

            return(items);
        }
コード例 #13
0
        public async Task It_can_get_resources_even_without_an_initial_search_call_if_you_know_what_you_are_doing()
        {
            // Arrange
            var           it            = IdmNetClientFactory.BuildClient();
            PagingContext pagingContext = new PagingContext
            {
                CurrentIndex         = 0,
                Filter               = "/ObjectTypeDescription",
                Selection            = new[] { "ObjectID", "ObjectType", "DisplayName" },
                Sorting              = new Sorting(),
                EnumerationDirection = "Forwards",
                Expires              = "9999-12-31T23:59:59.9999999"
            };

            // Act
            var pagedResults = await it.GetPagedResultsAsync(5, pagingContext);

            // Assert
            Assert.AreEqual(5, pagedResults.Results.Count);
            Assert.IsTrue(pagedResults.Results[0].DisplayName.Length > 0);

            Assert.AreEqual(null, pagedResults.EndOfSequence);
            Assert.AreEqual(true, pagedResults.Items is XmlNode[]);
            Assert.AreEqual(5, ((XmlNode[])(pagedResults.Items)).Length);
        }
コード例 #14
0
        public async Task T011_It_can_get_resources_back_from_a_search_a_page_at_a_time()
        {
            // Arrange
            var it       = IdmNetClientFactory.BuildClient();
            var criteria = new SearchCriteria("/ObjectTypeDescription");

            criteria.Selection.Add("DisplayName");
            PagedSearchResults pagedSearchResults = await it.GetPagedResultsAsync(criteria, 5);

            PagingContext pagingContext = pagedSearchResults.PagingContext;

            // Act
            var pagedResults = await it.GetPagedResultsAsync(5, pagingContext);

            // Assert
            Assert.AreEqual(5, pagedResults.Results.Count);
            Assert.IsTrue(pagedResults.Results[0].DisplayName.Length > 0);
            Assert.AreEqual("/ObjectTypeDescription", pagedResults.PagingContext.Filter);
            Assert.AreEqual(10, pagedResults.PagingContext.CurrentIndex);
            Assert.AreEqual("Forwards", pagedResults.PagingContext.EnumerationDirection);
            Assert.AreEqual("9999-12-31T23:59:59.9999999", pagedResults.PagingContext.Expires);
            Assert.AreEqual("ObjectID", pagedResults.PagingContext.Selection[0]);
            Assert.AreEqual("ObjectType", pagedResults.PagingContext.Selection[1]);
            Assert.AreEqual("DisplayName", pagedResults.PagingContext.Selection[2]);
            Assert.AreEqual("DisplayName", pagedResults.PagingContext.Sorting.SortingAttributes[0].AttributeName);
            Assert.AreEqual(true, pagedResults.PagingContext.Sorting.SortingAttributes[0].Ascending);

            Assert.AreEqual(null, pagedResults.EndOfSequence);
            Assert.AreEqual(true, pagedResults.Items is XmlNode[]);
            Assert.AreEqual(5, ((XmlNode[])(pagedResults.Items)).Length);
        }
        /// <inheritdoc />
        public virtual IEnumerable <TEntity> Retrieve(
            Expression <Func <TEntity, bool> > filter = null,
            PagingContext pagingContext = null,
            Func <IQueryable <TEntity>, IOrderedQueryable <TEntity> > sortCondition = null,
            params Expression <Func <TEntity, object> >[] includes)
        {
            IEnumerable <TEntity> retrieved =
                DecoratedService.Retrieve(filter, pagingContext, sortCondition, includes).ToList();

            try
            {
                // Due to size constraints, only audit the number of objects retrieved rather than the objects themselves.
                var options = new AuditScopeOptions
                {
                    EventType   = $"{EntityName}:Retrieve+",
                    ExtraFields = new { Count = retrieved.Count() },
                    AuditEvent  = new AuditEvent {
                        Target = new AuditTarget()
                    }
                };

                using (var auditScope = AuditScope.Create(options))
                {
                    auditScope.Event.Environment.UserName = UserContext.CurrentUser;
                    auditScope.Event.Target.Type          = $"{EntityFullName}";
                }
            }
            catch (Exception e)
            {
                Logger.Warning(e, "Auditing failed for Retrieve+ of type {Entity}.", EntityName);
            }

            return(retrieved);
        }
コード例 #16
0
ファイル: MusicDao.cs プロジェクト: sidny/d4d-studio
        internal static List <MusicTitle> GetPagedMusicTitlesByBandIdANDPublishYear(PagingContext pager, int bandId, int publishYear, int publishStatus)
        {
            List <MusicTitle> list = new List <MusicTitle>(pager.RecordsPerPage);

            SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(D4DDefine.DBInstanceName),
                                               "dbo.Music_GetPagedMusicTitleByBandIdANDPublishYear",
                                               delegate(IParameterSet parameters)
            {
                parameters.AddWithValue("@PublishYear", publishYear);
                parameters.AddWithValue("@BandId", bandId);
                parameters.AddWithValue("@PublishStatus", publishStatus);
                parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
            },
                                               delegate(IRecord record)
            {
                MapMusicTitleList(record, list);
            },
                                               delegate(IParameterSet outputParameters)
            {
                pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
            }
                                               );

            return(list);
        }
コード例 #17
0
        /// <summary>
        /// Search the Identity Manager  (async await)
        /// </summary>
        /// <param name="criteria"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public async Task <IEnumerable <IdmResource> > SearchAsync(SearchCriteria criteria, int pageSize = 50)
        {
            var results = new List <IdmResource>();

            try
            {
                if (criteria.Selection.Contains("*"))
                {
                    // Can throw the ArgumentOutOfRangeException if there are no results, in which case just return the empty list
                    await SetupGetStar(criteria);
                }

                PullInfo pullInfo = await PreparePagedSearchAsync(criteria, pageSize);

                // Pull all results
                PagedSearchResults pagedResults;
                PagingContext      pagingContext = pullInfo.PagingContext;
                do
                {
                    pagedResults = await GetPagedResultsAsync(pageSize, pagingContext);

                    results.AddRange(pagedResults.Results);
                } while (pagedResults.EndOfSequence == null);
            }
            catch (ArgumentOutOfRangeException)
            {
            }

            return(results);
        }
コード例 #18
0
 /// <summary>
 /// <see cref="IObjectService{TDto, TDtoKey}.Retrieve(Expression{Func{TDto, bool}}, PagingContext, Func{IQueryable{TDto}, IOrderedQueryable{TDto}}, Expression{Func{TDto, object}}[])"/>
 /// </summary>
 /// <exception cref="NotImplementedException">Not supported.</exception>
 public virtual IEnumerable <TDto> Retrieve(
     Expression <Func <TDto, bool> > filter = null,
     PagingContext pagingContext            = null,
     Func <IQueryable <TDto>, IOrderedQueryable <TDto> > sortCondition = null,
     params Expression <Func <TDto, object> >[] includes)
 {
     throw new NotImplementedException();
 }
コード例 #19
0
        /// <summary>
        /// Caricamento dati ricerca fascicoli
        /// </summary>
        private void Fetch()
        {
            PagingContext pagingContext = new PagingContext(this.GetInitPageNumber());

            this.FetchGridFascicoli(this.Search(pagingContext));

            this.GetListPagingControl().RefreshPaging(pagingContext);
        }
コード例 #20
0
        /// <summary>
        /// Impostazione visibilità campi UI
        /// </summary>
        private void SetFieldsVisibility()
        {
            PagingContext pagingContext = this.GetControlPaging().GetPagingContext();

            this.GetControlDatagrid().Visible = (pagingContext.RecordCount > 0);

            this.GetControlPaging().Visible = (pagingContext.RecordCount > 0);
        }
コード例 #21
0
        /// <summary>
        /// Caricamento dati
        /// </summary>
        /// <param name="pagingContext"></param>
        private void Fetch(PagingContext pagingContext)
        {
            InfoDocumento[] documenti = this.GetDocumenti(pagingContext);

            this.BindGrid(documenti);

            this.GetControlPaging().RefreshPaging(pagingContext);
        }
コード例 #22
0
 /// <summary>
 /// <see cref="IReadOnlyRepository{TEntity, TKey}.Retrieve(Expression{Func{TEntity, bool}}, PagingContext, Func{IQueryable{TEntity}, IOrderedQueryable{TEntity}}, Expression{Func{TEntity, object}}[])"/>
 /// </summary>
 public virtual IEnumerable <TEntity> Retrieve(
     Expression <Func <TEntity, bool> > filter = null,
     PagingContext pagingContext = null,
     Func <IQueryable <TEntity>, IOrderedQueryable <TEntity> > sortCondition = null,
     params Expression <Func <TEntity, object> >[] includes)
 {
     return(RetrieveQuery(filter, pagingContext, sortCondition, includes).ToList());
 }
コード例 #23
0
        internal static List <News> GetPagedNewsByTypeANDPublishDate(PagingContext pager, int newsType, DateTime sTime,
                                                                     DateTime eTime, int publishStatus, int newsRemarkType)
        {
            List <News> list = new List <News>(pager.RecordsPerPage);

            if (newsRemarkType == -1)
            {
                SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(D4DDefine.DBInstanceName),
                                                   "dbo.News_GetPagedByNewsTypeAndPublishDate",
                                                   delegate(IParameterSet parameters)
                {
                    parameters.AddWithValue("@NewsType", newsType);
                    parameters.AddWithValue("@STime", sTime);
                    parameters.AddWithValue("@ETime", eTime);
                    parameters.AddWithValue("@PublishStatus", publishStatus);
                    parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                    parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                    parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
                },
                                                   delegate(IRecord record)
                {
                    MapList(record, list);
                },
                                                   delegate(IParameterSet outputParameters)
                {
                    pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
                }
                                                   );
            }
            else
            {
                SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(D4DDefine.DBInstanceName),
                                                   "dbo.News_GetPagedByNewsTypeAndPublishDateV2",
                                                   delegate(IParameterSet parameters)
                {
                    parameters.AddWithValue("@RemarkType", newsRemarkType);
                    parameters.AddWithValue("@NewsType", newsType);
                    parameters.AddWithValue("@STime", sTime);
                    parameters.AddWithValue("@ETime", eTime);
                    parameters.AddWithValue("@PublishStatus", publishStatus);
                    parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                    parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                    parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
                },
                                                   delegate(IRecord record)
                {
                    MapList(record, list);
                },
                                                   delegate(IParameterSet outputParameters)
                {
                    pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
                }
                                                   );
            }


            return(list);
        }
コード例 #24
0
ファイル: Search.razor.cs プロジェクト: ScriptBox21/Money
        protected async override Task OnInitializedAsync()
        {
            FormSort          = Sort = DefaultSort;
            PagingContext     = new PagingContext(LoadPageAsync, Loading);
            CurrencyFormatter = await CurrencyFormatterFactory.CreateAsync();

            Navigator.LocationChanged += OnLocationChanged;
            BindEvents();
        }
コード例 #25
0
 /// <summary>
 /// <see cref="IObjectService{TDto, TDtoKey}.RetrieveAsync(Expression{Func{TDto, bool}}, PagingContext, Func{IQueryable{TDto}, IOrderedQueryable{TDto}}, CancellationToken, Expression{Func{TDto, object}}[])"/>
 /// </summary>
 /// <exception cref="NotImplementedException">Not supported.</exception>
 public virtual Task <IEnumerable <TDto> > RetrieveAsync(
     Expression <Func <TDto, bool> > filter = null,
     PagingContext pagingContext            = null,
     Func <IQueryable <TDto>, IOrderedQueryable <TDto> > sortCondition = null,
     CancellationToken cancellationToken = default,
     params Expression <Func <TDto, object> >[] includes)
 {
     throw new NotImplementedException();
 }
コード例 #26
0
        /// <summary>
        /// Caricamento dati trasmissioni effettuate
        /// </summary>
        private void FetchTrasmissioni(PagingContext pagingContext)
        {
            RicercaTrasmissioniHandler trasmissioniHandler = new RicercaTrasmissioniHandler();

            Trasmissione[] trasmissioni = trasmissioniHandler.GetTrasmissioni(TipiTrasmissioniEnum.Effettuate, pagingContext, this.GetFiltroRicerca());

            // Associazione dati al datagrid
            this.BindGridTrasmissioni(this.TrasmissioniEffettuateToDataset(trasmissioni));
        }
コード例 #27
0
ファイル: SearchProvider.cs プロジェクト: sidny/d4d-studio
 public List <SearchResult> GetPagedSearch(PagingContext pager,
                                           string searchText, ObjectTypeDefine objectType)
 {
     if (string.IsNullOrEmpty(searchText))
     {
         return(new List <SearchResult>());
     }
     return(SearchDao.GetPagedSearch(pager, searchText, objectType));
 }
コード例 #28
0
 /// <summary>
 /// <see cref="IReadOnlyRepository{TEntity, TKey}.RetrieveAsync(Expression{Func{TEntity, bool}}, PagingContext, Func{IQueryable{TEntity}, IOrderedQueryable{TEntity}}, CancellationToken, Expression{Func{TEntity, object}}[])"/>
 /// </summary>
 public virtual async Task <IEnumerable <TEntity> > RetrieveAsync(
     Expression <Func <TEntity, bool> > filter = null,
     PagingContext pagingContext = null,
     Func <IQueryable <TEntity>, IOrderedQueryable <TEntity> > sortCondition = null,
     CancellationToken cancellationToken = default,
     params Expression <Func <TEntity, object> >[] includes)
 {
     return(await RetrieveQuery(filter, pagingContext, sortCondition, includes).ToListAsync(cancellationToken));
 }
コード例 #29
0
        private void btnSearch_Click(object sender, System.EventArgs e)
        {
            // Reperimento contesto di paginazione
            PagingContext pagingContext = new PagingContext(1);

            this.FetchTrasmissioni(this.GetSelectedSearchType(), pagingContext);

            this.GetPagingNavigationControls().RefreshPaging(pagingContext);
        }
コード例 #30
0
        internal static List <SearchResult> GetPagedSearch(PagingContext pager,
                                                           string searchText, ObjectTypeDefine objectType)
        {
            List <SearchResult> list = new List <SearchResult>(pager.RecordsPerPage);

            string SearchSp = string.Empty;

            switch (objectType)
            {
            case ObjectTypeDefine.Show:
                SearchSp = "dbo.Search_GetPagedShow";
                break;

            case ObjectTypeDefine.MusicTitle:
            case ObjectTypeDefine.Song:
                SearchSp = "dbo.Search_GetPagedMusic";
                break;

            case ObjectTypeDefine.Album:
            case ObjectTypeDefine.Image:
                SearchSp = "dbo.Search_GetPagedAlbum";
                break;

            case ObjectTypeDefine.Video:
                SearchSp = "dbo.Search_GetPagedVideoNews";
                break;

            case ObjectTypeDefine.News:
                SearchSp = "dbo.Search_GetPagedNews";
                break;

            default:
                return(list);
            }

            SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(D4DDefine.DBInstanceName),
                                               SearchSp,
                                               delegate(IParameterSet parameters)
            {
                parameters.AddWithValue("@SearchTxt", searchText);
                parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
            },
                                               delegate(IRecord record)
            {
                MapSeachResultList(record, list, objectType);
            },
                                               delegate(IParameterSet outputParameters)
            {
                pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
            }
                                               );

            return(list);
        }
コード例 #31
0
        protected override async Task OnInitializedAsync()
        {
            PagingContext = new PagingContext(LoadDataAsync, Loading);

            BindEvents();

            MonthModel = new MonthModel(Year, Month);

            CurrencyFormatter = new CurrencyFormatter(await Queries.QueryAsync(new ListAllCurrency()));
            Reload();
        }
コード例 #32
0
 /// <summary>
 /// Impostazione messaggio
 /// </summary>
 /// <param name="pagingContext"></param>
 private void SetPanelMessageText(PagingContext pagingContext)
 {
     if (pagingContext.RecordCount == 0)
     {
         this.pnlMessage.InnerText = "Nessuna trasmissione trovata";
     }
     else
     {
         this.pnlMessage.InnerText = "Trovate " + pagingContext.RecordCount.ToString() + " trasmissioni";
     }
 }
コード例 #33
0
        /// <summary>
        /// With the repository setup
        /// </summary>
        /// <param name="users"></param>
        /// <param name="user"></param>
        /// <param name="pagingContext"></param>
        /// <returns>Service builder with EF core repository mockup</returns>
        public UserServiceBuilder WithRepositoryMock(List <User> users, User user, PagingContext pagingContext)
        {
            // 'GetAllAsync' repository mock
            _mockRepository.Setup(o => o.GetAllAsync(It.IsAny <Expression <Func <User, bool> > >()))
            .Returns((
                         Expression <Func <User, bool> > predicate) =>
                     Task.FromResult(users.Where(predicate.Compile()).ToList()
                                     as IEnumerable <User>));
            // 'GetAsync' repository mock

            foreach (var item in users)
            {
                _mockRepository.Setup(x => x.GetAsync(item.Id)).ReturnsAsync(() => users.FirstOrDefault(x => x.Id == item.Id));
            }
            _mockRepository.Setup(x => x.GetAsync(10)).ReturnsAsync(() => null);

            //'FindByAsync'

            _mockRepository.Setup(x => x.FindByAsync(It.IsAny <Expression <Func <User, bool> > >(), It.IsAny <string>())).Returns(
                (Expression <Func <User, bool> > predicate, string include) =>
                Task.FromResult(users.Where(predicate.Compile()).FirstOrDefault()));
            _mockRepository.Setup(x => x.FindByAsync(It.IsAny <Expression <Func <User, bool> > >())).Returns(
                (Expression <Func <User, bool> > predicate) =>
                Task.FromResult(users.Where(predicate.Compile()).FirstOrDefault()));
            // 'Update' repository mock
            _mockRepository.Setup(x => x.Update(It.IsAny <User>())).Returns(It.IsAny <EntityState>());

            // 'Add' repository mock
            _mockRepository.Setup(x => x.Add(It.IsAny <User>())).Returns(EntityState.Added);

            //'GetAllAsync' repository mock with paging
            var pageSize = (pagingContext.PageNumber - 1) * pagingContext.NumberPerPage;

            _mockRepository.Setup(o => o.GetAllAsync(It.IsAny <Expression <Func <User, bool> > >(), It.IsAny <PagingContext>()))
            .Returns((
                         Expression <Func <User, bool> > predicate, PagingContext paging) =>
                     Task.FromResult(users.Where(predicate.Compile())
                                     .AsQueryable().Sort(pagingContext.SortColums, pagingContext.SortDirection)
                                     .Skip(pageSize).Take(pagingContext.NumberPerPage) as IEnumerable <User>));
            //'CountAsync' repository mock
            _mockRepository.Setup(o => o.CountAsync(It.IsAny <Expression <Func <User, bool> > >()))
            .Returns((
                         Expression <Func <User, bool> > predicate) =>
                     Task.FromResult(users.Count(predicate.Compile())));

            //'ExistsAsync' repository mock
            _mockRepository.Setup(o => o.ExistsAsync(It.IsAny <Expression <Func <User, bool> > >()))
            .Returns((
                         Expression <Func <User, bool> > predicate) =>
                     Task.FromResult(users.Where(predicate.Compile()).Any()));

            return(this);
        }
コード例 #34
0
        /// <summary>
        /// Caricamento dati
        /// </summary>
        private void Fetch()
        {
            ListPagingNavigationControls ctl = this.GetPagingNavigationControls();

            // Reperimento contesto di paginazione
            PagingContext pagingContext = ctl.GetPagingContext();

            // Caricamento dati trasmissioni
            this.FetchTrasmissioni(this.GetSelectedSearchType(), pagingContext);

            ctl.RefreshPaging(pagingContext);
        }
コード例 #35
0
ファイル: TagsTestPage.aspx.cs プロジェクト: sidny/d4d-studio
 protected void btnGetPagedTags_Click(object sender, EventArgs e)
 {
     PagingContext pager = new PagingContext();
     pager.RecordsPerPage = 5;
     pager.CurrentPageNumber = 1;
     List<Tag> tagList = D4DGateway.TagsProvider.GetPagedTags(pager);
     ShowInfo("GetPageTagsList! TotalRecord:"+pager.TotalRecordCount.ToString());
     foreach (Tag tag in tagList)
     {
         ShowInfo(string.Format("GetTage[Name={0},Hits={1},AddUserId={2},AddDate={3}]",
          tag.TagName, tag.Hits, tag.AddUserID, tag.AddDate.ToLongDateString()));
     }
 }
コード例 #36
0
ファイル: SearchDao.cs プロジェクト: sidny/d4d-studio
        internal static List<SearchResult> GetPagedSearch(PagingContext pager, 
            string searchText,ObjectTypeDefine objectType)
        {
            List<SearchResult> list = new List<SearchResult>(pager.RecordsPerPage);

            string SearchSp = string.Empty;
            switch (objectType)
            {
                case ObjectTypeDefine.Show:
                    SearchSp = "dbo.Search_GetPagedShow";
                    break;
                case ObjectTypeDefine.MusicTitle:
                case ObjectTypeDefine.Song:
                    SearchSp = "dbo.Search_GetPagedMusic";
                    break;
                case ObjectTypeDefine.Album:
                case ObjectTypeDefine.Image:
                    SearchSp = "dbo.Search_GetPagedAlbum";
                    break;
                case ObjectTypeDefine.Video:
                    SearchSp = "dbo.Search_GetPagedVideoNews";
                    break;
                case ObjectTypeDefine.News:
                    SearchSp = "dbo.Search_GetPagedNews";
                    break;
                default:
                    return list;

            }

            SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(D4DDefine.DBInstanceName),
               SearchSp,
               delegate(IParameterSet parameters)
               {
                   parameters.AddWithValue("@SearchTxt", searchText);
                   parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                   parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                   parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
               },
               delegate(IRecord record)
               {
                   MapSeachResultList(record, list, objectType);
               },
               delegate(IParameterSet outputParameters)
               {
                   pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
               }
               );

            return list;
        }
コード例 #37
0
ファイル: ShowProvider.cs プロジェクト: sidny/d4d-studio
 public List<Show> GetPagedShowByTagAndBand(PagingContext pager, PublishStatus publishStatus, int tagId, int bandId)
 {
     return ShowDao.GetPagedShowByTagAndBand(pager, (int)publishStatus, tagId, bandId);
 }
コード例 #38
0
ファイル: ShowProvider.cs プロジェクト: sidny/d4d-studio
 public List<Show> GetPagedShowByShowDate(PagingContext pager, DateTime sTime,
     DateTime eTime, PublishStatus publishStatus)
 {
     return ShowDao.GetPagedShowByShowDate(pager,  sTime, eTime, (int)publishStatus);
 }
コード例 #39
0
ファイル: ShowProvider.cs プロジェクト: sidny/d4d-studio
 public List<Show> GetPagedShowByBandId(PagingContext pager, int bandId, PublishStatus publishStatus)
 {
     return ShowDao.GetPagedShowByBandId(pager, bandId,(int)publishStatus);
 }
コード例 #40
0
ファイル: AlbumProvider.cs プロジェクト: sidny/d4d-studio
 public List<Image> GetPagedImagesByAlbumId(PagingContext pager, int albumId, PublishStatus publishStatus)
 {
     return AlbumDao.GetPagedImagesByAlbumId(pager, albumId, (int)publishStatus);
 }
コード例 #41
0
ファイル: AlbumProvider.cs プロジェクト: sidny/d4d-studio
 public List<Album> GetPagedAlbumsByPublishYearMonth(PagingContext pager, PublishStatus publishStatus
     , int pulishYear, int publishMonth)
 {
     return AlbumDao.GetPagedAlbumsByPublishYearMonth(pager, (int)publishStatus,
         pulishYear, publishMonth);
 }
コード例 #42
0
ファイル: AlbumProvider.cs プロジェクト: sidny/d4d-studio
 public List<Image> GetPagedImagesByTag(PagingContext pager, PublishStatus publishStatus, int tagId)
 {
     return AlbumDao.GetPagedImagesByTag(pager, (int)publishStatus,
        tagId);
 }
コード例 #43
0
ファイル: CommentProvider.cs プロジェクト: sidny/d4d-studio
 public List<Comment> GetPagedComments(PagingContext pager, PublishStatus publishStatus, int objectId, ObjectTypeDefine objectType)
 {
     return CommentDao.GetPagedComments(pager, (int)publishStatus, objectId, (int)objectType);
 }
コード例 #44
0
ファイル: JaneShopProvier.cs プロジェクト: sidny/d4d-studio
 public List<ShopTradelist> GetPagedShopOrder(PagingContext pager, int orderid)
 {
     return JaneShopTradelistDao.GetPagedTradelist(pager, orderid);
 }
コード例 #45
0
ファイル: AlbumDao.cs プロジェクト: sidny/d4d-studio
        internal static List<Album> GetPagedAlbumsByPublishYearMonth(PagingContext pager, int publishStatus
            , int pulishYear, int publishMonth)
        {
            List<Album> list = new List<Album>(pager.RecordsPerPage);

            SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(D4DDefine.DBInstanceName),
               "dbo.Album_GetPagedByPublishYearMonth",
               delegate(IParameterSet parameters)
               {
                   parameters.AddWithValue("@PublishYear", pulishYear);
                   parameters.AddWithValue("@PublishMonth", publishMonth);
                   parameters.AddWithValue("@PublishStatus", publishStatus);
                   parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                   parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                   parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
               },
               delegate(IRecord record)
               {
                   MapAlbumList(record, list);
               },
               delegate(IParameterSet outputParameters)
               {
                   pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
               }
               );

            return list;
        }
コード例 #46
0
ファイル: NewsDao.cs プロジェクト: sidny/d4d-studio
        internal static List<News> GetPagedNewsByTypeANDPublishDate(PagingContext pager, int newsType, DateTime sTime,
            DateTime eTime, int publishStatus, int newsRemarkType)
        {
            List<News> list = new List<News>(pager.RecordsPerPage);

            if (newsRemarkType == -1)
            {
                SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(D4DDefine.DBInstanceName),
              "dbo.News_GetPagedByNewsTypeAndPublishDate",
              delegate(IParameterSet parameters)
              {
                  parameters.AddWithValue("@NewsType", newsType);
                  parameters.AddWithValue("@STime", sTime);
                  parameters.AddWithValue("@ETime", eTime);
                  parameters.AddWithValue("@PublishStatus", publishStatus);
                  parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                  parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                  parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
              },
              delegate(IRecord record)
              {
                  MapList(record, list);
              },
              delegate(IParameterSet outputParameters)
              {
                  pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
              }
              );
            }
            else
            {
                SafeProcedure.ExecuteAndMapRecords(Database.GetDatabase(D4DDefine.DBInstanceName),
              "dbo.News_GetPagedByNewsTypeAndPublishDateV2",
              delegate(IParameterSet parameters)
              {
                  parameters.AddWithValue("@RemarkType", newsRemarkType);
                  parameters.AddWithValue("@NewsType", newsType);
                  parameters.AddWithValue("@STime", sTime);
                  parameters.AddWithValue("@ETime", eTime);
                  parameters.AddWithValue("@PublishStatus", publishStatus);
                  parameters.AddWithValue("@PageIndex", pager.CurrentPageNumber);
                  parameters.AddWithValue("@PageSize", pager.RecordsPerPage);
                  parameters.AddWithValue("@NumberOfCount", 0, ParameterDirectionWrap.Output);
              },
              delegate(IRecord record)
              {
                  MapList(record, list);
              },
              delegate(IParameterSet outputParameters)
              {
                  pager.TotalRecordCount = outputParameters.GetValue("@NumberOfCount") == DBNull.Value ? 0 : (int)outputParameters.GetValue("@NumberOfCount");
              }
              );
            }

            return list;
        }
コード例 #47
0
ファイル: TagsProvider.cs プロジェクト: sidny/d4d-studio
 /// <summary>
 /// 获取带分页的Tags
 /// </summary>
 /// <param name="pager"></param>
 /// <returns></returns>
 public List<Tag> GetPagedTags(PagingContext pager)
 {
     return TagsDao.GetPagedTags(pager);
 }
コード例 #48
0
ファイル: AlbumProvider.cs プロジェクト: sidny/d4d-studio
 public List<Image> GetPagedImagesByBandId(PagingContext pager, PublishStatus publishStatus, int bandId)
 {
     return AlbumDao.GetPagedImagesByBandId(pager, (int)publishStatus,
        bandId);
 }
コード例 #49
0
ファイル: AlbumProvider.cs プロジェクト: sidny/d4d-studio
 public List<Image> GetPagedImagesByPublishYearMonth(PagingContext pager, PublishStatus publishStatus
     , DateTime sTime, DateTime eTime)
 {
     return AlbumDao.GetPagedImagesByPublishYearMonth(pager, (int)publishStatus,
         sTime, eTime);
 }
コード例 #50
0
ファイル: JaneShopProvier.cs プロジェクト: sidny/d4d-studio
 public List<ShopItem> GetPagedShopItem(PagingContext pager, PublishStatus publishStatus)
 {
     return JaneShopItemsDao.GetPagedShopItem(pager, (int)publishStatus);
 }
コード例 #51
0
ファイル: AlbumProvider.cs プロジェクト: sidny/d4d-studio
 public List<Album> GetPagedAlbums(PagingContext pager, PublishStatus publishStatus)
 {
     return AlbumDao.GetPagedAlbums(pager, (int)publishStatus);
 }
コード例 #52
0
ファイル: NewsProvider.cs プロジェクト: sidny/d4d-studio
 public List<News> GetPagedNewsByNewsType(PagingContext pager, BandType newsType,
     PublishStatus publishStatus, NewsRemarkType newsRemarkType)
 {
     return NewsDao.GetPagedNewsByNewsType(pager, (int)newsType, (int)publishStatus, (int)newsRemarkType);
 }
コード例 #53
0
ファイル: AlbumProvider.cs プロジェクト: sidny/d4d-studio
 public List<Album> GetPagedAlbumsByTagAndBand(PagingContext pager, PublishStatus publishStatus, int tagId, int bandId)
 {
     return AlbumDao.GetPagedAlbumsByTagAndBand(pager, (int)publishStatus,
       tagId, bandId);
 }
コード例 #54
0
ファイル: ProcessFilter.cs プロジェクト: GodLesZ/svn-dump
		public override void Invoke(AMFContext context) {
			MessageOutput messageOutput = context.MessageOutput;
			for (int i = 0; i < context.AMFMessage.BodyCount; i++) {
				AMFBody amfBody = context.AMFMessage.GetBodyAt(i);
				ResponseBody responseBody = null;
				//Check for Flex2 messages and skip
				if (amfBody.IsEmptyTarget)
					continue;

				if (amfBody.IsDebug)
					continue;
				if (amfBody.IsDescribeService) {
					responseBody = new ResponseBody();
					responseBody.IgnoreResults = amfBody.IgnoreResults;
					responseBody.Target = amfBody.Response + AMFBody.OnResult;
					responseBody.Response = null;
					DescribeService describeService = new DescribeService(amfBody);
					responseBody.Content = describeService.GetDescription();
					messageOutput.AddBody(responseBody);
					continue;
				}

				//Check if response exists.
				responseBody = messageOutput.GetResponse(amfBody);
				if (responseBody != null) {
					continue;
				}

				try {
					MessageBroker messageBroker = _endpoint.GetMessageBroker();
					RemotingService remotingService = messageBroker.GetService(RemotingService.RemotingServiceId) as RemotingService;
					if (remotingService == null) {
						string serviceNotFound = __Res.GetString(__Res.Service_NotFound, RemotingService.RemotingServiceId);
						responseBody = new ErrorResponseBody(amfBody, new FluorineException(serviceNotFound));
						messageOutput.AddBody(responseBody);
						if (log.IsErrorEnabled)
							log.Error(serviceNotFound);
						continue;
					}
					Destination destination = null;
					if (destination == null)
						destination = remotingService.GetDestinationWithSource(amfBody.TypeName);
					if (destination == null)
						destination = remotingService.DefaultDestination;
					//At this moment we got a destination with the exact source or we have a default destination with the "*" source.
					if (destination == null) {
						string destinationNotFound = __Res.GetString(__Res.Destination_NotFound, amfBody.TypeName);
						responseBody = new ErrorResponseBody(amfBody, new FluorineException(destinationNotFound));
						messageOutput.AddBody(responseBody);
						if (log.IsErrorEnabled)
							log.Error(destinationNotFound);
						continue;
					}

					try {
						remotingService.CheckSecurity(destination);
					} catch (UnauthorizedAccessException exception) {
						responseBody = new ErrorResponseBody(amfBody, exception);
						if (log.IsDebugEnabled)
							log.Debug(exception.Message);
						continue;
					}

					//Cache check
					string source = amfBody.TypeName + "." + amfBody.Method;
					IList parameterList = amfBody.GetParameterList();
					string key = GodLesZ.Library.Amf.Configuration.CacheMap.GenerateCacheKey(source, parameterList);
					if (FluorineConfiguration.Instance.CacheMap.ContainsValue(key)) {
						object result = GodLesZ.Library.Amf.Configuration.FluorineConfiguration.Instance.CacheMap.Get(key);
						if (result != null) {
							if (log != null && log.IsDebugEnabled)
								log.Debug(__Res.GetString(__Res.Cache_HitKey, source, key));
							responseBody = new ResponseBody(amfBody, result);
							messageOutput.AddBody(responseBody);
							continue;
						}
					}

					FactoryInstance factoryInstance = destination.GetFactoryInstance();
					factoryInstance.Source = amfBody.TypeName;
					if (FluorineContext.Current.ActivationMode != null)//query string can override the activation mode
						factoryInstance.Scope = FluorineContext.Current.ActivationMode;
					object instance = factoryInstance.Lookup();

					if (instance != null) {
						try {
							bool isAccessible = TypeHelper.GetTypeIsAccessible(instance.GetType());
							if (!isAccessible) {
								string msg = __Res.GetString(__Res.Type_InitError, amfBody.TypeName);
								if (log.IsErrorEnabled)
									log.Error(msg);
								responseBody = new ErrorResponseBody(amfBody, new FluorineException(msg));
								messageOutput.AddBody(responseBody);
								continue;
							}

							MethodInfo mi = null;
							if (!amfBody.IsRecordsetDelivery) {
								mi = MethodHandler.GetMethod(instance.GetType(), amfBody.Method, amfBody.GetParameterList());
							} else {
								//will receive recordsetid only (ignore)
								mi = instance.GetType().GetMethod(amfBody.Method);
							}
							if (mi != null) {
								object[] roleAttributes = mi.GetCustomAttributes(typeof(RoleAttribute), true);
								if (roleAttributes != null && roleAttributes.Length == 1) {
									RoleAttribute roleAttribute = roleAttributes[0] as RoleAttribute;
									string[] roles = roleAttribute.Roles.Split(',');

									bool authorized = messageBroker.LoginManager.DoAuthorization(roles);
									if (!authorized)
										throw new UnauthorizedAccessException(__Res.GetString(__Res.Security_AccessNotAllowed));
								}

								#region Invocation handling
								PageSizeAttribute pageSizeAttribute = null;
								MethodInfo miCounter = null;
								object[] pageSizeAttributes = mi.GetCustomAttributes(typeof(PageSizeAttribute), true);
								if (pageSizeAttributes != null && pageSizeAttributes.Length == 1) {
									pageSizeAttribute = pageSizeAttributes[0] as PageSizeAttribute;
									miCounter = instance.GetType().GetMethod(amfBody.Method + "Count");
									if (miCounter != null && miCounter.ReturnType != typeof(System.Int32))
										miCounter = null; //check signature
								}
								ParameterInfo[] parameterInfos = mi.GetParameters();
								//Try to handle missing/optional parameters.
								object[] args = new object[parameterInfos.Length];
								if (!amfBody.IsRecordsetDelivery) {
									if (args.Length != parameterList.Count) {
										string msg = __Res.GetString(__Res.Arg_Mismatch, parameterList.Count, mi.Name, args.Length);
										if (log != null && log.IsErrorEnabled)
											log.Error(msg);
										responseBody = new ErrorResponseBody(amfBody, new ArgumentException(msg));
										messageOutput.AddBody(responseBody);
										continue;
									}
									parameterList.CopyTo(args, 0);
									if (pageSizeAttribute != null) {
										PagingContext pagingContext = new PagingContext(pageSizeAttribute.Offset, pageSizeAttribute.Limit);
										PagingContext.SetPagingContext(pagingContext);
									}
								} else {
									if (amfBody.Target.EndsWith(".release")) {
										responseBody = new ResponseBody(amfBody, null);
										messageOutput.AddBody(responseBody);
										continue;
									}
									string recordsetId = parameterList[0] as string;
									string recordetDeliveryParameters = amfBody.GetRecordsetArgs();
									byte[] buffer = System.Convert.FromBase64String(recordetDeliveryParameters);
									recordetDeliveryParameters = System.Text.Encoding.UTF8.GetString(buffer);
									if (recordetDeliveryParameters != null && recordetDeliveryParameters != string.Empty) {
										string[] stringParameters = recordetDeliveryParameters.Split(new char[] { ',' });
										for (int j = 0; j < stringParameters.Length; j++) {
											if (stringParameters[j] == string.Empty)
												args[j] = null;
											else
												args[j] = stringParameters[j];
										}
										//TypeHelper.NarrowValues(argsStore, parameterInfos);
									}
									PagingContext pagingContext = new PagingContext(System.Convert.ToInt32(parameterList[1]), System.Convert.ToInt32(parameterList[2]));
									PagingContext.SetPagingContext(pagingContext);
								}

								TypeHelper.NarrowValues(args, parameterInfos);

								try {
									InvocationHandler invocationHandler = new InvocationHandler(mi);
									object result = invocationHandler.Invoke(instance, args);

									if (FluorineConfiguration.Instance.CacheMap != null && FluorineConfiguration.Instance.CacheMap.ContainsCacheDescriptor(source)) {
										//The result should be cached
										CacheableObject cacheableObject = new CacheableObject(source, key, result);
										FluorineConfiguration.Instance.CacheMap.Add(cacheableObject.Source, cacheableObject.CacheKey, cacheableObject);
										result = cacheableObject;
									}
									responseBody = new ResponseBody(amfBody, result);

									if (pageSizeAttribute != null) {
										int totalCount = 0;
										string recordsetId = null;

										IList list = amfBody.GetParameterList();
										string recordetDeliveryParameters = null;
										if (!amfBody.IsRecordsetDelivery) {
											//fist call paging
											object[] argsStore = new object[list.Count];
											list.CopyTo(argsStore, 0);
											recordsetId = System.Guid.NewGuid().ToString();
											if (miCounter != null) {
												//object[] counterArgs = new object[0];
												totalCount = (int)miCounter.Invoke(instance, args);
											}
											string[] stringParameters = new string[argsStore.Length];
											for (int j = 0; j < argsStore.Length; j++) {
												if (argsStore[j] != null)
													stringParameters[j] = argsStore[j].ToString();
												else
													stringParameters[j] = string.Empty;
											}
											recordetDeliveryParameters = string.Join(",", stringParameters);
											byte[] buffer = System.Text.Encoding.UTF8.GetBytes(recordetDeliveryParameters);
											recordetDeliveryParameters = System.Convert.ToBase64String(buffer);
										} else {
											recordsetId = amfBody.GetParameterList()[0] as string;
										}
										if (result is DataTable) {
											DataTable dataTable = result as DataTable;
											dataTable.ExtendedProperties["TotalCount"] = totalCount;
											dataTable.ExtendedProperties["Service"] = recordetDeliveryParameters + "/" + amfBody.Target;
											dataTable.ExtendedProperties["RecordsetId"] = recordsetId;
											if (amfBody.IsRecordsetDelivery) {
												dataTable.ExtendedProperties["Cursor"] = Convert.ToInt32(list[list.Count - 2]);
												dataTable.ExtendedProperties["DynamicPage"] = true;
											}
										}
									}
								} catch (UnauthorizedAccessException exception) {
									responseBody = new ErrorResponseBody(amfBody, exception);
									if (log.IsDebugEnabled)
										log.Debug(exception.Message);
								} catch (Exception exception) {
									if (exception is TargetInvocationException && exception.InnerException != null)
										responseBody = new ErrorResponseBody(amfBody, exception.InnerException);
									else
										responseBody = new ErrorResponseBody(amfBody, exception);
									if (log.IsDebugEnabled)
										log.Debug(__Res.GetString(__Res.Invocation_Failed, mi.Name, exception.Message));
								}
								#endregion Invocation handling
							} else
								responseBody = new ErrorResponseBody(amfBody, new MissingMethodException(amfBody.TypeName, amfBody.Method));
						} finally {
							factoryInstance.OnOperationComplete(instance);
						}
					} else
						responseBody = new ErrorResponseBody(amfBody, new TypeInitializationException(amfBody.TypeName, null));
				} catch (Exception exception) {
					if (log != null && log.IsErrorEnabled)
						log.Error(exception.Message, exception);
					responseBody = new ErrorResponseBody(amfBody, exception);
				}
				messageOutput.AddBody(responseBody);
			}
		}
コード例 #55
0
 public List<SpamKeyword> GetPagedSpamKeywords(PagingContext pager)
 {
     return SpamKeywordDao.GetPagedSpamKeywords(pager);
 }
コード例 #56
0
ファイル: ShowProvider.cs プロジェクト: sidny/d4d-studio
 public List<Show> GetPagedShow(PagingContext pager, PublishStatus publishStatus)
 {
     return ShowDao.GetPagedShow(pager, (int)publishStatus);
 }
コード例 #57
0
ファイル: JaneShopProvier.cs プロジェクト: sidny/d4d-studio
 public List<ShopItem> GetPagedShopItemByPublishDate(PagingContext pager, PublishStatus publishStatus,
     DateTime sTime, DateTime eTime)
 {
     return JaneShopItemsDao.GetPagedShopItemByPublishDate(pager, (int)publishStatus,sTime,eTime);
 }
コード例 #58
0
ファイル: MusicProvider.cs プロジェクト: sidny/d4d-studio
 public List<MusicTitle> GetPagedMusicTitlesByBandId(PagingContext pager, int bandId, PublishStatus publishStatus)
 {
     return MusicDao.GetPagedMusicTitlesByBandId(pager, bandId, (int)publishStatus);
 }
コード例 #59
0
ファイル: JaneShopProvier.cs プロジェクト: sidny/d4d-studio
 public List<ShopOrder> GetPagedShopOrderbyUser(PagingContext pager, int userid, OrderType ordertype)
 {
     return JaneShopOrdersDao.GetPagedShopOrderbyUser(pager, userid, (int)ordertype);
 }
コード例 #60
0
ファイル: MusicProvider.cs プロジェクト: sidny/d4d-studio
 public List<MusicTitle> GetPagedMusicTitlesByPublishYear(PagingContext pager, int publishYear, PublishStatus publishStatus)
 {
     return MusicDao.GetPagedMusicTitlesByPublishYear(pager, publishYear, (int)publishStatus);
 }