private bool ValidateRepairJobEntry(RepairJobEntry entryIn) { if (entryIn == null) { return(false); } if (entryIn.JobId == null || entryIn.JobId == "") { return(false); } if (entryIn.Make == null || entryIn.Make == "") { return(false); } if (entryIn.Model == null || entryIn.Model == "") { return(false); } if (entryIn.Complaint == null || entryIn.Complaint == "") { return(false); } if (entryIn.Problem == null || entryIn.Problem == "") { return(false); } return(true); }
private List <EntrySimilarity> getSimilar(RepairJobEntry Query, List <RepairJobEntry> potentials, int maxRet) { Dictionary <float, List <EntrySimilarity> > distanceMappings = new Dictionary <float, List <EntrySimilarity> >(); HashSet <float> keys = new HashSet <float>(); List <EntrySimilarity> ret = new List <EntrySimilarity>(); foreach (RepairJobEntry other in potentials) { float dist = CalcSimilarity(Query, other); if (!distanceMappings.ContainsKey(dist)) { keys.Add(dist); distanceMappings.Add(dist, new List <EntrySimilarity>()); } distanceMappings[dist].Add(new EntrySimilarity() { Entry = other, Difference = dist }); } float[] sortedKeys = new float[keys.Count]; keys.CopyTo(sortedKeys); sortedKeys.RadixSort(); int keyIndex = 0; while (ret.Count <= maxRet && keyIndex < sortedKeys.Length) { ret.AddRange(distanceMappings[sortedKeys[keyIndex]]); keyIndex++; } if (ret.Count < maxRet) { return(ret); } return(ret.GetRange(0, maxRet)); }
private void LoadRepairs() { var myRepairs = technicianService.GetRepairsByTechnicianId(technicianService.CurrentTechnician); myRepairs = from reps in myRepairs where reps.State == State.InProgress select reps; foreach (RepairView r in myRepairs) { var repairEntry = new RepairJobEntry(); repairEntry.descriptionTblock.Text = r.Description; repairEntry.repairIdLbl.Content = "ID: " + r.Id.ToString(); repairEntry.repairStateLbl.Content = r.State; repairEntry.licencePlateLbl.Content = r.Auto.LicencePlate.ToString(); repairEntry.managerLbl.Content = r.Manager?.User?.Username ?? "adminInside%"; List <long> techIDs = new List <long>(); List <TechnicianView> techs = new List <TechnicianView>(); if (r.RepairTechnicians != null) { techIDs = (from repair in r.RepairTechnicians where repair.RepairID == r.Id select repair.TechnicianId).ToList(); } if (technicianService.Technicians != null) { techs = technicianService.Technicians.FindAll(t => techIDs.Contains(t.Id)); } foreach (TechnicianView t in techs) { repairEntry.techsLbox.Items.Add(t.Name); } repairEntry.repairLogBtn.Click += (object sender, RoutedEventArgs args) => { topbarpanel.Children.Clear(); entryPanel.Children.Clear(); LoadRepairLogs(r.Id); }; repairEntry.doneBtn.Click += (object sender, RoutedEventArgs args) => { r.State = State.Done; if (MessageBox.Show("Leadás után a munka automatikusan írásvédett lesz.", "Biztosan leadja a munkát?", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { repairEntry.Visibility = Visibility.Collapsed; } technicianService.UpdateRepair(r); }; entryPanel.Children.Add(repairEntry); } }
private void LoadAvailableRepairs() { var myRepairs = technicianService.GetAvailableRepairs(); foreach (RepairView r in myRepairs) { var repairEntry = new RepairJobEntry(); repairEntry.descriptionTblock.Text = r.Description; repairEntry.repairIdLbl.Content = "ID: " + r.Id.ToString(); repairEntry.repairStateLbl.Content = r.State; repairEntry.licencePlateLbl.Content = r.Auto.LicencePlate.ToString(); repairEntry.managerLbl.Content = r.Manager?.User?.Username ?? "adminInside%"; List <long> techIDs = new List <long>(); List <TechnicianView> techs = new List <TechnicianView>(); if (r.RepairTechnicians != null) { techIDs = (from repair in r.RepairTechnicians where repair.RepairID == r.Id select repair.TechnicianId).ToList(); } if (technicianService.Technicians != null) { techs = technicianService.Technicians.FindAll(t => techIDs.Contains(t.Id)); } foreach (TechnicianView t in techs) { repairEntry.techsLbox.Items.Add(t.Name); } repairEntry.doneBtn.Click += (object sender, RoutedEventArgs args) => { r.State = State.InProgress; r.RepairTechnicians.Add( new RepairTechnicianView { RepairID = r.Id, TechnicianId = technicianService.CurrentTechnician.Id } ); technicianService.UpdateRepair(r); repairEntry.Visibility = Visibility.Collapsed; }; repairEntry.doneBtn.Content = "Felvesz"; repairEntry.repairLogBtn.IsEnabled = false; entryPanel.Children.Add(repairEntry); } }
public static double PerformAutomatedTestingWithData(MySqlDataManipulator manipulator, int companyId, DatabaseQueryProcessor processor, List <RepairJobEntry> entries) { double currentDifference = 0; foreach (RepairJobEntry entry in entries) { RepairJobEntry testEntryCopy = new RepairJobEntry() { Make = entry.Make, Model = entry.Model, Year = entry.Year, Complaint = entry.Complaint }; List <string> entryProblemKeywords = processor.PredictKeywordsInJobData(entry, false); int startingNumKeywords = entryProblemKeywords.Count; string complaintGroupsJson = processor.ProcessQueryForComplaintGroups(testEntryCopy, manipulator, companyId); List <ComplaintGroupJson> complaintGroups = JsonDataObjectUtil <List <ComplaintGroupJson> > .ParseObject(complaintGroupsJson); List <int> complaintGroupIds = complaintGroups.Select(group => { return(group.Id); }).ToList(); foreach (int complaintGroupId in complaintGroupIds) { string dataEntryJson = processor.ProcessQueryForSimilarQueries(testEntryCopy, manipulator, companyId, complaintGroupId, 5); List <SimilarQueryJson> jobDataEntries = JsonDataObjectUtil <List <SimilarQueryJson> > .ParseObject(dataEntryJson); List <RepairJobEntry> dataEntries = jobDataEntries.Select(query => new RepairJobEntry() { Make = query.Make, Model = query.Model, Problem = query.Problem, Complaint = query.Complaint }).ToList(); foreach (RepairJobEntry currEntry in dataEntries) { List <string> currEntryKeywords = processor.PredictKeywordsInJobData(currEntry, false); List <string> toRemove = entryProblemKeywords.Where(keyword => currEntryKeywords.Contains(keyword)).ToList(); foreach (string keyword in toRemove) { entryProblemKeywords.Remove(keyword); } } } currentDifference += (double)entryProblemKeywords.Count / startingNumKeywords; } return((currentDifference / entries.Count) * 100); }
private static float CalcSimilarity(RepairJobEntry query, RepairJobEntry other) { IKeywordPredictor keyPred = NaiveBayesKeywordPredictor.GetGlobalModel(); AveragedPerceptronTagger tagger = AveragedPerceptronTagger.GetTagger(); List <String> tokened = SentenceTokenizer.TokenizeSentence(query.Complaint); List <List <String> > tagged = tagger.Tag(tokened); List <String> InputComplaintKeywords = keyPred.PredictKeywords(tagged); tokened = SentenceTokenizer.TokenizeSentence(query.Problem); tagged = tagger.Tag(tokened); List <String> InputProblemKeywords = keyPred.PredictKeywords(tagged); float score = 0; tokened = SentenceTokenizer.TokenizeSentence(other.Complaint); tagged = tagger.Tag(tokened); List <String> JobComplaintKeywords = keyPred.PredictKeywords(tagged); tokened = SentenceTokenizer.TokenizeSentence(other.Problem); tagged = tagger.Tag(tokened); List <String> JobProblemKeywords = keyPred.PredictKeywords(tagged); foreach (String keyword in JobComplaintKeywords) { if (InputComplaintKeywords.Contains(keyword)) { score++; } } foreach (String keyword in JobProblemKeywords) { if (InputProblemKeywords.Contains(keyword)) { score++; } } return(score / (JobComplaintKeywords.Count + JobProblemKeywords.Count)); }
public override void PerformFunction(MySqlDataManipulator manipulator) { //Convert all MechanicQueries to RepairJobEntries FileSystemDataSource dataSource = new FileSystemDataSource(); List <MechanicQuery> queries = dataSource.LoadMechanicQueries(); List <RepairJobEntry> toWrite = new List <RepairJobEntry>(); foreach (MechanicQuery query in queries) { RepairJobEntry toAdd = new RepairJobEntry() { Make = query.Make, Model = query.Model, Complaint = query.Complaint, Problem = query.Problem, JobId = "Unknown", Year = -1 }; toWrite.Add(toAdd); } //Write all RepairJobEntries to the specified file StreamWriter fileWriter = new StreamWriter(FilePath); //This is a CLI for devs, so no worries if this goes wonky fileWriter.WriteLine('['); foreach (RepairJobEntry entry in toWrite) { string entryJson = JsonDataObjectUtil <RepairJobEntry> .ConvertObject(entry); fileWriter.WriteLine(entryJson); } fileWriter.WriteLine(']'); fileWriter.Close(); }