static public void RegisterDownload(String itemKey)
        {
            DatasetInfoDataSource datasetInfoDataSource = new DatasetInfoDataSource();
            ViewDataSource        viewDS = new ViewDataSource();

            datasetInfoDataSource.RegisterDownload(itemKey);
        }
        static public void RegisterView(String itemKey, String url, String user)
        {
            DatasetInfoDataSource datasetInfoDataSource = new DatasetInfoDataSource();
            ViewDataSource        viewDS = new ViewDataSource();

            datasetInfoDataSource.IncrementView(itemKey);
        }
Exemplo n.º 3
0
        private void LoadControls(string container, string entitySetName)
        {
            model.ViewDataModel = new DataBrowserModel();
            model.ViewDataModel.EntitySetName = entitySetName;
            model.ViewDataModel.Container     = container;

            EntitySet entitySet = EntitySetRepository.GetEntitySet(container, entitySetName);

            var viewDs = new DatasetInfoDataSource();
            var views  = viewDs.GetAnalyticSummary(Helper.GenerateDatasetItemKey(entitySet.ContainerAlias, entitySet.EntitySetName));

            model.ViewDataModel.EntitySetWrapper = new EntitySetWrapper()
            {
                EntitySet     = entitySet,
                PositiveVotes = views.PositiveVotes,
                NegativeVotes = views.NegativeVotes,
                Views         = views.views_total
            };

            if (!entitySet.IsDownloadOnly && !entitySet.IsEmpty)
            {
                EntitySetDetails metaDataDetails = EntitySetDetailsRepository.GetMetaData(container, entitySetName);
                model.ViewDataModel.EntitySetDetails = metaDataDetails;
            }
        }
        static public VoteResults GetVoteResults(string itemKey)
        {
            DatasetInfoDataSource datasetInfoDS = new DatasetInfoDataSource();

            AnalyticInfo dInfo = datasetInfoDS.GetAnalyticSummary(itemKey);

            return(new VoteResults()
            {
                Positive = dInfo.PositiveVotes,
                Negative = dInfo.NegativeVotes,
            });
        }
        static public IEnumerable <Request> GetRequests(string status, DateTime?postedFrom, DateTime?postedTo)
        {
            RequestDataSource     reqDS  = new RequestDataSource();
            DatasetInfoDataSource viewDs = new DatasetInfoDataSource();

            // We should use values SqlDateTime.MinValue otherwies exception during query execution
            //January 1, 1753.
            if (!postedFrom.HasValue)
            {
                postedFrom = SqlDateTime.MinValue.Value;
            }

            //December 31, 9999.
            if (!postedTo.HasValue)
            {
                postedTo = DateTime.UtcNow;
            }

            IQueryable <RequestEntry> requests = (status == "All") ? reqDS.SelectAllWithHidden() : reqDS.SelectAll();

            var datasetViews = viewDs.SelectAll();

            var requestList = (from req in requests
                               where
                               req.PostedDate >= postedFrom &&
                               req.PostedDate <= postedTo
                               select req).AsEnumerable();

            var result = (from request in requestList
                          join r1 in datasetViews on request.RowKey equals r1.RowKey into lstWithViews
                          from es2 in lstWithViews.DefaultIfEmpty()
                          select new Request
            {
                Name = request.Name,
                Email = request.Email,
                RequestID = request.RowKey,
                Subject = request.Subject,
                Description = request.Description,
                Status = request.Status,
                ReleaseDate = request.ReleaseDate,
                PostedDate = request.PostedDate,
                Links = request.Links,
                DatasetLink = request.DatasetLink,
                PositiveVotes = (es2 != null ? es2.PositiveVotes : 0),
                NegativeVotes = (es2 != null ? es2.NegativeVotes : 0),
                Views = es2 != null ? es2.views_total : 0,
            });

            return(result);
        }
        static public void AddVote(Rate item)
        {
            RateDataSource        rateDS        = new RateDataSource();
            DatasetInfoDataSource datasetInfoDS = new DatasetInfoDataSource();

            rateDS.AddVote(new RateEntry()
            {
                RowKey       = Guid.NewGuid().ToString(),
                ItemKey      = item.ItemKey,
                PartitionKey = "rates",
                RateDate     = item.RateDate,
                RateValue    = item.RateValue,
                User         = item.User,
            });

            datasetInfoDS.IncrementVote(item.ItemKey, item.RateValue);
        }
Exemplo n.º 7
0
        static public void RegisterView(String itemKey, String url, String user)
        {
            DatasetInfoDataSource datasetInfoDataSource = new DatasetInfoDataSource();
            ViewDataSource        viewDS = new ViewDataSource();

            datasetInfoDataSource.IncrementView(itemKey);

            // No logging if analytics are disabled
            if (OgdiConfiguration.GetValue("IsAnalytics") == "0")
            {
                return;
            }

            viewDS.AddView(new ViewEntry()
            {
                Date         = DateTime.Now,
                ItemKey      = itemKey,
                User         = user,
                RequestedUrl = url,
            });
        }
        static public Request GetRequest(string requestId)
        {
            RequestDataSource     reqDS  = new RequestDataSource();
            DatasetInfoDataSource viewDs = new DatasetInfoDataSource();
            RequestEntry          req    = reqDS.GetById(requestId);
            AnalyticInfo          dsInfo = viewDs.GetAnalyticSummary(Helper.GenerateRequestKey(requestId));

            return(new Request()
            {
                DatasetLink = req.DatasetLink,
                Description = req.Description,
                Links = req.Links,
                NegativeVotes = dsInfo.NegativeVotes,
                PositiveVotes = dsInfo.PositiveVotes,
                PostedDate = req.PostedDate,
                ReleaseDate = req.ReleaseDate,
                Status = req.Status,
                Subject = req.Subject,
                Views = dsInfo.views_total,
                RequestID = req.RowKey
            });
        }
        static public void IncrementView(String itemKey)
        {
            DatasetInfoDataSource datasetInfoDS = new DatasetInfoDataSource();

            datasetInfoDS.IncrementView(itemKey);
        }