private void BtnExecuteSelected_Click(object sender, RoutedEventArgs e) { ViewModel.executeReportsCollection.Clear(); var execList = new List <ReportExecutionWPFRecord>(); if (ViewModel.selectedReportsCollection.Count > 0) { var execService = new ReportExecutionService(RepositoryInjector.GetInjector <JAPISessionRepository>()); execList = ViewModel.selectedReportsCollection.Select(r => new ReportExecutionWPFRecord { Image = new BitmapImage(new Uri(@"C:\Users\cameron.heilman\Documents\WR\GIT_JAPI\japi\JAPI\JAPI.App\Resources\clock-8-32.png")), rowStatus = WPFRecrodStatus.Waiting, resultSet = new ReportExecutionResultSet { guid = Guid.NewGuid(), resource = r, status = "waiting", } }).ToList(); ViewModel.executeReportsCollection.AddRange(execList); Task.Factory.StartNew(async() => { await ViewModel.pollService.SendExecutionRequests(execList); }); } tabResults.IsEnabled = (ViewModel.executeReportsCollection.Count > 0); tabResults.IsSelected = true; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { /* string conn = Configuration.GetConnectionString("DefaultConnection"); * * services.AddDbContext<UsuarioContext>(x => * { * x.UseMySql(conn); * }); */ services.AddDbContext <UsuarioContext>(); services.AddControllers() .AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; // api ignora os valores nulos }) .AddNewtonsoftJson(options => { options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; // ignora referencias circulares }); services.AddCors(); RepositoryInjector.RegisterRepositories(services); services.AddSwaggerGen(s => { s.SwaggerDoc("v1", new OpenApiInfo { Title = "Usuarios", Version = "v1", }); }); }
public async Task ExecuteReportReturnDetails() { var service = new ReportExecutionService(RepositoryInjector.GetInjector <JAPISessionRepository>()); var reportPath = "/reports/X2R_User_Report"; try { var requestObject = new ReportExecutionRequest { reportUnitUri = reportPath, async = true, outputFormat = "pdf", }; var reportJob = await service.ExecuteReportAsync(requestObject); if (reportJob != null && !string.IsNullOrEmpty(reportJob.requestId)) { if (!service.cancelStatuses.Contains(reportJob.status)) { Task <ExecutionStatus> pollTask = service.PollReport(reportJob.requestId); pollTask.Wait(); } var jobDetails = await service.GetExecutionDetails(reportJob.exports[0].id); Debug.Assert(true); } } catch (Exception ex) { Assert.Fail(ex.Message); } }
public async Task FetchReportsAsync(string selectedOrgId) { var reportsList = new List <ReportUnit>(); var rService = new ResourceService(RepositoryInjector.GetInjector <JAPISessionRepository>()); var requestParams = new Dictionary <RequestParamKey, string>() { { RequestParamKey.ResourceType, "reportUnit" }, { RequestParamKey.FolderURI, "/reports" }, { RequestParamKey.Limit, "0" } }; try { var reportsLookup = await rService.GetResourcesAsync <ReportUnit>(requestParams); reportsList = reportsLookup.resourceLookup; } catch (Exception ex) { var msg = $"exception Occurred - message {ex.Message}"; if (ex is RestException restex) { if (restex.HttpStatusCode == System.Net.HttpStatusCode.Unauthorized || restex.HttpStatusCode == System.Net.HttpStatusCode.Forbidden) { msg = $"REST Operations error occurred with status code {restex.HttpStatusCode.ToString()} - attempting to load defaults"; } } } reportsCollection.Clear(); reportsCollection.AddRange(reportsList); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <Contexto>(options => { string conn = Configuration.GetConnectionString("ConexaoDB"); options.UseSqlServer(conn); }); services.AddIdentity <Usuario, Funcao>().AddEntityFrameworkStores <Contexto>(); services.ConfigurarSenhaUsuario(); // configuraçao Scopeds RepositoryInjector.RegisterRepositories(services); services.AddCors(); // habilita o cors //configurando arquivos estáticos do angular spa services.AddSpaStaticFiles(diretory => { diretory.RootPath = "ControleFinanceiro-UI"; // caminho do projeto angular }); var key = Encoding.ASCII.GetBytes(Settings.ChaveSecreta); // codificara a chave secreta do usuario services.AddAuthentication(opcoes => { opcoes.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; opcoes.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(opcoes => { opcoes.RequireHttpsMetadata = false; // nao ser� necessario o uso do https opcoes.SaveToken = true; // salva o token opcoes.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, // faz com que o token seja validado IssuerSigningKey = new SymmetricSecurityKey(key), ValidateIssuer = false, ValidateAudience = false }; }); services.AddControllers() .AddFluentValidation() .AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; // api ignora os valores nulos }) .AddNewtonsoftJson(options => { options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; // ignora referencias circulares }); }
public override Task OnConnected() { Console.WriteLine($"Welcome new Client!!"); Console.WriteLine($"ConnectionId : {Context.ConnectionId}"); //get JAPI session connect it to connectionId var repository = RepositoryInjector.GetInjector <JAPISessionRepository>(); _clientMappings.Add(Context.ConnectionId, repository); Console.WriteLine($"JAPI Repository session established: {repository.jClient.JSessionID}"); return(base.OnConnected()); }
public async Task GetServerInfoAsync() { var japiService = new JAPIService(RepositoryInjector.GetInjector <JAPISessionRepository>()); var serverInfo = await japiService.GetInfo(); if (serverInfo.version == null) { Debug.Assert(false); } else { Debug.Assert(true); } }
public async Task GetOrganization() { var orgName = "X2RDATA_DEV"; var orgService = new OrganizationService(RepositoryInjector.GetInjector <JAPISessionRepository>()); var org = await orgService.GetOrg(orgName); if (string.IsNullOrEmpty(org.id)) { Debug.Assert(false); } else { Debug.Assert(true); } }
public async Task SearchOrganizations() { var paramList = RequestParamExtensions.GetBaseParams(); paramList.Add(RequestParamKey.Query, "X2RDATA_DEV"); var orgService = new OrganizationService(RepositoryInjector.GetInjector <JAPISessionRepository>()); var orgList = await orgService.SearchOrgs(paramList); if (orgList.Count > 0) { Debug.Assert(true); } else { Debug.Assert(false); } }
public async Task GetExecutedReportContentShouldNotHappenThisWay() { // f7bebd78-965c-4e08-ac27-6ade43f75163/exports/383b0c75-551d-43b0-9736-06af2fa4610d/outputResource var service = new ReportExecutionService(RepositoryInjector.GetInjector <JAPISessionRepository>()); var reportPath = "/reports/X2R_User_Report"; var reportName = "X2R_User_Report.pdf"; var requestObject = new ReportExecutionRequest { reportUnitUri = reportPath, async = false, outputFormat = "pdf", }; try { Task <ReportExecutionResponse> execTask = service.ExecuteReportAsync(requestObject); execTask.Wait(); var execResponse = execTask.Result; if (!string.IsNullOrEmpty(execResponse.requestId) && execResponse.status.Equals("ready", StringComparison.OrdinalIgnoreCase)) { foreach (var export in execResponse.exports) { var downloadPath = System.AppContext.BaseDirectory + reportName + ".pdf"; if (System.IO.File.Exists(downloadPath)) { System.IO.File.Delete(downloadPath); } var rawBytes = await service.GetExecutionOuput(execResponse.requestId, export.id); System.IO.File.WriteAllBytes(downloadPath, rawBytes); } } Debug.Assert(true); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public async Task GetReportUnits() { var requestParams = new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("type", "reportUnit"), new KeyValuePair <string, string>("folderUri", "/reports"), }; try { var service = new ResourceService(RepositoryInjector.GetInjector <JAPISessionRepository>()); //var reportUnits = await service.GetResourcesAsync(requestParams); Debug.Assert(true); } catch (Exception ex) { Assert.Fail(ex.Message); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddCors(options => { options.AddPolicy("CorsAllowAll", builder => builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod()); }); services.AddSwaggerGen(x => { x.SwaggerDoc("v1", new Info { Title = "Cadastro Generico", Version = "v1", Description = "Cadastro Gen.", TermsOfService = "None", Contact = new Contact { Name = "", Email = "", Url = "" }, License = new License { Name = "Rafael Martins", Url = "" } }); var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); //x.IncludeXmlComments(xmlPath); x.OperationFilter <SwaggerFileOperationFilter>(); }); // Injecting repositories dependencies RepositoryInjector.RegisterRepositories(services); }
public async Task RunSingleReport() { var reportService = new ReportService(RepositoryInjector.GetInjector <JAPISessionRepository>()); var reportPath = "/reports/AP_Invoice_Report.html"; var downloadPath = System.AppContext.BaseDirectory + "report.html"; if (System.IO.File.Exists(downloadPath)) { System.IO.File.Delete(downloadPath); } var rawBytes = await reportService.RunReportAsync(reportPath); System.IO.File.WriteAllBytes(downloadPath, rawBytes); if ((System.IO.File.Exists(downloadPath)) && (System.IO.File.ReadAllBytes(downloadPath).Length > 0)) { Debug.Assert(true); } else { Debug.Assert(false); } }
public async Task TestReportDetails() { var reportService = new ReportService(RepositoryInjector.GetInjector <JAPIBasicAuthRepository>()); }
public async Task TestReportExecutionService() { var sessionService = new JAPIService(RepositoryInjector.GetInjector <JAPISessionRepository>()); }