示例#1
0
        public async Task <int> CopyAsync(int profileId)
        {
            if (profileId <= 0)
            {
                return(ToResponse(0, "Dữ liệu không hợp lệ"));
            }

            var profileResult = await _rpMCredit.GetTemProfileByIdAsync(profileId);

            if (profileResult.data == null || !profileResult.success)
            {
                return(ToResponse(0, profileResult.error));
            }

            profileResult.data.MCId      = string.Empty;
            profileResult.data.UpdatedBy = 0;
            profileResult.data.Status    = 0;
            var createResult = await _rpMCredit.CreateDraftProfileAsync(profileResult.data);

            if (createResult.data > 0)
            {
                await _rpFile.CopyFileFromProfileAsync(profileId, (int)ProfileType.MCredit, createResult.data);

                await _rpMCredit.DeleteByIdAsync(profileId);

                return(createResult.data);
            }

            return(ToResponse(0, createResult.error));
        }
示例#2
0
        protected async Task <List <FileProfile> > GetFileUploadMcreditAsync(int profileId, string mcId = null, string webRootPath = null)
        {
            var profile = await _rpMCredit.GetTemProfileByIdAsync(profileId);

            if (!profile.success || profile.data == null)
            {
                return(ToResponse <List <FileProfile> >(null, "Hồ sơ không tồn tại"));
            }

            if (string.IsNullOrWhiteSpace(profile.data.ProductCode))
            {
                return(ToResponse <List <FileProfile> >(null, "Vui lòng chọn sản phẩm vay"));
            }

            if (string.IsNullOrWhiteSpace(profile.data.LocSignCode))
            {
                return(ToResponse <List <FileProfile> >(null, "Vui lòng chọn địa điểm ký văn kiện"));
            }

            var data = await _svMcredit.GetFileUpload(new GetFileUploadRequest
            {
                Code    = profile.data.ProductCode.Trim(),
                Id      = "0",
                Loccode = profile.data.LocSignCode.Trim(),
                Issl    = profile.data.IsAddr ? "1" : "0",
                Money   = profile.data.LoanMoney.ToString().Replace(",0000", "")
            });

            await _rpLog.InsertLog($"mcredit-GetFileUpload-{mcId}", data.Dump());

            if (!data.success)
            {
                return(ToResponse <List <FileProfile> >(null, data.error));
            }
            var uploadedFiles = new List <FileUploadModel>();

            if (profileId > 0)
            {
                uploadedFiles = await _rpFile.GetFilesByProfileIdAsync((int)ProfileType.MCredit, profileId);
            }
            if (uploadedFiles == null)
            {
                uploadedFiles = new List <FileUploadModel>();
            }
            var result = new List <FileProfile>();
            var groups = data.data.Groups;

            foreach (var group in groups)
            {
                if (group.Documents == null)
                {
                    continue;
                }

                foreach (var doc in group.Documents)
                {
                    if (group.GroupId == 24 && doc.DocumentCode == "ElectricBill")
                    {
                        continue;
                    }
                    var files = uploadedFiles.Where(p => p.Key == doc.Id && p.MC_GroupId == group.GroupId);
                    result.Add(new FileProfile
                    {
                        Id             = doc.Id,
                        FileKey        = doc.Id,
                        RootPath       = webRootPath,
                        IsRequire      = group.Mandatory ? 1 : 0,
                        Name           = doc.DocumentName,
                        DocumentId     = doc.Id,
                        GroupId        = group.GroupId,
                        GroupName      = group.GroupName,
                        IsRequireGroup = group.Mandatory,
                        DocumentCode   = doc.DocumentCode,
                        MapBpmVar      = doc.MapBpmVar,
                        ProfileId      = profileId,
                        ProfileTypeId  = (int)ProfileType.MCredit,
                        DocumentName   = doc.DocumentName,
                        ProfileFiles   = files.ToList(),
                        AllowUpload    = string.IsNullOrWhiteSpace(profile.data.MCId)
                    });
                }
            }
            result = result.OrderByDescending(p => p.IsRequire == 1).ToList();
            return(result);
        }