Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Rebuilding Image File Reference data in a Db

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Rebuilding Image File Reference data in a Db

    In the past with financial applications I have provided a Rebuild process to sort out and recalculate balances and results in an app.

    My latest project is for the production of legally admissible photographs.
    At present, the user attaches a photo to a Db field using Image File Reference approach.
    In anticipation of their next request - to attach multiple photos automatically - has anyone done this?

    Situation.
    One table, multiple fields for Image File References
    One photo repository
    Unique ID in the table always matches the photo name in the proto repository

    Format
    Field 1 ID = 12345_A
    Photo ID = 12345_A (could be any extension, jpg, png, etc)

    Field 2 ID = 12345_B
    Photo ID = 12345_B

    Process;
    User adds record to table to create unique Id
    User adds photos to repository using record unique ID above - a manual job

    On a button press,
    Image File Reference for Field 1 is found and inserted using 12345_A in the Photo repository
    or
    All IFRs are added to the fields in a similar operation.

    As always, any help appreciated.
    See our Hybrid Option here;
    https://hybridapps.example-software.com/


    Apologies to anyone I haven't managed to upset yet.
    You are held in a queue and I will get to you soon.

    #2
    Re: Rebuilding Image File Reference data in a Db

    One approach here https://www.alphasoftware.com/alphaf...ighlight=image

    If you don't want to do it in a field event you could loop.
    There can be only one.

    Comment


      #3
      Re: Rebuilding Image File Reference data in a Db

      I have an image-heavy application where a key table has multiple image reference fields. Since it is a production table any corruption in the fpt file is a big problem. It only happened a couple of times but that was enough! So I now rebuild the rebuild the fpt file nightly and, since then, no problems. I found that just repopulating the field values in the table did not solve a corruption problem, hence the removal and re-creation of the entire fpt file.

      You have to be able to accurately tie the image back to the field in question, so a good image naming strategy is essential.It looks like you have that in hand. I'm not sure about one photo repository. I have created a single folder "ImageFiles" which has multiple sub folders for different image types (customer pictures, signature images, fingerprint images, Scales Pictures etc). Most are located in a sub-folder of the main application folder but there are a few outliers.

      The fun begins when you want to display the images. Since the path/file location is embedded in the IFR, the image will not display if that doesn't match the workstation path which might happen if running shadowed or across a network. I save everything on the application server and, almost always, in a sub-folder of the app folder. I establish that master path in the autoexec so that it is always the same for all workstations.

      FWIW here's a sample of the function I use to rebuild the fpt file in our ticket header table. For simplicity I reconfigured the table to put all the IRF fields at the end of the table structure before I started doing this.

      Code:
      FUNCTION RebuildTheadDL as L ( )
      msg_txt = "This process will remove and rebuild the ticket header fpt file." + crlf(2) + "Are you sure you want to proceed?"
      resp = ui_msg_box("",msg_txt,ui_yes_no+ui_second_button_default+ui_question_symbol)
      if resp = ui_no_selected then
      	END
      end if
      
      dim global app_path as c
      
      dim remlist as c = <<%txt%
      Dl_Image
      Signature
      Finger
      Yellow_Ticket
      Veh_Image
      s_id_img
      %txt%
      
      on error goto errors
      a5_del_fields_fm_table(app_path + "ticket_header.dbf",remlist)
      on error goto 0
      msg_txt = "Fields removed."
      MYL(msg_txt,5,10)
      sleep(5)
      
      on error goto errors2
      dim remlist as c = <<%txt%
      Dl_Image,I,10,0
      Signature,I,10,0
      Finger,I,10,0
      Yellow_Ticket,I,10,0
      Veh_Image,I,10,0
      s_id_img,I,10,0
      %txt%
      a5_add_fields_to_table(app_path + "ticket_header.dbf",remlist)
      on error goto 0
      msg_txt = "Fields added."
      MYL(msg_txt,5,10)
      sleep(5)
      
      dim RTHWD as L = RebuildTicketHeaderWithDL()
      if RTHWD then
      	msg_txt = "Ticket header table updated!"
      	MYL(msg_txt,4,10)
      	else
      		msg_txt = "Error updating Ticket header table!"
      		MYL(msg_txt,4,10)
      End if
      
      RebuildTheadDL = .T.
      END
      
      errors:
      msg_txt = "An error occurred removing the fields from the table."
      MYL(msg_txt,5,10)
      END
      
      errors2:
      msg_txt = "An error occurred adding the fields back to the table."
      MYL(msg_txt,5,10)
      end
      
      END FUNCTION
      '=======================================================
      Function RebuildTicketHeaderWithDL as L ()
      dim pw as waitdialog
      dim th as p = table.open("ticket_header")
      dim threcs as n = th.records_get()
      dim cid as c = ""
      dim tnum as c = ""
      pw.Set_Title("Please wait ...")
      pw.create(3,"percent")
      pw.Set_Message("Processing tickets for dl images")
      pw.Set_Bottom_Message(crlf() + "from ticket #: " + alltrim(tnum) + " of " + ltrim(str(threcs)))
      
      dim no_image as c = ""
      dim dl_image_path as c = app_path + "tex-images" + chr(92) + "Tex-images" + chr(92)
      dim sig_image_path as c = app_path + "ImageFiles" + chr(92) + "Signatures" + Chr(92)
      dim finger_image_path as c = app_path + "ImageFiles" + chr(92) + "Finger_jpg" + Chr(92)
      dim vehicle_image_path as c = app_path + "ImageFiles" + chr(92) + "VehiclePictures" + Chr(92)
      dim scrapid_image_path as c = app_path + "CC_Images" + chr(92)
      dim img_file as c = ""
      dim img_search as c = ""
      dim wcnt as n = 0
      dim set_image as c = ""
      dim fh as p
      dim savename as c = ""
      dim cnt as n = 0
      th.fetch_first()
      
      while .not. th.fetch_eof()
      	cid = alltrim(th.customer_id)
      	tnum = alltrim(th.ticket_number)
      	if cid = "1" then		'its a cans customer, no image	
      		goto next_record
      	end if
      	'----------------------------------------------
      	'first dl images look for the associated image in the image folder
      	img_search = dl_image_path + cid + "*.jpg" 	
      	img_file = filefind.get(img_search,FILE_FIND_NORMAL+FILE_FIND_NOT_DIRECTORY,"PN")
      	
      	if alltrim(img_file) = "" then		'no image found
      		no_image = no_image + Crlf() + cid	
      			goto next_record
      	end if
      	
      	wcnt = w_count(img_file,Crlf())
      		if wcnt = 1 then
      			set_image = image_filename_encode(alltrim(img_file))
      			else				'if more than one asscoiated image file 
      				set_image = word(img_file,wcnt,crlf())
      		end if
      		fh = th.field_get("dl_image")
      		th.change_begin()
      			fh.value_put(set_image)		
      				th.change_end(.T.)
      				img_search = ""
      				img_file = ""
      	'----------------------------------------------
      	'signatures ....
      	img_search = sig_image_path + cid + "*.jpg" 	
      	img_file = filefind.get(img_search,FILE_FIND_NORMAL+FILE_FIND_NOT_DIRECTORY,"PN")
      	if alltrim(img_file) = "" then		'no image found
      		no_image = no_image + Crlf() + cid	
      			goto next_record
      	end if
      	wcnt = w_count(img_file,Crlf())
      		if wcnt = 1 then
      			set_image = image_filename_encode(alltrim(img_file))
      			else				'if more than one asscoiated image file 
      				set_image = word(img_file,wcnt,crlf())
      		end if
      		fh = th.field_get("Signature")
      		th.change_begin()
      			fh.value_put(set_image)		
      				th.change_end(.T.)
      				img_search = ""
      				img_file = ""
      	'----------------------------------------------
      	'Fingerprints ....
      	img_search = finger_image_path + tnum + "*.jpg"
      	img_file = filefind.get(img_search,FILE_FIND_NORMAL+FILE_FIND_NOT_DIRECTORY,"PN")
      	if alltrim(img_file) = "" then		'no image found
      		no_image = no_image + Crlf() + cid	
      			goto next_record
      	end if
      	wcnt = w_count(img_file,Crlf())
      		if wcnt = 1 then
      			set_image = image_filename_encode(alltrim(img_file))
      			else				'if more than one asscoiated image file 
      				set_image = word(img_file,wcnt,crlf())
      		end if
      		fh = th.field_get("Finger")
      		th.change_begin()
      			fh.value_put(set_image)		
      				th.change_end(.T.)
      				img_search = ""
      				img_file = ""
      
      	'----------------------------------------------
      	'Vehicles ....
      	img_search = vehicle_image_path + tnum + "*.jpg"
      	img_file = filefind.get(img_search,FILE_FIND_NORMAL+FILE_FIND_NOT_DIRECTORY,"PN")
      	if alltrim(img_file) = "" then		'no image found
      		no_image = no_image + Crlf() + cid	
      			goto next_record
      	end if
      	wcnt = w_count(img_file,Crlf())
      		if wcnt = 1 then
      			set_image = image_filename_encode(alltrim(img_file))
      			else				'if more than one asscoiated image file 
      				set_image = word(img_file,wcnt,crlf())
      		end if
      		fh = th.field_get("veh_image")
      		th.change_begin()
      			fh.value_put(set_image)		
      				th.change_end(.T.)
      				img_search = ""
      				img_file = ""
      	'----------------------------------------------
      	'scrapper ID's
      	'lookup based on ticket number
      	img_search = scrapid_image_path + tnum + "*.jpg"
      	img_file = filefind.get(img_search,FILE_FIND_NORMAL+FILE_FIND_NOT_DIRECTORY,"PN")
      	if alltrim(img_file) = "" then		'no image found
      		no_image = no_image + Crlf() + cid	
      			goto next_record
      	end if
      	wcnt = w_count(img_file,Crlf())
      		if wcnt = 1 then
      			set_image = image_filename_encode(alltrim(img_file))
      			else				'if more than one asscoiated image file 
      				set_image = word(img_file,wcnt,crlf())
      		end if
      		fh = th.field_get("S_ID_Img")
      		th.change_begin()
      			fh.value_put(set_image)		
      				th.change_end(.T.)
      				img_search = ""
      				img_file = ""
      	'----------------------------------------------
      	next_record:
      	cnt = cnt + 1
      	pw.Set_Bottom_Message(crlf() + "from ticket #: " + alltrim(tnum) + " of " + ltrim(str(threcs)) + " tickets.")
      	pw.Set_Percent(cnt,threcs)
      	sleep(1/50)
      
      	th.fetch_next()
      end while
      if alltrim(no_image) <> "" then
      '	savename = "C:\temp\RecordsWithoutImages.txt"
      '		save_to_file(no_image,savename)
      end if
      Pw.Close()
      th.close()
      RebuildTicketHeaderWithDL = .T.
      END
      End Function
      '=======================================================
      Finian

      Comment


        #4
        Re: Rebuilding Image File Reference data in a Db

        I am wondering why you have chosen to use an image reference field. I have found that this field type makes it very difficult to open the table in default browse mode having to load all those images and the thought of having to rebuild? Arg! I also have work that is very image intense and I abandoned IRF and instead have images show in xdialog or bitmap fields. I have one form and xdialog that builds dynamically with 20 thumbnail images with button access to the original full size image. Attached is a small example.
        Attached Files
        Mike W
        __________________________
        "I rebel in at least small things to express to the world that I have not completely surrendered"

        Comment


          #5
          Re: Rebuilding Image File Reference data in a Db

          Mike, I absolutely agree with you regarding the use of images in xdialog.

          Unfortunately I don't have the time to redo some pretty massive traditional data entry forms I inherited that must show a newly acquired image during data entry. Thinking about it, which I really hadn't done before, would it be possible to use an embedded xdialog on the form to show the images. Which might be easier than having to redo the entire forms. Now I'll think about it. OTOH, I'm not as concerned about the IFR files as I once was.

          I use xdialogs for any other image display requirements, such as the attached where I use an xdialog with an embedded browse where the on fetch event gets the next image.
          Attached Files
          Finian

          Comment


            #6
            Re: Rebuilding Image File Reference data in a Db

            Thank you gents.
            The problem about using embedded pictures is a difficult one.
            FPT is always open to corruption and had a few users here tearing hair out.
            IFR enables the user to disassociate the pics from the app, which is really what they want. And so do I to be honest. If they chage software, they are secure.
            I'll look at the options you have kindly provided, and thanks once again for your valuable suggestions.
            See our Hybrid Option here;
            https://hybridapps.example-software.com/


            Apologies to anyone I haven't managed to upset yet.
            You are held in a queue and I will get to you soon.

            Comment


              #7
              Re: Rebuilding Image File Reference data in a Db

              Very nice Finian! And I see someone is peeking in as well..
              Mike W
              __________________________
              "I rebel in at least small things to express to the world that I have not completely surrendered"

              Comment


                #8
                Re: Rebuilding Image File Reference data in a Db

                Not sure I understand your comment Mike, but whatever.
                I too have thumbnails with optional full size pics, but the output is in a totally closed system to pdf.
                As I mentioned, one long time contributor to this forum had major problems with corruption using fpt structures, so I don't want to be before a Judge explaining why my app is not separate from the evidence. IFR seems appropriate, and I get Finian's point about separate folders. However, we are talking about > 1 million records with 8 photos per record, per annum.
                Looked at SQL, but that's not a lot different.
                See our Hybrid Option here;
                https://hybridapps.example-software.com/


                Apologies to anyone I haven't managed to upset yet.
                You are held in a queue and I will get to you soon.

                Comment


                  #9
                  Re: Rebuilding Image File Reference data in a Db

                  Hi Ted,
                  I'm thinking there is a misunderstanding. The IRF and how we are suggesting both use independent files stored somewhere. The difference is that the IRF field has a literal file path value that is a direct table value-to-file image display field. What we are using are image display objects that receive image data dynamically. This affords a great advantage (for me) that the image folder paths are variables and can be changed centrally, and are not literal record data entries as they are with IRF. I have a table that holds the folder directory paths as the literal of folder paths for all files in the system. These folder paths are incorporated into a single global variable on URSA (my current app) startup. In the code that calls the images, the particular folder path the image reside in is parsed from the global variable into the variable of the file name string. Why this way? Because I can move around images into different folders and I just have to change the literal file path of the folders in the table, not the in any code. Just like Finian suggests he does. If there is ever a moment I can do something dynamically in Alpha, I'm there.
                  Mike W
                  __________________________
                  "I rebel in at least small things to express to the world that I have not completely surrendered"

                  Comment


                    #10
                    Re: Rebuilding Image File Reference data in a Db

                    Rebuilding an fpt file for 1 million records would take a while! In fact, I think it would be impractical. My overnight rebuild only takes a couple of minutes and is usually dealing in the range of 6 - 12,000 records, though I expect that to grow somewhat. While I'm at peace with our fpt situation for that header table now, I would definitely change if the table count was to get much higher than 20,000. The approach historically has been to control table size by archiving records. There's some merit to that, but it's also a pain to maintain.

                    The sample xdialog I posted is showing images associated with a table where, even though we have an IRF field for those images, we don't actually display them in any form and I could and probably will dispense with the irf field. The record and associated images count in that table is much higher (it's a detail table) and I wouldn't want to be relying on the fpt file there. There is the issue of printing the images, of course, but I already use a temp table for that, in most cases.

                    In general it's the security issues that have most concerned me since it's possible to embed the images in an SQL database where they are invisible to a snooper. I was surprised to find recently in my own informal survey of a bunch of discussion sites where this issue was a hot topic, that a majority of the posters using various flavors of SQL preferred to save the image file location in a character field and NOT store the image file in the db. These folks prefer to use network security and active directory and other techniques to protect the images from unauthorized access. Still, there was a hard core of the other side who feel that "best practice" should be to store the files as blobs in the data structure no matter how big the resulting files are.
                    Finian

                    Comment


                      #11
                      Re: Rebuilding Image File Reference data in a Db

                      @ Finian.
                      We had the debate about storing in a Blob, but the SQL DBA vetoed it. In the end we are saving in a simple folder structure.
                      @ Mike.
                      I will examine that option as you explained it.
                      As an aside, I won't be using Browses at all.
                      Each record has a specific number of photo's - only ever 12, each of which has defined content so it is somewhat easier than disparate photo's all over a network.
                      The application records the status of a component, as an example, a photo of each of the six sides of a dice which is a unique dice with a specific dice identifier.
                      What I was trying to achieve in the simplest terms is to hit a button and have all IRF's fill in from the folder, which will be a defined and static one on the server.

                      Having said all that, I will be exploring your option, Finian's approach and Stan's process.
                      Much obliged for the input. maybe I made it sound more complex than it is.
                      See our Hybrid Option here;
                      https://hybridapps.example-software.com/


                      Apologies to anyone I haven't managed to upset yet.
                      You are held in a queue and I will get to you soon.

                      Comment


                        #12
                        Re: Rebuilding Image File Reference data in a Db

                        Last silly question from me on this topic.
                        How do I target a specific folder and a file type of JPG only?
                        See our Hybrid Option here;
                        https://hybridapps.example-software.com/


                        Apologies to anyone I haven't managed to upset yet.
                        You are held in a queue and I will get to you soon.

                        Comment


                          #13
                          Re: Rebuilding Image File Reference data in a Db

                          In Finian's much more complete example

                          img_search = dl_image_path + cid + "*.jpg"
                          img_file = filefind.get(img_search,FILE_FIND_NORMAL+FILE_FIND_NOT_DIRECTORY,"PN")

                          dl_image_path specifies where to look and "*.jpg" specifies the file extension to find.
                          There can be only one.

                          Comment


                            #14
                            Re: Rebuilding Image File Reference data in a Db

                            Thanks Stan.
                            See our Hybrid Option here;
                            https://hybridapps.example-software.com/


                            Apologies to anyone I haven't managed to upset yet.
                            You are held in a queue and I will get to you soon.

                            Comment


                              #15
                              Re: Rebuilding Image File Reference data in a Db

                              Nope, still cannot get it to work.
                              I get to the correct Folder, but the windows option is still showing BMP as the primary search option. I would rather that the users didn't have to scroll down to the jpeg option.
                              Is it possible to get the windows search button to show just jpeg in the options list?
                              When updating a photo, windows displays the option attached to the existing photo.

                              So, when selecting an IFR, I want to show only those with an extension of jpeg.

                              Possible?
                              See our Hybrid Option here;
                              https://hybridapps.example-software.com/


                              Apologies to anyone I haven't managed to upset yet.
                              You are held in a queue and I will get to you soon.

                              Comment

                              Working...
                              X