Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. c# Win Forms, Event Handlers, Store a global setting and retrieve it in an event handler

c# Win Forms, Event Handlers, Store a global setting and retrieve it in an event handler

Scheduled Pinned Locked Moved C#
mongodbcsharpdatabasecomwindows-admin
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jkirkerx
    wrote on last edited by
    #1

    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

    OriginalGriffO N B M 4 Replies Last reply
    0
    • J jkirkerx

      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

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      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 no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      J 1 Reply Last reply
      0
      • J jkirkerx

        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

        N Offline
        N Offline
        Nathan Minier
        wrote on last edited by
        #3

        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

        J 1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          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!

          J Offline
          J Offline
          jkirkerx
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • N Nathan Minier

            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

            J Offline
            J Offline
            jkirkerx
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • J jkirkerx

              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

              B Offline
              B Offline
              BillWoodruff
              wrote on last edited by
              #6

              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

              J 1 Reply Last reply
              0
              • J jkirkerx

                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

                M Offline
                M Offline
                Mycroft Holmes
                wrote on last edited by
                #7

                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

                J 1 Reply Last reply
                0
                • B BillWoodruff

                  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

                  J Offline
                  J Offline
                  jkirkerx
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • M Mycroft Holmes

                    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

                    J Offline
                    J Offline
                    jkirkerx
                    wrote on last edited by
                    #9

                    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

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups