Is it possible to export Schedule (shifts) configuration? or how to copy to another gateway?

Hi

In my development environment I created a pretty complex set of shift schedules for the app. Now I need to have them in the production gateway server. But it looks like the only way is to backup the gateway configuration and restore in production (which is not an option due to different sources names...) or do it again manually.

is there a way to grab the schedules from a database or export them somehow so they don't need to be created manually again? Thanks!

I can think of a couple ways to do this

  1. Configure a gateway connection between them and use a gateway message handler to return the schedules and create them

    Put this in a gateway message handler on the gateway with the schedules to copy
    return system.user.getSchedules()

    Then on the gateway you want to copy them to, you can run this to create them

    schedules = system.util.sendRequest(
    									project='ProjectName', 
    									messageHandler='name-of-message', 
    									remoteServer='RemoteGatewayName'
    									)
    for schedule in schedules:
    	response = system.user.addSchedule(schedule)
    
  2. Write the schedule objects to files from the test gateway and import them on the production gateway

    On the test system, use this to create the schedule object files

    from java.io import FileOutputStream, ObjectOutputStream
    
    path = 'C:\\Temp\\Schedules\\'
    
    schedules = system.user.getSchedules()
    
    for schedule in schedules:
    	# You may need to .replace() any characters in the schedule.name to create a valid file name
    	filePath = path + schedule.name
    	
    	fos = FileOutputStream(filePath)
    
    	oos = ObjectOutputStream(fos)
    	fos.close()
    	oos.writeObject(schedule)
    	oos.close()
    

    Copy the files into their own folder on the production server and run this to read them back in and create the schedules

    from java.io import FileInputStream, ObjectInputStream
    import os
    
    path = 'C:\\Temp\\Schedules\\'
    for f in os.listdir(path):
    	fis = FileInputStream(path + f)
    	ois = ObjectInputStream(fis)
    	fis.close()
    	schedule = ois.readObject()
    	ois.close()
    
    	system.user.addSchedule(schedule)
    
3 Likes

Thanks a lot Jeremy. Option 2 is the one I think I will try. Had not thought about looking for a system function that could deal with schedules. Great information!