Example #1
0
        internal List <EM_Country> countries;             // holds the extracted XML information

        // This function is responsible for running the pluggin
        public override void Run(Dictionary <string, object> _settings)
        {
            // Get necessary information form active UI
            mainForm         = EM_Common_Win.UISessionInfo.GetActiveMainForm();
            euromodFilesPath = UISessionInfo.GetEuromodFilesFolder();

            var done = false;

            settings  = _settings ?? new Dictionary <string, object>(); // get the application settings
            inputForm = new InputForm(this);

            // Then show the Input form until you Cancel or you manage to get some results
            while (!done && inputForm.ShowDialog(mainForm) == DialogResult.OK)
            {
                checkForm = new CheckCountriesYears(this);
                DialogResult res = checkForm.ShowDialog(mainForm);
                if (res == DialogResult.Abort)
                {
                    done = true;
                }
                while (!done && res == DialogResult.OK)
                {
                    outputForm = new OutputForm(this);
                    outputForm.ShowDialog(mainForm);
                    done = true;
                }
            }
        }
Example #2
0
 internal void RunTransfomer(List <string> countries, out List <string> errors)
 {
     errors = new List <string>();
     foreach (string country in countries)
     {
         EM3Country.Transform(UISessionInfo.GetEuromodFilesFolder(), country, out errors);
     }
     EM3Global.Transform(UISessionInfo.GetEuromodFilesFolder(), out List <string> gErrors); errors.AddRange(gErrors);
     EM3Variables.Transform(UISessionInfo.GetEuromodFilesFolder(), out List <string> vErrors); errors.AddRange(vErrors);
 }
Example #3
0
        internal static void SaveVar()
        {
            varData.AcceptChanges();
            string varPath    = Path.Combine(UISessionInfo.GetEuromodFilesFolder(), @"XMLParam\Config\VarConfig.xml");
            Stream fileStream = new FileStream(varPath, FileMode.Create);

            using (XmlTextCDATAWriter xmlWriter = new XmlTextCDATAWriter(fileStream, DefGeneral.DEFAULT_ENCODING,
                                                                         new string[] { "LongName", "ShortName", "Name", "Description", "AutoLabel", "Label", "NamePattern" }))
                varData.WriteXml(xmlWriter);
        }
