static List <EcuFunctionStructs.EcuJobResult> GetMatchingEcuJobResults(EcuFunctionStructs.EcuJob ecuJob, EcuFunctionStructs.EcuJobResult ecuJobResultComp) { if (ecuJobResultComp == null || string.IsNullOrEmpty(ecuJobResultComp.Name)) { return(null); } int resultCount = 0; List <EcuFunctionStructs.EcuJobResult> jobResultList = new List <EcuFunctionStructs.EcuJobResult>(); if (ecuJob.EcuJobResultList != null) { foreach (EcuFunctionStructs.EcuJobResult ecuJobResult in ecuJob.EcuJobResultList) { if (!string.IsNullOrEmpty(ecuJobResult.Name)) { resultCount++; if ((string.Compare(ecuJobResult.Name.Trim(), ecuJobResultComp.Name.Trim(), StringComparison.OrdinalIgnoreCase) == 0) && (string.Compare(ecuJobResult.FuncNameResult.Trim(), ecuJobResultComp.FuncNameResult.Trim(), StringComparison.OrdinalIgnoreCase) == 0)) { jobResultList.Add(ecuJobResult); } } } } if (resultCount == 0) { return(null); } return(jobResultList); }
static int MergeEcuJobResults(TextWriter outTextWriter, string fileName, EcuFunctionStructs.EcuJob ecuJobIn, EcuFunctionStructs.EcuJob ecuJobMerge) { int resultCount = 0; if (ecuJobMerge.EcuJobResultList != null) { foreach (EcuFunctionStructs.EcuJobResult ecuJobResult in ecuJobMerge.EcuJobResultList) { if (!string.IsNullOrEmpty(ecuJobResult.Name)) { List <EcuFunctionStructs.EcuJobResult> jobResultList = GetMatchingEcuJobResults(ecuJobIn, ecuJobResult); if (jobResultList != null) { foreach (EcuFunctionStructs.EcuJobResult ecuJobResultMatch in jobResultList) { resultCount++; if (ecuJobResult.CompatIdListList != null) { List <string> compatIdListList = ecuJobResultMatch.CompatIdListList ?? new List <string>(); foreach (string compatId in ecuJobResult.CompatIdListList) { if (!ecuJobResult.IdPresent(compatId)) { compatIdListList.Add(compatId); } } ecuJobResultMatch.CompatIdListList = compatIdListList; } if (!ecuJobResultMatch.IdPresent(ecuJobResult.Id)) { List <string> compatIdListList = ecuJobResultMatch.CompatIdListList ?? new List <string>(); compatIdListList.Add(ecuJobResult.Id); ecuJobResultMatch.CompatIdListList = compatIdListList; if (compatIdListList.Count > 1) { outTextWriter?.WriteLine("Merge Results multi IDs: File='{0}', Job='{1}', Args='{2}', Res='{3}', Count={4}", fileName, ecuJobIn.Name, JobsArgsToString(ecuJobIn), JobsResultsToString(ecuJobIn), compatIdListList.Count); } } } } else { outTextWriter?.WriteLine("Merge Results no match: File='{0}', Job='{1}', Args='{2}', Res='{3}', JobM='{4}', ArgsM='{5}', ResM='{6}'", fileName, ecuJobIn.Name, JobsArgsToString(ecuJobIn), JobsResultsToString(ecuJobIn), ecuJobMerge.Name, JobsArgsToString(ecuJobMerge), JobsResultsToString(ecuJobMerge)); } } } } return(resultCount); }
static bool EcuJobsArgsIdentical(EcuFunctionStructs.EcuJob ecuJob1, EcuFunctionStructs.EcuJob ecuJob2) { List <EcuFunctionStructs.EcuJobParameter> parList1 = new List <EcuFunctionStructs.EcuJobParameter>(); if (ecuJob1.EcuJobParList != null) { parList1 = ecuJob1.EcuJobParList.OrderBy(x => x.Name).ToList(); } List <EcuFunctionStructs.EcuJobParameter> parList2 = new List <EcuFunctionStructs.EcuJobParameter>(); if (ecuJob2.EcuJobParList != null) { parList2 = ecuJob2.EcuJobParList.OrderBy(x => x.Name).ToList(); } if (parList1.Count != parList2.Count) { if ((string.Compare(ecuJob1.Name.Trim(), "SVK_LESEN", StringComparison.OrdinalIgnoreCase) == 0) && (string.Compare(ecuJob2.Name.Trim(), "SVK_LESEN", StringComparison.OrdinalIgnoreCase) == 0)) { if (parList1.Count == 1 && parList2.Count == 0 && string.Compare(parList1[0].Value.Trim(), "SVK_AKTUELL", StringComparison.OrdinalIgnoreCase) == 0) { return(true); } if (parList1.Count == 0 && parList2.Count == 1 && string.Compare(parList2[0].Value.Trim(), "SVK_AKTUELL", StringComparison.OrdinalIgnoreCase) == 0) { return(true); } } return(false); } for (int i = 0; i < parList1.Count; i++) { if (string.Compare(parList1[i].Value.Trim(), parList2[i].Value.Trim(), StringComparison.OrdinalIgnoreCase) != 0) { return(false); } } return(true); }
static string JobsResultsToString(EcuFunctionStructs.EcuJob ecuJob) { if (ecuJob.EcuJobResultList == null) { return(string.Empty); } StringBuilder sb = new StringBuilder(); foreach (EcuFunctionStructs.EcuJobResult ecuJobResult in ecuJob.EcuJobResultList) { if (sb.Length > 0) { sb.Append(", "); } sb.Append(ecuJobResult.Name); } return(sb.ToString()); }
static string JobsArgsToString(EcuFunctionStructs.EcuJob ecuJob) { if (ecuJob.EcuJobParList == null) { return(string.Empty); } StringBuilder sb = new StringBuilder(); foreach (EcuFunctionStructs.EcuJobParameter ecuJobPar in ecuJob.EcuJobParList) { if (sb.Length > 0) { sb.Append(", "); } sb.Append(ecuJobPar.Value); } return(sb.ToString()); }
static int MergeEcuJob(TextWriter outTextWriter, string fileName, List <EcuFunctionStructs.EcuFixedFuncStruct> fixedFuncStructList, EcuFunctionStructs.EcuJob ecuJobMerge, EcuFunctionStructs.EcuFixedFuncStruct ecuFixedFuncStructMerge) { if (ecuJobMerge == null || string.IsNullOrEmpty(ecuJobMerge.Name) || ecuJobMerge.EcuJobResultList?.Count == 0) { return(0); } int matches = 0; foreach (EcuFunctionStructs.EcuFixedFuncStruct ecuFixedFuncStruct in fixedFuncStructList) { if (ecuFixedFuncStruct.EcuJobList != null) { foreach (EcuFunctionStructs.EcuJob ecuJob in ecuFixedFuncStruct.EcuJobList) { if (!string.IsNullOrEmpty(ecuJob.Name)) { if ((string.Compare(ecuJob.Name.Trim(), ecuJobMerge.Name.Trim(), StringComparison.OrdinalIgnoreCase) == 0) && string.Compare(ecuJob.FuncNameJob.Trim(), ecuJobMerge.FuncNameJob.Trim(), StringComparison.OrdinalIgnoreCase) == 0) { if (EcuJobsArgsIdentical(ecuJob, ecuJobMerge)) { int results = MergeEcuJobResults(null, fileName, ecuJob, ecuJobMerge); if (results > 0) { if (ecuFixedFuncStructMerge.CompatIdListList != null) { List <string> compatIdListList = ecuFixedFuncStruct.CompatIdListList ?? new List <string>(); foreach (string compatId in ecuFixedFuncStructMerge.CompatIdListList) { if (!ecuFixedFuncStruct.IdPresent(compatId)) { compatIdListList.Add(compatId); } } ecuFixedFuncStruct.CompatIdListList = compatIdListList; } if (!ecuFixedFuncStruct.IdPresent(ecuFixedFuncStructMerge.Id)) { List <string> compatIdListList = ecuFixedFuncStruct.CompatIdListList ?? new List <string>(); compatIdListList.Add(ecuFixedFuncStructMerge.Id); ecuFixedFuncStruct.CompatIdListList = compatIdListList; } if (ecuJobMerge.CompatIdListList != null) { List <string> compatIdListList = ecuJob.CompatIdListList ?? new List <string>(); foreach (string compatId in ecuJobMerge.CompatIdListList) { if (!ecuJob.IdPresent(compatId)) { compatIdListList.Add(compatId); } } ecuJob.CompatIdListList = compatIdListList; } if (!ecuJob.IdPresent(ecuJobMerge.Id)) { List <string> compatIdListList = ecuJob.CompatIdListList ?? new List <string>(); compatIdListList.Add(ecuJobMerge.Id.Trim()); ecuJob.CompatIdListList = compatIdListList; if (compatIdListList.Count > 1) { outTextWriter?.WriteLine("Merge Jobs multi IDs: File='{0}', Job='{1}({2})', Args='{3}', Res='{4}', Count={5}", fileName, ecuJob.Name, ecuJob.FuncNameJob, JobsArgsToString(ecuJob), JobsResultsToString(ecuJob), compatIdListList.Count); } } matches += results; } } } } } } } if (matches == 0) { outTextWriter?.WriteLine("Merge Jobs no match: File='{0}', Job='{1}({2})', Args='{3}', Res='{4}'", fileName, ecuJobMerge.Name, ecuJobMerge.FuncNameJob, JobsArgsToString(ecuJobMerge), JobsResultsToString(ecuJobMerge)); } return(matches); }