Esempio n. 1
0
        /// <summary>
        /// Get number of components for selected language
        /// </summary>
        /// <param name="language">Selected language</param>
        /// <param name="connection">Database connection</param>
        /// <returns>Dictionary of components names and their numbers</returns>
        public static Dictionary <string, int> GetNumerOfComponents(string language, Database_Operation.Connection connection)
        {
            // Get SQL Connection
            SqlConnection myConnection = connection.GetConnection();

            // Load components
            LoadComponents(language, myConnection);

            // Get number of component
            Dictionary <string, int> numberOf = new Dictionary <string, int>();
            int numberOfScenarios             = 0;
            int numberOfSections    = 0;
            int numberOfCheckPoints = 0;
            int numberOfOperations  = 0;

            // Scenarios
            numberOfScenarios = export_scenarios.Count;

            // Sections
            foreach (Database_Export.Scenario scenario in export_scenarios.Values)
            {
                numberOfSections += scenario.sections.Count;
            }

            // CheckPoints
            numberOfCheckPoints = export_checkpoints.Count;

            // Operations
            foreach (Database_Export.CheckPoint checkPoint in export_checkpoints.Values)
            {
                numberOfOperations += checkPoint.operations.Count;
            }

            // Add all to output
            numberOf.Add("Scenarios", numberOfScenarios);
            numberOf.Add("Sections", numberOfSections);
            numberOf.Add("CheckPoints", numberOfCheckPoints);
            numberOf.Add("Operations", numberOfOperations);

            // Clear old values
            ClearComponents();

            return(numberOf);
        }
Esempio n. 2
0
        /// <summary>
        /// Generate database output in JSON, into 'export' file, in program folder
        /// </summary>
        /// <param name="language">Selected language</param>
        /// <param name="myConnection">Database connection</param>
        public static void Generate(string language, Database_Operation.Connection connection)
        {
            // Get SQL Connection
            SqlConnection myConnection = connection.GetConnection();

            // Load components
            LoadComponents(language, myConnection);

            // Create JSON and save into file
            Directory.CreateDirectory(@".\export\" + language);
            StreamWriter sw;

            foreach (string key in scenarios.Keys)
            {
                sw = new StreamWriter(@".\export\" + language + @"\" + export_scenarios[key].name + ".json");
                sw.Write(export_scenarios[key].ToJson());
                sw.Flush();
                sw.Close();
            }

            // Clear old values
            ClearComponents();
        }