def helper_add_transfer(self, result):
    if not result:
      gLogger.error("There is no infomation")
      return False

    res = self.transferDB.get_TransferRequest(condDict={
                                                      "id": result.trans_req_id
                                                      })
    if not res["OK"]:
      return False
    req_list = res["Value"]
    if len(req_list) != 1:
      return False
    req =  TransRequestEntryWithID._make(req_list[0])

    # construct the info
    info = {"id": result.id,
            "LFN": result.LFN,
            "srcSE": req.srcSE,
            "dstSE": req.dstSE,
            "retransfer": -1,
            "error": ""}
    # Add the Transfer
    worker = gTransferFactory.generate(req.protocol, info)
    self.transferAgent.transfer_worker.append(worker)
    # Change the status
    self.helper_status_update(
        self.transferDB.tables["TransferFileList"],
        result.id,
        {"status":"transfer", 
          "start_time":datetime.datetime.utcnow()})
    # Add Accounting:
    d = {}
    d["User"] = req.username
    d["Source"] = req.srcSE
    d["Destination"] = req.dstSE
    d["Protocol"] = req.protocol
    d["FinalStatus"] = "OK"
    d["TransferSize"] = 0 # TODO
    r = self.fileCatalog.getFileSize(result.LFN)
    if r["OK"]:
      if r["Value"]["Successful"]:
        d["TransferSize"] = r["Value"]["Successful"][result.LFN]
    d["TransferTime"] = 1 # 1s 
    d["TransferOK"] = 1
    d["TransferTotal"] = 1
    acct_dt = DataTransfer()
    acct_dt.setValuesFromDict(d)
    acct_dt.setNowAsStartAndEndTime()
    # save it 
    worker.acct_dt = acct_dt

    return True
""")

Script.parseCommandLine( ignoreErrors = True )

# TODO
# Add an entry by hand
from BESDIRAC.AccountingSystem.Client.Types.DataTransfer import DataTransfer

dt = DataTransfer()
res = dt.registerToServer()
print res

# Add From a dict
d = {}
d["User"] = "******"
d["Source"] = "IHEPD-USER"
d["Destination"] = "JINR-USER"
d["Protocol"] = "DIRACDMS"
d["FinalStatus"] = "OK"

d["TransferSize"] = 800 * 2**20 # 800 MB
d["TransferTime"] = 10 * 60 # 10min
d["TransferOK"] = 1
d["TransferTotal"] = 1

res = dt.setValuesFromDict(d)
print res
dt.setNowAsStartAndEndTime()
res = dt.commit()
print res