Activities of "sunivycsm"

@liangshiwei Here is my source code. When I add AsNoTracking I get the following error: Should I add any additional libraries?

using CMCUNI_THUCTAP.NganhHocs; using Volo.Abp.Identity; using CMCUNI_THUCTAP.TrinhDos; using CMCUNI_THUCTAP.Khoas; using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Threading.Tasks; using System.Linq.Dynamic.Core; using Microsoft.AspNetCore.Authorization; using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Repositories; using CMCUNI_THUCTAP.Permissions; using CMCUNI_THUCTAP.GiangViens; using MiniExcelLibs; using Volo.Abp.Content; using Volo.Abp.Authorization; using Volo.Abp.Caching; using Microsoft.Extensions.Caching.Distributed; using CMCUNI_THUCTAP.Shared;

namespace CMCUNI_THUCTAP.GiangViens {

[Authorize(CMCUNI_THUCTAPPermissions.GiangViens.Default)]
public abstract class GiangViensAppServiceBase : CMCUNI_THUCTAPAppService
{
    protected IDistributedCache<GiangVienExcelDownloadTokenCacheItem, string> _excelDownloadTokenCache;
    protected IGiangVienRepository _giangVienRepository;
    protected GiangVienManager _giangVienManager;
    protected IRepository<Khoa, Guid> _khoaRepository;
    protected IRepository<TrinhDo, Guid> _trinhDoRepository;
    protected IRepository<IdentityUser, Guid> _identityUserRepository;
    protected IRepository<NganhHoc, Guid> _nganhHocRepository;

    public GiangViensAppServiceBase(IGiangVienRepository giangVienRepository, GiangVienManager giangVienManager, IDistributedCache<GiangVienExcelDownloadTokenCacheItem, string> excelDownloadTokenCache, IRepository<Khoa, Guid> khoaRepository, IRepository<TrinhDo, Guid> trinhDoRepository, IRepository<IdentityUser, Guid> identityUserRepository, IRepository<NganhHoc, Guid> nganhHocRepository)
    {
        _excelDownloadTokenCache = excelDownloadTokenCache;
        _giangVienRepository = giangVienRepository;
        _giangVienManager = giangVienManager; _khoaRepository = khoaRepository;
        _trinhDoRepository = trinhDoRepository;
        _identityUserRepository = identityUserRepository;
        _nganhHocRepository = nganhHocRepository;
    }

    public virtual async Task<PagedResultDto<GiangVienWithNavigationPropertiesDto>> GetListAsync(GetGiangViensInput input)
    {
        var totalCount = await _giangVienRepository.GetCountAsync(input.FilterText, input.MaGiangVien, input.TenGiangVien, input.KhoaId, input.TrinhDoId, input.IdentityUserId, input.NganhHocId);
        var items = await _giangVienRepository.GetListWithNavigationPropertiesAsync(input.FilterText, input.MaGiangVien, input.TenGiangVien, input.KhoaId, input.TrinhDoId, input.IdentityUserId, input.NganhHocId, input.Sorting, input.MaxResultCount, input.SkipCount);

        return new PagedResultDto<GiangVienWithNavigationPropertiesDto>
        {
            TotalCount = totalCount,
            Items = ObjectMapper.Map<List<GiangVienWithNavigationProperties>, List<GiangVienWithNavigationPropertiesDto>>(items)
        };
    }

    public virtual async Task<GiangVienWithNavigationPropertiesDto> GetWithNavigationPropertiesAsync(Guid id)
    {
        return ObjectMapper.Map<GiangVienWithNavigationProperties, GiangVienWithNavigationPropertiesDto>
            (await _giangVienRepository.GetWithNavigationPropertiesAsync(id));
    }

    public virtual async Task<GiangVienDto> GetAsync(Guid id)
    {
        return ObjectMapper.Map<GiangVien, GiangVienDto>(await _giangVienRepository.GetAsync(id));
    }

    public virtual async Task<PagedResultDto<LookupDto<Guid>>> GetKhoaLookupAsync(LookupRequestDto input)
    {
        var query = (await _khoaRepository.GetQueryableAsync())
            .WhereIf(!string.IsNullOrWhiteSpace(input.Filter),
                x => x.TenKhoa != null &&
                     x.TenKhoa.Contains(input.Filter));

        var lookupData = await query.PageBy(input.SkipCount, input.MaxResultCount).ToDynamicListAsync<Khoa>();
        var totalCount = query.Count();
        return new PagedResultDto<LookupDto<Guid>>
        {
            TotalCount = totalCount,
            Items = ObjectMapper.Map<List<Khoa>, List<LookupDto<Guid>>>(lookupData)
        };
    }

