Ejemplo n.º 1
0
        public IActionResult GetPaging(BaseCondition <DigitalSignature> condition)
        {
            var result = digitalSignatureBUS.GetPaging(condition);

            for (int i = 0; i < result.ItemList.Count; i++)
            {
                result.ItemList[i].Base64String = FilesUtillities.ConvertImageToBase64String(result.ItemList[i].Path);
            }
            return(Ok(result));
        }
Ejemplo n.º 2
0
        public IActionResult GetPaging([FromBody] BaseCondition <DigitalSignature> condition)
        {
            var result = digitalSignatureBUS.GetPaging(condition);

            for (int i = 0; i < result.ItemList.Count; i++)
            {
                var path = Path.Combine(Const.FILE_UPLOAD_DIGITAL_SIGNATURE, result.ItemList[i].FileName);
                result.ItemList[i].Base64String = FilesUtillities.ConvertImageToBase64String(path);
            }
            return(Ok(result));
        }
        public IActionResult UpdateDocument([FromBody] Document document, [FromQuery] string name = "", [FromQuery] string docPath = "")
        {
            DocumentBUS documentBUS  = new DocumentBUS();
            bool        hasSignature = false;

            if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(docPath))
            {
                hasSignature = FilesUtillities.InsertSignatureIntoDocument(name, docPath);
            }
            if (hasSignature)
            {
                document.Signature = 1;
            }
            var result = documentBUS.UpdateDocument(document);

            return(Ok(result));
        }
