Exemplo n.º 1
0
        /// <summary>
        /// event  logout
        /// </summary>
        /// <returns></returns>
        public Tuple <bool, string, NodeApiRes> EventRemove(RemoveReqDataBody reqBody)
        {
            try
            {
                NodeApiReqBody <RemoveReqDataBody> req = new NodeApiReqBody <RemoveReqDataBody>()
                {
                    header = GetReqHeader(),
                    body   = reqBody
                };
                req.mac = sign.Sign(FiscoReqMacExtends.GetFiscoEventRemoveReqMac(req));
                var res = SendHelper.SendPost <NodeApiRes>(config.reqUrl + EventremoveUrl, JsonConvert.SerializeObject(req), config.httpsCert);

                if (res != null)
                {
                    //Check the status codes in turn
                    if (res.header.code != 0)
                    {
                        return(new Tuple <bool, string, NodeApiRes>(false, res.header.msg, null));
                    }
                    //assemble the original string to verify
                    var datares = ResMacExtends.GetResHeaderMac(res.header);
                    //data verified
                    if (sign.Verify(res.mac, datares))
                    {
                        return(new Tuple <bool, string, NodeApiRes>(true, res.header.msg, res));
                    }
                    else
                    {
                        return(new Tuple <bool, string, NodeApiRes>(false, "failed to verify the signature", null));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(new Tuple <bool, string, NodeApiRes>(false, "failed to logout event chaincode", null));
        }