Júlio César de Carvalho 4 months ago
parent
commit
c925104eaa

+ 1 - 1
ConcursoProjetos/Components/Layout/NavMenu.razor

@@ -38,7 +38,7 @@
 
 
         <div class="nav-item px-3">
         <div class="nav-item px-3">
             <NavLink class="nav-link" href="gestaoprojetos">
             <NavLink class="nav-link" href="gestaoprojetos">
-                <span class="bi bi-lock-nav-menu" aria-hidden="true"></span> Gestão Projetos
+                <span class="bi bi-lock-nav-menu" aria-hidden="true"></span> Meus Projetos
             </NavLink>
             </NavLink>
         </div>
         </div>
 
 

+ 23 - 8
ConcursoProjetos/Components/Pages/GestaoProjetos.razor

@@ -12,16 +12,17 @@
 @inject AuthenticationStateProvider AuthenticationStateProvider
 @inject AuthenticationStateProvider AuthenticationStateProvider
 @inject ICandidatoService candidatoService
 @inject ICandidatoService candidatoService
 @inject IProjetoService projetoService
 @inject IProjetoService projetoService
+@inject ITipoDocumentoService tipoDocumentoService
 @inject NavigationManager Navigation
 @inject NavigationManager Navigation
 
 
 
 
-<PageTitle>Gestão de Projetos</PageTitle>
+<PageTitle>Meus Projetos</PageTitle>
 
 
-<h1>Gestão de Projetos</h1>
+<h1>Meus Projetos</h1>
 
 
 
 
 
 
-<button class="btn btn-primary" @onclick="() => EditarProjeto(0)">Add Projeto</button>
+<button class="btn btn-primary" @onclick="() => EditarProjeto(0)">Enviar Novo Projeto</button>
 
 
 @if (_projetos == null || !_projetos.Any())
 @if (_projetos == null || !_projetos.Any())
 {
 {
@@ -34,8 +35,9 @@ else
         <thead>
         <thead>
             <tr>
             <tr>
                 <th>Projeto</th>
                 <th>Projeto</th>
-                <th>Unidades</th>
+                <th>Unidades Habitacionais por Pavimento</th>
                 <th>Responsável Técnico</th>
                 <th>Responsável Técnico</th>
+                <th>Arquivos Enviados</th>
                 <th>Status</th>
                 <th>Status</th>
                 <th></th>
                 <th></th>
                 <th></th>
                 <th></th>
@@ -44,19 +46,29 @@ else
         <tbody>
         <tbody>
             @foreach (var projeto in _projetos)
             @foreach (var projeto in _projetos)
             {
             {
+                int totalArquivos = _listaTipoDocumento.Count();
+                int totalArquivosEnviados = projeto.Documentos.Count();
+
+                
                 <tr>
                 <tr>
                     <td>@projeto.Nome</td>
                     <td>@projeto.Nome</td>
                     <td>@projeto.NumeroUnidades.ToString()</td>
                     <td>@projeto.NumeroUnidades.ToString()</td>
                     <td>@projeto.ResponsavelTecnicoNomeCompleto</td>
                     <td>@projeto.ResponsavelTecnicoNomeCompleto</td>
+                    <td>@($"{totalArquivosEnviados} de {totalArquivos}")</td>
                     <td>
                     <td>
-                        <span class="bi bi-check-all fs-5 text-success" aria-hidden="true"></span>
-                        <span class="bi bi-x fs-5 text-danger" aria-hidden="true"></span>
-
-
+                        @if (totalArquivosEnviados < totalArquivos)
+                        {
+                            <span class="bi bi-x fs-5 text-danger" aria-hidden="true"></span>
+                        }
+                        else
+                        {
+                            <span class="bi bi-check-all fs-5 text-success" aria-hidden="true"></span>
+                        }
                     </td>
                     </td>
                     <th></th>
                     <th></th>
                     <th><button class="btn btn-primary" @onclick="() => EditarProjeto(projeto.Id)">Editar</button></th>
                     <th><button class="btn btn-primary" @onclick="() => EditarProjeto(projeto.Id)">Editar</button></th>
                 </tr>
                 </tr>
+
             }
             }
         </tbody>
         </tbody>
     </table>
     </table>
@@ -66,6 +78,7 @@ else
     private Candidato? _candidato;
     private Candidato? _candidato;
     private IEnumerable<Projeto>? _projetos;
     private IEnumerable<Projeto>? _projetos;
     private string _mensagem = "Loading...";
     private string _mensagem = "Loading...";
+    private IEnumerable<TipoDocumento> _listaTipoDocumento;
 
 
     protected override async Task OnInitializedAsync()
     protected override async Task OnInitializedAsync()
     {
     {
@@ -84,6 +97,8 @@ else
             }
             }
         }
         }
 
 
