private AmznAdHoc LoadAdHocData(string adhocFile) { AmznAdHoc newAmznAdHoc = new AmznAdHoc(); //TODO : ADD CHECK HERE List <AdHocItem> values = File.ReadAllLines(adhocFile) .Skip(1) .Select(v => AdHocItem.FromCsv(v)) .ToList(); newAmznAdHoc.AllAdhocItems = values; return(newAmznAdHoc); }
private void RunAnalysisBTN_Click(object sender, RoutedEventArgs e) { AmznAssist newAssist = new AmznAssist(); AmznAdHoc newAdHoc = new AmznAdHoc(); AssistError newErrors = new AssistError(); newAssist = LoadAssistCsv(PartDBTB.Text); newAdHoc = LoadAdHocData(AssistReportTB.Text); foreach (AdHocItem item in newAdHoc.AllAdhocItems) { SingleAmznAssist assistItem = newAssist.AllAmznList.Where(x => x.ASIN == item.PartNo).FirstOrDefault(); double correctValue = 0; double test = 0; if (assistItem != null) { //test = RoundUp(assistItem.AssistValue, 2); test = assistItem.AssistValue; correctValue = test * item.CommQty; } if (Math.Round(correctValue, 2) != (RoundUp(item.AssistValue, 2) / 100)) { //CREATE ERROR RECORD TO DISPLAY HERE SingleAssistError newError = new SingleAssistError(); newError.FileNo = item.FileNo; newError.ClientNo = item.ClientNo; newError.CommInvNo = item.CommInvNo; newError.CommInvLineNo = item.CommInvLineNo; newError.CommQty = item.CommQty; newError.Uom = item.Uom; newError.PartNo = item.PartNo; newError.ForeignValue = item.ForeignValue; //newError.AssistValue = (RoundUp(item.AssistValue,2)/100); newError.AssistValue = item.AssistValue / 100; newError.FileLogged = item.FileLogged; newError.CR = item.CR; newError.ES = item.ES; //if (assistItem != null) { newError.AmznAssistValuePerPart = RoundUp(assistItem.AssistValue,2); } if (assistItem != null) { newError.AmznAssistValuePerPart = assistItem.AssistValue; } newError.CorrectAssistValue = correctValue; newError.Status = "FAIL"; if (assistItem == null || assistItem.ASIN == "") { newError.PartStatus = "NO PART FOUND IN CAT FILE"; } else { newError.PartStatus = "PART FOUND IN CAT FILE"; } newErrors.AllAssistErrors.Add(newError); } else { SingleAssistError newError = new SingleAssistError(); newError.FileNo = item.FileNo; newError.ClientNo = item.ClientNo; newError.CommInvNo = item.CommInvNo; newError.CommInvLineNo = item.CommInvLineNo; newError.CommQty = item.CommQty; newError.Uom = item.Uom; newError.PartNo = item.PartNo; newError.ForeignValue = item.ForeignValue; //newError.AssistValue = (RoundUp(item.AssistValue, 2) / 100); newError.AssistValue = item.AssistValue / 100; newError.FileLogged = item.FileLogged; newError.CR = item.CR; newError.ES = item.ES; //if (assistItem != null) { newError.AmznAssistValuePerPart = RoundUp(assistItem.AssistValue,2); } if (assistItem != null) { newError.AmznAssistValuePerPart = assistItem.AssistValue; } newError.CorrectAssistValue = correctValue; newError.Status = "PASS"; if (assistItem == null || assistItem.ASIN == "") { newError.Status = "FAIL"; newError.PartStatus = "NO PART FOUND IN CAT FILE"; } else { newError.PartStatus = "PART FOUND IN CAT FILE"; } newErrors.AllAssistErrors.Add(newError); } } DataTable table = new DataTable(); table = ToDataTable <SingleAssistError>(newErrors.AllAssistErrors); DataGridViewDG.ItemsSource = newErrors.AllAssistErrors; double totalItems = newErrors.AllAssistErrors.Count(); double totalErrorItems = newErrors.AllAssistErrors.Where(x => x.Status == "FAIL").Count(); double accuracyPercentage = ((totalItems - totalErrorItems) / totalItems) * 100; AccPercLabel.Content = "Accuracy Rate : " + accuracyPercentage.ToString("f2") + " %"; if (accuracyPercentage >= 95) { AccPercLabel.Foreground = System.Windows.Media.Brushes.Green; } else if (accuracyPercentage >= 85 && accuracyPercentage < 95) { AccPercLabel.Foreground = System.Windows.Media.Brushes.Orange; } else { AccPercLabel.Foreground = System.Windows.Media.Brushes.Red; } }