예제 #1
0
        public IActionResult MainRequestFormat(string pinEmployee,
                                               [FromServices] IRepository <PermissionType> _permissionTypeRepository,
                                               [FromServices] IOrganigramaModelFactory organigramaModelFactory,
                                               [FromServices] IRepository <EmployeeFormat> formatRepository,
                                               [FromServices] INomipaqEmployeeVacationModelFactory nomipaqEmployeeVacations)
        {
            var    data          = System.Convert.FromBase64String(pinEmployee);
            string base64Decoded = System.Text.ASCIIEncoding.ASCII.GetString(data);
            var    getEmployeeId = base64Decoded.Split('|');

            ViewBag.permissionType = _permissionTypeRepository.GetAll().Select(k => new SelectListItem()
            {
                Text = k.Description, Value = k.Id.ToString()
            });

            var employees = organigramaModelFactory.GetAllData().Employess;

            var info = organigramaModelFactory.GetEmployeeData(getEmployeeId[1].TrimStart(new Char[] { '0' }));

            FormatRequestModel model = new FormatRequestModel()
            {
                Employee          = $"{info.GeneralInfo.Id}",
                FulName           = $"{info.GeneralInfo.Id}-{info.GeneralInfo.FirstName} {info.GeneralInfo.LastName}",
                Picture           = info.GeneralInfo.Picture,
                JobTitle          = $"Puesto: {info.GeneralInfo.JobTitle}",
                Area              = $"Area: {info.Area}",
                JobCenter         = $"Centro de trabajo: {info.JobCenter}",
                EmployeeVacations = nomipaqEmployeeVacations.GetEmployeeVacations(getEmployeeId[1])
            };

            if (formatRepository.SearhItemsFor(y => y.EmployeeId.Equals(getEmployeeId[1].TrimStart(new Char[] { '0' }))).Any())
            {
                model.EmployeeFormats.AddRange(formatRepository.SearhItemsFor(y => y.EmployeeId.Equals(getEmployeeId[1].TrimStart(new Char[] { '0' }))).Select(r => new EmployeeFormatItem()
                {
                    Id                 = r.Id,
                    EmployeeId         = r.EmployeeId,
                    ApprovalDate       = r.ApprovalDate.HasValue ? r.ApprovalDate.Value.ToShortDateString() : "",
                    Comments           = r.Comments,
                    CreateDate         = r.CreateDate.ToShortDateString(),
                    EndDate            = r.EndDate.ToShortDateString(),
                    PermissionType     = _permissionTypeRepository.GetElement(r.PermissionType).Description,
                    StartDate          = $"({r.StartDate.ToShortDateString()})-({r.EndDate.ToShortDateString()})",
                    EmployeeSubstitute = employees.Where(k => k.Id.Equals(r.EmployeeSubstitute.TrimStart('0'))).FirstOrDefault().Name
                }));

                //var permissions = formatRepository.SearhItemsFor(y => y.EmployeeId.Equals("17") && )
            }

            return(View(model));
        }
예제 #2
0
        public IActionResult MainRequestFormat(string idEmployee,
                                               [FromServices] IRepository <PermissionType> _permissionTypeRepository,
                                               [FromServices] IOrganigramaModelFactory organigramaModelFactory,
                                               [FromServices] IRepository <EmployeeFormat> formatRepository,
                                               [FromServices] INomipaqEmployeeVacationModelFactory nomipaqEmployeeVacations)
        {
            ViewBag.permissionType = _permissionTypeRepository.GetAll().Select(k => new SelectListItem()
            {
                Text = k.Description, Value = k.Id.ToString()
            });

            var employees = organigramaModelFactory.GetAllData().Employess;

            var info = organigramaModelFactory.GetEmployeeData(idEmployee);

            FormatRequestModel model = new FormatRequestModel()
            {
                Employee          = $"{info.GeneralInfo.Id.TrimStart(new Char[] { '0' })}",
                FulName           = $"{info.GeneralInfo.Id}-{info.GeneralInfo.FirstName} {info.GeneralInfo.LastName}",
                Picture           = info.GeneralInfo.Picture,
                JobTitle          = $"Puesto: {info.GeneralInfo.JobTitle}",
                Area              = $"Area: {info.Area}",
                JobCenter         = $"Centro de trabajo: {info.JobCenter}",
                EmployeeVacations = nomipaqEmployeeVacations.GetEmployeeVacations(int.Parse(idEmployee).ToString("00000"))
            };

            var formats = formatRepository.SearhItemsFor(y => y.EmployeeId.Equals(idEmployee));

            if (formats.Any())
            {
                model.EmployeeFormats.AddRange(formatRepository.SearhItemsFor(y => y.EmployeeId.Equals(idEmployee)).Select(r => new EmployeeFormatItem()
                {
                    Id                 = r.Id,
                    EmployeeId         = r.EmployeeId,
                    ApprovalDate       = r.ApprovalDate.HasValue ? r.ApprovalDate.Value.ToShortDateString() : "",
                    Comments           = r.Comments,
                    CreateDate         = r.CreateDate.ToShortDateString(),
                    EndDate            = r.EndDate.ToShortDateString(),
                    PermissionType     = _permissionTypeRepository.GetElement(r.PermissionType).Description,
                    StartDate          = $"({r.StartDate.ToShortDateString()})-({r.EndDate.ToShortDateString()})",
                    EmployeeSubstitute = employees.Where(k => k.Id.Equals(r.EmployeeSubstitute.TrimStart('0'))).FirstOrDefault().Name
                }));
            }

            model.TotalPermissionsApproved = model.EmployeeFormats.Where(h => !string.IsNullOrEmpty(h.ApprovalDate)).Count();

            return(View(model));
        }