    public virtual async Task<PagedResultDto<LookupDto<Guid>>> GetTrinhDoLookupAsync(LookupRequestDto input)
    {
        var query = (await _trinhDoRepository.GetQueryableAsync())
            .WhereIf(!string.IsNullOrWhiteSpace(input.Filter),
                x => x.TenTrinhDo != null &&
                     x.TenTrinhDo.Contains(input.Filter));

        var lookupData = await query.PageBy(input.SkipCount, input.MaxResultCount).ToDynamicListAsync<TrinhDo>();
        var totalCount = query.Count();
        return new PagedResultDto<LookupDto<Guid>>
        {
            TotalCount = totalCount,
            Items = ObjectMapper.Map<List<TrinhDo>, List<LookupDto<Guid>>>(lookupData)
        };
    }

    public virtual async Task<PagedResultDto<LookupDto<Guid>>> GetIdentityUserLookupAsync(LookupRequestDto input)
    {
        var query = (await _identityUserRepository.GetQueryableAsync())
            .WhereIf(!string.IsNullOrWhiteSpace(input.Filter),
                x => x.Name != null &&
                     x.Name.Contains(input.Filter));

        var lookupData = await query.PageBy(input.SkipCount, input.MaxResultCount).ToDynamicListAsync<IdentityUser>();
        var totalCount = query.Count();
        return new PagedResultDto<LookupDto<Guid>>
        {
            TotalCount = totalCount,
            Items = ObjectMapper.Map<List<IdentityUser>, List<LookupDto<Guid>>>(lookupData)
        };
    }

    public virtual async Task<PagedResultDto<LookupDto<Guid>>> GetNganhHocLookupAsync(LookupRequestDto input)
    {
        var query = (await _nganhHocRepository.GetQueryableAsync())
            .WhereIf(!string.IsNullOrWhiteSpace(input.Filter),
                x => x.TenNganh != null &&
                     x.TenNganh.Contains(input.Filter));

        var lookupData = await query.PageBy(input.SkipCount, input.MaxResultCount).ToDynamicListAsync<NganhHoc>();
        var totalCount = query.Count();
        return new PagedResultDto<LookupDto<Guid>>
        {
            TotalCount = totalCount,
            Items = ObjectMapper.Map<List<NganhHoc>, List<LookupDto<Guid>>>(lookupData)
        };
    }

    [Authorize(CMCUNI_THUCTAPPermissions.GiangViens.Delete)]
    public virtual async Task DeleteAsync(Guid id)
    {
        await _giangVienRepository.DeleteAsync(id);
    }

    [Authorize(CMCUNI_THUCTAPPermissions.GiangViens.Create)]
    public virtual async Task<GiangVienDto> CreateAsync(GiangVienCreateDto input)
    {
        if (input.KhoaId == default)
        {
            throw new UserFriendlyException(L["The {0} field is required.", L["Khoa"]]);
        }
        if (input.TrinhDoId == default)
        {
            throw new UserFriendlyException(L["The {0} field is required.", L["TrinhDo"]]);
        }

        var giangVien = await _giangVienManager.CreateAsync(
        input.NganhHocIds, input.KhoaId, input.TrinhDoId, input.IdentityUserId, input.MaGiangVien, input.TenGiangVien
        );

        return ObjectMapper.Map<GiangVien, GiangVienDto>(giangVien);
    }

    [Authorize(CMCUNI_THUCTAPPermissions.GiangViens.Edit)]
    public virtual async Task<GiangVienDto> UpdateAsync(Guid id, GiangVienUpdateDto input)
    {
        if (input.KhoaId == default)
        {
            throw new UserFriendlyException(L["The {0} field is required.", L["Khoa"]]);
        }
        if (input.TrinhDoId == default)
        {
            throw new UserFriendlyException(L["The {0} field is required.", L["TrinhDo"]]);
        }

        var giangVien = await _giangVienManager.UpdateAsync(
        id,
        input.NganhHocIds, input.KhoaId, input.TrinhDoId, input.IdentityUserId, input.MaGiangVien, input.TenGiangVien, input.ConcurrencyStamp
        );

        return ObjectMapper.Map<GiangVien, GiangVienDto>(giangVien);
    }

