Alpha Video Training
Results 1 to 28 of 28

Thread: Refresh Shadow automatically

  1. #1
    Member
    Real Name
    Jo Hulsen
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    331

    Default Refresh Shadow automatically

    Here's a little function to update a shadow automatically.
    I have been checking out quite a few threads about this subject and finally managed to create a function to refresh a shadow that requires no intervention of end users. No additonal table or text file is required to keep track of the version number.
    The function ShBldMgmt is called in the autoexec script.
    Once a new version is detected the Refresh_Shadow is executed and the usual refresh window pops up, showing the progress.

    The version number is set in the Network Optimization and the Update Options are set to "Do nothing- allow the user to open th Shadow Database". See attachment NetOpt_settings.png

    Hope this is of use to somebody.
    Attached Images Attached Images
    Attached Files Attached Files
    Jo Hulsen
    Dommel Valley Solutions
    The Netherlands

  2. #2
    Member Scott Kurimski's Avatar
    Real Name
    Scott Kurimski
    Join Date
    Jul 2009
    Posts
    330

    Default Re: Refresh Shadow automatically

    Jo, great job!

    I changed the last IF statement a little and added a few comments.

    Code:
    FUNCTION App_Refresh_Shadow AS C ( )
    	DIM CurVer AS N
    	DIM NewVer AS N
    
    	if a5.Get_Master_Path() <> ""  'Only run this code on Shadow clients
    
    		DIM Network_Optimize_Settings as p
    		a5_load_settings("NetworkOptimize",Network_Optimize_Settings)  'Load Network Optimize settings
    
    		CurVer = Network_Optimize_Settings.version_number  'Current Shadow version
    		NewVer = a5_getappversionnumber()  'New live application version
    
    		if NewVer > CurVer  'Refresh Shadow if the live application version is greater than the current Shadow version
    			REFRESH_SHADOW()
    		end if
    	end if
    
    END FUNCTION

  3. #3
    Member
    Real Name
    Jo Hulsen
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    331

    Default Re: Refresh Shadow automatically

    Scott,

    Thanks for your addition.
    I use this function in a version management tool in which I register the changes. Once a change is installed on the master db, I activate the new build by pressing an activate button in the version management. The shadow refresh is done automatically on each shadow db when the user opens the DB.
    I am currently managing an application that consists of 6 databases and is installed on 6 computers in Germany. As I am located in The Netherlands I do all the work remotely. The version management tool has a view option so that the end users can check out changes I applied.
    Jo Hulsen
    Dommel Valley Solutions
    The Netherlands

  4. #4
    Member Scott Kurimski's Avatar
    Real Name
    Scott Kurimski
    Join Date
    Jul 2009
    Posts
    330

    Default Re: Refresh Shadow automatically

    Jo,

    Thanks again for your post as I use this in a number of apps I have now and it works so easy / slick. I like the revision control idea and looking to implement my own very soon.

    Scott

  5. #5
    "Certified" Alphaholic
    Real Name
    Jetson Lilibeth
    Join Date
    Dec 2011
    Posts
    1,093

    Default Re: Refresh Shadow automatically

    Quote Originally Posted by Scott Kurimski View Post
    Jo, great job!

    I changed the last IF statement a little and added a few comments.

    Code:
    FUNCTION App_Refresh_Shadow AS C ( )
    	DIM CurVer AS N
    	DIM NewVer AS N
    
    	if a5.Get_Master_Path() <> ""  'Only run this code on Shadow clients
    
    		DIM Network_Optimize_Settings as p
    		a5_load_settings("NetworkOptimize",Network_Optimize_Settings)  'Load Network Optimize settings
    
    		CurVer = Network_Optimize_Settings.version_number  'Current Shadow version
    		NewVer = a5_getappversionnumber()  'New live application version
    
    		if NewVer > CurVer  'Refresh Shadow if the live application version is greater than the current Shadow version
    			REFRESH_SHADOW()
    		end if
    	end if
    
    END FUNCTION
    Scott, I tried your code and it returns an error on this on your code Network_Optimize_Settings.version_number. subelement not found

  6. #6
    Member
    Real Name
    Jo Hulsen
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    331

    Default Re: Refresh Shadow automatically

    Jetson,

    Please check first post for correct Network Optimize settings.
    Jo Hulsen
    Dommel Valley Solutions
    The Netherlands

  7. #7
    Member Scott Kurimski's Avatar
    Real Name
    Scott Kurimski
    Join Date
    Jul 2009
    Posts
    330

    Default Re: Refresh Shadow automatically

    Jetson,

    In addition to what Jo mentioned in the previous post, try this in the Interactive window....

    DIM Network_Optimize_Settings as p
    ?a5_load_settings("NetworkOptimize",Network_Optimize_Settings)

    and it should return something like this...
    = check_portion = 1
    outofdate_flag = 1
    version_number = 1.125

  8. #8
    "Certified" Alphaholic
    Real Name
    Jetson Lilibeth
    Join Date
    Dec 2011
    Posts
    1,093

    Default Re: Refresh Shadow automatically

    My mind again is not working very well so I did a copy paste from the post to make sure no typos.but still i get an error please see attached image for the result.
    Attached Images Attached Images

  9. #9
    Member
    Real Name
    Jo Hulsen
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    331

    Default Re: Refresh Shadow automatically

    Jetson,

    Take a good look and you might see something is missing........
    DIM Network_Optimize_Settings as p
    ?a5_load_settings("NetworkOptimize",Network_Optimize_Settings)
    Jo Hulsen
    Dommel Valley Solutions
    The Netherlands

  10. #10
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: Refresh Shadow automatically

    Jetson,

    Did you notice this text in the script-> Only run this code on Shadow clients (machine)
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  11. #11
    "Certified" Alphaholic
    Real Name
    Jetson Lilibeth
    Join Date
    Dec 2011
    Posts
    1,093

    Default Re: Refresh Shadow automatically

    Quote Originally Posted by DVSOL005 View Post
    Jetson,

    Take a good look and you might see something is missing........
    DIM Network_Optimize_Settings as p
    ?a5_load_settings("NetworkOptimize",Network_Optimize_Settings)
    Attached Images Attached Images
    Last edited by JetLi; 04-27-2012 at 09:56 AM.

  12. #12
    "Certified" Alphaholic
    Real Name
    Jetson Lilibeth
    Join Date
    Dec 2011
    Posts
    1,093

    Default Re: Refresh Shadow automatically

    Quote Originally Posted by Keith Hubert View Post
    Jetson,

    Did you notice this text in the script-> Only run this code on Shadow clients (machine)
    My purpose is to refresh the shadow database, so i was running the whole time the code that I copied on the Workstation. I never tried on the server because I don't want to refresh the database on the server, My only reason for refreshing the shadow is for the workstation to reflect any changes made on the server. Anyway, I'll try to run that code on the server, it might work.

  13. #13
    Member
    Real Name
    Jo Hulsen
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    331

    Default Re: Refresh Shadow automatically

    Jetson,

    I can generate the same error. It seems that you haven't pressed Enter after the first DIM-statement.
    Try again please.
    Jo Hulsen
    Dommel Valley Solutions
    The Netherlands

  14. #14
    "Certified" Alphaholic
    Real Name
    Jetson Lilibeth
    Join Date
    Dec 2011
    Posts
    1,093

    Default Re: Refresh Shadow automatically

    I'll try Jo.

    Edited: I tried, What is the meaning of this." = <Has no sub-properties>"?

    Edited Again: BTW Jo, If you download the first post attachment which is a text file, you will see a code like these
    dim network_optimize as p
    a5_load_settings("NetworkOptimize",network_optimize)
    the "settings" is omitted, I tried it again and same result "= <Has no sub-properties>" is this the correct result?
    Last edited by JetLi; 04-27-2012 at 10:03 AM.

  15. #15
    Member
    Real Name
    Jo Hulsen
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    331

    Default Re: Refresh Shadow automatically

    Quote Originally Posted by Keith Hubert View Post
    Jetson,

    Did you notice this text in the script-> Only run this code on Shadow clients (machine)
    The script tests whether or not it is started from the Master or SHADOW database. It is indeed aimed at the Shadow database (clients).

    Your Network Optimize Settings should be started on the Master Database.
    Jo Hulsen
    Dommel Valley Solutions
    The Netherlands

  16. #16
    Member
    Real Name
    Jo Hulsen
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    331

    Default Re: Refresh Shadow automatically

    That's not the correct result.
    Maybe best to restart Alpha completely and try again (on the Master DB)
    I get this result:

    dim network_optimize as p

    ?a5_load_settings("NetworkOptimize",network_optimize)
    = check_portion = 1
    outofdate_flag = 1
    version_number = 109
    Jo Hulsen
    Dommel Valley Solutions
    The Netherlands

  17. #17
    "Certified" Alphaholic
    Real Name
    Jetson Lilibeth
    Join Date
    Dec 2011
    Posts
    1,093

    Default Re: Refresh Shadow automatically

    Thank you Jo, for trying to help, I still get the same
    dim network_optimize as p

    ?a5_load_settings("NetworkOptimize",network_optimize)
    = <Has no sub-properties>

  18. #18
    Member
    Real Name
    Jo Hulsen
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    331

    Default Re: Refresh Shadow automatically

    Jetson,

    Are you sure you have pressed ENTER after each line in the interactive window?
    I have tested this on Alpha version 10.5 on two versions, each on a different PC and get the required result.
    Jo Hulsen
    Dommel Valley Solutions
    The Netherlands

  19. #19
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,625

    Default Re: Refresh Shadow automatically

    Quote Originally Posted by DVSOL005 View Post
    Jetson,

    Are you sure you have pressed ENTER after each line in the interactive window?
    I have tested this on Alpha version 10.5 on two versions, each on a different PC and get the required result.
    If the dim isn't executed you get this error..

    ERROR: Variable "network_optimize" not found.
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  20. #20
    "Certified" Alphaholic
    Real Name
    Jetson Lilibeth
    Join Date
    Dec 2011
    Posts
    1,093

    Default Re: Refresh Shadow automatically

    yap Jo, as you can see there is a space on my reply post#17, which I copied from the interactive window.Sometimes Jo, being a beginner in alpha five, if something goes wrong, what i thought for sure is I made the wrong code, which in desperation i searched for alpha wiki and samples on this forum, or immediately post the question,then if i found a code and tried to implement it in my own by copying and pasting which i don't get the desired result, With this situation, I am not encouraged to do things on my own because I will be doubting if I still can get the desired result (Sometimes not Always). The last statement is just a plain opinion, And it's good that we have this Forum, without it, I'm sure of myself that I can't use Alpha five as my development tool because unlike C# or VB .NET, codes are everywhere, Maybe someone will say, Why not go for c# or VB then? Well, Alpha five is much easier to learn but sometimes can get me stuck for days in some simple problems. back to reality, I just want the code above to check for version number before refreshing the shadow, other than that, i can refresh the shadow with Refresh_Shadow().

  21. #21
    "Certified" Alphaholic
    Real Name
    Jetson Lilibeth
    Join Date
    Dec 2011
    Posts
    1,093

    Default Re: Refresh Shadow automatically

    Al, I'm pretty sure you are talking about executing the code in the Interactive window, I don't want the client to go to the interactive window to press enter, the code needs to run from a function called on a button. And I get that error when the function is executed. And for some reason, i'm not getting that error anymore, instead i get a result like this. "= <Has no sub-properties> "

  22. #22
    Member
    Real Name
    Jo Hulsen
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    331

    Default Re: Refresh Shadow automatically

    Jetson,

    I understand what you are going through, I took me quite some time and a lot of reading to come to this solution.
    The purpose of this function is to automatically refresh a Shadow DB once the version number is changed on the Master DB.
    As explained in the first post the function is called in the autoexec script, so the client (shadow) will detect a new version and the Refresh_Shadow is executed and the usual refresh window pops up, showing the progress. You as the developer take care of the Master DB and the settings for Network Optimization.
    I cannot remember if I may have overlooked something that might cause the error but one thing I recall is that I had an operational situation in which the Shadows were updated once the version number was increased in the Network Optimization settings on the Master.
    So my advice is to do the following as a matter of test:
    - Set the Network Optimization settings as shown in attached picture;
    - Create a Shadow;
    - Test if Shadow actually works fine;
    - Now increase the version number on the Master DB in the Network Optimization settings;
    - Restart the Shadow and see if the shadow refresh is triggered automatically.

    If all this works fine, that should be your basis to start again with the first post in this thread.

    Best of luck,
    Attached Images Attached Images
    Jo Hulsen
    Dommel Valley Solutions
    The Netherlands

  23. #23
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,696

    Default Re: Refresh Shadow automatically

    Has anyone noticed that if you set your version number to reflect a date (YY.MMDD) you lose any trailing zeros? I tried this function today for version 12.0710 and it returns 12.071. I am also setting a character field with this value to display on a form, but using val(myvers_no) unfortunately does the same thing. I don't suppose there is a way around this since the app version number is a numeric field?
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  24. #24
    Member
    Real Name
    Jo Hulsen
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    331

    Default Re: Refresh Shadow automatically

    Robin,

    There should be an easy way around that.
    Why don't you consider the format YYYYMMDD and enter 20120710? I would guess that the way the number is stored isn't really important but you want it to be displayed correctly. For that purpose you could use a date formatting/conversion function.
    Example:
    dim version as n
    version = 20120710
    dim vrs as c
    vrs = str(version,8,0)
    ?stod(vrs)
    = {10-07-2012}
    Jo Hulsen
    Dommel Valley Solutions
    The Netherlands

  25. #25
    Member Scott Kurimski's Avatar
    Real Name
    Scott Kurimski
    Join Date
    Jul 2009
    Posts
    330

    Default Re: Refresh Shadow automatically

    Robin,

    Yes, I can confirm the trailing zeros drop off. I currently do not use the same scheme as you do. I skip versions ending in 0 i.e. - 1.159, 1.161 (skipping 1.160)

    I am sure there is probable a workaround.

    Scott

  26. #26
    "Certified" Alphaholic
    Real Name
    Raymond Lyons
    Join Date
    Apr 2000
    Location
    Carlsbad, CA
    Posts
    2,143

    Default Re: Refresh Shadow automatically

    Jo,

    What am I missing here? How is what you are doing with your function significantly different or better than just using the option to Automatically update the Shadow Database when the version changes?

    Raymond Lyons

  27. #27
    Member
    Real Name
    Jo Hulsen
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    331

    Default Re: Refresh Shadow automatically

    Raymond,

    It's not that it is better. The Alpha option to Automatically update the Shadow Database is aimed at automatic detection of a new version.
    The end user however needs to confirm whether or not the Shadow will actually be updated. I simply wanted to avoid end user intervention.
    I use this function in combination with a version management tool as mentioned in post #3.
    Jo Hulsen
    Dommel Valley Solutions
    The Netherlands

  28. #28
    "Certified" Alphaholic
    Real Name
    Raymond Lyons
    Join Date
    Apr 2000
    Location
    Carlsbad, CA
    Posts
    2,143

    Default Re: Refresh Shadow automatically

    Got it. Thanks.

    Raymond Lyons

Similar Threads

  1. Automatically update the Shadow Database
    By Scott Kurimski in forum Alpha Five Version 10 - Desktop Applications
    Replies: 48
    Last Post: 06-13-2011, 07:26 AM
  2. refresh shadow
    By gwsgreg in forum Alpha Five Version 8
    Replies: 8
    Last Post: 06-23-2008, 10:00 PM
  3. Grid Linker NOT REFRESH AUTOMATICALLY
    By andi in forum Application Server Version 8
    Replies: 1
    Last Post: 05-29-2007, 03:51 PM
  4. Refresh Shadow
    By Elke in forum Alpha Five Version 6
    Replies: 27
    Last Post: 01-24-2006, 12:16 PM
  5. How to Automatically Refresh a Form?
    By seidel1 in forum Alpha Five Version 6
    Replies: 9
    Last Post: 12-23-2004, 10:51 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •