Exemplo n.º 1
0
        public async Task <int> UpdateInformFinalDataSupervisor(BE.ReportBE.Report report)
        {
            int i = 0;

            try {
                if (report.ActionType == 1)
                {
                    i = _assignmentRepository.UpdateInformFinalDataSupervisor(report);
                }
                else if (report.ActionType == 2)
                {
                    i = _assignmentRepository.UpdateInformFinalDataSupervisor(report);
                    List <Attachment> listAttachments = new List <Attachment>();
                    if (!string.IsNullOrEmpty(report.UrlFile))
                    {
                        string[]   arrName     = report.UrlFile.Split('/');
                        var        stream      = new WebClient().OpenRead(new Uri(report.UrlFile));
                        Attachment attachement = new Attachment(stream, arrName[arrName.Length - 1]);
                        listAttachments.Add(attachement);
                        //listUsers.Add("*****@*****.**");
                        //listUsersCC.Add("*****@*****.**");
                        listUsersCC.Add("*****@*****.**");
                    }
                    else
                    {
                    }
                    listUsersCC.Add("*****@*****.**");
                    await email.PostSendEmail(listUsers, listUsersCC, "FERREYROS", "<p>Comentario del Supervisor:</p><p>" + report.Comment2 + "</p>", true, listAttachments);
                }
            } catch (Exception ex) {
                Log.Write(ex);
                throw;
            }
            return(i);
        }
Exemplo n.º 2
0
        public int DeleteArchiveInformFinal(BE.ReportBE.Report report)
        {
            int i = 0;

            i = _assignmentRepository.DeleteArchiveInformFinal(report);
            return(i);
        }
Exemplo n.º 3
0
        public async Task <int> UpdateArchiveInformFinal(BE.ReportBE.Report report)
        {
            int i = 0;

            if (report.ActionType == 1)
            {
                i = _assignmentRepository.UpdateArchiveInformFinal(report);
            }
            else if (report.ActionType == 2)
            {
                report.Sent1 = true;
                i            = _assignmentRepository.UpdateArchiveInformFinal(report);
                if (i >= 1)
                {
                    if (report.WhoUpdate == 1)
                    {
                        return(i);
                    }
                    listUsersCC.Add("*****@*****.**");
                    // listUsersCC.Add("*****@*****.**");
                    // listUsersCC.Add("*****@*****.**");
                    await email.PostSendEmail(listUsers, listUsersCC, "FERREYROS", "<p>El tecnico ha generado su informe Final de la OT-XXXX</p>", true, new List <Attachment>());
                }
            }
            return(i);
        }
Exemplo n.º 4
0
        public int UpdateUrlInformFinalSupervisor(BE.ReportBE.Report report)
        {
            int i = 0;

            i = _assignmentRepository.UpdateUrlInformFinalSupervisor(report);
            return(i);
        }
Exemplo n.º 5
0
        public async Task <int> UpdateExecutiveReport(BE.ReportBE.Report report)
        {
            int i = 0;

            if (report.ActionType == 1)
            {
                i = _assignmentRepository.UpdateExecutiveReport(report);
            }
            else if (report.ActionType == 2)
            {
                i = _assignmentRepository.UpdateExecutiveReport(report);
                if (i >= 1)
                {
                    var dynamicFile = await GenerateAct(report, 2);

                    report.UrlExe = dynamicFile.FileUrl;
                    i             = _assignmentRepository.UpdateExecutiveReport(report);
                    listAttachments.Add(new Attachment(dynamicFile.Route));
                    listUsers.Add("*****@*****.**");
                    listUsersCC.Add("*****@*****.**");
                    listUsersCC.Add("*****@*****.**");
                    await email.PostSendEmail(listUsers, listUsersCC, "FERREYROS", "<p>Este mensaje es para el cliente. Le estamos enviando un informe preliminar del servicio</p>", true, listAttachments);
                }
            }
            ;
            return(i);
        }
Exemplo n.º 6
0
        public int DeleteArchiveInformFinal(BE.ReportBE.Report report)
        {
            int i = 0;

            DatabaseFactory.CreateDatabase()
            .ExecuteNonQuery("TSP_REPORT_DELETE_INFORMFINAL", report.Id, report.AssignmentId, report.UrlFile, report.ModifiedBy);
            i = 1;
            return(i);
        }
Exemplo n.º 7
0
        public int UpdateSendFiletoReportSupervisor(BE.ReportBE.Report report)
        {
            int i = 0;

            try {
                foreach (var item in report.Files)
                {
                    if (item.status == 0)
                    {
                        i = _assignmentRepository.AddFileReportSupervisor(item);
                    }
                    else if (item.status == 1)
                    {
                        i = _assignmentRepository.DeleteFileReportSupervisor(item);
                    }
                }
            } catch (Exception ex) {
                Log.Write(ex);
                throw;
            }
            return(i);
        }
