public async Task <IActionResult> CacheGetOrCreateAsync()
    {
        IReportFactory reportFactory = this._createReportFactoryDelegate(this.HttpContext);
        var            x             = reportFactory.Create();

        // ...
        return(View("Cache", cacheEntry));
    }
Example #2
0
    private static string GetDocumentIntoJson(int clientId, int pager)
    {
        // Use factory to get a ReportHandler
        // You need provide "factoryId" from somewhere too
        IReportHandler dal               = _reportFactory.Create(factoryId);
        var            documents         = dal.FetchDocumentsList(clientId, pager);
        string         documentsDataJSON = JsonConvert.SerializeObject(documents);

        return(documentsDataJSON);
    }
Example #3
0
        public IHttpActionResult All(string reportName)
        {
            try
            {
                IReport report = _reportFactory.Create(reportName);
                if (report == null)
                {
                    return(NotFound());
                }

                // parameters should come from client, using fixed parameters for demo
                string parameters = CreateTemporaryTestParameters();
                var    reportObj  = report.Generate(parameters);
                return(Ok(reportObj));
            }
            catch (Exception e)
            {
                _log.Error("Exception on report generation reportName={reportName}", e);
                return(InternalServerError());
            }
        }
Example #4
0
        private async Task MoveNext()
        {
            try
            {
                switch (state)
                {
                case 0:
                    //logger.Trace("Open state");
                    device.Open(factory == null ? HidDeviceAccess.Read : HidDeviceAccess.ReadWrite);
                    if (device.IsOpen)
                    {
                        state++;
                    }
                    else
                    {
                        GoToErrorState("Cannot open device");
                    }

                    break;

                case 1:
                    //logger.Trace("Send output report state");
                    if (factory != null)
                    {
                        outReport = factory.Create(command);
                        await device.SendOutputReport(outReport);
                    }

                    state++;
                    break;

                case 2:
                    //logger.Trace("Get input report state");
                    inReport = await device.GetInputReport(0);

                    inReport.Data.Accept(validator);

                    if (validator.IsInvalid)
                    {
                        GoToErrorState("validation failure");
                        break;
                    }
                    else
                    {
                        inReport.Data.Accept(extractor);
                        result = extractor.Data;
                    }

                    state++;
                    break;

                default:
                    return;
                }
            }
            catch (Exception ex)
            {
                //logger.Error("Error MoveNext", ex);
                GoToErrorState(ex.ToString());
            }

            await MoveNext();
        }
Example #5
0
        public async Task Report([Remainder] string message)
        {
            await _report.Create(_reportFactory.Create(Context.Guild.Name, Context.User.Username, message));

            await ReplyAsync("You successfully made a report!");
        }