コード例 #1
0
        public string GetScript()
        {
            var items = propertyProvider.GetPropertyItemsFor(type).ToList();

            if (typeof(ICustomizedFormScript).IsAssignableFrom(type))
            {
                var instance = ActivatorUtilities.CreateInstance(
                    serviceProvider, type) as ICustomizedFormScript;
                instance.Customize(items);
            }

            return(string.Format(CultureInfo.InvariantCulture, "Q.ScriptData.set({0}, {1});",
                                 scriptName.ToSingleQuoted(), items.ToJson()));
        }
コード例 #2
0
        public ReportRetrieveResult Retrieve(ReportRetrieveRequest request,
                                             IServiceProvider serviceProvider, IPropertyItemProvider propertyItemProvider)
        {
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (request.ReportKey.IsEmptyOrNull())
            {
                throw new ArgumentNullException(nameof(request.ReportKey));
            }

            if (propertyItemProvider is null)
            {
                throw new ArgumentNullException(nameof(propertyItemProvider));
            }

            var reportInfo = ReportRegistry.GetReport(request.ReportKey);

            if (reportInfo == null)
            {
                throw new ArgumentOutOfRangeException(nameof(request.ReportKey));
            }

            if (reportInfo.Permission != null)
            {
                Permissions.ValidatePermission(reportInfo.Permission, Localizer);
            }

            var response = new ReportRetrieveResult
            {
                Properties = propertyItemProvider.GetPropertyItemsFor(reportInfo.Type).ToList(),
                ReportKey  = reportInfo.Key,
                Title      = reportInfo.Title
            };
            var reportInstance = ActivatorUtilities.CreateInstance(serviceProvider, reportInfo.Type);

            response.InitialSettings  = reportInstance;
            response.IsDataOnlyReport = reportInstance is IDataOnlyReport;
            response.IsExternalReport = reportInstance is IExternalReport;

            return(response);
        }