private string CreatedQREmailNewReport(QualityReport _report) { string EmailBody = "<html><body>"; EmailBody += "<h2>Ny kvalitetsrapport</h2>"; EmailBody += "<table style=\"width:700px\">"; EmailBody += "<tr><td style=\"font-size:8pt\">Rapportnr</td><td style=\"font-size:8pt\">Skapad</td></tr>"; EmailBody += "<tr><td></td><td>" + _report.Created.ToString("yyyy-MM-dd hh:mm") + "</td></tr>"; EmailBody += "</table><br/>"; EmailBody += "<table><tr><td style=\"font-size:8pt\">" + _report.CQReportTaskRows.First().OfficeDepartmentTask.OfficeDepartment.Name + "</td></tr>"; //// Förtsätt här EmailBody += "<tr><td style=\"color:Red;font-size:13pt\"><b>" + _report.CQReportTaskRows.First().OfficeDepartmentTask.Name + "</b></td></tr></table><br/>"; EmailBody += "<tr><td>" + _report.Description + "</td></tr></table><br/>"; EmailBody += "<table style=\"width:700px\">"; EmailBody += "<tr><td style=\"font-size:8pt\">Handläggare</td><td style=\"font-size:8pt\">Skapad av</td></tr>"; EmailBody += "<tr><td>" + _report.QRResponsible.Employee.FName + " " + _report.QRResponsible.Employee.LName + "</td><td>" + _report.Employee.FName + " " + _report.Employee.LName + "</td></tr>"; EmailBody += "<tr><td></td><td></td></tr>"; EmailBody += "</table>"; EmailBody += "<hr/>"; EmailBody += "<table style=\"width:700px\"><tr>"; EmailBody += "<td><b>" + _report.Office.Name + "</b></td>"; EmailBody += "<td>" + _report.Office.Address + "</td>"; EmailBody += "<td>" + _report.Office.ZipCode + "</td>"; EmailBody += "<td>" + _report.Office.City + "</td>"; EmailBody += "<td>" + _report.Office.Phone + "</td>"; EmailBody += "<td>" + _report.Office.Email + "</td>"; EmailBody += "</tr></table>"; EmailBody += "</body></html>"; return(EmailBody); }
static bool TakeInvestment(QualityReport report, AtratinusConfiguration config) { if (!config.TakeFilesBeforeSECReform && !report.SubmittedAfterSECReform) { return(false); } if (report.Quality == QualityLevel.T_TIER) { return(false); } if (!report.UsefulSubmissionType) { return(false); } return(true); }
private void GetAciveQualityReports() { try { DbContext = new Service1Client(Service1Client.EndpointConfiguration.BasicHttpBinding_IService1); var result = DbContext.GetMyActiveQualityReports(Application.Current.Properties["UN"].ToString(), Application.Current.Properties["PW"].ToString(), Application.Current.Properties["Ucid"].ToString(), Convert.ToInt32(Application.Current.Properties["EmpId"])); ObservableCollection <QualityReport> temp = new ObservableCollection <QualityReport>(); foreach (QualityReportRowData row in result) { QualityReport qualityReport = new QualityReport(); qualityReport.Id = row.Id; qualityReport.ReportNr = row.ReportNr; qualityReport.ResponsibleName = row.ResponsibleName; qualityReport.Department = row.Department; qualityReport.DepartmentTask = row.DepartmentTask; qualityReport.OfficeName = row.OfficeName; qualityReport.Year = row.Year; qualityReport.OfficeAddress = row.OfficeAddress; qualityReport.NextMeasure = row.NextMeasure; qualityReport.NextMeasureDate = row.NextMeasureDatetime; qualityReport.Interval = Interval(row.NextMeasureDatetime); temp.Add(qualityReport); } ActiveReports = new ObservableCollection <QualityReport>(temp); ReportsCounter = ActiveReports.Count(); } catch (Exception e) { Application.Current.MainPage.DisplayAlert("Fel", e.Message, "STÄNG"); } }
public void SendNewQualityReportMail(QualityReport mailreport) { try { KvalPortDbEntities db = new KvalPortDbEntities(); QualityReport _report = db.QualityReports.Where(r => r.Id == mailreport.Id).FirstOrDefault(); if (_report != null) { ObservableCollection <QRStatusEmailNotification> SelectedOfficeQREmailNotifications = new ObservableCollection <QRStatusEmailNotification>(from qrEmail in db.QRStatusEmailNotifications where qrEmail.OfficeId == _report.OfficeId && qrEmail.StatusId == 1 select qrEmail); if (SelectedOfficeQREmailNotifications.Count > 0) { ObservableCollection <string> sentEmails = new ObservableCollection <string>(); EmailSent es; QRLog qrLog = new QRLog(); qrLog.Cost = 0; qrLog.Created = DateTime.Now; qrLog.CreatedBy = _report.CreatedBy;; qrLog.LogTypeId = 3; // (int)QRLogTypesEnum.Programåtgärd; qrLog.QualityReportId = _report.Id; qrLog.Deleted = false; qrLog.Subject = "Epost har skickats (rapport skapad)"; qrLog.Description = ""; StringBuilder descrp = new StringBuilder(); string EmailBody = CreatedQREmailNewReport(_report); foreach (QRStatusEmailNotification not in SelectedOfficeQREmailNotifications) { es = new EmailSent(); es.Automatic = true; es.Created = DateTime.Now; es.FromAdress = "*****@*****.**"; es.ModuleId = 1; es.OfficeId = _report.OfficeId; es.Password = "******"; es.Username = "******"; es.UseSSL = true; es.Port = 25; es.Server = "localhost"; es.Subject = "Kvalitetsrapport"; es.ToAdress = ""; es.SendMessage = "test"; es.Sent = false; if (not.IsEmployee) { if (not.Employee.Email == null || not.Employee.Email.Count() < 1) { descrp.AppendLine("Epost kunde inte skickas till användaren: " + not.Employee.FName + " " + not.Employee.LName + ". Orsak: Epost-adress saknades"); } else if (not.Employee.Email.Count() < 5) { descrp.AppendLine("Epost kunde inte skickas till användaren: " + not.Employee.FName + " " + not.Employee.LName + ". Orsak: Epost-adress felaktig"); } else { es.Body = EmailBody; descrp.AppendLine("Epost har skickats till : " + not.Employee.FName + " " + not.Employee.LName + " (" + not.Employee.Email + ")"); es.ToAdress = not.Employee.Email; if (sentEmails.Contains(es.ToAdress)) { es.Sent = true; } else { sentEmails.Add(es.ToAdress); es.SendMessage = SendEmail(es); } db.EmailSents.Add(es); } } else if (not.IsMailContact) { if (not.EmailContact.Email == null || not.EmailContact.Email.Count() < 1) { descrp.AppendLine("Epost kunde inte skickas till epost-kontakten: " + not.EmailContact.Name + ". Orsak: Epost-adress saknades"); } else if (not.EmailContact.Email.Count() < 5) { descrp.AppendLine("Epost kunde inte skickas till epost-kontakten: " + not.EmailContact.Name + ". Orsak: Epost-adress felaktig"); } else { es.Body = EmailBody; descrp.AppendLine("Epost har skickats till epost-kontkten: " + not.EmailContact.Email + " (" + not.EmailContact.Email + ")"); es.ToAdress = not.EmailContact.Email; if (sentEmails.Contains(es.ToAdress)) { es.Sent = true; } else { es.SendMessage = SendEmail(es); sentEmails.Add(es.ToAdress); } db.EmailSents.Add(es); } } else if (not.IsReportRole) { if (not.ReportRoll == "Responsible") { if (_report.QRResponsible.Employee.Email == null || _report.QRResponsible.Employee.Email.Count() < 1) { descrp.AppendLine("Epost kunde inte skickas till handläggaren: " + _report.QRResponsible.Employee.FName + " " + _report.QRResponsible.Employee.LName + ". Orsak: Epost-adress saknades"); } else if (_report.QRResponsible.Employee.Email.Count() < 5) { descrp.AppendLine("Epost kunde inte skickas till handläggaren: " + _report.QRResponsible.Employee.FName + " " + _report.QRResponsible.Employee.LName + ". Orsak: Epost-adress felaktig"); } else { es.Body = EmailBody; descrp.AppendLine("Epost har skickats till handläggaren: " + _report.QRResponsible.Employee.FName + " " + _report.QRResponsible.Employee.LName + " (" + _report.QRResponsible.Employee.Email + ")"); es.ToAdress = _report.QRResponsible.Employee.Email; if (sentEmails.Contains(es.ToAdress)) { es.Sent = true; } else { es.SendMessage = SendEmail(es); sentEmails.Add(es.ToAdress); } db.EmailSents.Add(es); } } else if (not.ReportRoll == "CausedBy") { if (_report.OfficeDepartment.Employee.Email == null || _report.OfficeDepartment.Employee.Email.Count() < 1) { descrp.AppendLine("Epost kunde inte skickas till avdelningsansvarig för orsakad av: " + _report.OfficeDepartment.Employee.FName + " " + _report.OfficeDepartment.Employee.LName + ". Orsak: Epost-adress saknades"); } else if (_report.OfficeDepartment.Employee.Email.Count() < 5) { descrp.AppendLine("Epost kunde inte skickas till avdelningsansvarig för orsakad av: " + _report.OfficeDepartment.Employee.FName + " " + _report.OfficeDepartment.Employee.LName + ". Orsak: Epost-adress felaktig"); } else { es.Body = EmailBody; descrp.AppendLine("Epost har skickats till avdelningsansvarig för orsakad av: " + _report.OfficeDepartment.Employee.FName + " " + _report.OfficeDepartment.Employee.LName); es.ToAdress = _report.OfficeDepartment.Employee.Email; if (sentEmails.Contains(es.ToAdress)) { es.Sent = true; } else { es.SendMessage = SendEmail(es); sentEmails.Add(es.ToAdress); } db.EmailSents.Add(es); } } else if (not.ReportRoll == "CreatedBy") { if (_report.Employee.Email == null || _report.Employee.Email.Count() < 1) { descrp.AppendLine("Epost kunde inte skickas till användaren som skapade ärendet: " + _report.Employee.FName + " " + _report.Employee.LName + ". Orsak: Epost-adress saknades"); } else if (_report.Employee.Email.Count() < 5) { descrp.AppendLine("Epost kunde inte skickas till användaren som skapade ärendet: " + _report.Employee.FName + " " + _report.Employee.LName + ". Orsak: Epost-adress felaktig"); } else { es.Body = EmailBody; descrp.AppendLine("Epost har skickats till användaren som skapade ärendet: " + _report.Employee.FName + " " + _report.Employee.LName + " (" + _report.Employee.Email + ")"); es.ToAdress = _report.Employee.Email; if (sentEmails.Contains(es.ToAdress)) { es.Sent = true; } else { es.SendMessage = SendEmail(es); sentEmails.Add(es.ToAdress); } db.EmailSents.Add(es); } } } } if (descrp.Length > 5) { qrLog.Description = descrp.ToString(); db.QRLogs.Add(qrLog); } db.SaveChanges(); } } } catch (Exception ex) { //IsLoading = false; // ErrorWindow.CreateNew("Kunde inte skapa och skicka email. Felmeddelande: " + ex.Message); } }
public void UpdateValue(QualityReport report) { UpdateValue(report.Id, report.ProjectId, report.CriticalBugs, report.MajorBugs, report.MinorBugs, report.DoneBugs, report.ReOpenBugs, report.YearWeek); }
internal static QualityReport Measure(InvestmentActivity investment, AtratinusConfiguration config) { var report = new QualityReport(); ushort badStates = 0; if (!DataValidators.IsValidAccessionNumber(investment.AccessionNumber)) { report.Invalidations.Add("AccessionNumber"); report.Quality = QualityLevel.T_TIER; investment.DataQualityLevel = QualityLevel.T_TIER.ToString(); } if (!DataValidators.IsValidFilingDate(investment.FilingDate)) { badStates++; report.Invalidations.Add("FilingDate"); } else { var year = Convert.ToInt32(investment.FilingDate.Substring(0, 4)); var month = Convert.ToInt32(investment.FilingDate.Substring(4, 2)); var day = Convert.ToInt32(investment.FilingDate.Substring(6, 2)); if (new DateTime(year, month, day) < new DateTime(1998, 2, 17)) { report.SubmittedAfterSECReform = false; } else { report.SubmittedAfterSECReform = true; } } if (!DataValidators.IsValidPurposeOfTransaction(investment.PurposeOfTransaction)) { badStates++; report.Invalidations.Add("PurposeOfTransaction"); } if (!DataValidators.IsValidTypeOfReportingPerson(investment.TypeOfReportingPerson)) { badStates++; report.Invalidations.Add("TypeOfReportingPerson"); } if (!investment.SubmissionType.HasValue) { badStates++; report.Invalidations.Add("SubmissionType"); report.UsefulSubmissionType = false; } else { if (investment.SubmissionType.Value == Core.Enums.SubmissionType.SC_13D) { report.UsefulSubmissionType = true; } else { report.UsefulSubmissionType = false; } } if (report.Quality == QualityLevel.T_TIER) { return(report); } switch (badStates) { case 0: { investment.DataQualityLevel = QualityLevel.S_TIER.ToString(); report.Quality = QualityLevel.S_TIER; break; } case 1: { investment.DataQualityLevel = QualityLevel.A_TIER.ToString(); report.Quality = QualityLevel.A_TIER; break; } case 2: { investment.DataQualityLevel = QualityLevel.B_TIER.ToString(); report.Quality = QualityLevel.B_TIER; break; } case 3: { investment.DataQualityLevel = QualityLevel.C_TIER.ToString(); report.Quality = QualityLevel.C_TIER; break; } default: { investment.DataQualityLevel = QualityLevel.T_TIER.ToString(); report.Quality = QualityLevel.T_TIER; break; } } report.ShouldBeConsidered = TakeInvestment(report, config); return(report); }
private void GetReportData() { DbContext = new Service1Client(Service1Client.EndpointConfiguration.BasicHttpBinding_IService1); var data = DbContext.GetQualityReportById(Application.Current.Properties["UN"].ToString(), Application.Current.Properties["PW"].ToString(), Application.Current.Properties["Ucid"].ToString(), IniQRId); ReportData = new QualityReport(); QualityReport qualityReport = new QualityReport(); qualityReport.Id = data.Id; qualityReport.ReportNr = data.ReportNr; qualityReport.DateCreated = data.Created; qualityReport.Status = data.Status; TimeSpan span = DateTime.Now - data.Created; qualityReport.Interval = span.Days + " dag " + span.Hours + " tim"; if (data.CreatedByEmployee != null) { Employee createdBy = new Employee(); createdBy.Id = data.CreatedByEmployee.Id; createdBy.Name = data.CreatedByEmployee.FName + " " + data.CreatedByEmployee.LName; qualityReport.CreatedByEmployee = createdBy; } if (data.OfficeData != null) { Office off = new Office(); off.Id = data.OfficeData.Id; off.Name = data.OfficeData.Name; qualityReport.Office = off; } //"Felbeskrivning" the following 3 properties qualityReport.Department = data.OfficeDepartment; qualityReport.DepartmentTask = data.OfficeDepartmentTask; qualityReport.OfficeDepartmentTaskId = data.OfficeDepartmentTaskId; qualityReport.Description = data.Description; //"Trolig orsak" the following 3 properties qualityReport.QRAnalysisHeaderId = data.QRAnalysisHeaderId; qualityReport.QRAnalysisHeader = data.QRAnalysisHeader; qualityReport.AnalysisText = data.AnalysisText; qualityReport.AnalysisCausedById = data.AnalysisCausedById; if (data.CausedByEmployees != null) { qualityReport.CausedByEmployees = new ObservableCollection <Employee>(); Employee causedBy; foreach (var emp in data.CausedByEmployees) { causedBy = new Employee(); causedBy.Id = emp.Id; causedBy.Name = emp.FName + " " + emp.LName; qualityReport.CausedByEmployees.Add(causedBy); } } //"Slutlig åtgärd" the following 4 properties qualityReport.QRFinalDecisionHeader = data.QRFinalDecisionHeader; qualityReport.FinalDecisionText = data.FinalDecisionText; qualityReport.FinalDecisionCost = data.FinalDecisionCost; qualityReport.IsRepeatRepair = data.IsRepeatRepair; if (data.ResponsibleEmployee != null) { Employee responsible = new Employee(); responsible.Id = data.ResponsibleEmployee.Id; responsible.Name = data.ResponsibleEmployee.FName + " " + data.ResponsibleEmployee.LName; qualityReport.ResponsibleEmployee = responsible; } if (data.QRAttachedFileData != null) { QRAttachedFile attachedFile; AllImages = new ObservableCollection <QRAttachedFile>(); foreach (var img in data.QRAttachedFileData) { attachedFile = new QRAttachedFile(); attachedFile.Id = img.Id; attachedFile.FileName = img.FileName; attachedFile.FilePath = img.FilePath; AllImages.Add(attachedFile); } } qualityReport.AoNr = data.AoNr; qualityReport.RegNr = data.RegNr; qualityReport.TotalCost = data.TotalCost; qualityReport.Year = data.Year; qualityReport.Deleted = data.Deleted; if (data.QRLogs != null) { qualityReport.QRLog = new ObservableCollection <QRLog>(); QRLog qrlog; foreach (var log in data.QRLogs.OrderBy(o => o.Id)) { qrlog = new QRLog(); qrlog.QRId = log.QualityReportId; qrlog.Id = log.Id; qrlog.LogTypeId = log.LogTypeId; qrlog.LogTypeText = log.LogTypeText; qrlog.Subject = log.Subject; qrlog.Created = log.Created; qrlog.Description = log.Description; if (log.CreatedEmployee != null) { Employee emp = new Employee(); emp.Id = log.CreatedEmployee.Id; emp.Name = log.CreatedEmployee.FName + " " + log.CreatedEmployee.LName; qrlog.CreatedByEmployee = emp; } qualityReport.QRLog.Add(qrlog); } } ReportData = qualityReport; }
public async Task HandleAsync(AddEditWeeklyReportPhrCommand request) { var currentYearWeek = TimeHelper.CalculateYearWeek(request.Report.SelectedYear, request.Report.SelectedWeek); using (var transaction = await _dbContext.Database.BeginTransactionAsync()) { try { var project = await _dbContext.Projects .FirstAsync(p => p.Id == request.Report.ProjectId); var cache = (await _mediator.SendAsync(new GetProjectCachingQuery() { ProjectId = request.Report.ProjectId, })).GetResponse(); project.SetCollections(_mapper.Map <IEnumerable <QualityReport> >(cache.QualityReports), _mapper.Map <IEnumerable <BacklogItem> >(cache.BacklogItems), _mapper.Map <IEnumerable <Status> >(cache.Statuses)); _dbContext.Projects.Attach(project); var s = request.Report.Status; var status = new Status(s.Id, request.Report.ProjectId, s.StatusColor, s.ProjectStatus, s.RetrospectiveFeedBack, s.MilestoneDate, s.Milestone, currentYearWeek); project.AddEditStatus(status); var i = request.Report.BacklogItem; var item = new BacklogItem(i.Id, request.Report.ProjectId, i.Sprint, i.ItemsAdded, i.StoryPointsAdded, i.ItemsDone, i.StoryPointsDone, currentYearWeek); project.AddEditBacklogItem(item); var q = request.Report.QualityReport; var report = new QualityReport(q.Id, request.Report.ProjectId, q.CriticalBugs, q.MajorBugs, q.MinorBugs, q.DoneBugs, q.ReOpenBugs, currentYearWeek); project.AddEditQualityReport(report); if (project.DodRequired) { var command = new EditDoDReportCommand() { DodReports = request.Report.DodRecords.Select(r => new EditDoDReportCommand.DoDReportDto { MetricId = r.MetricId, ProjectId = project.Id, Value = r.Value, YearWeek = currentYearWeek, LinkToReport = r.LinkToReport, ReportFileName = r.ReportFileName }).ToList() }; await _mediator.SendAsync(command); } await _dbContext.SaveChangesAsync(); await transaction.CommitAsync(); request.Response = 1; } catch (Exception) { await transaction.RollbackAsync(); throw; } } }