示例#1
0
def send_order_to_WW(orderID):
	local = MongoTools.LocalDB()
	order = local.get_delivery_by_walden_id(orderID)
	ordersArray = [WorkWave.build_order_from_document(order)]
	response = WorkWave.add_orders(ordersArray)
	print response
	print response.text
	local.disconnect()
	return response
示例#2
0
def send_all_orders_to_WW():
	# this adds all active deliveries to WW
	# Make sure to clear WW before doing this
	local = MongoTools.LocalDB()

	print "Building deliveries array"
	deliveries = local.get_all_active_deliveries()

	order_array = []
	for order in deliveries:
		order_array.append(WorkWave.build_order_from_document(order))

	# Calulate time to add and send
	time = len(order_array)/60.0 # len of time to add in minutes
	print "Sending to WorkWave - this should take " + str(time) + " minutes"
	response = WorkWave.add_orders(order_array)
	print response
	print response.text

	local.disconnect()
示例#3
0
def update_local_mid_month():
    # First update from ww
    flag = update_local_from_WW()
    if not flag:
        print "Update from WW not successfull"
        return False

    # Get WaldenDB
    print "Updating from Walden...",
    update_local_from_walden()
    print "Done"


    local = mTools.LocalDB()
    # Build add/drop arrays
    drop_IDs = []
    add_array = []
    all_orders = local.get_all()
    for order in all_orders:
        if order['status'] == "active" or order['status'] == "manual":
            if 'workwave_ID' not in order:
                add_array.append( ww.build_order_from_document(order) )
        else:
            if 'workwave_ID' in order:
                drop_IDs.append( order['workwave_ID'] )
		local.remove_ww_id( order['walden_ID'] )

    local.disconnect()

    print "num to drop: " + str(len(drop_IDs))
    print "num to add: " + str(len(add_array))

    # Send to work wave
    response = ww.add_orders(add_array)
    print "added: " + str(response.status_code)
    response = ww.drop_orders(drop_IDs)
    print "deleted: " + str(response.status_code) + "  " + response.text
示例#4
0
def update_local_mid_month():
    # First update from ww
    flag = update_local_from_WW()
    if not flag:
        print "Update from WW not successfull"
        return False

    # Get WaldenDB
    print "Updating from Walden...",
    update_local_from_walden()
    print "Done"

    local = mTools.LocalDB()
    # Build add/drop arrays
    drop_IDs = []
    add_array = []
    all_orders = local.get_all()
    for order in all_orders:
        if order['status'] == "active" or order['status'] == "manual":
            if 'workwave_ID' not in order:
                add_array.append(ww.build_order_from_document(order))
        else:
            if 'workwave_ID' in order:
                drop_IDs.append(order['workwave_ID'])
                local.remove_ww_id(order['walden_ID'])

    local.disconnect()

    print "num to drop: " + str(len(drop_IDs))
    print "num to add: " + str(len(add_array))

    # Send to work wave
    response = ww.add_orders(add_array)
    print "added: " + str(response.status_code)
    response = ww.drop_orders(drop_IDs)
    print "deleted: " + str(response.status_code) + "  " + response.text