Beispiel #1
0
        public JsonResult getReportDetails(int ReportID)
        {
            try
            {
                ListDatabaseObjects db       = new ListDatabaseObjects();
                SqlReportModel      model    = new SqlReportModel();
                DataSet             dsReport = db.getReportDetails(ReportID);
                DataTable           dtReport = dsReport.Tables.Count > 0 ? dsReport.Tables[0] : null;
                DataTable           dtResult = new DataTable();
                dynamic             filters  = new Dictionary <string, Object>();
                if (dtReport.Rows.Count > 0)
                {
                    dtResult = db.getReportView(ReportID, "");

                    if (dsReport != null && dsReport.Tables.Count > 0)
                    {
                        var     report   = Converter.GetEntities <SqlViewsModel>(dsReport.Tables[0]);
                        var     dtFields = Converter.GetEntityList <ReportFieldModel>(dsReport.Tables[1]);
                        var     dtFilter = Converter.GetEntityList <FilterFieldModel>(dsReport.Tables[2]);
                        var     dtRoles  = Converter.GetEntityList <RolesModel>(dsReport.Tables[3]);
                        DataRow drReport = (dsReport.Tables[0].Rows.Count > 0) ? dsReport.Tables[0].Rows[0] : null;
                        model = Converter.DataRowTonEntity <SqlReportModel>(drReport);
                        model.dtReportFields = dtFields;
                        model.dtFilterFields = dtFilter;
                        model.SelectedRoles  = dtRoles;

                        DataTable dtFilters = dsReport.Tables[2];

                        for (int i = 0; i < dtFilters.Rows.Count; i++)
                        {
                            if (dtFilters.Rows[i]["FieldType"].ToString() == "Dropdown")
                            {
                                var key           = dtFilters.Rows[i]["ReportField"].ToString();
                                var dtResultField = db.getFilterDetails(ReportID, key);
                                if (dtResultField != null)
                                {
                                    filters[key] = Converter.DataTableToDict(dtResultField);
                                }
                            }
                        }
                    }
                }

                var result = dtResult != null?Converter.DataTableToDict(dtResult) : new List <Dictionary <string, object> >();

                var resultJson = new { result = result, schema = model, filters = filters };
                return(Json(resultJson, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #2
0
        public JsonResult searchReportDetails(int ReportID, string condition)
        {
            try
            {
                ListDatabaseObjects db       = new ListDatabaseObjects();
                DataTable           dtResult = new DataTable();
                dtResult = db.getReportView(ReportID, condition);
                var result = dtResult != null?Converter.DataTableToDict(dtResult) : new List <Dictionary <string, object> >();

                var resultJson = new { result = result };
                return(Json(resultJson, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }