Esempio n. 1
0
        public JsonResult SaveProfileData(EmployeeProfileModel model,
                                          [FromServices] IRepository <EmployeeProfile> employeeProfileRepository,
                                          [FromServices] SARH.Core.Configuration.IConfigurationManager configurationManager)
        {
            string employeeFormat = int.Parse(model.EmployeeId).ToString("00000");
            string documentPath   = string.Empty;

            if (!string.IsNullOrEmpty(model.DocumentPath))
            {
                string path = configurationManager.EmployeeProfileDocumentPath.Replace("|EmpNumber|", employeeFormat);
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                System.IO.File.Delete($"{path}PerfilPuesto.pdf");
                System.IO.File.Move(model.DocumentPath, $"{path}PerfilPuesto.pdf");
                documentPath = $"{path}PerfilPuesto.pdf";
            }

            var row = employeeProfileRepository.SearhItemsFor(l => l.EmployeeId.Equals(model.EmployeeId));

            if (!row.Any())
            {
                employeeProfileRepository.Create(new EmployeeProfile()
                {
                    EmployeeId           = model.EmployeeId,
                    ProfileSectionValues = JsonConvert.SerializeObject(model),
                    DocumentPath         = documentPath
                });
            }
            else
            {
                var  data         = row.FirstOrDefault();
                bool overwriteDoc = false;

                if (!string.IsNullOrEmpty(data.DocumentPath) && !string.IsNullOrEmpty(documentPath))
                {
                    overwriteDoc = true;
                }
                if (string.IsNullOrEmpty(data.DocumentPath) && !string.IsNullOrEmpty(documentPath))
                {
                    overwriteDoc = true;
                }


                data.ProfileSectionValues = JsonConvert.SerializeObject(model);
                data.DocumentPath         = overwriteDoc ? documentPath : data.DocumentPath;
                employeeProfileRepository.Update(data);
            }

            return(Json("Ok"));
        }
Esempio n. 2
0
        public FileResult PrintIncidenciaReportData(string dateIni, string dateFin,
                                                    [FromServices] IDashboardModelFactory dashboardModelFactory,
                                                    [FromServices] IEmployeeFormatModelFactory employeeFormatModelFactory,
                                                    [FromServices] SARH.Core.Configuration.IConfigurationManager configManager)
        {
            List <ReportEmployeeDetailModel> model = new List <ReportEmployeeDetailModel>();

            var dias = Math.Abs(Math.Round((DateTime.Parse(dateIni) - DateTime.Parse(dateFin)).TotalDays, 0));

            if (dias == 0)
            {
                dias = 1;
            }

            for (int i = 0; i < dias; i++)
            {
                var t       = DateTime.Parse(dateIni).AddDays(i);
                var results = dashboardModelFactory.GetNoRegistry(t.ToShortDateString());
                model.AddRange(results);

                var formats = employeeFormatModelFactory.GetAllApprovedFormats(t);

                var f = formats.Where(d => d.FormatName.ToLower().Contains("incapacidad"));
                model.AddRange(f.Select(h => new ReportEmployeeDetailModel()
                {
                    Area       = h.Area,
                    JobCenter  = h.Centro,
                    JobTitle   = h.JobTitle,
                    Fecha      = $"{h.StartDate} - {h.EndDate}",
                    Name       = h.Name,
                    DetailType = h.Comments,
                    ID         = h.EmployeeId,
                    Type       = 2
                }));

                var g = formats.Where(d => d.FormatName.ToLower().Contains("vacacion"));
                model.AddRange(g.Select(h => new ReportEmployeeDetailModel()
                {
                    Area       = h.Area,
                    JobCenter  = h.Centro,
                    JobTitle   = h.JobTitle,
                    Fecha      = $"{h.StartDate} - {h.EndDate}",
                    Name       = h.Name,
                    DetailType = h.Comments,
                    ID         = h.EmployeeId,
                    Type       = 3
                }));

                var p = formats.Where(d => d.FormatName.ToLower().Contains("permiso"));
                model.AddRange(p.Select(h => new ReportEmployeeDetailModel()
                {
                    Area       = h.Area,
                    JobCenter  = h.Centro,
                    JobTitle   = h.JobTitle,
                    Fecha      = $"{h.StartDate} - {h.EndDate}",
                    Name       = h.Name,
                    DetailType = h.Comments,
                    ID         = h.EmployeeId,
                    Type       = 4
                }));
            }

            IConfigPdf config = new ConfigPdf()
            {
                FontPathPdf     = configManager.FontPathPdf,
                ImgPathPdf      = configManager.ImgPathPdf,
                FontPathBarCode = configManager.FontPathBarCode
            };
            PdfManager manager = new PdfManager(config);


            string fileName = $"{Path.GetTempPath()}IncidenciasPeriodo-{dateIni.Replace("/", string.Empty)}-{dateFin.Replace("/", string.Empty)}.pdf";

            if (System.IO.File.Exists(fileName))
            {
                System.IO.File.Delete(fileName);
            }

            try
            {
                manager.CreateIncidenciasReport(new Core.PdfCreator.FormatData.DocumentInfoPdfData()
                {
                    TitleDocumento    = "Reporte Diario de Incidencias",
                    FormatId          = $"{dateIni}-{dateFin}",
                    IncidenciasReport = model.Select(n => new Core.PdfCreator.FormatData.ReportEmployeeDetail()
                    {
                        Area       = n.Area,
                        DetailType = n.DetailType,
                        Fecha      = n.Fecha,
                        JobCenter  = n.JobCenter,
                        JobTitle   = n.JobTitle,
                        ID         = n.ID,
                        Name       = n.Name,
                        Type       = n.Type
                    }).ToList()
                }, fileName);
            }
            catch (Exception ex)
            {
                byte[] FileBytesError = System.Text.Encoding.UTF8.GetBytes(ex.Message);
                return(File(FileBytesError, "text/plain"));
            }


            byte[] FileBytes = System.IO.File.ReadAllBytes(fileName);
            return(File(FileBytes, "application/pdf"));
        }
