Exemplo n.º 1
0
        /// <summary>
        /// 插入记录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string SetExamRecord(RecordModel model)
        {
            string orderId         = $"order_{Guid.NewGuid()}";
            string contractName    = "ExamRecord4";
            string methodSignature = "setExamRecord(string,string,string,string,string,string,string,string,string,string,string,string)";

            List <string> list = new List <string>()
            {
                model.RecordId,
                model.ExamId,
                model.PatientName,
                model.ExamNumber,
                model.ExamDate.ToString("yyyy-MM-dd HH:mm"),
                model.UploadDate.ToString("yyyy-MM-dd HH:mm"),
                model.Uploader,
                model.Operation,
                model.Operator,
                model.PowerUser,
                model.PowerDate.ToString("yyyy-MM-dd HH:mm"),
                model.PowerNote
            };
            string paramListStr          = JsonSerializer.Serialize(list);
            AntChainRequestResult result = chainHelper.CallSolidityContract(orderId, contractName, methodSignature, paramListStr);

            if (!result.Success)
            {
                throw new Exception($"Set Record Error,Error Code :{result.Code}");
            }
            return(result.Data);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 刷新AccessToken
        /// </summary>
        private void RefreshAccessToken()
        {
            string url = $"{ApiUrl}api/contract/shakeHand";

            DateTime dt     = DateTime.Now;
            long     time   = ConvertDateTime(dt);
            string   secret = CertUtil.Sign($"{Config.AccessId}{time}", Config.AccessKey);

            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("accessId", Config.AccessId);
            dic.Add("time", time);
            dic.Add("secret", secret);
            AntChainRequestResult result = Post <AntChainRequestResult>(url, dic);

            if (!result.Success)
            {
                throw new Exception($"Error Code :{result.Code}");
            }
            accessToken           = result.Data;
            AccessTokenExpireTime = DateTime.Now.AddSeconds(30 * 60);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 执行Solidity合约交易
        /// </summary>
        public AntChainRequestResult CallSolidityContract(string orderId, string contractName, string methodSignature, string paramListStr, string outTypes = "[\"string\"]")
        {
            string url = $"{ApiUrl}api/contract/chainCallForBiz";

            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("orderId", orderId);
            dic.Add("bizid", Bizid);
            dic.Add("account", Config.Account);
            dic.Add("contractName", contractName);
            dic.Add("methodSignature", methodSignature);
            dic.Add("mykmsKeyId", Config.MykmsKeyId);
            dic.Add("method", Method.CALLCONTRACTBIZASYNC.ToString());
            dic.Add("inputParamListStr", paramListStr);
            dic.Add("outTypes", outTypes);
            dic.Add("accessId", Config.AccessId);
            dic.Add("token", AccessToken);
            dic.Add("gas", 10000000);
            dic.Add("tenantid", Config.TenantId);
            AntChainRequestResult result = Post <AntChainRequestResult>(url, dic);

            return(result);
        }