+        _listaTipoDocumento = tipoDocumentoService.Listar();
+
     }
     }
 
 
     private void EditarProjeto(long projetoId)
     private void EditarProjeto(long projetoId)

+ 96 - 77
ConcursoProjetos/Components/Pages/PageProjeto.razor

@@ -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);
+        }
 
 
 
 
 
 

BIN
ConcursoProjetos/Files/10/Projeto_10_Projeto Hidrossanitário-gInk_v1.1.1-638699624691370522.zip


+ 13 - 0
ConcursoProjetos/Files/10/config.txt

@@ -0,0 +1,13 @@
+
+            Candidado:
+                Nome......: Nome completo
+                E-mail....: cesarsof345345t@yahoo.com.br
+                Telefone..: cesarsof345345t@yahoo.com.br
+                    Empresa:
+                       Nome....: asdfsadfasdf
+                       E-mail..: mail@gmail.com
+                       Telefone..: fasdfasdfdsa
+            Projeto 'Projeto 46':
+                Responsável.....: cesar
+                E-mail...: soasoftware@yahoo.com.br
+                Telefone.: jsjdflkdsa

BIN
ConcursoProjetos/Files/11/Projeto_11_Projeto Elétrico-gInk_v1.1.1-638699625798855991.zip


+ 13 - 0
ConcursoProjetos/Files/11/config.txt

@@ -0,0 +1,13 @@
+
+            Candidado:
+                Nome......: Nome completo
+                E-mail....: cesarsof345345t@yahoo.com.br
+                Telefone..: cesarsof345345t@yahoo.com.br
+                 Empresa:
+                    Nome....: asdfsadfasdf
+                    E-mail..: mail@gmail.com
+                    Telefone..: fasdfasdfdsa
+            Projeto 'Projeto 46':
+                Responsável.....: cesar
+                E-mail...: soasoftware@yahoo.com.br
+                Telefone.: jsjdflkdsa

BIN
ConcursoProjetos/Files/12/Projeto_12_Projeto de Implantação de Água Fria-gInk_v1.2.0-638699626378063826.zip


+ 13 - 0
ConcursoProjetos/Files/12/config.txt

@@ -0,0 +1,13 @@
+
+            Candidado:
+                Nome......: Nome completo
+                E-mail....: cesarsof345345t@yahoo.com.br
+                Telefone..: cesarsof345345t@yahoo.com.br
+                Empresa:
+                    Nome....: asdfsadfasdf
+                    E-mail..: mail@gmail.com
+                    Telefone..: fasdfasdfdsa
+            Projeto 'Projeto 46':
+                Responsável.....: cesar
+                E-mail...: soasoftware@yahoo.com.br
+                Telefone.: jsjdflkdsa

+ 1 - 1
ConcursoProjetos/Service/ProjetoService.cs

@@ -67,6 +67,6 @@ public class ProjetoService : IProjetoService
     public IEnumerable<Projeto> Listar(long candidatoId)
     public IEnumerable<Projeto> Listar(long candidatoId)
     {
     {
         using var context = _dbContextFactory.CreateDbContext();
         using var context = _dbContextFactory.CreateDbContext();
-        return context.Projeto.Where(p => p.CandidatoId == candidatoId).ToList();
+        return context.Projeto.Include(p => p.Documentos).Where(p => p.CandidatoId == candidatoId).ToList();
     }
     }
 }
 }