 
 await = require 'await'
 soap = require 'soap'
+ObjectId = require('mongodb').ObjectID
 membersSvcUri = "./wsdl/Members.svc.xml"
 
 # Data returned by node-soap that was nil in the output is represented

    upsert: true,
    safe: true
  , (err, doc) ->
    if err?
      promise.fail(err)
    else
      promise.keep('member', doc)

module.exports = (jobs, db) ->
  jobs.process 'import members', (job, callback) ->
    soap.createClient membersSvcUri, (err, client) -> ifSuccessful err, callback, ->
      db.collection("sessions").find().toArray (err, results) -> ifSuccessful err, callback, ->
        results.forEach (session) ->
          getMembersArgs =
            SessionId: session.assemblyId

          client.MemberService.BasicHttpBinding_MemberFinder.GetMembersBySession getMembersArgs, (err, result, raw) -> ifSuccessful err, callback, ->
            members = result.GetMembersBySessionResult.MemberListing

            promises = members.map (member) ->
              await('member').run (promise) ->
                persistMember(session, member, db, promise)

            await.all(promises).onkeep((got) -> callback()).onfail(() -> callback([].slice.call(arguments).join('\n')))


  baseUri + member.lastName + member.firstName + assemblyId + ".jpg"

persistMember = (session, member, db, callback) ->
  assemblyIdForMember = Number(member.Id)

  memberDetails =