Esempio n. 3
0
        public FileResult PrintVacationFormat(int idFormat,
                                              [FromServices] IEmployeeFormatModelFactory employeeFormatModelFactory,
                                              [FromServices] SARH.Core.Configuration.IConfigurationManager configManager,
                                              [FromServices] IOrganigramaModelFactory organigramaModelFactory,
                                              [FromServices] INomipaqEmployeeVacationModelFactory nomipaqVacationModelFactory)
        {
            IConfigPdf config = new ConfigPdf()
            {
                FontPathPdf     = configManager.FontPathPdf,
                ImgPathPdf      = configManager.ImgPathPdf,
                FontPathBarCode = configManager.FontPathBarCode
            };
            PdfManager manager = new PdfManager(config);

            var    format    = employeeFormatModelFactory.GetformatInfo(idFormat);
            var    formats   = employeeFormatModelFactory.GetAllFormatsByEmployee(format.EmployeeId);
            string path      = System.IO.Path.GetTempPath();
            string empId     = int.Parse(format.EmployeeId).ToString("00000");
            var    vacations = nomipaqVacationModelFactory.GetEmployeeVacations(int.Parse(format.EmployeeId).ToString("00000"));

            Core.PdfCreator.FormatData.FormatVacationData vacationInfo = new Core.PdfCreator.FormatData.FormatVacationData();

            var empInfo = organigramaModelFactory.GetEmployeeData(format.EmployeeId);

            var sustitute = organigramaModelFactory.GetEmployeeData(format.Suplente);

            if (vacations != null)
            {
                var formatDays = (DateTime.Parse(format.EndDate) - DateTime.Parse(format.StartDate)).TotalDays + 1;
                vacationInfo = new Core.PdfCreator.FormatData.FormatVacationData()
                {
                    AñosCumplidos          = vacations.Antiguedad.ToString("00"),
                    DiasGozado             = vacations.DiasTomados.ToString(),
                    DiasPendinteAñoAnteior = vacations.TotalDias.ToString(),
                    DiasPorAño             = vacations.DiasPorAño.ToString(),
                    DiasPorGozar           = vacations.DiasDisponibles.ToString(),
                    FechaIngreso           = empInfo.GeneralInfo.HireDate,
                    PorGozar        = Math.Round((vacations.DiasDisponibles - formatDays), 0).ToString(),
                    DiasSolicitados = formatDays.ToString("00"),
                    FechaInicial    = format.StartDate,
                    FechaFinal      = format.EndDate
                };
            }

            string fileName = $"{path}FormatNumber{idFormat}.pdf";

            if (System.IO.File.Exists(fileName))
            {
                System.IO.File.Delete(fileName);
            }

            try
            {
                manager.CreateVacationFormat(new Core.PdfCreator.FormatData.DocumentInfoPdfData()
                {
                    TitleDocumento = "SOLICITUD DE VACACIONES",
                    FormatId       = $"Fecha de Solicitud: {format.FechaSolicitud}",
                    Area           = empInfo.Area,
                    JobTitle       = empInfo.GeneralInfo.JobTitle,
                    EmployeeName   = $"{empInfo.GeneralInfo.FirstName} {empInfo.GeneralInfo.LastName} {empInfo.GeneralInfo.LastName2}",
                    EmployeInfo    = new Core.PdfCreator.FormatData.EmployeeInfoData()
                    {
                        EmployeeId      = empInfo.GeneralInfo.Id,
                        EmployeeName    = $"{empInfo.GeneralInfo.FirstName} {empInfo.GeneralInfo.LastName} {empInfo.GeneralInfo.LastName2}",
                        Rfc             = empInfo.GeneralInfo.RFC,
                        Curp            = empInfo.GeneralInfo.CURP,
                        NSS             = empInfo.GeneralInfo.NSS,
                        BrithDate       = empInfo.GeneralInfo.FechaNacimiento,
                        HireDate        = empInfo.GeneralInfo.HireDate,
                        FireDate        = "N/A",
                        PhotoPath       = empInfo.GeneralInfo.Picture,
                        PersonalPhone   = empInfo.PersonalInfo.Phone,
                        CellNumber      = empInfo.PersonalInfo.CellPhone,
                        PersonalEmail   = empInfo.PersonalInfo.Email,
                        Address         = empInfo.PersonalInfo.Address,
                        City            = empInfo.PersonalInfo.City,
                        State           = empInfo.PersonalInfo.State,
                        Cp              = empInfo.PersonalInfo.Zip,
                        ContactName     = empInfo.EmergencyData.Name,
                        ContactRelation = empInfo.EmergencyData.Relacion,
                        ContactPhone    = empInfo.EmergencyData.Phone,
                        JobTitle        = empInfo.GeneralInfo.JobTitle
                    },
                    EmployeeSustitute = new Core.PdfCreator.FormatData.FormatEmployeeSustitute()
                    {
                        Name     = $"{sustitute.GeneralInfo.FirstName} {sustitute.GeneralInfo.LastName} {sustitute.GeneralInfo.LastName2}",
                        JobTitle = sustitute.GeneralInfo.JobTitle
                    },
                    FormatVacationData = vacationInfo
                }, fileName);
            }
            catch (Exception ex)
            {
                byte[] FileBytesError = System.Text.Encoding.UTF8.GetBytes(ex.Message);
                return(File(FileBytesError, "text/plain"));
            }


            byte[] FileBytes = System.IO.File.ReadAllBytes(fileName);
            return(File(FileBytes, "application/pdf"));
        }
