PatrickG
Can a console APP use a OAUTH 2 REST API?
My boss wants me to make a console app that will basically sync data between ZOHO CRM and a datawarehouse database we have.
I have done similar projects with other sources of data so I thought it wouldnt be too bad.
But what im reading and what im seeing it might not even be possible.
First on zoho, when you create a client application it keeps asking for a domain and URL which my console app wont have.
Then from what I read OAUTH2 requires a callback url where it sends the token or i dont know what back to....
so yea am I wasting my time or is it something thats possible?
12 replies
❔ Cast is not valid when casting interface to comcrete impl
this is my concrete imp:
public class TempFile : IBrowserFile
{
public TempFile(string uuid, string name, long size, string contentType)
{
Uuid = uuid;
Name = name;
Size = size;
ContentType = contentType;
}
public TempFile()
{
}
public string Uuid { get; set; } = "";
public string ContentType { get; set; } = "";
public string Name { get; set; } = "";
public long Size { get; set; }
public DateTimeOffset LastModified => throw new NotImplementedException();
public Stream OpenReadStream(long maxAllowedSize = 512000, CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
}
=========================
this is where im trying to cast ibrowserFile as TempFile and getting invalid Cast.
private async Task UploadFileAsync(IBrowserFile file)
{
if (file == null)
return;
if (EditModel == null)
{
throw new Exception("No edit model");
}
if (EditModel.Id == 0)
{
var result = await this.EmployeeComptesDepensesService.UploadTemporaryAttachmentFileAsync(file);
if (!result.ApiCallSuccess)
{
this.serverResponseValidator?.DisplayErrors(result.ServerErrors, result.ApiCallResultErrorMessage);
}
else
{
try
{
TempFile tf = (TempFile)file;
tf.Uuid = result.ResultModel?.Result!;
EditModel.TempFiles.Add(tf);
} catch (Exception ex) {
this.serverResponseValidator?.DisplayErrors(null, $"cast error {ex.Message}"); } } } What's going on???
} catch (Exception ex) {
this.serverResponseValidator?.DisplayErrors(null, $"cast error {ex.Message}"); } } } What's going on???
10 replies
❔ want to add a conditional .Take(10) to a query without duplicating the code
Im looking for an easy way to add a .Take(10) or .Take(x) to a iqueryable so that my test go faster instead of running on the entire data.
is there a way to make it so if x is null it takes all or ignres the take() option ??
20 replies
❔ question about console app host.RunAsync();
In this example:
https://learn.microsoft.com/en-us/dotnet/core/extensions/logging-providers
using Microsoft.Extensions.Hosting;
using IHost host = Host.CreateDefaultBuilder(args).Build();
// Application code should start here.
await host.RunAsync();
I am wondering what is the point of host.RunAsync(); because I have tested without it and there is no difference.
186 replies
❔ asp.net MVC, can I store some data in a static variable to access in a future request??
I might need to modify a current process where user uploads a shit ton of data via excel.
the server side scan the data computes additional fields and then stores it in the DB.
if some rows have problems, i just send a error msg back.
I might have to change it where the server would have to scan all data and if errors are found, the user would be prompted to correct them, but I dont want them to reupload the data again and I dont want to transfer it back and forth between front end and back end because its too much data.
So is there a way other than database, I was thinking maybe a static class on server that could store the data ??
12 replies
❔ feedback on clientside api request limiter
Hello I just want to know if this is a good way of limiting requests made by a client to a public API.
Is there a better way to do it ??
public static class Limit
{
static List<DateTime> requests = new List<DateTime>();
static public bool WaitForConstraint()
{
requests = requests.Where(x => x >= DateTime.Now.AddSeconds(-10)).ToList();
while (requests.Count > 150)
{
requests = requests.Where(x => x >= DateTime.Now.AddSeconds(-10)).ToList();
Console.WriteLine("throttleing requests.");
}
requests.Add(DateTime.Now);
return true;
}
}
13 replies
❔ how to use EF6 in library with no dependancy injection and no startup.cs
I used EF core power tools to generate DB Context and reverse engineer the models.
now I get an error:
System.InvalidOperationException
HResult=0x80131509
Message=No database provider has been configured for this DbContext. A provider can be configured by overriding the 'DbContext.OnConfiguring' method or by using 'AddDbContext' on the application service provider. If 'AddDbContext' is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.
Source=Microsoft.EntityFrameworkCore
all the answers I can find are doing something in startup.cs which i dont have or using the dependancy injection framework which i dont use either
all the answers I can find are doing something in startup.cs which i dont have or using the dependancy injection framework which i dont use either
3 replies
❔ how to tell if a TCP request is a HTTP request
I am making a little proof of concept for a service that listens to TCP port
when it receives a request it returns the same text as an answer for now
I can also send request via a browser and I receive it but i need to apply special header and stuff to reply to HTTP request
When a request is sent from browser it looks like this:
GET /OMEGALUL HTTP/1.1
HOST: LOCALHOST:13000
CONNECTION: KEEP-ALIVE
CACHE-CONTROL: MAX-AGE=0
SEC-CH-UA: "GOOGLE CHROME";V="111", "NOT(A:BRAND";V="8", "CHROMIUM";V="111"
SEC-CH-UA-MOBILE: ?0
SEC-CH-UA-PLATFORM: "WINDOWS"
UPGRADE-INSECURE-REQUESTS: 1
2023-03-24 09:06:03.570 -04:00 [INF]
USER-AGENT: MOZILLA/5.0 (WINDOWS NT 10.0; WIN64; X64) APPLEWEBKIT/537.36 (KHTML, LIKE GECKO) CHROME/111.0.0.0 SAFARI/537.36
ACCEPT: TEXT/HTML,APPLICATION/XHTML+XML,APPLICATION/XML;Q=0.9,IMAGE/AVIF,IMAGE/WEBP,IMAGE/APNG,/;Q=0.8,APPLICATION/SIGNED-EXCHAN
2023-03-24 09:06:03.570 -04:00 [INF] GE;V=B3;Q=0.7
SEC-FETCH-SITE: NONE
SEC-FETCH-MODE: NAVIGATE
SEC-FETCH-USER: ?1
SEC-FETCH-DEST: DOCUMENT
ACCEPT-ENCODING: GZIP, DEFLATE, BR
ACCEPT-LANGUAGE: EN-US,EN;Q=0.9,FR;Q=0.8
is it safe to say that if request contains "HTTP/1.1" it is a http request and should be answered differently?
10 replies
❔ Binding a list<tuple<string,bool> to a form with switches in asp.net
does anyone know how I can send a list of tuple string bool to a
mvc page and display a checkbox in a form that has the string as the name and the bool as the checked or not
i am able to display the switches but I have no idea how to make the submit work ive asked chat gpt and tried everything it keeps returning null. in asp.net 5 mvc btw
40 replies
❔ how to set a dynamic's property of a unknown name
if i have var dyn = new dynamic
and i have string variableName = "toto"
how can i set dyn.variableName = "hello"
for example.
the thing is variableName could be anything and I then want to be able to access it by calling for example dyn.toto if that was the name used for that property
19 replies
❔ Simple url parameter not working in blazor wasm???
I have a page with routes:
@page "/Administration/Security/UserAccounts"
@page "/Administration/Security/UserAccounts/{id?}"
first route works but if I use
NavigationManager.NavigateTo($"/Administration/Security/UserAccounts/1");
I get a message saying unable to cast parameter?????
I set up my parameter as a long
@code {
[Parameter]
public long? Id { get; set; }
}
i tried with an int too same thing
I also tried
@page "/Administration/Security/UserAccounts/{id}"
without a question mark
4 replies
❔ Get a sum of timespans but only counting overlapping time zones once
Hello I have a problem at my job where I have a list of timespans and I need know the total hours of these timespans but while only counting any overlapping regions once.
So for example if I have (7am-10am) + (8am-11am) I would only get a total of 4 hours.
if I have (8am-10am) + (8am-11am) i would only get 3 hours
if i have (7am-7pm) + (8am - 9 aM) + (9am - 10 aM) + (10am - 11 aM) + (10pm - 11 pm) i would only get 13hours
13 replies