Ejemplo n.º 1
0
        public async Task <ReportResults> GetSearchResults(ReportParms reportParms)
        {
            string sqlcmd    = "Reports_SP";
            var    parmsList = new List <SqlParameter>()
            {
                new SqlParameter("@Name", SqlDbType.NVarChar)
                {
                    Value = reportParms.Name ?? (object)DBNull.Value
                },
                new SqlParameter("@Type", SqlDbType.NVarChar)
                {
                    Value = reportParms.Type ?? (object)DBNull.Value
                },
                new SqlParameter("@PolicyID", SqlDbType.NVarChar)
                {
                    Value = reportParms.PolicyID ?? (object)DBNull.Value
                },
                new SqlParameter("@Status", SqlDbType.NVarChar)
                {
                    Value = reportParms.Status ?? (object)DBNull.Value
                },
            };
            var results = new List <Dictionary <string, object> >();

            using (var connection = GetDBContext())
            {
                Task open    = connection.OpenAsync();
                var  command = new SqlCommand(sqlcmd, connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddRange(parmsList.ToArray());
                await         open;
                SqlDataReader reader = await command.ExecuteReaderAsync();

                if (reader.HasRows)
                {
                    int count = reader.FieldCount;
                    while (await reader.ReadAsync())
                    {
                        var rowDict = new Dictionary <string, object>();
                        for (int i = 0; i < count; i++)
                        {
                            object columnVal;
                            string columnName = reader.GetName(i);
                            columnVal = reader.IsDBNull(i) ? "" : await reader.GetFieldValueAsync <object>(i);

                            rowDict.Add(columnName, columnVal);
                        }
                        results.Add(rowDict);
                    }
                }
            }
            return(new ReportResults
            {
                ResultsList = results,
                ItemsCount = results.Count
            });
        }
Ejemplo n.º 2
0
        public void GetPagoReport()
        {
            // connection();
            ReportParms objReporParams = new ReportParms();
            var         data           = GetPagoInfo();

            objReporParams.DataSource  = data.Tables[0];
            objReporParams.ReportTitle = "Pago Info Report";
            objReporParams.RptFileName = "PagoInfoReport.rdlc";
            objReporParams.ReportType  = "PagoInfoReport";
            objReporParams.DataSetName = "dsPagoReport";
            this.HttpContext.Session["ReportParam"] = objReporParams;
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Accounts([FromServices] IReportsRepository data, [FromForm] ReportParms parms)
        {
            if (!ModelState.IsValid)
            {
                return(new BadRequestResult());
            }
            ReportResults results = await data.GetAccountSearchResults(parms);

            return(Content(JsonConvert.SerializeObject(results), "application/json"));
        }