private static void RunAlgorithmsForFolder() { if (m_bIsRunning) return; m_bIsRunning = true; ClFileLogger FileLogger = new ClFileLogger(m_sTestDirectory + "log.txt", false); if (m_bLogging) { ClInformationSender.RegisterReceiver(FileLogger, ClInformationSender.eInformationType.eDebugText); ClInformationSender.RegisterReceiver(FileLogger, ClInformationSender.eInformationType.eTextExternal); ClInformationSender.RegisterReceiver(FileLogger, ClInformationSender.eInformationType.eTextInternal); ClInformationSender.RegisterReceiver(FileLogger, ClInformationSender.eInformationType.eError); } try { ClInformationSender.SendInformation(null, ClInformationSender.eInformationType.eStartProcessing); int current = 1; int howMany = m_lFilesList.Count; ClInformationSender.SendInformation(null, ClInformationSender.eInformationType.eStartProcessing); string fullAlgorithmAdditionalData = ""; foreach (IFaceAlgorithm alg in m_lAlgorithmsList) { fullAlgorithmAdditionalData += "\n- " + alg.GetAlgorithmFullPath(); fullAlgorithmAdditionalData += "\n"; foreach (KeyValuePair<string, string> prop in alg.GetProperitis()) fullAlgorithmAdditionalData += "\t" + prop.Key + " -> " + prop.Value + "\n"; } fullAlgorithmAdditionalData += "\n------------------------------"; ClInformationSender.SendInformation(fullAlgorithmAdditionalData, ClInformationSender.eInformationType.eDebugText); TimeSpan mean = TimeSpan.Zero; foreach (String file in m_lFilesList) { DateTime start = DateTime.Now; ClInformationSender.SendInformation(((current * 100) / howMany).ToString(), ClInformationSender.eInformationType.eProgress); try { Cl3DModel newModel = new Cl3DModel(); newModel.LoadModel(file); foreach (IFaceAlgorithm alg in m_lAlgorithmsList) { alg.MakeAlgorithm(ref newModel); } } catch (ThreadAbortException) { ClInformationSender.SendInformation("Processing Interrupted", ClInformationSender.eInformationType.eTextInternal); break; } catch (Exception ex) { ClInformationSender.SendInformation("ERROR:\n(" + file + ")\n" + ex.ToString(), ClInformationSender.eInformationType.eDebugText); } DateTime stop = DateTime.Now; mean += (stop - start); double MeanTotalHours = mean.TotalHours; double MeanTotalMin = mean.TotalMinutes; int TotalTimeHours = (int)((MeanTotalHours / current) * (howMany - current)); int TotalTimeMin = (int)((MeanTotalMin / current) * (howMany - current)); TotalTimeMin = TotalTimeMin - (TotalTimeHours * 60); ClInformationSender.SendInformation("Time Remaining: " + TotalTimeHours.ToString() + "h" + TotalTimeMin.ToString("00")+"min [" + current.ToString() + "/" + howMany.ToString()+"]", ClInformationSender.eInformationType.eTextExternal); current++; } } catch (Exception e) { ClInformationSender.SendInformation("ERROR:\n" + e.ToString(), ClInformationSender.eInformationType.eError); } m_bIsRunning = false; ClInformationSender.SendInformation(null, ClInformationSender.eInformationType.eStopProcessing); ClInformationSender.UnRegisterReceiver(FileLogger, ClInformationSender.eInformationType.eDebugText); ClInformationSender.UnRegisterReceiver(FileLogger, ClInformationSender.eInformationType.eTextExternal); ClInformationSender.UnRegisterReceiver(FileLogger, ClInformationSender.eInformationType.eTextInternal); ClInformationSender.UnRegisterReceiver(FileLogger, ClInformationSender.eInformationType.eError); }
static private void RunAlgorithmsForFolder() { if (m_bIsRunning) { return; } m_bIsRunning = true; ClFileLogger FileLogger = new ClFileLogger(m_sTestDirectory + "log.txt", false); if (m_bLogging) { ClInformationSender.RegisterReceiver(FileLogger, ClInformationSender.eInformationType.eDebugText); ClInformationSender.RegisterReceiver(FileLogger, ClInformationSender.eInformationType.eTextExternal); ClInformationSender.RegisterReceiver(FileLogger, ClInformationSender.eInformationType.eTextInternal); ClInformationSender.RegisterReceiver(FileLogger, ClInformationSender.eInformationType.eError); } try { ClInformationSender.SendInformation(null, ClInformationSender.eInformationType.eStartProcessing); int current = 1; int howMany = m_lFilesList.Count; ClInformationSender.SendInformation(null, ClInformationSender.eInformationType.eStartProcessing); string fullAlgorithmAdditionalData = ""; foreach (IFaceAlgorithm alg in m_lAlgorithmsList) { fullAlgorithmAdditionalData += "\n- " + alg.GetAlgorithmFullPath(); fullAlgorithmAdditionalData += "\n"; foreach (KeyValuePair <string, string> prop in alg.GetProperitis()) { fullAlgorithmAdditionalData += "\t" + prop.Key + " -> " + prop.Value + "\n"; } } fullAlgorithmAdditionalData += "\n------------------------------"; ClInformationSender.SendInformation(fullAlgorithmAdditionalData, ClInformationSender.eInformationType.eDebugText); TimeSpan mean = TimeSpan.Zero; foreach (String file in m_lFilesList) { DateTime start = DateTime.Now; ClInformationSender.SendInformation(((current * 100) / howMany).ToString(), ClInformationSender.eInformationType.eProgress); try { Cl3DModel newModel = new Cl3DModel(); newModel.LoadModel(file); foreach (IFaceAlgorithm alg in m_lAlgorithmsList) { alg.MakeAlgorithm(ref newModel); } } catch (ThreadAbortException) { ClInformationSender.SendInformation("Processing Interrupted", ClInformationSender.eInformationType.eTextInternal); break; } catch (Exception ex) { ClInformationSender.SendInformation("ERROR:\n(" + file + ")\n" + ex.ToString(), ClInformationSender.eInformationType.eDebugText); } DateTime stop = DateTime.Now; mean += (stop - start); double MeanTotalHours = mean.TotalHours; double MeanTotalMin = mean.TotalMinutes; int TotalTimeHours = (int)((MeanTotalHours / current) * (howMany - current)); int TotalTimeMin = (int)((MeanTotalMin / current) * (howMany - current)); TotalTimeMin = TotalTimeMin - (TotalTimeHours * 60); ClInformationSender.SendInformation("Time Remaining: " + TotalTimeHours.ToString() + "h" + TotalTimeMin.ToString("00") + "min [" + current.ToString() + "/" + howMany.ToString() + "]", ClInformationSender.eInformationType.eTextExternal); current++; } } catch (Exception e) { ClInformationSender.SendInformation("ERROR:\n" + e.ToString(), ClInformationSender.eInformationType.eError); } m_bIsRunning = false; ClInformationSender.SendInformation(null, ClInformationSender.eInformationType.eStopProcessing); ClInformationSender.UnRegisterReceiver(FileLogger, ClInformationSender.eInformationType.eDebugText); ClInformationSender.UnRegisterReceiver(FileLogger, ClInformationSender.eInformationType.eTextExternal); ClInformationSender.UnRegisterReceiver(FileLogger, ClInformationSender.eInformationType.eTextInternal); ClInformationSender.UnRegisterReceiver(FileLogger, ClInformationSender.eInformationType.eError); }