コード例 #1
0
        public List <Report> GetClientReports(ReportsRequest request)
        {
            var conn           = GetConnection(ConnectionNames.CSPSqlDatabase);
            var commandWrapper = GetStoredProcCommand("dbo.Get_Client_Reports", conn);

            AddInParameter(commandWrapper, "@CustomerNumber", DbType.Int32, request.ClientId);

            IDataReader   reader = null;
            List <Report> tmp    = new List <Report>();

            try
            {
                conn.Open();
                reader = commandWrapper.ExecuteReader();
                FillReports(reader, tmp, 0, int.MaxValue);
                MakeDboLog(request.ToString(), reader.ToString(), "dbo.Get_Client_Reports");
                return(tmp);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                commandWrapper.Dispose();
                conn.Close();
            }
        }
コード例 #2
0
        public ReportsResponse GetReports(ReportsRequest request)
        {
            var response = new ReportsResponse {
                ResponseStatus = ResponseStatus.Success
            };

            var clientsProvider = new ClientsProvider();

            try
            {
                if (request.ActionType == ActionType.Select)
                {
                    response.Reports = clientsProvider.GetClientReports(request);
                }
                else
                {
                    response.ResponseStatus      = ResponseStatus.Failure;
                    response.ResponseDescription = "Not update action";
                }
            }
            catch (Exception ex)
            {
                response.ResponseStatus      = ResponseStatus.Failure;
                response.ResponseDescription = ex.Message;
            }

            return(response);
        }
コード例 #3
0
        public ReportsRequest GetReportsRequest(int clientId)
        {
            var request = new ReportsRequest
            {
                ClientId   = clientId,
                ActionType = DataBaseCommunication.Mappers.Requests.ActionType.Select
            };

            return(request);
        }
コード例 #4
0
        private void Submit(object sender, EventArgs e)
        {
            var req = new ReportsRequest
            {
                date_from = Request.Form["date_from"],
                date_to   = Request.Form["date_to"]
            };
            var resp = new Reports().Post(req);

            if (resp.Error != null)
            {
                DataError   = resp.Error.ErrorMessage;
                DataErrorId = resp.Error.RequestId;
            }
            else
            {
                if (resp.response.Count == 0)
                {
                    DataNoList = "No data";
                }
                Data = resp;
            }
        }
コード例 #5
0
ファイル: ReviewerController.cs プロジェクト: SOBotics/Higgs
        public PagingResponse <ReviewerReportsResponse> Reports(ReportsRequest request)
        {
            IQueryable <DbReport> reportQuery = _dbContext.Reports;

            if (!string.IsNullOrWhiteSpace(request.Content))
            {
                reportQuery = reportQuery.Where(r => r.Title.Contains(request.Content));
            }
            if (request.DashboardId.HasValue)
            {
                reportQuery = reportQuery.Where(r => r.DashboardId == request.DashboardId.Value);
            }
            if (request.HasFeedback.HasValue)
            {
                reportQuery = reportQuery.Where(r => r.Feedbacks.Any() == request.HasFeedback.Value);
            }
            if (request.Conflicted.HasValue)
            {
                reportQuery = reportQuery.Where(r => r.Conflicted == request.Conflicted);
            }
            if (request.Reasons?.Any() ?? false)
            {
                reportQuery = reportQuery.Where(r => r.Reasons.Any(reportReason => reportReason.Tripped && request.Reasons.Contains(reportReason.ReasonId)));
            }
            if (request.Feedbacks?.Any() ?? false)
            {
                reportQuery = reportQuery.Where(r => r.Feedbacks.Any(reportFeedback => request.Feedbacks.Contains(reportFeedback.FeedbackId)));
            }

            var pagedReportData = reportQuery
                                  .Select(r => new
            {
                r.Id,
                r.Title,
                r.Dashboard.DashboardName,
                r.DetectionScore,
            }).OrderByDescending(r => r.Id)
                                  .Page(request);

            var reports = pagedReportData.Data;

            var reportIds = reports.Select(r => r.Id).ToList();
            var feedbacks = _dbContext.ReportFeedbacks
                            .Where(f => f.InvalidatedDate == null)
                            .Where(rf => reportIds.Contains(rf.ReportId))
                            .Select(feedback => new
            {
                feedback.ReportId,
                feedback.Feedback.Icon,
                feedback.Feedback.Colour,
                FeedbackName = feedback.Feedback.Name,
                UserName     = feedback.User.Name
            }).GroupBy(r => r.ReportId)
                            .ToDictionary(r => r.Key, r => r.ToList());

            var result =
                new PagingResponse <ReviewerReportsResponse>
            {
                PageNumber = pagedReportData.PageNumber,
                PageSize   = pagedReportData.PageSize,
                TotalPages = pagedReportData.TotalPages,
                Data       = reports
                             .Select(r => new ReviewerReportsResponse
                {
                    Id             = r.Id,
                    Title          = r.Title,
                    DashboardName  = r.DashboardName,
                    DetectionScore = r.DetectionScore,
                    Feedback       = feedbacks.ContainsKey(r.Id)
                                ? feedbacks[r.Id].Select(feedback => new ReviewerReportFeedbackResponse
                    {
                        Icon         = feedback.Icon,
                        Colour       = feedback.Colour,
                        FeedbackName = feedback.FeedbackName,
                        UserName     = feedback.UserName
                    }).ToList()
                                : new List <ReviewerReportFeedbackResponse>()
                })
                             .OrderByDescending(r => r.Id)
                             .ToList()
            };

            return(result);
        }