Example #4
0
 public override void Run(System.Collections.Generic.Dictionary <string, object> arguments = null)
 {
     try
     {
         string varPath = Path.Combine(UISessionInfo.GetEuromodFilesFolder(), @"XMLParam\Config\VarConfig.xml");
         varData = new VarConfig();
         using (StreamReader streamReader = new StreamReader(varPath, DefGeneral.DEFAULT_ENCODING)) varData.ReadXml(streamReader);
         (new VariablesCheckerForm()).ShowDialog();
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
Example #5
0
        internal Program Plugin;                    // varialbe that links to the actual plugin

        public InputForm(Program _plugin)
        {
            InitializeComponent();
            Plugin = _plugin;

            // Try reading the starting path from the plugin and pass it to the textbox
            object path = "";

            inputPathEUROMOD.Text = UISessionInfo.GetEuromodFilesFolder();
            if (Plugin.settings.TryGetValue("EuromodFolder", out path))
            {
                inputPathEUROMOD.Text = path.ToString();
                //               inputPathSTATA.Text = Path.Combine(Path.GetDirectoryName(path.ToString()), "Excel_folders");
            }
        }
Example #6
0
        internal bool RunExe(string country, string year, string dataFullPath, bool outputInEuro, out List <string> errors)
        {
            Dictionary <string, string> config = ExeRunConfig.GetBasicConfig(
                UISessionInfo.GetEuromodFilesFolder(),                               // EurmodFiles-folder
                country, $"{country}_{year}",                                        // country and system
                Path.GetDirectoryName(dataFullPath), Path.GetFileName(dataFullPath), // data-folder and data-file
                UISessionInfo.GetOutputFolder());                                    // output-folder

            if (outputInEuro)
            {
                config.Add(TAGS.CONFIG_FORCE_OUTPUT_EURO, DefPar.Value.YES);
            }

            List <string> err     = new List <string>();
            bool          success = new Control().Run(config, null, e => { err.Add((e.isWarning ? "Warning: " : "Error: ") + e.message); });

            errors = err;

            return(success);
        }
Example #7
0
        public PresenterForm(Template template, List <FilePackageContent> filePackages, List <Template.TemplateInfo.UserVariable> userInput)
        {
            InitializeComponent();
            try
            {
                try
                {
                    if (requiresWarmUp)
                    {
                        requiresWarmUp = false;
                        string dummyHtml = Path.Combine(new EMPath(UISessionInfo.GetEuromodFilesFolder()).GetFolderTemp(), "dummy.html");
                        if (!File.Exists(dummyHtml))
                        {
                            File.WriteAllText(dummyHtml, Resources.dummy_html);
                        }
                        webBrowser.Url = new Uri(dummyHtml);
                        //webBrowser.Url = new Uri(@"C:\Users\Christine\Downloads\LIGHTS\A_PUBLISH\MultiUser\View\wwwroot\login.html");
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("ojeoje: " + e.Message);
                }

                EM_StatisticsBackEndResponder backEndResponder = new EM_StatisticsBackEndResponder(backEnd, template, filePackages, userInput);
                responderKey = backEndResponder.responderKey;
                backEnd.Start(new Dictionary <string, EM_BackEndResponder>()
                {
                    { responderKey, backEndResponder }
                });
                webBrowser.Url = new Uri($"http://localhost:{backEnd.Port}/{responderKey}_{EM_StatisticsBackEndResponder.LOAD_STATISTICS_HTML}?packageKey={filePackages[0].Key}");
            }
            catch (Exception exception) { Error(exception.Message); }

            void Error(string message)
            {
                MessageBox.Show("Error starting Statistics Back-End:" + Environment.NewLine + message);
            }
        }
Example #8
0
        internal static string VarUsage(List <string> print, BackgroundWorker bkWorker)
        {
            Dictionary <string, VarUsePattern> varUsages = new Dictionary <string, VarUsePattern>();

            foreach (VarConfig.VariableRow v in VariablesChecker.varData.Variable)
            {
                varUsages.Add(v.Name, new VarUsePattern()
                {
                    autoLabel = v.AutoLabel
                });
            }

            string ccFolderPath = Path.Combine(UISessionInfo.GetEuromodFilesFolder(), @"XMLParam\Countries");

            DirectoryInfo[] ccFolders = new DirectoryInfo(ccFolderPath).GetDirectories(); double done = 0; bool canceled = false;

            Parallel.ForEach(ccFolders, ccFolder =>
            {
                if (bkWorker.CancellationPending)
                {
                    canceled = true; return;
                }

                List <CountryParValue> parValues; string shortName;
                if (!ReadCountry(Path.Combine(ccFolderPath, ccFolder.Name, ccFolder.Name + ".xml"), out parValues, out shortName))
                {
                    return;
                }

                List <string> usedVar = new List <string>(), naVar = new List <string>(), noLabelVar = new List <string>();
                foreach (VarConfig.VariableRow v in VariablesChecker.varData.Variable)
                {
                    if (bkWorker.CancellationPending)
                    {
                        canceled = true; return;
                    }
                    bool?used = false;
                    foreach (CountryParValue parValue in parValues)
                    {
                        if (UsedInFormula(v.Name.Trim().ToLower(), parValue.formula))
                        {
                            if (parValue.isNa)
                            {
                                used = null;                // means used as n/a - note: no break, i.e. can still be overwritten by true
                            }
                            else
                            {
                                used = true; break;
                            }
                        }
                    }
                    if (used == false)
                    {
                        continue;
                    }
                    if (used == true)
                    {
                        usedVar.Add(v.Name);
                    }
                    else
                    {
                        naVar.Add(v.Name);
                    }
                    var ccDesc = (from l in v.GetCountryLabelRows() where l.Country.ToLower().Trim() == shortName.ToLower().Trim() select l);
                    if (ccDesc.Count() == 0 || ccDesc.First().Label.Trim() == string.Empty || ccDesc.First().Label.Trim() == "-")
                    {
                        noLabelVar.Add(v.Name);
                    }
                }

                lock (varListLock)
                {
                    foreach (string v in usedVar)
                    {
                        varUsages[v].useCountries += shortName + " ";
                    }
                    foreach (string v in naVar)
                    {
                        varUsages[v].naCountries += shortName + " ";
                    }
                    foreach (string v in noLabelVar)
                    {
                        varUsages[v].noLabelCountries += shortName + " ";
                    }
                    bkWorker.ReportProgress((int)Math.Round(++done / ccFolders.Count() * 100));
                }
            });

            if (canceled)
            {
                return("Checking variable usage canceled");
            }

            int unused = 0;

            print.Add(string.Format("{0}\t{1}\t{2}\t{3}\t{4}", "Variable", "Used in", "Used in n/a only", "No description for", "Auto-description"));
            foreach (var vu in varUsages)
            {
                if (vu.Value.useCountries == string.Empty && vu.Value.naCountries == string.Empty)
                {
                    vu.Value.useCountries = "not used"; ++unused;
                }
                print.Add(string.Format("{0}\t{1}\t{2}\t{3}\t{4}",
                                        vu.Key, vu.Value.useCountries.TrimEnd(), vu.Value.naCountries.TrimEnd(), vu.Value.noLabelCountries.TrimEnd(), vu.Value.autoLabel));
            }

            return((unused == 0) ? "No unused variables found" : unused + " unused variables found");
        }