예제 #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"));
        }
예제 #4
0
        public JsonResult SaveFormat(FormatInputModel format,
                                     [FromServices] IRepository <EmployeeFormat> formatRepository,
                                     [FromServices] IOrganigramaModelFactory organigramaModelFactory,
                                     [FromServices] IConfigurationManager configurationManager,
                                     [FromServices] INomipaqEmployeeVacationModelFactory nomipaqEmployeeVacations)
        {
            var    vacations       = nomipaqEmployeeVacations.GetEmployeeVacations(int.Parse(format.EmployeeId).ToString("00000"));
            string vacationsConfig = string.Empty;

            if (vacations != null)
            {
                vacationsConfig = JsonConvert.SerializeObject(vacations);
            }


            var element = new EmployeeFormat()
            {
                Comments           = format.Comments,
                EmployeeId         = format.EmployeeId.TrimStart(new Char[] { '0' }),
                EmployeeSubstitute = string.IsNullOrEmpty(format.EmployeeSubId) ? "0" : format.EmployeeSubId.TrimStart(new Char[] { '0' }),
                EndDate            = DateTime.Parse(format.EndDate),
                PermissionType     = format.PermissionType,
                StartDate          = DateTime.Parse(format.StartDate),
                CreateDate         = DateTime.Today,
                ApprovalDate       = null,
                ApprovalWorkFlow   = "",
                WithPay            = format.WithPay,
                StartTime          = format.StartTime,
                EndTime            = format.EndTime,
                NomipaqVacations   = vacationsConfig
            };

            formatRepository.Create(element);

            if (format.EmployeeSubId == null)
            {
                format.EmployeeSubId = "99999";
            }

            var suplente    = organigramaModelFactory.GetEmployeeData(format.EmployeeSubId.TrimStart(new Char[] { '0' }));
            var solicitante = organigramaModelFactory.GetEmployeeData(format.EmployeeId.TrimStart(new Char[] { '0' }));

            string urlRoute = $"http://{configurationManager.ServerIP}/FormatRequest/ConfirmacionSuplente?IdFormat={element.Id.ToString()}";

            if (suplente != null && !string.IsNullOrEmpty(suplente.GeneralInfo.Email))
            {
                try
                {
                    MailMessage mail = new MailMessage();
                    mail.To.Add(suplente.GeneralInfo.Email);
                    mail.From    = new MailAddress(configurationManager.MailUsername);
                    mail.Subject = "Solicitud de Confirmación para cubrir puesto";

                    string htmlString = $@"<html>
                      <body>
                      <p>Hola, <br>{suplente.GeneralInfo.FirstName} {suplente.GeneralInfo.LastName} {suplente.GeneralInfo.LastName2}</br></p>
                      <p><br>{solicitante.GeneralInfo.JobTitle}</br> solicita tu confirmación para cubrir su puesto durante el periodo:</p>
                      <p>{format.StartDate}-{format.EndDate}</p>
                      <p>Da click en el siguiente enlace para confirmar que estas enterado y aceptas su solicitud</p>
                      <p><a href = '{urlRoute}'>Confirmar solicitud</a></p>
                      </body>
                      </html>
                     ";

                    mail.Body       = htmlString;
                    mail.IsBodyHtml = true;
                    SmtpClient smtp = new SmtpClient(configurationManager.MailServer, int.Parse(configurationManager.MailPort));
                    smtp.UseDefaultCredentials = false;
                    smtp.EnableSsl             = true;
                    smtp.Credentials           = new System.Net.NetworkCredential(configurationManager.MailUsername, configurationManager.MailUserpassword);
                    smtp.Send(mail);
                }
                catch
                {
                }
            }

            return(Json(new { idformat = element.Id }));
        }