13 Replies Latest reply on Jun 1, 2012 8:20 AM by Jonathan Chaalan

    Take a pic & save it in db using RE.

      Hi There,

       

      can you please help me figure out how I would go to accomplish this?

      1- User clicks on Take Picture button.

      2- He will get the cam enabled (full screen).  Then he will take the pic, it is either sent directly for saveOr maybe just put locally until he clicks on SAVE to save all the data entry he entered and not just the picture he took.

      3- After that the pic will get saved in the database(SQL Server 2008 db).

       

      What's the best way to make that happen? can you please provide the code as I was unable to figure it out...

       

      Thank you,

      Jonathan

        • Re: Take a pic & save it in db using RE.
          Robert Galvin

          Jonathan

           

          I moved this post to the RhoElements forums (you had posted to the site help forum).

           

          Before you use the Imager.enable() API to open up the Camera preview, you would specify the destination for the image to be captured using the imager.destination property. This can be a HTTP, ftp or local file path. Depending on your specific environment (are you running the pages from a Web Server or local on the device) you may have different ways to get it to the database. You could also use the Html5 Canvas object to load the captured image, then use the Canvas.toDataURI method which would translate the physical file into a base64 encoded string and just store the images as a text field.

           

          There are some code examples in the help file that was part of the installation.

           

          Rob

            • Re: Take a pic & save it in db using RE.

              Thanks Rob! I will try that and post back if I have more questions.

               

              I have another unrelated problem which is that RE will sometimes freeze if the internet connection wasn't too good, or let's say the user suddenly looses his internet connection, he will get an error messag with a button "Back" in the middle of the screen. and Even though he clicks on Back nothing will happen. the app will freeze and there is no way to go out but to restart the device!!

              How should I have more control over the app? Like when the connection is not too good or lost, the user doesn't  get this error msg or the system freezes? is there a wait limit before the app throws this error?

               

              Thanks again!

              Jonathan

                • Re: Take a pic & save it in db using RE.
                  Benedict Kennedy

                  Hi Jonathan,

                   

                  This is the Bad Link page that you are seeing, the back button wouldn't work in this case as the device cannot connect to the server to get the last page. You can change the timeout value to delay the bad link page from appearing by changing the:

                   

                  <Navigation>
                         <NavTimeout VALUE="45000"/>
                  </Navigation>
                  

                   

                  value in your Config.xml, found in your \Program Files\RhoElements\Config\ (windows) or /Android/data/com.motorolasolutions.rhoelements/ (android) directories. The value is in milliseconds, with a maximum value of 45000.

                   

                  The Bad Link page itself is available to be modified also, this is found at \Program Files\RhoElements\HTML\BadLink.html (windows) or /Android/data/com.motorolasolutions.rhoelements/badlink.html (android). If the user is not supposed to be locked out of the operating system, you can change this page to add a minimise (application.minimise()) or quit link (application.quit()) for example. This way the user can hide RhoElements and check their network settings, if this is appropriate.

                   

                  You don't have to use the default badlink page either, you can change the URI of the badlink page in the Config.xml page also, (but best not to use a remote url, otherwise it wont be able to be reached if the user loses connection on page load!). The setting is the following:

                   

                  <Navigation>
                          <BadLinkURI VALUE=""/>
                  </Navigation>
                  

                   

                  Regards,

                  Ben

                    • Re: Take a pic & save it in db using RE.

                      Thanks Ben.

                       

                      However can you guys please give me a working example for the Image Capture? like how do you use this Destination thing? I was able to Enable the imager so I can take a pic, but when I click the button to take the pic the system will go to the BadLink page. So I guess the destination I am using is incorrect. I tried to put the destination as an aspx page just like the example in the help file did but wasnt able to make it work. probably im doing something wrong. Can you please tell me how to Save the pic taken locally. how would I put the destination then?

                       

                      Thanks,

                      Jonathan

                        • Re: Take a pic & save it in db using RE.

                          Guys?! can you please help?

                          • Re: Take a pic & save it in db using RE.
                            Billie Hecox

                            From help docs:

                            <meta HTTP-Equiv="Imager" Content="destination:url('http://ds-laptop/PHTest/Received/HTTP/Upload.aspx')">

                             

                            I think this line in the help file assumes that you have an ASPX page that will accept the file you are sending.

                             

                            Which version of RhoElements are you running?

                            Are you running this app from the device, or is it hosted on a webserver?

                              • Re: Take a pic & save it in db using RE.

                                Hi Bill,

                                 

                                I am running V1.0.8.0. I will be moving to V1.0.3.11 soon...

                                I am running an asp.net app, so it's all about aspx pages. I am only using RhoElements to enable hardware functions like Barcode, SIP, Image Capture,etc...

                                 

                                What is the best way to go in order to save the captured image? I am able to show the image preview, but what should I do to handle the picture when it is taken? I would like to know how to save it locally, and also know how to transfer it to be saved in the database as well. Please advise.

                                 

                                Thank you!

                                Jonathan

                                  • Re: Take a pic & save it in db using RE.
                                    Sushil Gusain

                                    Hi,

                                    Please find the attached file - FeatureDemo.

                                    I think it will help you to capture/save image through button. and  save it in the database by the help of web services. Firstly you convert the image to bytes and send the bytes form and save in the database( like SQL-Server, Oracle)

                                      • Re: Take a pic & save it in db using RE.

                                        Hi Sushil,

                                         

                                        Thank you for your reply. However, the code mentioned in the file shows how to enable the imager which I did already. But it doesnt give the way to use in order to save the pic locally or send it. I also tried the aspx file destination in the help file to no avail. I would like if someone can give a piece of code showing how to enable the imager, then take the pic, then after taking the pic, it will be saved:

                                        1) to the local device.

                                        2)to the main SQL database. i.e. send this pic to the server.

                                         

                                        Thank you,

                                        Jonathan

                                          • Re: Take a pic & save it in db using RE.
                                            Robert Galvin

                                            Hi Jonathan

                                             

                                            The imager section of the help file shows some .NET code for receiving the file. This is similar to any typical code where a user would select a file to upload and you need code on the backend to handle the file post.

                                             

                                            http://edgedocs.rhomobile.com/rhoelements/imager#htmljavascript-examples

                                             

                                            Scroll down to where you see: “The following ASP.NET example receives a file from the imager and saves it in a new filename:”

                                             

                                            Rob

                                              • Re: Take a pic & save it in db using RE.

                                                Hi Guys,

                                                 

                                                I just updated to V1.0.3.11. My application was working fine in the older version of RhoElements. but now suddenly I can't even login! when I click on the Login button instead of being transferred to the main menu page, I get the following error:

                                                Bad Request - Invalid Header

                                                HTTP Error 400. The request has an invalid header name.

                                                 

                                                Can someone help/advise please? is there something I must do in IIS for that new version to work?!

                                                 

                                                Thank you,

                                                Jonathan

                                                  • Re: Take a pic & save it in db using RE.
                                                    Robert Galvin

                                                    When you install a new version it also replaces the config.xml. Did you adjust any settings like WebSQL quota and did not reapply them in the new config.xml?

                                                     

                                                    Also try enable logging and attach the log to your reply.

                                                     

                                                    Sent from my Verizon Wireless 4G LTE DROID

                                                      • Re: Take a pic & save it in db using RE.

                                                        Hi Rob,

                                                         

                                                        No I dont have any other values changes in the config.xml, I just changed in the StartPage tag after the Update.

                                                         

                                                        Thank you,

                                                        Jonathan

                                                         

                                                        This is what the Log file is showing:

                                                        MEMORY:   Stats: Load=82%  TotalPhy=183432KB  FreePhy=34796KB  TotalVM=32768KB  FreeVM=27072KB 0 2012-06-01 18:14:06

                                                        INFO: Core Initialise RhoElements Build Date: 09/03/2012 890 2012-06-01 18:14:06

                                                        INFO: Core Initialise RhoElements Build Time:  7:06:47 892 2012-06-01 18:14:06

                                                        INFO: CAppManager CAppManager::Init Engine is use is the Motorola WebKit engine (default) 161 2012-06-01 18:14:06

                                                        INFO: Core LoadPlugin Scanner 771 2012-06-01 18:14:11

                                                        INFO: Abstract Preload First call 194 2012-06-01 18:14:11

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:11

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:11

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:11

                                                        INFO: Core CSyncMsg::RegisterCallback Registered Primary Callback 125 2012-06-01 18:14:11

                                                        INFO: Core LoadPlugin Hourglass 771 2012-06-01 18:14:11

                                                        INFO: Abstract Preload First call 194 2012-06-01 18:14:11

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:11

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:11

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:11

                                                        INFO: Scanner CScanner::LowBatteryScanThread Starting Thread to monitor power state and disable Scanner if power gets low 1537 2012-06-01 18:14:11

                                                        INFO: Core LoadPlugin KeyCapture 771 2012-06-01 18:14:11

                                                        INFO: Abstract Preload First call 194 2012-06-01 18:14:11

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:11

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:11

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:11

                                                        INFO: Core CSyncMsg::RegisterCallback Registered Primary Callback 125 2012-06-01 18:14:11

                                                        INFO: Core LoadPlugin SIP 771 2012-06-01 18:14:11

                                                        INFO: Abstract Preload First call 194 2012-06-01 18:14:11

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:11

                                                        INFO: Core CSyncMsg::RegisterCallback Registered Primary Callback 125 2012-06-01 18:14:11

                                                        INFO: Core LoadPlugin Signal 771 2012-06-01 18:14:11

                                                        INFO: Abstract Preload First call 194 2012-06-01 18:14:11

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:11

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:11

                                                        INFO: Core CSyncMsg::RegisterCallback Registered Primary Callback 125 2012-06-01 18:14:11

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:11

                                                        WARNING: Controls CControlsModule::onInit Cannot load keyboard driver DLL 185 2012-06-01 18:14:11

                                                        INFO: Core LoadPlugin ScreenOrientation 771 2012-06-01 18:14:11

                                                        INFO: Abstract Preload First call 194 2012-06-01 18:14:11

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:11

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:11

                                                        INFO: Core CSyncMsg::RegisterCallback Registered Primary Callback 125 2012-06-01 18:14:11

                                                        INFO: Core Initialise RhoElements Component Version: RhoElements.exe = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_CardReader_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_Comm_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_Config_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_Controls_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_DeviceApplication_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_EMMP_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_FileTransfer_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_Gesture_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_ImageCapture_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_IO_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_KeyCapture_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_Push_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_Scanner_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_Signature_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_Telemetry_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: WTG_Network_PLG.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: PocketBrowser.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: CeODAX.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: NoSIP.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: npwtg_legacy.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: Core Initialise RhoElements Component Version: npwtg_jsobjects.dll = 1.0.3.11.0 994 2012-06-01 18:14:12

                                                        INFO: CAppManager CAppManager::AddLicenceApp RhoElements Core Version: 1.0.3.11  509 2012-06-01 18:14:12

                                                        INFO: Core CSync::Run Running Event:  1 2012-06-01 18:14:12

                                                        INFO: Core CSync::Run Creating Thread for:  1 2012-06-01 18:14:12

                                                        INFO: Core CSync::Run Running Event:  6 2012-06-01 18:14:12

                                                        INFO: Core CSync::Run Creating Thread for:  32 2012-06-01 18:14:12

                                                        INFO: Core CSync::Run Running Event:  2 2012-06-01 18:14:12

                                                        INFO: Core CSync::Run Creating Thread for:  2 2012-06-01 18:14:12

                                                        INFO: Core Navigate Navigating to: file://\test.html 1535 2012-06-01 18:14:12

                                                        INFO: Core CSync::Run Running Event:  3 2012-06-01 18:14:12

                                                        INFO: Core CSync::Run Creating Thread for:  4 2012-06-01 18:14:12

                                                        INFO: Core CSync::Run Running Event:  4 2012-06-01 18:14:12

                                                        INFO: Core CSync::Run Creating Thread for:  8 2012-06-01 18:14:12

                                                        INFO: Core CMeta::GetModule Plug-in: viewportcannot be found in Plugin.xml 212 2012-06-01 18:14:12

                                                        WARNING: Core CMeta::SetPlugProperty Module viewport not found. 61 2012-06-01 18:14:12

                                                        INFO: Core CSync::Run Running Event:  2 2012-06-01 18:14:12

                                                        INFO: Core CSync::Run Creating Thread for:  2 2012-06-01 18:14:12

                                                        INFO: Core CSync::Run Running Event:  3 2012-06-01 18:14:13

                                                        INFO: Core CSync::Run Creating Thread for:  4 2012-06-01 18:14:13

                                                        MEMORY:   Stats: Load=83%  TotalPhy=183432KB  FreePhy=31260KB  TotalVM=32768KB  FreeVM=17856KB 0 2012-06-01 18:14:13

                                                        INFO: Core CSync::Run Running Event:  4 2012-06-01 18:14:13

                                                        INFO: Core CSync::Run Creating Thread for:  8 2012-06-01 18:14:13

                                                        INFO: Core CMeta::GetModule Plug-in: viewportcannot be found in Plugin.xml 212 2012-06-01 18:14:13

                                                        WARNING: Core CMeta::SetPlugProperty Module viewport not found. 61 2012-06-01 18:14:13

                                                        INFO: Core LoadPlugin SIPButton 771 2012-06-01 18:14:13

                                                        INFO: Core LoadPlugin FileTransfer 771 2012-06-01 18:14:14

                                                        INFO: Abstract Preload First call 194 2012-06-01 18:14:14

                                                        INFO: Core CSync::RegisterCallback Registered Callback 97 2012-06-01 18:14:14

                                                        INFO: FileTransfer CFileTransfer::onAttachInstance Creating Instance 32 2012-06-01 18:14:14

                                                        INFO: FileTransfer CFileTransfer::onAttachInstance Creating Instance 32 2012-06-01 18:14:14

                                                        INFO: Core LoadPlugin QuitButton 771 2012-06-01 18:14:14

                                                        INFO: Scanner CScanner::RSMGetSupportedAttributes Unable to retrieve supported RSM attributes, this scanner does not support RSM (2684354578) 45 2012-06-01 18:14:14

                                                        INFO: FileTransfer CHttp::GetFile File successfully received 152 2012-06-01 18:14:16

                                                        INFO: FileTransfer CHttp::GetFile File successfully received 152 2012-06-01 18:14:16

                                                        INFO: Core CSync::Run Running Event:  1 2012-06-01 18:14:16

                                                        INFO: Core CSync::Run Creating Thread for:  1 2012-06-01 18:14:16

                                                        INFO: Core CSync::Run Running Event:  1 2012-06-01 18:14:16

                                                        INFO: Core CSync::Run Creating Thread for:  1 2012-06-01 18:14:16

                                                        MEMORY:   Stats: Load=86%  TotalPhy=183432KB  FreePhy=26340KB  TotalVM=32768KB  FreeVM=16000KB 0 2012-06-01 18:14:18

                                                        MEMORY:   Stats: Load=87%  TotalPhy=183432KB  FreePhy=25452KB  TotalVM=32768KB  FreeVM=16000KB 0 2012-06-01 18:14:23

                                                        MEMORY:   Stats: Load=88%  TotalPhy=183432KB  FreePhy=22784KB  TotalVM=32768KB  FreeVM=16000KB 0 2012-06-01 18:14:28

                                                        MEMORY:   Stats: Load=89%  TotalPhy=183432KB  FreePhy=21336KB  TotalVM=32768KB  FreeVM=16000KB 0 2012-06-01 18:14:33

                                                        MEMORY:   Stats: Load=90%  TotalPhy=183432KB  FreePhy=19588KB  TotalVM=32768KB  FreeVM=15936KB 0 2012-06-01 18:14:38

                                                        MEMORY:   Stats: Load=91%  TotalPhy=183432KB  FreePhy=17764KB  TotalVM=32768KB  FreeVM=15936KB 0 2012-06-01 18:14:43

                                                        INFO: Core CSync::Run Running Event:  2 2012-06-01 18:14:45

                                                        INFO: Core CSync::Run Creating Thread for:  2 2012-06-01 18:14:45

                                                        INFO: Scanner CScanner::SubmitReadThread Data not successfully read from the Scanner 1451 2012-06-01 18:14:45

                                                        INFO: Core CSync::Run Running Event:  3 2012-06-01 18:14:46

                                                        INFO: Core CSync::Run Creating Thread for:  4 2012-06-01 18:14:46

                                                        INFO: Core CSync::Run Running Event:  4 2012-06-01 18:14:46

                                                        INFO: Core CSync::Run Creating Thread for:  8 2012-06-01 18:14:46

                                                        INFO: Core CMeta::GetModule Plug-in: contentcannot be found in Plugin.xml 212 2012-06-01 18:14:46

                                                        WARNING: Core CMeta::SetPlugProperty Module content not found. 61 2012-06-01 18:14:46

                                                        INFO: Core CMeta::GetModule Plug-in: contentcannot be found in Plugin.xml 212 2012-06-01 18:14:46

                                                        WARNING: Core CMeta::SetPlugProperty Module content not found. 61 2012-06-01 18:14:46

                                                        MEMORY:   Stats: Load=90%  TotalPhy=183432KB  FreePhy=19924KB  TotalVM=32768KB  FreeVM=16512KB 0 2012-06-01 18:14:48