Ejemplo n.º 4
0
        public IActionResult CreateSignature()
        {
            var signature = Request.Form["signatureInfo"];
            DigitalSignature digitalSignature      = Libs.DeserializeObject <DigitalSignature>(signature.ToString());
            ReturnResult <DigitalSignature> result = new ReturnResult <DigitalSignature>();
            string fileNameExists = string.Empty;

            try
            {
                IFormFile file      = Request.Form.Files["file"]; // danh sách file
                string    overwrite = Request.Form["overwrite"].ToString();
                string    filePath  = Path.Combine(Const.FILE_UPLOAD_DIGITAL_SIGNATURE);
                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                }
                filePath = Path.Combine(Const.FILE_UPLOAD_DIGITAL_SIGNATURE, file.FileName);
                int overwriteValue = 0;

                if (file.Length > 0)
                {
                    // check exists
                    string[] lstFileAlreadyExists = Directory.GetFiles(Const.FILE_UPLOAD_DIGITAL_SIGNATURE);
                    if (lstFileAlreadyExists.Length > 0)
                    {
                        foreach (var item in lstFileAlreadyExists)
                        {
                            if (Path.GetFileName(item) == file.FileName)
                            {
                                fileNameExists = file.FileName;
                            }
                        }

                        if (!string.IsNullOrEmpty(fileNameExists))
                        {
                            if (overwrite == "1")
                            {
                                overwriteValue = 1;
                                System.IO.File.Delete(filePath);
                                FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                            }
                            else
                            {
                                var fileResult = new ReturnResult <ComputerFile>()
                                {
                                    ReturnValue = file.FileName
                                };
                                fileResult.Failed("-2", "Tồn tại file đã được upload lên hệ thống.");
                                return(Ok(fileResult));
                            }
                        }
                        else
                        {
                            FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                        }
                    }
                    else
                    {
                        FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                    }
                    digitalSignature.Path       = filePath;
                    digitalSignature.ServerPath = Const.DIGITAL_SIGNATURE_FOLDER + file.FileName;
                }

                // send information
                result = digitalSignatureBUS.Create(digitalSignature, overwriteValue);
                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(Ok(ex));
            }
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> ProfilesAddNewAndUploadFile()
        {
            IFormCollection form;

            form = await Request.ReadFormAsync();

            object   obj3    = Request.Form["profile"]; // object
            Profiles profile = Libs.DeserializeObject <Profiles>(obj3.ToString());
            ReturnResult <Profiles> result = new ReturnResult <Profiles>();

            try
            {
                ICollection <IFormFile> files          = Request.Form.Files.ToList(); // danh sách file
                List <ComputerFile>     lstFilesExists = new List <ComputerFile>();
                List <ComputerFile>     lstFileInfo    = new List <ComputerFile>();

                string directoryPathFileUpload = Const.FILE_UPLOAD_DIR + profile.FileCode;
                //string directoryPathFileUpload = Path.Combine(path, profile.FileCode);
                var profileCheck = profileBUS.GetProfileByFileCode(profile.FileCode);
                if (Directory.Exists(directoryPathFileUpload) || profile.FileCode == profileCheck.Item.FileCode)
                {
                    result.Failed("-3", "Tồn tại hồ sơ có mã hồ sơ " + profile.FileCode + " trên hệ thống, vui lòng thử lại.");
                    return(Ok(result));
                }
                Directory.CreateDirectory(directoryPathFileUpload);
                if (files.Count > 0)
                {
                    // upload file lên server
                    foreach (var file in files)
                    {
                        var fileExtension = file.FileName.Split('.');
                        if (fileExtension.Length != 0)
                        {
                            if (fileExtension[1].Equals("pdf"))
                            {
                                var filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                                FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                            }
                        }
                    }

                    // lấy lại danh sách file đã được tải lên
                    string[]            lstDirFilesUploaded = Directory.GetFiles(directoryPathFileUpload);
                    List <ComputerFile> lstFiles            = new List <ComputerFile>();
                    foreach (var fileUrl in lstDirFilesUploaded)
                    {
                        string fileName = Path.GetFileName(fileUrl);
                        foreach (var file in files)
                        {
                            if (fileName.Equals(file.FileName))
                            {
                                lstFiles.Add(new ComputerFile()
                                {
                                    FileName   = file.FileName,
                                    Size       = (Math.Round((double)(file.Length / 1000000.0), 6)).ToString(),
                                    Url        = fileUrl,
                                    PageNumber = GetNumberOfPdfPages(fileUrl),
                                    CreatedBy  = profile.CreatedBy,
                                    FolderPath = directoryPathFileUpload,
                                    ClientUrl  = Const.FILE_SERVER_FOLDER + profile.FileCode + "/" + file.FileName
                                });
                            }
                        }
                    }

                    result = profileBUS.Create(profile, lstFiles);
                }
                else
                {
                    // không tải file lên thì chỉ send thông tin hồ sơ
                    result = profileBUS.Create(profile);
                }
                return(Ok(result));
            }
            catch (Exception ex)
            {
                result.Failed("1", ex.Message);
                return(Ok(result));
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> ProfileUpdate()
        {
            IFormCollection         form;
            object                  obj3    = Request.Form["profile"]; // object
            Profiles                profile = Libs.DeserializeObject <Profiles>(obj3.ToString());
            ReturnResult <Profiles> result  = new ReturnResult <Profiles>();

            try
            {
                ICollection <IFormFile> files          = Request.Form.Files.ToList();
                List <ComputerFile>     lstFilesExists = new List <ComputerFile>();
                List <ComputerFile>     lstFileInfo    = new List <ComputerFile>();
                List <ComputerFile>     lstFiles       = new List <ComputerFile>();

                string path = Libs.GetFullPathDirectoryFileUpload();

                string directoryPathFileUpload = Const.FILE_UPLOAD_DIR + profile.FileCode;

                //string directoryPathFileUpload = Path.Combine(path, profile.FileCode);
                if (!Directory.Exists(directoryPathFileUpload))
                {
                    // FileCode changed
                    //    string[] directories = Directory.GetDirectories(Const.FILE_UPLOAD_DIR);
                    var    profileCheck       = profileBUS.GetProfileByID(profile.ProfileId);
                    string directoryOfProfile = Path.Combine(path, profileCheck.Item.FileCode);
                    if (Directory.Exists(directoryOfProfile))
                    {
                        Directory.Move(directoryOfProfile, directoryPathFileUpload);
                    }
                    else
                    {
                        Directory.CreateDirectory(directoryPathFileUpload);
                    }
                    if (files.Count > 0)
                    {
                        string[] lstFilesDir = Directory.GetFiles(directoryPathFileUpload);
                        if (lstFilesDir.Length > 0)
                        {
                            string[] lstDirFilesUpload = lstFilesDir;
                            foreach (var fileAlreadyExsists in lstDirFilesUpload)
                            {
                                foreach (var file in files)
                                {
                                    if (fileAlreadyExsists.IndexOf(file.FileName) > -1)
                                    {
                                        lstFilesExists.Add(new ComputerFile()
                                        {
                                            FileName  = Path.GetFileName(fileAlreadyExsists),
                                            ProfileId = profile.ProfileId,
                                            Url       = fileAlreadyExsists
                                        });
                                    }
                                }
                            }
                            string overwrite = Request.Form["overwrite"].ToString();
                            if (lstFilesExists.Count > 0)
                            {
                                if (overwrite == "accept")
                                {
                                    foreach (var fileAlreadyExists in lstFilesExists)
                                    {
                                        System.IO.File.Delete(fileAlreadyExists.Url);
                                    }
                                    //    overwrite file already exists
                                    foreach (var file in files)
                                    {
                                        string filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                                        FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                                    }
                                }
                                else
                                {
                                    var fileResult = new ReturnResult <ComputerFile>()
                                    {
                                        ReturnValue = Libs.SerializeObject(lstFilesExists.Select(item => item.FileName))
                                    };
                                    fileResult.Failed("-2", "Tồn tại file đã được upload lên hệ thống.");
                                    return(Ok(fileResult));
                                }
                            }
                            else
                            {
                                foreach (var file in files)
                                {
                                    var filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                                    FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                                }
                            }
                        }
                        else
                        {
                            foreach (var file in files)
                            {
                                var filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                                FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                            }
                        }
                        // lấy lại danh sách file đã được tải lên
                        string[] lstDirFilesUploaded = Directory.GetFiles(directoryPathFileUpload);
                        foreach (var fileUrl in lstDirFilesUploaded)
                        {
                            string fileName = Path.GetFileName(fileUrl);
                            foreach (var file in files)
                            {
                                if (fileName.Equals(file.FileName))
                                {
                                    lstFiles.Add(new ComputerFile()
                                    {
                                        FileName   = file.FileName,
                                        Size       = (Math.Round((double)(file.Length / 1000000.0), 6)).ToString(),
                                        Url        = fileUrl,
                                        PageNumber = GetNumberOfPdfPages(fileUrl),
                                        CreatedBy  = profile.CreatedBy,
                                        FolderPath = directoryPathFileUpload,
                                        ClientUrl  = Const.FILE_SERVER_FOLDER + profile.FileCode + "/" + HttpUtility.HtmlEncode(fileName)
                                    });
                                }
                            }
                        }

                        result = profileBUS.Update(profile, lstFiles, lstFilesExists, directoryPathFileUpload);
                    }
                    else
                    {
                        // không tải file lên thì chỉ send thông tin hồ sơ
                        result = profileBUS.Update(profile, null, null, directoryPathFileUpload);
                    }
                }
                else
                {
                    if (files.Count > 0)
                    {
                        string[] lstFilesDir = Directory.GetFiles(directoryPathFileUpload);
                        if (lstFilesDir.Length > 0)
                        {
                            string[] lstDirFilesUpload = lstFilesDir;
                            foreach (var fileAlreadyExsists in lstDirFilesUpload)
                            {
                                foreach (var file in files)
                                {
                                    if (fileAlreadyExsists.IndexOf(file.FileName) > -1)
                                    {
                                        lstFilesExists.Add(new ComputerFile()
                                        {
                                            FileName  = Path.GetFileName(fileAlreadyExsists),
                                            ProfileId = profile.ProfileId,
                                            Url       = fileAlreadyExsists
                                        });
                                    }
                                }
                            }
                            string overwrite = Request.Form["overwrite"].ToString();
                            if (lstFilesExists.Count > 0)
                            {
                                if (overwrite == "accept")
                                {
                                    foreach (var fileAlreadyExists in lstFilesExists)
                                    {
                                        System.IO.File.Delete(fileAlreadyExists.Url);
                                    }

                                    //    overwrite file already exists
                                    foreach (var file in files)
                                    {
                                        string filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                                        FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                                    }
                                }
                                else
                                {
                                    var fileResult = new ReturnResult <ComputerFile>()
                                    {
                                        ReturnValue = Libs.SerializeObject(lstFilesExists.Select(item => item.FileName))
                                    };

                                    fileResult.Failed("-2", "Tồn tại file đã được upload lên hệ thống.");
                                    return(Ok(fileResult));
                                }
                            }
                            else
                            {
                                foreach (var file in files)
                                {
                                    var filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                                    FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                                }
                            }
                        }
                        else
                        {
                            foreach (var file in files)
                            {
                                var filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                                FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                            }
                        }
                        // lấy lại danh sách file đã được tải lên
                        string[] lstDirFilesUploaded = Directory.GetFiles(directoryPathFileUpload);
                        foreach (var fileUrl in lstDirFilesUploaded)
                        {
                            string fileName = Path.GetFileName(fileUrl);
                            foreach (var file in files)
                            {
                                if (fileName.Equals(file.FileName))
                                {
                                    lstFiles.Add(new ComputerFile()
                                    {
                                        FileName   = file.FileName,
                                        Size       = (Math.Round((double)(file.Length / 1000000.0), 6)).ToString(),
                                        Url        = fileUrl,
                                        PageNumber = GetNumberOfPdfPages(fileUrl),
                                        CreatedBy  = profile.CreatedBy,
                                        FolderPath = directoryPathFileUpload,
                                        ClientUrl  = Const.FILE_SERVER_FOLDER + profile.FileCode + "/" + HttpUtility.HtmlEncode(fileName)
                                    });
                                }
                            }
                        }
                        result = profileBUS.Update(profile, lstFiles, lstFilesExists, directoryPathFileUpload);
                    }
                    else
                    {
                        // không tải file lên thì chỉ send thông tin hồ sơ
                        result = profileBUS.Update(profile, null, null, directoryPathFileUpload);
                    }
                }
                // check FileCode was edit ?
                #region FILE UPLOAD
                //if (files.Count > 0)
                //{
                //    string[] lstFilesDir = Directory.GetFiles(directoryPathFileUpload);
                //    if (lstFilesDir.Length > 0)
                //    {
                //        string[] lstDirFilesUpload = lstFilesDir;
                //        foreach (var fileAlreadyExsists in lstDirFilesUpload)
                //        {
                //            foreach (var file in files)
                //            {
                //                if (fileAlreadyExsists.IndexOf(file.FileName) > -1)
                //                {
                //                    lstFilesExists.Add(new ComputerFile()
                //                    {
                //                        FileName = fileAlreadyExsists,
                //                        ProfileId = profile.ProfileId,
                //                        Url = fileAlreadyExsists
                //                    });
                //                }
                //            }
                //        }
                //        string overwrite = Request.Form["overwrite"].ToString();
                //        if (lstFilesExists.Count > 0)
                //        {
                //            if (overwrite == "accept")
                //            {
                //                foreach (var fileAlreadyExists in lstFilesExists)
                //                {
                //                    System.IO.File.Delete(fileAlreadyExists.FileName);
                //                }

                //                //    overwrite file already exists
                //                foreach (var file in files)
                //                {
                //                    string filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                //                    FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                //                }
                //            }
                //            else
                //            {
                //                var fileResult = new ReturnResult<ComputerFile>()
                //                {
                //                    ReturnValue = Libs.SerializeObject(lstFilesExists.Select(item => item.FileName))
                //                };

                //                fileResult.Failed("-2", "Tồn tại file đã được upload lên hệ thống.");
                //                return Ok(fileResult);
                //            }
                //        }
                //        else
                //        {
                //            foreach (var file in files)
                //            {
                //                var filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                //                FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                //            }
                //        }
                //    }
                //    else
                //    {
                //        foreach (var file in files)
                //        {
                //            var filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                //            FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                //        }
                //    }
                //    // lấy lại danh sách file đã được tải lên
                //    string[] lstDirFilesUploaded = Directory.GetFiles(directoryPathFileUpload);

                //    foreach (var fileUrl in lstDirFilesUploaded)
                //    {
                //        string fileName = Path.GetFileName(fileUrl);
                //        foreach (var file in files)
                //        {
                //            if (fileName.Equals(file.FileName))
                //            {
                //                lstFiles.Add(new ComputerFile()
                //                {
                //                    FileName = file.FileName,
                //                    Size = (Math.Round((double)(file.Length / 1000000.0), 6)).ToString(),
                //                    Url = fileUrl,
                //                    PageNumber = GetNumberOfPdfPages(fileUrl),
                //                    CreatedBy = profile.CreatedBy,
                //                    FolderPath = directoryPathFileUpload
                //                });
                //            }
                //        }
                //    }

                //    result = profileBUS.Update(profile, lstFiles, lstFilesExists, directoryPathFileUpload);
                //}
                //else
                //{
                //    // không tải file lên thì chỉ send thông tin hồ sơ
                //    result = profileBUS.Update(profile, null, null, directoryPathFileUpload);
                //}
                #endregion
                return(Ok(result));
            }
            catch (Exception ex)
            {
                result.Failed("1", ex.Message);
                return(Ok(result));
            }
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> ValidateBulkInsert()
        {
            IFormCollection form;

            form = await Request.ReadFormAsync();

            object          obj  = Request.Form["validData"]; // object
            ValidaImportDto data = Libs.DeserializeObject <ValidaImportDto>(obj.ToString());
            ReturnResult <ValidaImportDto> result = new ReturnResult <ValidaImportDto>();
            IFormFile file = Request.Form.Files.FirstOrDefault();

            result.Item.ImportDataDTOs = new List <ImportDataDTO>();
            string directoryPathFileUpload = Path.Combine(Const.FILE_UPLOAD_DIR, Const.FILE_IMPORT);

            if (!_fileService.FileExist(directoryPathFileUpload))
            {
                Directory.CreateDirectory(directoryPathFileUpload);
                _fileService.Delete(directoryPathFileUpload, file.FileName);
            }
            var dataValidations = new DataValidations();

            dataValidations.IsCorrect          = true;
            dataValidations.dataValidationDTOs = new List <DataValidationDTO>();
            var fileExtension = file.FileName.Split('.');

            if (fileExtension.Length != 0)
            {
                if (fileExtension[1].Equals("xls") || fileExtension[1].Equals("xlsx") || fileExtension[1].Equals("csv"))
                {
                    string path = Path.Combine(directoryPathFileUpload, file.FileName);
                    FilesUtillities.CopyFileToPhysicalDiskSync(file, path);
                    Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
                    using (var stream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
                    {
                        using (var reader = ExcelReaderFactory.CreateReader(stream))
                        {
                            int column = 1;
                            do
                            {
                                while (reader.Read())
                                {
                                    if (column == 1 || column == 2)
                                    {
                                        UpdateDataCustom(reader, column, result.Item);
                                    }
                                    else if (column == 4 || column == 5 || column == 6)
                                    {
                                        result.Item.ProfileTitle = ReadDataProfileTitle(reader, column);
                                    }
                                    else if (column == 3)
                                    {
                                        column++;
                                        continue;
                                    }
                                    else if (column != reader.RowCount)
                                    {
                                        var importData = GetImportDataDTO(reader, column);
                                        if (importData != null)
                                        {
                                            DataValidation(column, importData, dataValidations);
                                            result.Item.ImportDataDTOs.Add(importData);
                                        }
                                    }
                                    column++;
                                }
                            } while (reader.NextResult());
                        }
                    }
                    _fileService.Delete(directoryPathFileUpload, file.FileName);
                }
            }
            return(Ok(dataValidations));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> ProfilesAddNewAndUploadFile()
        {
            IFormCollection form;
            //form = await Request.ReadFormAsync();
            object   obj3    = Request.Form["profile"]; // object
            Profiles profile = Libs.DeserializeObject <Profiles>(obj3.ToString());
            ReturnResult <Profiles> result = new ReturnResult <Profiles>();

            try
            {
                ICollection <IFormFile> files          = Request.Form.Files.ToList(); // danh sách file
                List <ComputerFile>     lstFilesExists = new List <ComputerFile>();
                List <ComputerFile>     lstFileInfo    = new List <ComputerFile>();

                //string path = Libs.GetFullPathDirectoryFileUpload();

                #region
                //string clientPath = Path.Combine(path, "pdffile");
                //if (!Directory.Exists(clientPath))
                //{
                //    Directory.CreateDirectory(clientPath);
                //}
                // directory of profile

                // mỗi hồ sơ có thư mục lưu trữ riêng ứng với FileCode
                //string directoryPathFileUpload = Const.FILE_UPLOAD_DIR + profile.FileCode;
                #endregion

                string directoryPathFileUpload = Const.FILE_UPLOAD_DIR + profile.FileCode;
                //string directoryPathFileUpload = Path.Combine(path, profile.FileCode);
                var profileCheck = profileBUS.GetProfileByFileCode(profile.FileCode);
                if (Directory.Exists(directoryPathFileUpload) || profile.FileCode == profileCheck.Item.FileCode)
                {
                    result.Failed("-3", "Tồn tại hồ sơ có mã hồ sơ " + profile.FileCode + " trên hệ thống, vui lòng thử lại.");
                    return(Ok(result));
                }
                Directory.CreateDirectory(directoryPathFileUpload);
                if (files.Count > 0)
                {
                    // upload file lên server
                    foreach (var file in files)
                    {
                        var filePath = Path.Combine(directoryPathFileUpload, file.FileName);
                        FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                    }

                    //string[] lstDirFilesUpload = Directory.GetFiles(Const.FILE_UPLOAD_DIR);
                    //foreach (var fileAlreadyExsists in lstDirFilesUpload)
                    //{
                    //    foreach (var file in files)
                    //    {
                    //        if (fileAlreadyExsists.IndexOf(file.FileName) > -1)
                    //        {
                    //            lstFilesExists.Add(new ComputerFile() {
                    //                FileName = fileAlreadyExsists
                    //            });
                    //        }
                    //    }
                    //}

                    #region overwrite
                    //string overwrite = Request.Form["overwrite"].ToString();
                    //if (lstFilesExists.Count > 0)
                    //{
                    //    if (overwrite == "accept")
                    //    {
                    //        foreach (var fileAlreadyExists in lstFilesExists)
                    //        {
                    //            System.IO.File.Delete(fileAlreadyExists.FileName);
                    //        }

                    //        // cập nhật lại trạng thái danh sách file được ghi đè


                    //        //    overwrite file already exists
                    //        foreach (var file in files)
                    //        {
                    //            var filePath = FilesUtillities.GetFilePath(file);
                    //            //    await FilesUtillities.CopyFileToPhysicalDisk(file, filePath);
                    //            FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                    //        }

                    //        //for (int i = 0; i < files.Count; i++)
                    //        //{
                    //        //    string filePath = FilesUtillities.GetFilePath(files[i]);

                    //        //    using (var stream = new FileStream(filePath, FileMode.CreateNew))
                    //        //    {
                    //        //        files[i].CopyTo(stream);
                    //        //        stream.Close();
                    //        //    }
                    //        //}
                    //    }
                    //    else
                    //    {
                    //        var fileResult = new ReturnResult<ComputerFile>()
                    //        {
                    //            ReturnValue = Libs.SerializeObject(lstFilesExists.Select(item => item.FileName))
                    //        };

                    //        fileResult.Failed("-2", "Tồn tại file đã được upload lên hệ thống.");
                    //        return Ok(fileResult);
                    //    }
                    //}
                    //else
                    //{
                    //    foreach (var file in files)
                    //    {
                    //        var filePath = FilesUtillities.GetFilePath(file);
                    //        //   await FilesUtillities.CopyFileToPhysicalDisk(file, filePath);
                    //        FilesUtillities.CopyFileToPhysicalDiskSync(file, filePath);
                    //    }
                    //}
                    #endregion

                    // lấy lại danh sách file đã được tải lên
                    string[]            lstDirFilesUploaded = Directory.GetFiles(directoryPathFileUpload);
                    List <ComputerFile> lstFiles            = new List <ComputerFile>();
                    foreach (var fileUrl in lstDirFilesUploaded)
                    {
                        string fileName = Path.GetFileName(fileUrl);
                        foreach (var file in files)
                        {
                            if (fileName.Equals(file.FileName))
                            {
                                lstFiles.Add(new ComputerFile()
                                {
                                    FileName   = file.FileName,
                                    Size       = (Math.Round((double)(file.Length / 1000000.0), 6)).ToString(),
                                    Url        = fileUrl,
                                    PageNumber = GetNumberOfPdfPages(fileUrl),
                                    CreatedBy  = profile.CreatedBy,
                                    FolderPath = directoryPathFileUpload,
                                    ClientUrl  = Const.FILE_SERVER_FOLDER + profile.FileCode + "/" + file.FileName
                                });
                            }
                        }
                    }

                    result = profileBUS.Create(profile, lstFiles);
                }
                else
                {
                    // không tải file lên thì chỉ send thông tin hồ sơ
                    result = profileBUS.Create(profile);
                }
                return(Ok(result));
            }
            catch (Exception ex)
            {
                result.Failed("1", ex.Message);
                return(Ok(result));
            }
        }