Esempio n. 1
0
        private void CopyFiles()
        {
            string currentDirectory = DirHandler.Instance.CurrentDirectory;

            // Copy Css files from the Repository dir to the Output Css dir...
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.CSS_DIR, Ids.COMMON_CSS_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.CSS_DIR, Ids.COMMON_CSS_FILE));

            // Copy Images from the Repository dir to the Output Images dir...
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.IMAGES_DIR, Ids.PLUS_PNG_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.IMAGES_DIR, Ids.PLUS_PNG_FILE));
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.IMAGES_DIR, Ids.MINUS_PNG_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.IMAGES_DIR, Ids.MINUS_PNG_FILE));

            // Copy js files from the Repository dir to the Output JavaScript dir...
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.JAVASCRIPT_DIR, Ids.COMMON_JS_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.JAVASCRIPT_DIR, Ids.COMMON_JS_FILE));

            // Copy xslt files from the Repository dir to the Output XSLT dir...
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.XSLT_DIR, Ids.ALL_MATCHES_XSLT_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.XSLT_DIR, Ids.ALL_MATCHES_XSLT_FILE));
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.XSLT_DIR, Ids.ALL_PROJECT_DEFINITIONS_XSLT_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.XSLT_DIR, Ids.ALL_PROJECT_DEFINITIONS_XSLT_FILE));
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.XSLT_DIR, Ids.ALL_CATEGORY_DEFINITIONS_XSLT_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.XSLT_DIR, Ids.ALL_CATEGORY_DEFINITIONS_XSLT_FILE));
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.XSLT_DIR, Ids.ALL_RULE_DEFINITIONS_XSLT_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.XSLT_DIR, Ids.ALL_RULE_DEFINITIONS_XSLT_FILE));
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.XSLT_DIR, Ids.ALL_CATEGORY_DECLARATIONS_XSLT_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.XSLT_DIR, Ids.ALL_CATEGORY_DECLARATIONS_XSLT_FILE));
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.XSLT_DIR, Ids.ALL_LANGUAGE_DECLARATIONS_XSLT_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.XSLT_DIR, Ids.ALL_LANGUAGE_DECLARATIONS_XSLT_FILE));
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.XSLT_DIR, Ids.ALL_RULE_DECLARATIONS_XSLT_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.XSLT_DIR, Ids.ALL_RULE_DECLARATIONS_XSLT_FILE));
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.XSLT_DIR, Ids.TOC_XSLT_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.XSLT_DIR, Ids.TOC_XSLT_FILE));
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.XSLT_DIR, Ids.SUMMARY_XSLT_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.XSLT_DIR, Ids.SUMMARY_XSLT_FILE));
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.XSLT_DIR, Ids.SUB_TOC_XSLT_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.XSLT_DIR, Ids.SUB_TOC_XSLT_FILE));
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.XSLT_DIR, Ids.FILES_SEARCHED_XSLT_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.XSLT_DIR, Ids.FILES_SEARCHED_XSLT_FILE));

            // Copy xml files from the Repository dir to the Output dir (empty fallback files)...
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.SUMMARY_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.SUMMARY_FILE));
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.SUB_TOC_XML_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.SUB_TOC_XML_FILE));

            // Copy index file from the Repository dir to the Output dir...
            FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.INDEX_HTML_FILE), Path.Combine(OutputRootDir, Ids.OUTPUT_DIR, Ids.INDEX_HTML_FILE));
        }
        public XmlConfigLoaderProduct(ConfigManager manager) : base(manager)
        {
            Doc = null;
            IsConfigFileValid = true;


            string currentDirectory = DirHandler.Instance.CurrentDirectory;

            RulesConfigFilePath   = Path.Combine(currentDirectory, Ids.CONFIG_DIR, Ids.RULES_CONFIG_FILE);
            RulesConfigSchemaPath = Path.Combine(currentDirectory, Ids.CONFIG_DIR, Ids.RULES_CONFIG_SCHEMA_FILE);

            // Check the for existence of the configuration file...
            if (string.IsNullOrWhiteSpace(RulesConfigFilePath) || !File.Exists(RulesConfigFilePath))
            {
                // Copy default configuration file 'rules.config' from the 'Repository\examples\' to current execution dir...
                FileAccesser.CopyFile(Path.Combine(currentDirectory, Ids.REPOSITORY_DIR, Ids.EXAMPLES_DIR, Ids.RULES_CONFIG_FILE), Path.Combine(currentDirectory, Ids.CONFIG_DIR, Ids.RULES_CONFIG_FILE));

                string warnTxt = string.Format("Unable to find the configuration file. Expected to find it here: {0}. Created default file for entering settings in. Change the content of the configuration file {1} and run the application again.", RulesConfigFilePath, Ids.RULES_CONFIG_FILE);
                Log.Warning(warnTxt);

                throw new InitializationException(this, -1, warnTxt);
            }

            // Check for existence of the schema file for the configuration file...
            if (string.IsNullOrWhiteSpace(RulesConfigSchemaPath) || !File.Exists(RulesConfigSchemaPath))
            {
                string s = string.Format("Unable to find the schema validation file for the configuration file. Expected to find the schema validation file here: {0}.", RulesConfigSchemaPath);
                Log.Error(s);

                throw new InitializationException(this, -1, s);
            }

            // Load the configuration file and place the content of it in a XDocument...
            Doc = LoadConfigurationFile();
            if (Doc == null)
            {
                throw new NullReferenceException("Failed to load the configuration file.");
            }
        }