Esempio n. 4
0
        public FileResult PrintCurrentFormat(int idFormat,
                                             [FromServices] IEmployeeFormatModelFactory employeeFormatModelFactory,
                                             [FromServices] SARH.Core.Configuration.IConfigurationManager configManager,
                                             [FromServices] IOrganigramaModelFactory organigramaModelFactory)
        {
            IConfigPdf config = new ConfigPdf()
            {
                FontPathPdf     = configManager.FontPathPdf,
                ImgPathPdf      = configManager.ImgPathPdf,
                FontPathBarCode = configManager.FontPathBarCode
            };
            PdfManager manager = new PdfManager(config);

            var    format  = employeeFormatModelFactory.GetformatInfo(idFormat);
            var    formats = employeeFormatModelFactory.GetAllFormatsByEmployee(format.EmployeeId);
            string path    = System.IO.Path.GetTempPath();
            string empId   = int.Parse(format.EmployeeId).ToString("00000");

            var empInfo = organigramaModelFactory.GetEmployeeData(format.EmployeeId);

            var sustitute = organigramaModelFactory.GetEmployeeData(format.Suplente);

            string fileName = $"{path}FormatNumber{idFormat}.pdf";

            if (System.IO.File.Exists(fileName))
            {
                System.IO.File.Delete(fileName);
            }

            try
            {
                manager.CreatePermissionFormat(new Core.PdfCreator.FormatData.DocumentInfoPdfData()
                {
                    TitleDocumento = "SOLICITUD DE PERMISOS",
                    FormatId       = $"Fecha de Solicitud: {format.FechaSolicitud}",
                    Area           = empInfo.Area,
                    JobTitle       = empInfo.GeneralInfo.JobTitle,
                    EmployeeName   = $"{empInfo.GeneralInfo.FirstName} {empInfo.GeneralInfo.LastName} {empInfo.GeneralInfo.LastName2}",
                    EmployeInfo    = new Core.PdfCreator.FormatData.EmployeeInfoData()
                    {
                        EmployeeId      = empInfo.GeneralInfo.Id,
                        EmployeeName    = $"{empInfo.GeneralInfo.FirstName} {empInfo.GeneralInfo.LastName} {empInfo.GeneralInfo.LastName2}",
                        Rfc             = empInfo.GeneralInfo.RFC,
                        Curp            = empInfo.GeneralInfo.CURP,
                        NSS             = empInfo.GeneralInfo.NSS,
                        BrithDate       = empInfo.GeneralInfo.FechaNacimiento,
                        HireDate        = empInfo.GeneralInfo.HireDate,
                        FireDate        = "N/A",
                        PhotoPath       = empInfo.GeneralInfo.Picture,
                        PersonalPhone   = empInfo.PersonalInfo.Phone,
                        CellNumber      = empInfo.PersonalInfo.CellPhone,
                        PersonalEmail   = empInfo.PersonalInfo.Email,
                        Address         = empInfo.PersonalInfo.Address,
                        City            = empInfo.PersonalInfo.City,
                        State           = empInfo.PersonalInfo.State,
                        Cp              = empInfo.PersonalInfo.Zip,
                        ContactName     = empInfo.EmergencyData.Name,
                        ContactRelation = empInfo.EmergencyData.Relacion,
                        ContactPhone    = empInfo.EmergencyData.Phone,
                        JobTitle        = empInfo.GeneralInfo.JobTitle
                    },
                    EmployeeSustitute = new Core.PdfCreator.FormatData.FormatEmployeeSustitute()
                    {
                        Name     = $"{sustitute.GeneralInfo.FirstName} {sustitute.GeneralInfo.LastName} {sustitute.GeneralInfo.LastName2}",
                        JobTitle = sustitute.GeneralInfo.JobTitle
                    },
                    FormatPermission = new Core.PdfCreator.FormatData.FormatPermissionData()
                    {
                        Cause            = format.Comments,
                        DateStart        = format.StartDate,
                        DateEnd          = format.EndDate,
                        TimeStart        = format.StartTime,
                        TimeEnd          = format.EndTime,
                        Comments         = format.AdditionalInfo,
                        TotalPermissions = formats.Count()
                    }
                }, fileName);
            }
            catch (Exception ex)
            {
                byte[] FileBytesError = System.Text.Encoding.UTF8.GetBytes(ex.Message);
                return(File(FileBytesError, "text/plain"));
            }


            byte[] FileBytes = System.IO.File.ReadAllBytes(fileName);
            return(File(FileBytes, "application/pdf"));
        }