    [AllowAnonymous]
    public virtual async Task<IRemoteStreamContent> GetListAsExcelFileAsync(GiangVienExcelDownloadDto input)
    {
        var downloadToken = await _excelDownloadTokenCache.GetAsync(input.DownloadToken);
        if (downloadToken == null || input.DownloadToken != downloadToken.Token)
        {
            throw new AbpAuthorizationException("Invalid download token: " + input.DownloadToken);
        }

        var giangViens = await _giangVienRepository.GetListWithNavigationPropertiesAsync(input.FilterText, input.MaGiangVien, input.TenGiangVien, input.KhoaId, input.TrinhDoId, input.IdentityUserId, input.NganhHocId);
        var items = giangViens.Select(item => new
        {
            MaGiangVien = item.GiangVien.MaGiangVien,
            TenGiangVien = item.GiangVien.TenGiangVien,

            Khoa = item.Khoa?.TenKhoa,
            TrinhDo = item.TrinhDo?.TenTrinhDo,
            IdentityUser = item.IdentityUser?.Name,

        });

        var memoryStream = new MemoryStream();
        await memoryStream.SaveAsAsync(items);
        memoryStream.Seek(0, SeekOrigin.Begin);

        return new RemoteStreamContent(memoryStream, "GiangViens.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
    }

    public virtual async Task<CMCUNI_THUCTAP.Shared.DownloadTokenResultDto> GetDownloadTokenAsync()
    {
        var token = Guid.NewGuid().ToString("N");

        await _excelDownloadTokenCache.SetAsync(
            token,
            new GiangVienExcelDownloadTokenCacheItem { Token = token },
            new DistributedCacheEntryOptions
            {
                AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(30)
            });

        return new CMCUNI_THUCTAP.Shared.DownloadTokenResultDto
        {
            Token = token
        };
    }
}

}

Sorry, this code doesn't work.

I am selecting user _identityUserRepository.

  var query = (await _identityUserRepository.GetQueryableAsync())
      .WhereIf(!string.IsNullOrWhiteSpace(input.Filter),
          x => x.Name != null &&
               x.Name.Contains(input.Filter));

But when I use the following code, it is automatically saved in the datatable.
foreach (var item in query)
{
     item.Name = item.Surname + item.Name;
}

Is there a way I can edit the data without automatically updating it to the database? Here is all my source information:

public virtual async Task<PagedResultDto<LookupDto<Guid>>> GetIdentityUserLookupAsync(LookupRequestDto input)
{
    var query = (await _identityUserRepository.GetQueryableAsync())
        .WhereIf(!string.IsNullOrWhiteSpace(input.Filter),
            x => x.Name != null &&
                 x.Name.Contains(input.Filter));

    foreach (var item in query)
    {
        item.Name = item.Surname + item.Name
    }

    var lookupData = await query.PageBy(input.SkipCount, input.MaxResultCount).ToDynamicListAsync<IdentityUser>();
    var totalCount = query.Count();
    return new PagedResultDto<LookupDto<Guid>>
    {
        TotalCount = totalCount,
        Items = ObjectMapper.Map<List<IdentityUser>, List<LookupDto<Guid>>>(lookupData)
    };
}
  • ABP Framework version: v7.4.1
  • UI Type: MVC
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes/no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Hi, Thank you. I will give it a try.

Hello, What should I do next?

Question

**ABP Framework version: v7.4.1

UI Type: MVC

Database System: EF Core (SQL Server)

Tiered (for MVC) or Auth Server Separated (for Angular): no

Exception message and full stack trace:

Steps to reproduce the issue:**

Hi,

I want to publish my abp.Web project to Docker. But when I configure docker in publish, the project cannot be published. Is there any documentation that can guide me through configuring or handling this? Thank you.

I found the cause. The reason is because my server lost some services. Thank you for your help.

Hi, I didn't find any such code in my source. ! image.png

Hi,

I guess you are using the Response compression.

Can you try to disable it to test again?

Where can I turn them off?

Showing 1 to 10 of 52 entries
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11