Пример #1
0
        public static ReturnObject Delete(HttpContext context, long id)
        {
            if( id <= 0 )
                return new ReturnObject() { Error = true, Message = "Invalid Output." };

            var item = new Lib.Data.ReportOutput( id );
            item.Delete();

            return new ReturnObject() {
                Growl = new ReturnGrowlObject() {
                    Type = "default",
                    Vars = new ReturnGrowlVarsObject() {
                        text = "You have successfully deleted this output.",
                        title = "Output deleted"
                    }
                },
                Actions = new List<ReturnActionObject>()
                {
                    new ReturnActionObject() {
                        Ele = "#outputs-table tr[data-id=\""+id.ToString()+"\"]",
                        Type = "remove"
                    }
                }
            };
        }
Пример #2
0
        protected void Page_Init( object sender, EventArgs e )
        {
            string strID = Request.QueryString["id"];
            long id;
            if( string.IsNullOrEmpty( strID ) || !long.TryParse( strID, out id ) )
            {
                item = new Lib.Data.ReportOutput();

                strID = Request.QueryString["report-id"];
                if( string.IsNullOrEmpty( strID ) || !long.TryParse( strID, out id ) )
                {
                    SendError( "Invalid Report selected." );
                    return;
                }

                item.ReportID = id;
            }
            else
                item = new Lib.Data.ReportOutput( id );
        }
Пример #3
0
        public static ReturnObject Get( HttpContext context, long id, long output_id )
        {
            var report = new Lib.Data.Report( id );

            if( !Lib.Systems.Reports.CanViewReport(report) )
                return new ReturnObject() {
                    Error = true,
                    Message = "Invalid report requested."
                };

            var output = new Lib.Data.ReportOutput( output_id );

            if( output.ReportID != report.ID )
                return new ReturnObject() {
                    Error = true,
                    Message = "Invalid output requested."
                };

            var filters = report.GetFilters();
            var data = new Dictionary<string, object>();

            foreach( var f in filters )
            {
                string name = "filter-" + f.ID.Value.ToString();

                if( string.IsNullOrWhiteSpace( context.Request.Form[name] ) )
                    continue;

                string val = context.Request.Form[name];

                object r = null;
                switch( f.Type )
                {
                case Data.ReportFilter.FilterTypes.String:
                    r = val;
                    break;
                case Data.ReportFilter.FilterTypes.Integer:
                    int t;
                    if( int.TryParse(val, out t) )
                        r = t;
                    break;
                case Data.ReportFilter.FilterTypes.DateTime:
                    DateTime dt;
                    if( DateTime.TryParse( val, out dt ) )
                        r = dt;
                    break;
                }

                if( r == null )
                    return new ReturnObject() {
                        Error = true,
                        Message = "Invalid filter value \""+val+"\" for filter ["+f.DisplayName+"]."
                    };

                data[f.ParameterName] = r;
            }

            return new ReturnObject() {
                Error = false,
                Result = Lib.Systems.Reports.RunOutput(report, output, data)
            };
        }