Ejemplo n.º 1
0
        public IApiResultModel getAnnualLeave()
        {
            var url    = "http://github.com/";
            var client = httpClientFactory.CreateClient();

            client.Timeout = TimeSpan.FromSeconds(timeOut++);
            var task = client.GetStringAsync(url);
            var back = task.Result;
            var jo   = Newtonsoft.Json.JsonConvert.DeserializeObject <AnnelBack>(back);

            return(ApiResultModel.FromData(jo.UserAnnelNum));
        }
        public IApiResultModel DoConvert([FromBody] ConvertDto dto)
        {
            if (string.IsNullOrWhiteSpace(dto.SolutionName))
            {
                return(ApiResultModel.FromError("解决方案名称不能为空!"));
            }
            if (!convertService.IsProjectPreValid(dto.SolutionName))
            {
                return(ApiResultModel.FromError("解决方案名称不合法,请更换!"));
            }
            if (dto.SolutionName.StartsWith("xLiAd."))
            {
                return(ApiResultModel.FromError("解决方案名称不能以 xLiAd. 开头,请更换!"));
            }
            OptionsSelect optionsSelect = new OptionsSelect()
            {
                Items = dto.Items
            };

            try
            {
                var fileItems = convertService.Convert(dto.SolutionName, optionsSelect);
                using (MemoryStream zipToOpen = new MemoryStream())
                {
                    using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Create))
                    {
                        foreach (var item in fileItems)
                        {
                            var en = archive.CreateEntry(item.FileFullName.TrimStart('/'));
                            using (var stream = en.Open())
                                stream.Write(item.Content, 0, item.Content.Length);
                        }
                    }
                    if (!Directory.Exists(configModel.ZipSavePath))
                    {
                        Directory.CreateDirectory(configModel.ZipSavePath);
                    }
                    var fileName = $"{dto.SolutionName}.{DateTime.Now:yyyy-MM-dd-HH-mm-ss}.zip";
                    var fullName = Path.Combine(configModel.ZipSavePath, fileName);
                    var bs       = zipToOpen.ToArray();
                    using (var fs = new FileStream(fullName, FileMode.Create))
                        fs.Write(bs, 0, bs.Length);
                    return(ApiResultModel.FromData(fileName));
                }
            }
            catch (Exception ex)
            {
                return(ApiResultModel.FromError(ex.Message));
            }
        }
Ejemplo n.º 3
0
        public IApiResultModel TestAopTransaction()
        {
            var maxId = jsonCacheRepository.WhereOrderSelect(x => true, x => x.Id, x => x.Id, 1, true).FirstOrDefault();
            var id    = jsonCacheRepository.Add(new Entities.JsonCache()
            {
                Name  = "测试",
                Value = $"这次取得的最大ID是:{maxId},本记录ID应该是{maxId + 1}"
            });
            var i           = id - id;
            var j           = 1 / i;
            var updateCount = authRoleRepository.UpdateWhere(x => x.Id == 376, x => x.RoleName, "运营审批人1");

            return(ApiResultModel.FromData(updateCount));
        }
 public IApiResultModel GetOptionsConfig()
 {
     return(ApiResultModel.FromData(codeLoader.Options));
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 切片缓存测试方法
        /// </summary>
        /// <returns></returns>
        public IApiResultModel GetModelsByRoleId()
        {
            var result = authRoleRepository.GetModelsByRoleId("RC01");

            return(ApiResultModel.FromData(result));
        }
Ejemplo n.º 6
0
        public IApiResultModel Delete(int id)
        {
            var result = authRoleRepository.Delete(id);

            return(ApiResultModel.FromData(true));
        }
Ejemplo n.º 7
0
        public IApiResultModel Edit(AuthRole authRole)
        {
            var result = authRoleRepository.Update(authRole);

            return(ApiResultModel.FromData(result > 0));
        }
Ejemplo n.º 8
0
        public IApiResultModel Add(AuthRole authRole)
        {
            var id = authRoleRepository.Add(authRole);

            return(ApiResultModel.FromData(true));
        }
Ejemplo n.º 9
0
 public IApiResultModel TestLimit()
 {
     return(ApiResultModel.FromData(true));
 }