public static string BuildEmailBody(Bll.MetricValue.Extend OldMetricValue, Bll.MetricValue.Extend NewMetricValue, string message, Micajah.Common.Security.UserContext context) { StringBuilder sb = new StringBuilder(); sb.Append("<!DOCTYPE HTML PUBLIC\"-//IETF//DTD HTML//EN\"><html xmlns=\"http://www.w3.org/1999/xhtml\">"); sb.Append("<head><title></title><style type=\"text/css\">body {font-family: Arial;font-size:12pt; }table {font-family: Arial;} .TableValues { text-align:left; font-weight:bolder; } .TableHeaders { text-align:right; }</style></head>"); sb.Append("<body>"); if (context != null) { sb.Append("<h3>Data Approver: " + context.FirstName + " " + context.LastName + " (" + context.Email + ")</h3> "); } if (OldMetricValue.Approved != NewMetricValue.Approved) { sb.Append("change value status from \"" + GetStatusName(OldMetricValue.Approved) + "\" to \"" + GetStatusName(NewMetricValue.Approved) + "\""); } else { sb.Append("add comment for value"); } sb.Append("<br /><br />"); sb.Append("Comment to Data Collector: " + HttpUtility.HtmlEncode(message) + "<br /><br />"); if (NewMetricValue != null) { sb.Append("Metric Value:<br /><table cellpadding=\"0\" cellspacing=\"5\" border=\"0\">"); sb.Append("<tr><th style=\"text-align:right;\">Metric</th><td style=\"text-align:left;\">" + NewMetricValue.MetricName + "</td></tr>"); sb.Append("<tr><th style=\"text-align:right;\">Org Location</th><td style=\"text-align:left;\">" + NewMetricValue.OrgLocationFullName + "</td></tr>"); sb.Append("<tr><th style=\"text-align:right;\">Date</th><td style=\"text-align:left;\">" + NewMetricValue.Period + "</td></tr>"); sb.Append("<tr><th style=\"text-align:right;\">Value</th><td style=\"text-align:left;\">" + NewMetricValue.Value + " " + NewMetricValue.ValueInputUnitOfMeasureName + "</td></tr>"); sb.Append("</table>"); } sb.Append("</body>"); sb.Append("</html>"); return(sb.ToString()); }
public static string BuildLogMessageBody(Bll.MetricValue.Extend OldValue, MetricTrac.Bll.MetricValue.Extend NewValue, string message, Micajah.Common.Security.UserContext context, Bll.Mc_User.Extend e, MetricTrac.Bll.MetricValueChangeTypeEnum changeType) { StringBuilder sb = new StringBuilder(); sb.Append("User"); if (context != null) { sb.Append(": " + context.FirstName + " " + context.LastName); } sb.Append(" "); switch (changeType) { case MetricTrac.Bll.MetricValueChangeTypeEnum.StatusChanged: sb.Append("change value status from \"" + GetStatusName(OldValue.Approved) + "\" to \"" + GetStatusName(NewValue.Approved) + "\""); break; case MetricTrac.Bll.MetricValueChangeTypeEnum.CommentToDataCollector: break; case MetricTrac.Bll.MetricValueChangeTypeEnum.NoteChanged: sb.Append("change value note from \"" + OldValue.Notes + "\" to \"" + NewValue.Notes + "\" "); break; case MetricTrac.Bll.MetricValueChangeTypeEnum.ValueEntered: sb.Append("enter value " + NewValue.Value + "\" "); break; case MetricTrac.Bll.MetricValueChangeTypeEnum.ValueChanged: default: sb.Append("change Value from \"" + OldValue.Value + "\" to \"" + NewValue.Value + "\" "); break; } sb.Append("<br />"); if (changeType != MetricTrac.Bll.MetricValueChangeTypeEnum.ValueChanged) { sb.Append("Comment to Data Collector: " + HttpUtility.HtmlEncode(message) + "<br />"); } else { sb.Append("Note: " + message + "<br />"); } if (e != null) { sb.Append("Data Collector: " + e.FullName); } sb.Append("<br />"); if (NewValue != null) { sb.Append("Metric Value:<br />"); sb.Append("Metric - " + NewValue.MetricName + "<br />"); sb.Append("Org Location - " + NewValue.OrgLocationFullName + "<br />"); sb.Append("Date - " + NewValue.Period + "<br />"); sb.Append("Value - " + NewValue.Value + " " + NewValue.ValueInputUnitOfMeasureName + "<br />"); } return(sb.ToString()); }
private void SaveBulkValues() { int i = 0; LastFrequencyMetric = GetData(); List <Bll.MetricValue.Extend> NewValues = new List <MetricValue.Extend>(); List <Bll.MetricValue.Extend> OldValues = new List <MetricValue.Extend>(); List <Bll.MetricOrgLocationUoM> MetricOrgLocationUoMList = new List <Bll.MetricOrgLocationUoM>(); foreach (RepeaterItem ri in rMetric.Items) { MetricOrgValue mov = LastFrequencyMetric.Metrics[i]; DateTime iTime = DateTime.Now; DropDownList ddlInputUnitOfMeasure = (DropDownList)ri.FindControl("ddlInputUnitOfMeasure"); HiddenField hfUoM = (HiddenField)ri.FindControl("hfUoM"); HiddenField hfMetric = (HiddenField)ri.FindControl("hfMetric"); HiddenField hfOrgLocation = (HiddenField)ri.FindControl("hfOrgLocation"); Repeater r = (Repeater)ri.FindControl("rMericValue"); Guid?ActualUoMID = null; if (ddlInputUnitOfMeasure.Visible) { if (!String.IsNullOrEmpty(ddlInputUnitOfMeasure.SelectedValue)) { ActualUoMID = new Guid(ddlInputUnitOfMeasure.SelectedValue); } } else { if (!String.IsNullOrEmpty(hfUoM.Value)) { ActualUoMID = new Guid(hfUoM.Value); } } Guid oMetricID = new Guid(hfMetric.Value); Guid oOrgLocationID = new Guid(hfOrgLocation.Value); Bll.MetricOrgLocationUoM muom = new Bll.MetricOrgLocationUoM(); muom.MetricID = oMetricID; muom.OrgLocationID = oOrgLocationID; muom.InputUnitOfMeasureID = ActualUoMID; MetricOrgLocationUoMList.Add(muom); int j = 0; foreach (RepeaterItem rri in r.Items) { DateTime jTime = DateTime.Now; HiddenField hfDate = (HiddenField)rri.FindControl("hfDate"); DateTime oDate = DateTime.Parse(hfDate.Value); Telerik.Web.UI.RadNumericTextBox rntValue = (Telerik.Web.UI.RadNumericTextBox)rri.FindControl("rntValue"); System.Web.UI.WebControls.TextBox tbValue = (System.Web.UI.WebControls.TextBox)rri.FindControl("tbValue"); System.Web.UI.WebControls.CheckBox chbValue = (System.Web.UI.WebControls.CheckBox)rri.FindControl("chbValue"); Telerik.Web.UI.RadDatePicker rdpDateValue = (Telerik.Web.UI.RadDatePicker)rri.FindControl("rdpDateValue"); System.Web.UI.WebControls.DropDownList ddlApprovalStatus = (System.Web.UI.WebControls.DropDownList)rri.FindControl("ddlApprovalStatus"); Bll.MetricValue.Extend OldMetricValue = mov.MetricValues[j]; string Value = String.Empty; if (rntValue.Visible) { Value = rntValue.Value.ToString(); } else if (tbValue.Visible) { Value = tbValue.Text; } else if (chbValue.Visible) { Value = chbValue.Checked ? bool.TrueString : bool.FalseString; } else if (rdpDateValue.Visible) { Value = rdpDateValue.SelectedDate.ToString(); } bool?Approved = OldMetricValue.Approved; if (DataMode == Mode.Approve) { switch (ddlApprovalStatus.SelectedValue) { case "": Approved = null; break; case "True": Approved = true; break; case "False": default: Approved = false; break; } } if ( ( ( !String.IsNullOrEmpty(Value) || (OldMetricValue.MetricValueID != Guid.Empty && String.IsNullOrEmpty(Value)) ) && Value != OldMetricValue.Value ) || (DataMode == Mode.Approve && Approved != OldMetricValue.Approved)) { MetricValue.Extend nv = new MetricValue.Extend(); nv.MetricID = oMetricID; nv.Date = oDate; nv.OrgLocationID = oOrgLocationID; nv.InputUnitOfMeasureID = ActualUoMID; nv.Value = Value; nv.Approved = Approved; // additional fields nv.Period = Frequency.GetPeriodName(oDate, FrequencyID); nv.MetricName = mov.Name; nv.OrgLocationFullName = mov.OrgLocationFullName; nv.Notes = OldMetricValue.Notes; nv.ValueInputUnitOfMeasureName = mov.OrgLocationUnitOfMeasureName; NewValues.Add(nv); OldValues.Add(OldMetricValue); } LogTime += " value " + j.ToString() + " time " + ((TimeSpan)(DateTime.Now - jTime)).TotalMilliseconds; j++; } LogTime += "Row " + i.ToString() + " time " + ((TimeSpan)(DateTime.Now - iTime)).TotalMilliseconds + "<br />"; i++; } Bll.MetricValue.SaveBulkValues(MetricOrgLocationUoMList, NewValues, OldValues, Micajah.Common.Security.UserContext.Current, DataMode == Mode.Input); }