|
@@ -116,7 +116,6 @@
|
|
</td>
|
|
</td>
|
|
</tr>
|
|
</tr>
|
|
}
|
|
}
|
|
-
|
|
|
|
</tbody>
|
|
</tbody>
|
|
</table>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
@@ -131,89 +130,81 @@
|
|
|
|
|
|
|
|
|
|
@code {
|
|
@code {
|
|
- bool Uploading = false;
|
|
|
|
- bool UploadingLargeFile = false;
|
|
|
|
- string LargeUploadMessage = "";
|
|
|
|
- long UploadedBytes;
|
|
|
|
- long TotalBytes;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ bool Uploading = false;
|
|
|
|
+ bool UploadingLargeFile = false;
|
|
|
|
+ string LargeUploadMessage = "";
|
|
|
|
+ long UploadedBytes;
|
|
|
|
+ long TotalBytes;
|
|
|
|
|
|
|
|
+ async Task OnLargeFileInputFileChange(InputFileChangeEventArgs args, Candidato candidato, Projeto projeto, InputModelDocuments modelDocument)
|
|
|
|
+ {
|
|
|
|
+ Documento resultado;
|
|
|
|
|
|
- /// <summary>
|
|
|
|
- /// Occurs when a large file is selected or dropped
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="args"></param>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- async Task OnLargeFileInputFileChange(InputFileChangeEventArgs args, Candidato candidato, Projeto projeto, InputModelDocuments modelDocument)
|
|
|
|
- {
|
|
|
|
- Documento resultado;
|
|
|
|
-
|
|
|
|
- UploadedBytes = 0;
|
|
|
|
|
|
+ UploadedBytes = 0;
|
|
|
|
|
|
- // Disable the file input field
|
|
|
|
- //UploadingLargeFile = true;
|
|
|
|
- var tipoDocumentoLoading = listaTipoDocumentoLoading.Where(x => x.TipoDocumento.Id == modelDocument.TipoDocumento.Id).First();
|
|
|
|
- tipoDocumentoLoading.Uploading = true;
|
|
|
|
|
|
+ // Disable the file input field
|
|
|
|
+ //UploadingLargeFile = true;
|
|
|
|
+ var tipoDocumentoLoading = listaTipoDocumentoLoading.Where(x => x.TipoDocumento.Id == modelDocument.TipoDocumento.Id).First();
|
|
|
|
+ tipoDocumentoLoading.Uploading = true;
|
|
|
|
|
|
- await InvokeAsync(StateHasChanged);
|
|
|
|
|
|
+ await InvokeAsync(StateHasChanged);
|
|
|
|
|
|
- // calculate the chunks we have to send
|
|
|
|
- TotalBytes = args.File.Size;
|
|
|
|
- long percent = 0;
|
|
|
|
- long chunkSize = 400000;
|
|
|
|
- long numChunks = TotalBytes / chunkSize;
|
|
|
|
- long remainder = TotalBytes % chunkSize;
|
|
|
|
|
|
+ // calculate the chunks we have to send
|
|
|
|
+ TotalBytes = args.File.Size;
|
|
|
|
+ long percent = 0;
|
|
|
|
+ long chunkSize = 400000;
|
|
|
|
+ long numChunks = TotalBytes / chunkSize;
|
|
|
|
+ long remainder = TotalBytes % chunkSize;
|
|
|
|
|
|
- // get new filename with a bit of entropy
|
|
|
|
- string justFileName = Path.GetFileNameWithoutExtension(args.File.Name);
|
|
|
|
- string extension = Path.GetExtension(args.File.Name);
|
|
|
|
- string newFileNameWithoutPath = $"Projeto_{projeto.Id}_{modelDocument.TipoDocumento.Nome}-{justFileName}-{DateTime.Now.Ticks.ToString()}{extension}";
|
|
|
|
- string projectPath = $"{Environment.CurrentDirectory}\\files\\{projeto.Id}";
|
|
|
|
- string filename = $"{projectPath}\\{newFileNameWithoutPath}";
|
|
|
|
|
|
+ // get new filename with a bit of entropy
|
|
|
|
+ string justFileName = Path.GetFileNameWithoutExtension(args.File.Name);
|
|
|
|
+ string extension = Path.GetExtension(args.File.Name);
|
|
|
|
+ string newFileNameWithoutPath = $"Projeto_{projeto.Id}_{modelDocument.TipoDocumento.Nome}-{justFileName}-{DateTime.Now.Ticks.ToString()}{extension}";
|
|
|
|
+ string projectPath = $"{Environment.CurrentDirectory}\\files\\{projeto.Id}";
|
|
|
|
+ string filename = $"{projectPath}\\{newFileNameWithoutPath}";
|
|
|
|
|
|
- if (!Directory.Exists(projectPath))
|
|
|
|
- {
|
|
|
|
- Directory.CreateDirectory(projectPath);
|
|
|
|
- }
|
|
|
|
|
|
+ if (!Directory.Exists(projectPath))
|
|
|
|
+ {
|
|
|
|
+ Directory.CreateDirectory(projectPath);
|
|
|
|
+ GerarArquivoTextoParaProjeto(candidato, projeto, projectPath);
|
|
|
|
+ }
|
|
|
|
|
|
- // Delete the file if it already exists in our \Files folder
|
|
|
|
- if (File.Exists(filename))
|
|
|
|
- {
|
|
|
|
- File.Delete(filename);
|
|
|
|
- }
|
|
|
|
|
|
+ // Delete the file if it already exists in our \Files folder
|
|
|
|
+ if (File.Exists(filename))
|
|
|
|
+ {
|
|
|
|
+ File.Delete(filename);
|
|
|
|
+ }
|
|
|
|
|
|
- // Open the input and output file streams
|
|
|
|
- using (var inStream = args.File.OpenReadStream(long.MaxValue))
|
|
|
|
- {
|
|
|
|
- using (var outStream = File.OpenWrite(filename))
|
|
|
|
|
|
+ // Open the input and output file streams
|
|
|
|
+ using (var inStream = args.File.OpenReadStream(long.MaxValue))
|
|
{
|
|
{
|
|
- while (UploadedBytes < TotalBytes)
|
|
|
|
|
|
+ using (var outStream = File.OpenWrite(filename))
|
|
{
|
|
{
|
|
- var whatsLeft = TotalBytes - UploadedBytes;
|
|
|
|
- if (whatsLeft < chunkSize)
|
|
|
|
- chunkSize = remainder;
|
|
|
|
- // Read the next chunk
|
|
|
|
- var bytes = new byte[chunkSize];
|
|
|
|
- var buffer = new Memory<byte>(bytes);
|
|
|
|
- var read = await inStream.ReadAsync(buffer);
|
|
|
|
- // Write it
|
|
|
|
- await outStream.WriteAsync(bytes, 0, read);
|
|
|
|
- // Update our progress data and UI
|
|
|
|
- UploadedBytes += read;
|
|
|
|
- percent = UploadedBytes * 100 / TotalBytes;
|
|
|
|
- // Report progress with a string
|
|
|
|
- LargeUploadMessage = $"Uploading {args.File.Name} {percent}%";
|
|
|
|
- await InvokeAsync(StateHasChanged);
|
|
|
|
|
|
+ while (UploadedBytes < TotalBytes)
|
|
|
|
+ {
|
|
|
|
+ var whatsLeft = TotalBytes - UploadedBytes;
|
|
|
|
+ if (whatsLeft < chunkSize)
|
|
|
|
+ chunkSize = remainder;
|
|
|
|
+ // Read the next chunk
|
|
|
|
+ var bytes = new byte[chunkSize];
|
|
|
|
+ var buffer = new Memory<byte>(bytes);
|
|
|
|
+ var read = await inStream.ReadAsync(buffer);
|
|
|
|
+ // Write it
|
|
|
|
+ await outStream.WriteAsync(bytes, 0, read);
|
|
|
|
+ // Update our progress data and UI
|
|
|
|
+ UploadedBytes += read;
|
|
|
|
+ percent = UploadedBytes * 100 / TotalBytes;
|
|
|
|
+ // Report progress with a string
|
|
|
|
+ LargeUploadMessage = $"Uploading {args.File.Name} {percent}%";
|
|
|
|
+ await InvokeAsync(StateHasChanged);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- LargeUploadMessage = "Upload Complete.";
|
|
|
|
- //await ListFiles();
|
|
|
|
|
|
+ LargeUploadMessage = "Upload Completo.";
|
|
|
|
+ //await ListFiles();
|
|
|
|
|
|
- Documento documentoGravado = new()
|
|
|
|
|
|
+ Documento documentoGravado = new()
|
|
{
|
|
{
|
|
Descricao = "",
|
|
Descricao = "",
|
|
ArquivoNomeOriginal = newFileNameWithoutPath,
|
|
ArquivoNomeOriginal = newFileNameWithoutPath,
|
|
@@ -225,19 +216,47 @@
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
- if (documentoGravado.Id > 0) // Alteração
|
|
|
|
- {
|
|
|
|
- documentoGravado.AtribuiId(modelDocument.DocumentoId);
|
|
|
|
|
|
+ if (documentoGravado.Id > 0) // Alteração
|
|
|
|
+ {
|
|
|
|
+ documentoGravado.AtribuiId(modelDocument.DocumentoId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ resultado = documentoService.Gravar(documentoGravado);
|
|
|
|
+
|
|
|
|
+ //UploadingLargeFile = false;
|
|
|
|
+ tipoDocumentoLoading.Uploading = false;
|
|
|
|
+
|
|
|
|
+ AtualizarListaDocumentos();
|
|
}
|
|
}
|
|
|
|
|
|
- resultado = documentoService.Gravar(documentoGravado);
|
|
|
|
|
|
+ private void GerarArquivoTextoParaProjeto(Candidato candidato, Projeto projeto, string path)
|
|
|
|
+ {
|
|
|
|
+ string saudacao = $@"
|
|
|
|
+ Candidado:
|
|
|
|
+ Nome......: {candidato.NomeCompleto}
|
|
|
|
+ E-mail....: {candidato.Email}
|
|
|
|
+ Telefone..: { candidato.Email}";
|
|
|
|
+
|
|
|
|
+ if(candidato.TipoPessoa) // Representa empresa
|
|
|
|
+ {
|
|
|
|
+ saudacao += $@"
|
|
|
|
+ Empresa:
|
|
|
|
+ Nome....: {candidato.EmpresaRazaoSocial}
|
|
|
|
+ E-mail..: {candidato.EmpresaEmail}
|
|
|
|
+ Telefone..: {candidato.EmpresaTelefone}";
|
|
|
|
+ }
|
|
|
|
|
|
- //UploadingLargeFile = false;
|
|
|
|
- tipoDocumentoLoading.Uploading = false;
|
|
|
|
|
|
+ saudacao += $@"
|
|
|
|
+ Projeto '{projeto.Nome}':
|
|
|
|
+ Responsável.....: {projeto.ResponsavelTecnicoNomeCompleto}
|
|
|
|
+ E-mail...: {projeto.ResponsavelTecnicoEmail}
|
|
|
|
+ Telefone.: {projeto.ResponsavelTecnicoTelefone}";
|
|
|
|
|
|
- AtualizarListaDocumentos();
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ string fullPath = Path.Combine(path, "config.txt");
|
|
|
|
|
|
|
|
+ File.WriteAllText(fullPath, saudacao);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|