Exemplo n.º 8
0
        public async Task <dynamic> GenerateAct(BE.ReportBE.Report report, int type)
        {
            var assignment  = _assignmentRepository.GetReportSupervisor(report.AssignmentId);
            var users       = _assignmentRepository.GetByPersonnelIdAssignment(report.AssignmentId).ToList();
            var usersClient = _assignmentRepository.GetContactByAssignemtnId(report.AssignmentId).ToList();

            var supervisor = users.Where(x => x.UserType == 1).FirstOrDefault();
            var technician = users.Where(x => x.UserType == 2).FirstOrDefault();
            var client     = usersClient.Where(x => x.Id == report.ContactId).FirstOrDefault();

            var sValue     = ConvertNumberToString(report.Value) + "\"";
            var pdfContent = string.Empty;

            if (type == 1)
            {
                pdfContent = Resources.Template.ActString.ToString();
            }
            else if (type == 2)
            {
                pdfContent = Resources.Template.ExeString.ToString();
            }

            CultureInfo ci = new CultureInfo("es-PE");

            var colorStyle = sValue + " " + strFill.Replace("@@strcolor", strColor);

            pdfContent = pdfContent
                         .Replace("@SocialName", assignment.CompanyName)
                         .Replace("@RUC", assignment.RUC)
                         .Replace("@Branch", assignment.CorpId)
                         .Replace("@Description", assignment.Description)

                         .Replace("@OT", assignment.WorkOrderNumber)
                         .Replace("@Brand", assignment.Machine.Brand)
                         .Replace("@Model", assignment.Machine.Model)
                         .Replace("@Technical", technician?.Name)
                         .Replace("@Horometro", assignment.Machine.TotalHoursFunction.ToString())
                         .Replace("@NumberSerie", assignment.Machine.SerialNumber)
                         .Replace("@DateDelivery", report.Date.ToString("dd-MM-yyyy", ci))
                         .Replace("@DateService", assignment.RequestDate.ToString("dd-MM-yyyy", ci))

                         .Replace("@Antecedent", report.Antecedent)
                         .Replace("@Work", report.Work)
                         .Replace("@Observations", report.Observation)
                         .Replace("@Recommendations", report.Replacement)
                         .Replace("@Client", client?.Name + " " + client?.LastName)
                         .Replace("@SignAct", report.UrlSign)
                         .Replace(sValue.ToString(), colorStyle)
                         //EXE
                         .Replace("@Supervisor", supervisor?.Name)
                         .Replace("@SPhone", supervisor?.Phone)
                         .Replace("@SMail", supervisor?.Email);

            var converter = new HtmlToPdfConverter();
            var pdfFile   = converter.GeneratePdf(pdfContent);
            var path      = System.IO.Path.GetTempPath();

            dynamic dynamicAttachment = new ExpandoObject();

            string pdfString = ""; string nameFile = "";

            nameFile = report.Id + ".pdf";
            if (type == 1)
            {
                pdfString = nameFile;
            }
            else if (type == 2)
            {
                pdfString = $"{path}\\" + nameFile;
                dynamicAttachment.Route = pdfString;
                System.IO.File.WriteAllBytes(pdfString, pdfFile);
            }

            string container = "act";

            dynamicAttachment.File      = pdfFile;
            dynamicAttachment.Container = container;
            dynamicAttachment.Name      = nameFile;
            dynamicAttachment.Route     = pdfString;
            dynamicAttachment.FileUrl   = "";

            var result = await StorageHelperAzure.UploadFileToAzure(dynamicAttachment
                                                                    , Constants.AzureStorage.DefaultConnectionString);

            dynamicAttachment.FileUrl = result.FileUrl;
            return(dynamicAttachment);
        }
Exemplo n.º 9
0
        public int SyncReport(BE.ReportBE.Report item)
        {
            var i = _assignmentRepository.InsertReport(item);

            return(i);
        }
Exemplo n.º 10
0
 public int UpdateUrlInformFinalSupervisor(BE.ReportBE.Report report)
 {
     return(DatabaseFactory.CreateDatabase()
            .ExecuteNonQuery("TSP_REPORT_UPDATE_FINAL_URL", report.Id, report.AssignmentId, report.UrlFile, report.ModifiedBy));
 }
Exemplo n.º 11
0
 public int UpdateInformFinalDataSupervisor(BE.ReportBE.Report report)
 {
     return(DatabaseFactory.CreateDatabase()
            .ExecuteNonQuery("TSP_REPORT_UPDATE_FINAL_SUPERVISOR", report.Id, report.AssignmentId, report.Comment2, report.Check,
                             report.ModifiedBy));
 }
Exemplo n.º 12
0
 public int UpdateArchiveInformFinal(BE.ReportBE.Report report)
 {
     return(DatabaseFactory.CreateDatabase()
            .ExecuteNonQuery("TSP_REPORT_UPDATE_FINAL", report.Id, report.AssignmentId, report.TotalMinute, report.Comment1,
                             report.UrlFile, report.Sent1, report.ModifiedBy));
 }
Exemplo n.º 13
0
 public int UpdateExecutiveReport(BE.ReportBE.Report report)
 {
     return(DatabaseFactory.CreateDatabase()
            .ExecuteNonQuery("TSP_REPORT_UPDATE_EXECUTIVE", report.Id, report.AssignmentId, report.Antecedent, report.Work,
                             report.Observation, report.Replacement, report.UrlExe, report.ModifiedBy));
 }
Exemplo n.º 14
0
 //TÉCNICO
 public int InsertReport(BE.ReportBE.Report entity)
 {
     return(DatabaseFactory.CreateDatabase()
            .ExecuteNonQuery("TSP_REPORT_INSERT", entity.Id, entity.AssignmentId, entity.Antecedent, entity.Work,
                             entity.Observation, entity.Replacement, entity.Date, entity.UrlAct, entity.UrlSign, entity.ContactId, entity.Value, entity.Online, entity.CreatedBy));
 }