/// <summary> /// Method to load all projects found on the base path /// </summary> public void LoadProjects() { GlobalResult.LogGeneralMessage(Constants.IMG_SEARCH_MSG_START_APP); GlobalResult.LogGeneralMessage(String.Format(Constants.IMG_SEARCH_MSG_START_BASE_DIR, BasePath)); GlobalResult.LogGeneralMessage(String.Format(Constants.IMG_SEARCH_MSG_START_BASE_IMAGE_DIR, ImagePath)); GlobalResult.LogGeneralMessage(String.Format(Constants.IMG_SEARCH_MSG_START_IMAGE_NAME, ImageName)); GlobalResult.LogGeneralMessage(Constants.IMG_SEARCH_MSG_START_LOADING_PROJECT); IEnumerable <string> m_lstProjects; try { m_lstProjects = Directory.EnumerateFileSystemEntries(BasePath, Constants.IMG_SEARCH_PROJECT_EXTENSION, SearchOption.AllDirectories); if (m_lstProjects.Count() > 0) { foreach (string m_strProject in m_lstProjects) { Project m_prjProject = new Project(m_strProject); if (m_prjProject.CheckSearchFolder(ImagePath)) { Projects.Add(m_prjProject); } } GlobalResult.LogGeneralMessage(String.Format(Constants.IMG_SEARCH_MSG_PROJECT_FOUND, m_lstProjects.Count(), Projects.Count())); } else { GlobalResult.LogErrorAndQuit(String.Format(Constants.IMG_SEARCH_MSG_ERROR_NO_PROJECT, BasePath)); } } catch (ArgumentException m_exArg) { GlobalResult.LogErrorAndQuit(String.Format(Constants.IMG_SEARCH_MSG_ERROR_ARG_EXCEPTION, BasePath, m_exArg.Message)); } catch (DirectoryNotFoundException m_exDirNotFound) { GlobalResult.LogErrorAndQuit(String.Format(Constants.IMG_SEARCH_MSG_ERROR_DIR_EXCEPTION, BasePath, m_exDirNotFound.Message)); } catch (IOException m_exIO) { GlobalResult.LogErrorAndQuit(String.Format(Constants.IMG_SEARCH_MSG_ERROR_IO_EXCEPTION, BasePath, m_exIO.Message)); } }
/// <summary> /// Method to search for an image file on all topics /// of all projects found on the base path /// </summary> public void SearchForImageOnTopics() { GlobalResult.LogGeneralMessage(String.Format(Constants.IMG_SEARCH_MSG_START_SEARCH_IMAGE, ImageName)); foreach (Project m_prj in Projects) { m_prj.LoadTopics(); m_prj.SearchImageOnTopics(ImageName); } GlobalResult.LogSeparator(); if (GlobalResult.NumberOfReferences > 0) { GlobalResult.LogGeneralMessage(String.Format(Constants.IMG_SEARCH_MSG_REFERENCE_FOUND, GlobalResult.NumberOfReferences)); } else { GlobalResult.LogGeneralMessage(String.Format(Constants.IMG_SEARCH_MSG_NO_REFERENCE_FOUND, ImageName)); } ExecutionTime.Stop(); GlobalResult.LogGeneralMessage(String.Format(Constants.IMG_SEARCH_MSG_EXECUTION_TIME, ExecutionTime.Elapsed.Hours, ExecutionTime.Elapsed.Minutes, ExecutionTime.Elapsed.Seconds, ExecutionTime.Elapsed.Milliseconds)); GlobalResult.SaveLogFile(); }
/// <summary> /// Method to search for an image file on a topic file /// </summary> /// <param name="p_strImage">Name of an image file, without a path</param> public void SearchForImage(string p_strImage) { XmlDocument m_xmlTopic = new XmlDocument(); try { m_xmlTopic.Load(TopicPath); XmlNodeList m_xmlImages = m_xmlTopic.SelectNodes(String.Format(Constants.IMG_TOPIC_XPATH_IMAGE_SRC, p_strImage)); if (m_xmlImages.Count > 0) { if (m_xmlImages.Count == 1) { GlobalResult.LogGeneralMessage(String.Format(Constants.IMG_TOPIC_MSG_IMAGE_FOUND_SINGLE, m_xmlImages.Count, p_strImage, TopicPath)); } else { GlobalResult.LogGeneralMessage(String.Format(Constants.IMG_TOPIC_MSG_IMAGE_FOUND_MANY, m_xmlImages.Count, p_strImage, TopicPath)); } GlobalResult.NumberOfReferences += m_xmlImages.Count; } } catch (FileNotFoundException m_exNotFound) { GlobalResult.LogErrorAndQuit(String.Format(Constants.IMG_TOPIC_MSG_ERROR_FILE_NOT_FOUND, TopicPath, m_exNotFound.Message)); } catch (IOException m_exIO) { GlobalResult.LogErrorAndQuit(String.Format(Constants.IMG_TOPIC_MSG_ERROR_IO_EXCEPTION, TopicPath, m_exIO.Message)); } catch (XmlException m_exXml) { GlobalResult.LogErrorAndQuit(String.Format(Constants.IMG_TOPIC_MSG_ERROR_XML_EXCEPTION, TopicPath, m_exXml.Message)); } catch (XPathException m_exXPath) { GlobalResult.LogErrorAndQuit(String.Format(Constants.IMG_TOPIC_MSG_ERROR_XPATH_EXCEPTION, TopicPath, m_exXPath.Message)); } }