Jona4Play
Jona4Play
CC#
Created by Jona4Play on 10/14/2023 in #help
✅ Issues with interfaces and generic classes
No description
64 replies
CC#
Created by Jona4Play on 8/13/2023 in #help
❔ ✅ Why are my MudBlazor components not rendering correctly
I am running a server-hosted version with .Net 7 but the components seem to not show correctly, such as a slider missing the background or the color not showing as they should. Have I misconfigured my project? Where do I need to look? This is the _Host.cshtml:
14 replies
CC#
Created by Jona4Play on 6/30/2023 in #help
❔ F#: General Memory Issue
14 replies
CC#
Created by Jona4Play on 5/30/2023 in #help
✅ Help with Avalonia Templated Controls
8 replies
CC#
Created by Jona4Play on 12/16/2022 in #help
✅ Awaiting a method exits program
I don't why but awaiting this method will result in the code exiting with only ever reaching Checkpoint A. While this has let me to believe that there was some error in the method I'm calling I added a debug message. This debug message is also never displayed before the program exits. Same applies when creating a list of tasks and awaiting them with Task.WhenAll(). Is there anything super simple I'm missing?
foreach (var link in outstanding)
{
Console.WriteLine("Checkpoint A");
docs.Add(await Scraper.ScrapFromLinkAsync(link));
Console.WriteLine("Checkpoint B");
}
foreach (var link in outstanding)
{
Console.WriteLine("Checkpoint A");
docs.Add(await Scraper.ScrapFromLinkAsync(link));
Console.WriteLine("Checkpoint B");
}
38 replies
CC#
Created by Jona4Play on 12/8/2022 in #help
✅ Task not returning and stopping program
Hey, I am currently trying to start one task for every string in the list, but this isn't working and the program closes without actually calling the requested method nor displaying an error message. Any help appreciated
var tasks = links.Select(x => Task.Run(() => Scraper.ScrapFromLink(x)));
await Task.WhenAll(tasks);
var tasks = links.Select(x => Task.Run(() => Scraper.ScrapFromLink(x)));
await Task.WhenAll(tasks);
64 replies
CC#
Created by Jona4Play on 12/2/2022 in #help
✅ PostgreSQL foreach() insert not working
Hey, currently working on a DB project for the first time with PostgreSQL and for some reason this insert operation inserts the first entry in the list for the length of the list into the DB resulting in mass duplicate entries of just the first entry of the list.
var sql = @"INSERT INTO outstanding(name) VALUES(@name)";
using var cmd = new NpgsqlCommand(sql, con);
foreach (var item in outstanding)
{
cmd.Parameters.AddWithValue("name",item);
cmd.Prepare();
cmd.ExecuteNonQuery();
}
var sql = @"INSERT INTO outstanding(name) VALUES(@name)";
using var cmd = new NpgsqlCommand(sql, con);
foreach (var item in outstanding)
{
cmd.Parameters.AddWithValue("name",item);
cmd.Prepare();
cmd.ExecuteNonQuery();
}
What did I miss? TYIA
13 replies
CC#
Created by Jona4Play on 11/16/2022 in #help
❔ Write X amount of lines to file and then start overriding
Hey, I want to log the last 20000 outputs of my project to a log file. I get one string per output and want it to append it to the bottom of the log file until 20000 entries have been reached. From thereon it should replace whatever line BatchCount currently is. Sadly, I haven't been able to figure it out myself. (BatchLimit is 20000 currently) TYIA Code Sample from Main Method
for (BatchCount = 0; BatchCount < BatchLimit; BatchCount++)
{
var doc = Scraper.ScrapFromLink(url);

DBManager.PushDataToDB(doc);
var w = DocumentSerializable.Convert(doc);
string jsonString = JsonConvert.SerializeObject(w);
LogWriter.WriteLineToLog(jsonstring,BatchCounter);
}
Batch++;
for (BatchCount = 0; BatchCount < BatchLimit; BatchCount++)
{
var doc = Scraper.ScrapFromLink(url);

DBManager.PushDataToDB(doc);
var w = DocumentSerializable.Convert(doc);
string jsonString = JsonConvert.SerializeObject(w);
LogWriter.WriteLineToLog(jsonstring,BatchCounter);
}
Batch++;
And here what I have now for the LogWriter
public static void WriteLineToLog(string content, int i)
{
if(Linecount <= CoreHandler.BatchLimit)
{
File.AppendAllText(CoreHandler.fileName, content);
}
else
{


}
}
public static void WriteLineToLog(string content, int i)
{
if(Linecount <= CoreHandler.BatchLimit)
{
File.AppendAllText(CoreHandler.fileName, content);
}
else
{


}
}
2 replies
CC#
Created by Jona4Play on 11/12/2022 in #help
Find all HREFs out of string and extract value
Hey, I am currently developing a web scraper and therefore want to extract all available information. Because of that I want to get the links to the JavaScripts and CSS Files. As far as I know this isn't supposed to be done with HTML Agility Pack and so I looked into Regex. Sadly, I didn't find a working example of Regex for that purpose. I tried myself but as I am unfamiliar with Regex syntax I haven't made much progress. I already have a method to construct the full URL from the relative one. Does anyone of you have a working approach to extract just JS and CSS file links? TYIA
4 replies