c# Win Forms, Event Handlers, Store a global setting and retrieve it in an event handler
-
I have a program that uses the WebBrowser to scrape a website. As each page is scraped for data, I call event handlers to write the data. I need to store the AccountId for unique pricing in the database. I really don't want to modify the eventHandlers called "WebBrowserDocumentCompletedEventArgs" because I'm adding and removing them so often. I tried a global class but the event handler is not picking it up. I'm looking for a durable way to store this single string, it's a MongoDB Id. I suppose I could store it in the registry? or is that a bad idea. Store it in a Mongo document? Does sound better. I don't need the Id till I do the final batch write.
If it ain't broke don't fix it Discover my world at jkirkerx.com
-
I have a program that uses the WebBrowser to scrape a website. As each page is scraped for data, I call event handlers to write the data. I need to store the AccountId for unique pricing in the database. I really don't want to modify the eventHandlers called "WebBrowserDocumentCompletedEventArgs" because I'm adding and removing them so often. I tried a global class but the event handler is not picking it up. I'm looking for a durable way to store this single string, it's a MongoDB Id. I suppose I could store it in the registry? or is that a bad idea. Store it in a Mongo document? Does sound better. I don't need the Id till I do the final batch write.
If it ain't broke don't fix it Discover my world at jkirkerx.com
Registry? Bad idea. Don't store anything in the registry. It's restricted access now, because people stored everything in the registry so it became a bloated mess. It's likely to become more restricted in the future, not less. Store it anywhere else: settings file, DB, Excel file, Inca Quipu/Khipu Knotted ropes. Anywhere but the registry.
Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!
-
I have a program that uses the WebBrowser to scrape a website. As each page is scraped for data, I call event handlers to write the data. I need to store the AccountId for unique pricing in the database. I really don't want to modify the eventHandlers called "WebBrowserDocumentCompletedEventArgs" because I'm adding and removing them so often. I tried a global class but the event handler is not picking it up. I'm looking for a durable way to store this single string, it's a MongoDB Id. I suppose I could store it in the registry? or is that a bad idea. Store it in a Mongo document? Does sound better. I don't need the Id till I do the final batch write.
If it ain't broke don't fix it Discover my world at jkirkerx.com
I think it depends on what the final batch is going to look like. If you're associating data, how you persist it depends greatly on what you ultimately want to do with it. If you're potentially associating a piece of data with multiple other pieces of data, or if you're going to need complex querying, a database is most likely the right fit. If you're building a fairly flat data association, a file is just fine, and the question shifts to how you intend that data be consumed. Are you providing it through RSS? Use XML serialization. Through a web service? Use JSON serialization. Human readable? Wrtielines to a txt. Making a pretty report for management? Put yourself through the living hell that is iTextSharp and generate PDFs.
"Never attribute to malice that which can be explained by stupidity." - Hanlon's Razor
-
Registry? Bad idea. Don't store anything in the registry. It's restricted access now, because people stored everything in the registry so it became a bloated mess. It's likely to become more restricted in the future, not less. Store it anywhere else: settings file, DB, Excel file, Inca Quipu/Khipu Knotted ropes. Anywhere but the registry.
Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!
I'll have to create a new method of storing stuff then. Right now I store the screen size, screen location in the registry. But your right, find another place.
If it ain't broke don't fix it Discover my world at jkirkerx.com
-
I think it depends on what the final batch is going to look like. If you're associating data, how you persist it depends greatly on what you ultimately want to do with it. If you're potentially associating a piece of data with multiple other pieces of data, or if you're going to need complex querying, a database is most likely the right fit. If you're building a fairly flat data association, a file is just fine, and the question shifts to how you intend that data be consumed. Are you providing it through RSS? Use XML serialization. Through a web service? Use JSON serialization. Human readable? Wrtielines to a txt. Making a pretty report for management? Put yourself through the living hell that is iTextSharp and generate PDFs.
"Never attribute to malice that which can be explained by stupidity." - Hanlon's Razor
It's just unique pricing from a channel distributor for that chosen customer account. Manufacture > Products > Pricing string Id string AccountId decimal MSRP decimal Price
If it ain't broke don't fix it Discover my world at jkirkerx.com
-
I have a program that uses the WebBrowser to scrape a website. As each page is scraped for data, I call event handlers to write the data. I need to store the AccountId for unique pricing in the database. I really don't want to modify the eventHandlers called "WebBrowserDocumentCompletedEventArgs" because I'm adding and removing them so often. I tried a global class but the event handler is not picking it up. I'm looking for a durable way to store this single string, it's a MongoDB Id. I suppose I could store it in the registry? or is that a bad idea. Store it in a Mongo document? Does sound better. I don't need the Id till I do the final batch write.
If it ain't broke don't fix it Discover my world at jkirkerx.com
jkirkerx wrote:
I really don't want to modify the eventHandlers called "WebBrowserDocumentCompletedEventArgs" because I'm adding and removing them so often.
I think if we know why you are adding/removing frequently, that will, perhaps, lead to more insight into the issue.
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
-
I have a program that uses the WebBrowser to scrape a website. As each page is scraped for data, I call event handlers to write the data. I need to store the AccountId for unique pricing in the database. I really don't want to modify the eventHandlers called "WebBrowserDocumentCompletedEventArgs" because I'm adding and removing them so often. I tried a global class but the event handler is not picking it up. I'm looking for a durable way to store this single string, it's a MongoDB Id. I suppose I could store it in the registry? or is that a bad idea. Store it in a Mongo document? Does sound better. I don't need the Id till I do the final batch write.
If it ain't broke don't fix it Discover my world at jkirkerx.com
Shameless plug Retain the size and position of forms and dialogs[^] This article will give you the code for storing in the users data folders.
Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP
-
jkirkerx wrote:
I really don't want to modify the eventHandlers called "WebBrowserDocumentCompletedEventArgs" because I'm adding and removing them so often.
I think if we know why you are adding/removing frequently, that will, perhaps, lead to more insight into the issue.
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
I'm using the Web Browser control. Each Time I change the URL, I add an event handler called Document Complete. When it fires I unload the handler and scrape the page data. Then I go to the next page and reload the event handler. Some pages are more complex, so I call the Url, load the event handler Document Complete, then unload the handler and go through all the links on the parent page, and call those Urls while calling a child version of Document Complete. Other pages have a Json file that I can just download and scrape the data so I call a JSON version of Document Complete. So depending on what I detect on the page, I call the appropriate version of Document Complete. The reason why I need to store the AccountId is for when I write the pricing, that is unique for each account. Sounds silly, why can't I just go straight to the cloud database for this. Because I can grab everything, the product, it's images, associated videos and pdf's, and group them together into the database. Then I can generate emails that showcase the product with all the needed resources to promote it. Or create Excel spreadsheets with the image, pricing matrix and delivery dates.
If it ain't broke don't fix it Discover my world at jkirkerx.com
-
Shameless plug Retain the size and position of forms and dialogs[^] This article will give you the code for storing in the users data folders.
Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP
I'll try it since you wrote it! wow 10 years old now. That was the shameless plug for your project.
If it ain't broke don't fix it Discover my world at jkirkerx.com