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

Creating a shadow DB

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

  • Creating a shadow DB

    Ok, believe me I have searched and read every thing I could find on this.


    From http://wiki.alphasoftware.com/Prepar...hadow+Database

    Code:
    dim master_db_name as C
    dim shadow_db_name as C
    master_db_name = ""
    shadow_db_name = ""
    ui_modeless_dlg_box("Install MyAppName",<<%dlg%
    {can_exit=exit}
    {lf};
    Specify the filename of the master copy of the application:;
    %P=ui_get_file("Select file","(*.adb)",master_db_name)%.100master_db_name;
    {lf};
    ;
    %dlg%,<<%code%
    if a_dlg_button = "cancel" then
        ui_modeless_dlg_close("Install MyAppName")
        a_dlg_button = ""
    end if
    if a_dlg_button = "oK" then
        if file.exists(master_db_name) = .f. then
            ui_msg_box("Error", "Master Database not found.")
        else
            shadow_db_name = a5.Get_Name()
            a5.Load(master_db_name)
            a5_nopt_CopyAddFiles(shadow_db_name, master_db_name)
            create_shadow2(shadow_db_name, .t., .t.)
            ui_modeless_dlg_close("Install MyAppName")
        end if
    end if
    %code%)
    Does not work and results in this little pop up window that will never go away.
    SDB_Error.png


    The method using the network optimization shown at http://wiki.alphasoftware.com/Network+Optimization works except that means I have to make the main system toolbar visible and I do not want have that showing in my app.

    Got to be away that the end user does not need to jump thru hoops to install a shadow.

  • #2
    Re: Creating a shadow DB

    Originally posted by preston;606130
    The method using the network optimization shown at [url
    http://wiki.alphasoftware.com/Network+Optimization[/url] works except that means I have to make the main system toolbar visible and I do not want have that showing in my app.

    Got to be away that the end user does not need to jump thru hoops to install a shadow.
    Make your own toolbar with only network optimization on it.

    Control panel - code tab - new - toolbar - blank toollbar - context control panel - pick the existing button form the list.

    toolbar_NetworkOptimize.PNG
    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.

    Comment


    • #3
      Re: Creating a shadow DB

      I will try and build off that Al. I had seen the network optimize elsewhere but all it did was a refresh.

      I have to make this operation dummy proof for my end users.

      I will say it again, with the help of the generous members here, the accidentally stumbling across the correct search syntax in wiki and reading the books, I am starting to understand Alpha 5. I like what I see.

      With all that guidance mentioned above my 3+ months of developing my app is now out in preliminary beta testing (still have a lot to do on it though) and the people testing it in the industry the app is designed for are very impressed with it.

      A big thank you to all the guys and gals here who have thrown me some bones.

      Comment


      • #4
        Re: Creating a shadow DB

        At the very least, I think creating a Shadow DB requires that the user knows or can find the Master DB. So I have the user open the Master DB in the runtime and never show them the Control Panel. There I have a Make Shadow button that runs a script and calls a function (UDF) I created: Make_Shadow():
        Code:
        'Date Created: 20-May-2009 05:29:44 PM
        'Last Updated: 21-May-2009 01:26:15 PM
        'Created By  : Raymond Lyons
        'Updated By  : Raymond Lyons
        FUNCTION Make_Shadow AS C ( )
        
        	DBname = file.filename_parse(a5.get_name(),"N")
        	create_shadow2("C:\A5_shadows\Master_DB"+"\\"+DBname,.t.)
        	topparent.close()	'Needed to close the form the calling script is run from
        
        END FUNCTION
        Note that I hard coded where I wanted the shadow to go, but you could easily let the user choose a location.

        Then the problem is, how can you make this function run? If run from a form, that form and virtually everything else has to first be shut down--just as if you were backing up the database. So I used Action Scripting: Database Utilities, Backup Database Dialog Box and converted it to xbasic. Then I merely replaced the line cmd_initial = " backup_database()" with cmd_initial = " Make_Shadow()", and a few other minor tweaks. Voila, it works, opening the shadow to my menu form where I also have a button to create a desktop shortcut for the Shadow and a Refresh Shadow button. I suppose I could have the shortcut created automatically, but I don't.

        The slightly modified AS generated xbasic code for my Make Shadow from Master button is as follows:

        Code:
        'Date Created: 25-May-2009 05:50:39 PM
        'Last Updated: 05-Apr-2012 11:14:49 AM
        'Created By  : Raymond Lyons
        'Updated By  : Raymond Lyons
        'Code below is based on the Backup script generated by AS
        'Make_Shadow() is a UDF that creates the shadow and also closes the form this script is run from.
        'All other forms are closed in this script and CP is minimized.
        
        'Display the 'Make Shadow' dialog box
        dim cmd_initial as c 
        cmd_initial = " Make_Shadow()"
        dim msg as c 
        msg = "A Shadow version of this database will made (or refreshed with an updated ver # if a Shadow already exists)."
        dim cmd_result as c 
        
        'get list of all open windows...........................................
        dim open_windows as c 
        open_windows = a5_list_open_windows()	
        dim current_window as c 
        if is_object(topparent.this)
        	if topparent.class() = "form" .or. topparent.class() = "browse" then 
        		current_window = topparent.name()
        		'remove the current window from the list
        		open_windows = word_subtract(open_windows,current_window,crlf())  
        	end if 
        end if 
        
        'generate the xbasic to close all of the open windows (excepting the current window)....................
        if open_windows <> "" then 
        	dim cmd_close as c 
        	cmd_close = *for_each(x,x+".close()" , open_windows)
        	''now execute the xbasic
        	cmd_result = evaluate_template(cmd_close)
        	if cmd_result <> "" then 
        		ui_msg_box("Error",cmd_result)
        		goto skip_rest_close_open_windows
        	end if 
        end if 
        
        if is_object(topparent.this) then 
        	if topparent.class() = "form" .or. topparent.class() = "browse" then 
        '		dim q_msg as n 
        '		q_msg = ui_msg_box("Notice",msg,UI_ATTENTION_SYMBOL+UI_OK_CANCEL)
        '		if q_msg = ui_ok_selected then
        			dim topparent_name as c 
        			dim cmd as c 
        			dim condition as c 
        			
        			dim open_sessions as c 
        			open_sessions = session_enum()
        			dim open_session_count as n 
        			open_session_count = line_count(open_sessions)
        
        			if topparent.class() = "form" then 
        				cmd = "dim tempP as p; tempP = form.view(" + quote(topparent.name(1)+"@" + topparent.Dictionary_Get(1))+")"
        			else
        				cmd = "dim tempP as p; tempP = browse.view(" +quote( topparent.name(1)+"@" + topparent.Dictionary_Get(1))+")"
        			end if 
        			
        			if a5_IsMaximized() = .t. then 
        				cmd =  cmd +  crlf() +"xbasic_wait_for_idle()" + crlf() +  "tempP.maximize()" + crlf()
        			end if 
        			
        			'when the number of sessions is one less than the number before the layout is closed then 
        			'the session that the form/browse was based on has been closed, and it is safe to run the
        			'command.
        			condition = "line_count(session_enum()) =  " + (open_session_count - 1 )
        			cmd = cmd_initial + crlf() + cmd
        			
        			'is the control panel hidden? if so then you have to temporarily show it, or else the database will close
        			'after you close this form.
        			if ControlPanel.IsVisible() = .f. then 
        				ControlPanel.Minimize()
        				cmd = cmd + crlf() + "controlpanel.hide()"
        				if a5_IsMaximized() then 
        					topparent.restore()
        				end if 
        			end if 
        
        			on_condition(condition,cmd)
        			topparent.close()
        '		end if 
        	
        	else   'topparent is an object, but it is not a form or browse
        		cmd_result = evaluate_template(cmd_initial)
        		if cmd_result <> "" then 
        			ui_msg_box("Error",cmd_result)
        		end if 
        	end if 
        else '	topparent is not an object 
        	cmd_result = evaluate_template(cmd_initial)
        	if cmd_result <> "" then 
        		ui_msg_box("Error",cmd_result)
        	end if 
        end if 
        
        skip_rest_close_open_windows:
        Hope this helps, if not Preston who may go down a different road, maybe someone else.

        Raymond Lyons
        Last edited by Raymond Lyons; 04-05-2012, 03:20 PM. Reason: Clarification

        Comment


        • #5
          Re: Creating a shadow DB

          Thanks Raymond. I will definitely give this a try.

          I agree, the person installing the shadow needs to know how to find the master. They will have to navigate to where the master is as the app is not going to be used by one big company but a lot of small companies and they will all have their network paths different.

          I plan on making this function available only to those that log in with admin access (got to keep their employees from pushing buttons just to see).

          One of these days my head may get totally out of the old Pascal way of thinking and then things will become easier. Getting better though.

          Again, thank you.

          Comment


          • #6
            Re: Creating a shadow DB

            Preston,

            There is some nice code and help above. I applaud the work and the help for you.

            I use maybe a different slightly method:

            I create the database install in one step and then create the shadow in another on my machine. I then make the 2 installs using an outside installer(astrum in my case). The first is for the data files for the server and the other is for the shadow on the work station.
            The shadow has a bootstrap adb that when opened on the work station allows the user/IT to locate the data files and it updates the shadow from the data files.
            The user never sees the Control Panel in any of my apps.
            The shadow along with the runtime is actually copied from the installer in one step to the work station.

            Hope this helps as well.

            Contact me if you want to know more. One of my apps has many installs by others without any intervention from me.
            Dave Mason
            dave@aldadesktop.com
            Skype is dave.mason46

            Comment


            • #7
              Re: Creating a shadow DB

              Hi Dave,
              I'm doing the same thing, but can't get the database to run once the shadow has been created, it simply opens to the control panel. My form on the "bootstrap" app has a "select file" field on the form that shows on startup. Then I pass it to a function to create the shadow. Once complete, the app is opened on the control panel.
              Ernie

              P.S. I can hard code the location of the master and it works fine. Put the code in the autoexec script of the bootstrap. It creates it then runs the app opening to the Main Menu.
              P.S.2 Well, never mind what I've said. Somewhere along the line of trying to get all this to work, the master copy of the db lost all the code, i.e. scripts, functions, etc. Consequently, no autoexec to make it open as planned.
              Last edited by enstorms; 04-06-2012, 10:32 AM.

              Comment


              • #8
                Re: Creating a shadow DB

                Ok, have it working just fine. Don't know what happened to all the scripts and functions on the Code tab.
                Ernie

                Comment


                • #9
                  Re: Creating a shadow DB

                  I gleaned this from others and modified it as I needed it, then changed it slightly for hard coded paths. Change it as you want. It gets used 2 - 3 times a week now.
                  The code I gave for creating a shadow from a dataset on a server:
                  dim master_db_name as C
                  dim shadow_db_name as C
                  master_db_name = "\\networkpath\ups55\sales.adb"
                  shadow_db_name = "c:\ups55\sales.adb"

                  ui_modeless_dlg_box("Install Ups55",<<%dlg%
                  {can_exit=exit}
                  {lf};
                  Specify the path and filename of the master copy of the applicationlike: \\pc2\ups55\sales.adb ;
                  [%P=ui_get_file("Select file","(*.adb)",master_db_name)%.100master_db_name];
                  {lf};
                  <Click Here to Start Install!oK?.not.(master_db_name="")> <Cancel!cancel>;
                  %dlg%,<<%code%

                  if a_dlg_button = "cancel" then
                  ui_modeless_dlg_close("Install UPS55")
                  a_dlg_button = ""
                  end if

                  if a_dlg_button = "oK" then
                  if file.exists(master_db_name) = .f. then
                  ui_msg_box("Error","Master Database not found.")
                  else
                  shadow_db_name = a5.Get_Name()
                  a5.Load(master_db_name)
                  a5_nopt_CopyAddFiles(shadow_db_name, master_db_name)
                  create_shadow(shadow_db_name, master_db_name,.t.)
                  ui_modeless_dlg_close("Install Ups55")
                  end if
                  end if
                  %code%)
                  Dave Mason
                  dave@aldadesktop.com
                  Skype is dave.mason46

                  Comment


                  • #10
                    Re: Creating a shadow DB

                    Hi Preston,

                    You have discovered that there is some typos with the script in the wiki.
                    Should read:
                    Code:
                    Specify the filename of the master copy of the application:;
                    [%P=ui_get_file("Select file","(*.adb)",master_db_name)%.100master_db_name];
                    <Click Here to Start Install!oK?.not.(master_db_name="")> <Cancel!cancel>;
                    Regards
                    Keith Hubert
                    Alpha Guild Member
                    London.
                    KHDB Management Systems
                    Skype = keith.hubert


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

                    Comment


                    • #11
                      Re: Creating a shadow DB

                      Originally posted by Keith Hubert View Post
                      Hi Preston,

                      You have discovered that there is some typos with the script in the wiki.
                      Should read:
                      Code:
                      Specify the filename of the master copy of the application:;
                      [%P=ui_get_file("Select file","(*.adb)",master_db_name)%.100master_db_name];
                      <Click Here to Start Install!oK?.not.(master_db_name="")> <Cancel!cancel>;
                      Hey Keith.

                      Yes I discovered that after comparing an example Dave had to the one in Wiki. I have a program that allows me to load 2 versions of code and look at them side by side as it points out all the differences. This is why using Wiki can be frustrating at times as this is not the first thing I found in Wiki that was wrong.

                      Comment


                      • #12
                        Re: Creating a shadow DB

                        I also advise not using drive letters as the path to the adb. Use the server name. like "\\my server\myappfolder\my.adb" instead of "z:\myappfolder\my.adb". Just one help to keep a user from messing with the real data files so easily.
                        Dave Mason
                        dave@aldadesktop.com
                        Skype is dave.mason46

                        Comment

                        Working...
                        X