0
Good afternoon Galera!
Good people, I’m new here at Stackoverflow and this is my first post so please forgive me if I make any mistakes.
I’m doing a C# program to take a picture of each person served in the company with webcams installed on Pcs. So far so good, I managed with the help of tutorials on the internet, to make a program that takes photos of the webcam and stores them in our central server in an automated way. Currently these images are saved from the parameters of the PC itself (Ex.: PC kernel name + date + time .png) which later makes it difficult to search for them. That is where the problem arises and it is where I need the help of vcs, the system used by our employees is an intranet running in the Internet Explorer browser and during the service the employee makes a registration of the person to be served (Name and other information). I need my program to "spy" some of this information (more precisely the name of the person to be answered) and use as the name of the photo file to be saved. I have read something about using the library "Htmlagilitypack" but I could not understand how to apply it to the situation. Do I need the program to read the web page (html code) behind the value "Value=??????" in the line of the code referring to the vehicle plate and use this value as part of the file name.
Below follows lines of my code referring to automatic photo saving:
private void btnCaptura_Click(object sender, EventArgs e)
{
try
{
CaptureInfo.CaptureFrame();
}
catch (Exception ex)
{
MessageBox.Show("Erro " + ex.Message);
}
try
{
caminhoImagemSalva = @"\\XXX.XXX.XXX.XXX\CIRETRAN Criciuma\Arquivo Digital\Arquivo de imagem atendimento\Guichê 01\" + "Atendente 01" + Att.Value.constais() + " " + DateTime.Now.Day.ToString() + "." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Year.ToString() + " as " + DateTime.Now.Hour.ToString() + "h" + DateTime.Now.Minute.ToString() + "min" + ".jpg";
picWebCam.Image.Save(caminhoImagemSalva, ImageFormat.Jpeg);
}
catch (Exception ex)
{
MessageBox.Show("Erro " + ex.Message);
}
{
// calling method
ExtractHref("https://sistema.detrannet.sc.gov.br/arearestrita/tela_principal.asp");
}
Now the part of the code referring to capture the information on the page:
static void ExtractHref(string URL)
{
// declaring & loading dom
HtmlWeb web = new HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc = web.Load(URL);
// extracting all links
foreach (HtmlNode link in doc.DocumentNode.SelectNodes("<INPUT onkeypress=javascript:maiusculo() onfocus=javascript:this.select() maxLength=7 size=12 value=?????? name=txtPlaca>"))
{
HtmlAttribute att = link.Attributes["value="];
if (att.Value.Contains("value="))
{
// showing output
Console.WriteLine(att.Value);
}
}
}
I did and re-did the code in several different ways, but I can’t capture the html information and put it in the file name. Does anyone know what it can be?
In this case the page has 3 inputs, I wanted only one to simplify but if bring all better still. As for the rescue method, he knows whether it is correct to use "Att.Value.Contains" to use what was captured in the imputs?
– Informatica 6drp
Now I got it, that’s right!
– Informatica 6drp
@Informatica6drp if this answer helped you in solving the problem, mark as "accept". If you have any questions these guides can help Stack Overflow Survival Guide in English (short version).
– tvdias
@Informatica 6drp Good that you have succeeded. I suggest you research on how to filter with XPATH. It can be used for XML too, can search for attributes, text, etc. Very interesting and will give you a good view. If you are having problems with this library, understand that it generates an XML-like document, that is, you can search for XPATH and how to access NODES in an XML using Microsoft XML or another component, most are very similar.
– Eric Torres