Esempio n. 1
0
        /// <summary>
        /// 呼叫
        /// </summary>
        /// <param name="method">HttpMethod</param>
        /// <param name="path">资源路径(比如"/api/security/myself")</param>
        /// <param name="data">上传数据</param>
        /// <param name="encryptData">是否加密上传数据(服务端的控制器代码请用Request.ReadBodyXXX(true)解密)(如果data是HttpContent则忽略)</param>
        /// <param name="paramValues">参数值</param>
        public async Task CallAsync(HttpMethod method, string path, object data, bool encryptData, params NameValue[] paramValues)
        {
            if (String.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            if (Identity == null)
            {
                throw new AuthenticationException();
            }
            if (!Identity.IsAuthenticated)
            {
                throw new UserVerifyException();
            }

            using (HttpRequestMessage request = new HttpRequestMessage(method, BuildUri(path, paramValues)))
            {
                if (data != null)
                {
                    if (data is HttpContent httpContent)
                    {
                        request.Content = httpContent;
                    }
                    else
                    {
                        if (data is NameValue[] nameValues)
                        {
                            data = NameValue.ToDictionary(nameValues);
                        }
                        request.Content = new StringContent(encryptData ? Identity.User.Encrypt(Utilities.JsonSerialize(data)) : Utilities.JsonSerialize(data), Encoding.UTF8);
                    }
                }

                using (HttpResponseMessage response = await SendAsync(request))
                {
                    await response.ThrowIfFailedAsync();
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 新增从业务对象(自动填充主键和保留字段)
 /// </summary>
 /// <param name="propertyValues">待更新属性值队列</param>
 /// <returns>业务对象</returns>
 public new TDetail NewDetail <TDetail>(params NameValue <TDetail>[] propertyValues)
     where TDetail : BusinessBase <TDetail>
 {
     return(NewDetail <TDetail>(NameValue <TDetail> .ToDictionary(propertyValues)));
 }
 Task ITreeEntityGrain <TKernel> .UpdateNode(long id, params NameValue <TKernel>[] propertyValues)
 {
     UpdateNode(id, NameValue <TKernel> .ToDictionary(propertyValues));
     return(Task.CompletedTask);
 }
Esempio n. 4
0
 /// <summary>
 /// 新增根实体对象(自动填充保留字段)
 /// </summary>
 /// <param name="database">数据库入口</param>
 /// <param name="id">主键值</param>
 /// <param name="propertyValues">待更新属性值队列(如果没有set语句的话就直接更新字段)</param>
 /// <returns>根实体对象</returns>
 public static T NewRoot(Database database, long id, params NameValue <T>[] propertyValues)
 {
     return(NewRoot(database, id, NameValue <T> .ToDictionary(propertyValues)));
 }
 Task <long> ITreeEntityGrain <TKernel> .AddChildNode(long parentId, params NameValue <TKernel>[] propertyValues)
 {
     return(Task.FromResult(AddChildNode(parentId, NameValue <TKernel> .ToDictionary(propertyValues))));
 }
Esempio n. 6
0
 Task IEntityGrain <TKernel> .PatchKernel(params NameValue <TKernel>[] propertyValues)
 {
     return(PatchKernel(NameValue <TKernel> .ToDictionary(propertyValues)));
 }
Esempio n. 7
0
 Task IEntityGrain.PutKernel(params NameValue[] propertyValues)
 {
     return(PutKernel(NameValue.ToDictionary(propertyValues)));
 }
Esempio n. 8
0
 Task IEntityGrain.PutKernel(NameValue propertyValue, bool throwIfFound, bool?throwIfNotOwn)
 {
     return(PutKernel(NameValue.ToDictionary(propertyValue), throwIfFound, throwIfNotOwn));
 }
Esempio n. 9
0
 Task IEntityGrain.PatchKernel(params NameValue[] propertyValues)
 {
     PatchKernel(NameValue.ToDictionary(propertyValues));
     return(Task.CompletedTask);
 }