コード例 #1
0
        /// <summary>
        /// event chaincode logout
        /// </summary>
        /// <param name="config"></param>
        /// <param name="reqBody"></param>
        /// <returns></returns>
        public Tuple <bool, string> EventRemove(EventRemoveReqBody reqBody)
        {
            try
            {
                NodeApiReqBody <EventRemoveReqBody> req = new NodeApiReqBody <EventRemoveReqBody>
                {
                    header = new ReqHeader()
                    {
                        appCode  = config.appInfo.AppCode,
                        userCode = config.userCode
                    },
                    body = new EventRemoveReqBody()
                    {
                        eventId = reqBody.eventId
                    }
                };
                //assemble the original string to sign
                var data = ReqMacExtends.EventRemoveReqMac(req);
                //sign data
                req.mac = sign.Sign(data);

                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>(false, res.header.msg));
                    }
                    //assemble the original string to sign
                    var datares = ResMacExtends.GetResHeaderMac(res.header);

                    //verify data
                    if (sign.Verify(res.mac, datares))
                    {
                        return(new Tuple <bool, string>(true, res.header.msg));
                    }
                    else
                    {
                        return(new Tuple <bool, string>(false, "failed to sign the signature"));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(new Tuple <bool, string>(false, "failed to logout event chaincode"));
        }
コード例 #2
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));
        }