Exemplo n.º 1
0
    public bool SetPosInfo(string posInfo, string customerID, int type)
    {
        this.log(LogLevel.DEBUG, "AuthBsWebServices", "SetPosInfo", "Params", "pos=" + posInfo);
        this.log(LogLevel.DEBUG, "AuthBsWebServices", "SetPosInfo", "Params", "customer_id=" + customerID);
        this.log(LogLevel.DEBUG, "AuthBsWebServices", "SetPosInfo", "Params", "type=" + type.ToString());

        cPos.Service.PosService pos_service = new PosService();
        if (string.IsNullOrEmpty(posInfo))
        {
            throw new ArgumentNullException("posInfo");
        }

        if (string.IsNullOrEmpty(customerID))
        {
            throw new ArgumentNullException("customerID");
        }

        if (type < 1 || type > 2)
        {
            throw new ArgumentOutOfRangeException("type");
        }

        //todo:解密
        string  decrypt_pos_info = posInfo;
        PosInfo pos = (PosInfo)cPos.Service.cXMLService.Deserialize(decrypt_pos_info, typeof(PosInfo));

        if (pos == null)
        {
            throw new ArgumentException("posInfo");
        }

        if (string.IsNullOrEmpty(pos.ID))
        {
            throw new ArgumentNullException("terminal_id");
        }
        if (string.IsNullOrEmpty(pos.SN))
        {
            throw new ArgumentNullException("terminal_sn");
        }
        if (string.IsNullOrEmpty(pos.HoldType))
        {
            throw new ArgumentNullException("terminal_hold_type");
        }
        if (string.IsNullOrEmpty(pos.Type))
        {
            throw new ArgumentNullException("terminal_type");
        }

        switch (type)
        {
        case 1:
            return(pos_service.InsertPosFromAP(pos, customerID));

        case 2:
            return(pos_service.ModifyPosFromAP(pos, customerID));

        default:
            return(false);
        }
    }