static bool IsFunctionSpecifier(string functionName, string parameterName, out bool isSingleSpecifier)
        {
            Dictionary <string, Tuple <string, bool> > funSpec = new Dictionary <string, Tuple <string, bool> >()
            {
                { DefFun.DefIl.ToLower(), new Tuple <string, bool>(DefPar.DefIl.Name, true) },
                { DefFun.DefTu.ToLower(), new Tuple <string, bool>(DefPar.DefTu.Name, true) },
                { DefFun.UpdateTu.ToLower(), new Tuple <string, bool>(DefPar.UpdateTu.Name, true) },
                { DefFun.DefOutput.ToLower(), new Tuple <string, bool>(DefPar.DefOutput.File, true) },
                { DefFun.Uprate.ToLower(), new Tuple <string, bool>(DefPar.Uprate.Dataset, false) },
                { DefFun.SetDefault.ToLower(), new Tuple <string, bool>(DefPar.SetDefault.Dataset, false) },
                { DefFun.Elig.ToLower(), new Tuple <string, bool>(DefPar.Elig.Elig_Cond, true) },
                { DefFun.Allocate.ToLower(), new Tuple <string, bool>(DefPar.Allocate.Share, true) },
                { DefFun.Loop.ToLower(), new Tuple <string, bool>(DefPar.Loop.Loop_Id, true) },
                { DefFun.UnitLoop.ToLower(), new Tuple <string, bool>(DefPar.UnitLoop.Loop_Id, true) },
                { DefFun.Store.ToLower(), new Tuple <string, bool>("post*", true) },
                { DefFun.Restore.ToLower(), new Tuple <string, bool>("post*", true) },
                { DefFun.DropUnit.ToLower(), new Tuple <string, bool>(DefPar.DropUnit.Drop_Cond, true) },
                { DefFun.KeepUnit.ToLower(), new Tuple <string, bool>(DefPar.KeepUnit.Keep_Cond, true) },
                { DefFun.CallProgramme.ToLower(), new Tuple <string, bool>(DefPar.CallProgramme.Programme, true) },
                { DefFun.AddOn_Applic.ToLower(), new Tuple <string, bool>(DefPar.AddOn_Applic.Sys, false) },
                { DefFun.AddOn_Pol.ToLower(), new Tuple <string, bool>(DefPar.AddOn_Pol.Pol_Name, true) },
                { DefFun.DefInput.ToLower(), new Tuple <string, bool>(DefPar.DefInput.file, true) },
                { "default", new Tuple <string, bool>("output*var", true) } //output_var and output_add_var are default if function has no specific specifier
            };

            Tuple <string, bool> specifyingParameter = funSpec.ContainsKey(functionName.ToLower()) ? funSpec[functionName.ToLower()] : funSpec["default"];

            isSingleSpecifier = true;
            if (!EM_Helpers.DoesValueMatchPattern(specifyingParameter.Item1, parameterName))
            {
                return(false);
            }
            isSingleSpecifier = specifyingParameter.Item2;
            return(true);
        }
Exemplo n.º 2
0
        internal override bool Perform()
        {
            DataGridViewRow changedRow = _dgvCategories.Rows[_eventArgs.RowIndex];

            VarConfig.CategoryRow categoryRow = changedRow.Tag as VarConfig.CategoryRow;
            string newValue = changedRow.Cells[_eventArgs.ColumnIndex].Value.ToString();

            if (_eventArgs.ColumnIndex == _dgvCategories.Columns.IndexOf(_variablesForm.colCategoryValue))
            {
                if (categoryRow.Value == newValue)
                {
                    return(false); //only change if different
                }
                if (!EM_Helpers.IsNumeric(newValue))
                {
                    if (Tools.UserInfoHandler.GetInfo(newValue + " is not numeric.\n\nUndo change?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        _variablesForm._acronymManager.FillCategoriesList(_variablesForm.treeAcronyms.FocusedNode);
                        return(false);
                    }
                }

                categoryRow.Value = newValue;
            }
            else if (_eventArgs.ColumnIndex == _dgvCategories.Columns.IndexOf(_variablesForm.colCategoryDescription))
            {
                if (categoryRow.Description == newValue)
                {
                    return(false); //only change if different
                }
                categoryRow.Description = newValue;
            }

            return(true);
        }
Exemplo n.º 3
0
        private void GetHICPFromGlobalTable()
        {
            hicpFromGlobalTable = false;
            HICPConfigFacade hcf = EM_AppContext.Instance.GetHICPConfigFacade(false); if (hcf == null)
            {
                return;
            }
            List <string> hicpRow = new List <string>()
            {
                "Harmonised Index of Consumer Prices", "$HICP"
            }; string comment = string.Empty;

            foreach (DataColumn col in dgvDataTable.Columns)
            {
                if (!col.Caption.StartsWith(_colYear))
                {
                    continue;
                }
                HICPConfig.HICPRow globalHICP = hcf.GetHICP(EM_AppContext.Instance.GetActiveCountryMainForm().GetCountryShortName(), col.Caption.Substring(_colYear.Length));
                string             hicpVal    = "100";
                if (globalHICP != null)
                {
                    hicpVal = EM_Helpers.ConvertToString(globalHICP.Value); comment = globalHICP.Comment; hicpFromGlobalTable = true;
                }                                                                                                                                              // make sure you always show "." as decimal separator
                hicpRow.Add(hicpVal);
            }
            hicpRow.Add(comment); hicpRow.Insert(0, null);
            if (hicpFromGlobalTable)
            {
                dgvDataTable.Rows.Add(hicpRow.ToArray());
            }
        }
Exemplo n.º 4
0
        // generate user-setting-string as:
        // "keepMode°country1-settings° ... °countryX-settings", with country-settings as:
        // "country-short-name^01|system-widths^02|hidden systems^03|hidden nodes^04|text-size", with
        // system-widths: "Policy|policy-column-with|Grp/No|group-column-width|system1-name|system1-width| ... |systemX-name|systemX-width|Comment|comment-column-widht"
        // hidden systems: "system-name1| ... |system-nameX"
        // hidden nodes: "node-id1| ... |node-idX", where node-id is what one gets by calling BaseTreeListTag.GetDefaultID
        // text-size: "size1|size2", as used by TreeListBuilder.GetTextSize/SetTextSize
        // example:
        // True°MT^01|Policy|184|Grp/No|51|MT_2007|138|MT_2008|138|MT_2009|138|MT_2010|138|MT_2011|138|MT_2012|138|MT_2013|138|MT_2014|138|MT_2015|138|MT_2016|138|Comment|205
        //        ^02|mt_2009|mt_2011|mt_2013
        //        ^03|FE08A670-11E8-44E0-B252-4F7EFBD264F4|26D04809-3A88-475E-BFFA-D08CB7A8A36D|277E4A9C-B656-4129-B59A-77D1D51B3E98|46B7E1F6-7338-4694-B4AF-F5297C86867C|a27793f4-447d-42f8-8ba9-529378560eed|1FA3B90F-0A46-4011-A86A-AA6D5F93A46F|BAC4D66B-8D78-498C-8CDC-E3D0C5EA12FF|8B894E7E-BB92-4F2D-9F89-63E60CAA0A58|3B690AD9-B908-4C05-800E-D63D9164ED6B|CA8A4CAF-C318-4E64-85C7-91A71A075738|FE15E471-BB69-4D33-938F-AB8DDF85546A|06AAF911-DA85-4A5A-B843-3322BA55F7D5|8FB5A2A5-E83F-475E-9A35-1631B6A810CA|972FD183-6619-4B29-8D7C-D61129C4C20B|B4BEC492-CEE1-4EC2-AE54-1A3439265641|C8F84404-508C-416E-AE38-A453F7D29171|2E3FBBDC-9F7B-49A0-BCD4-2350F38C8600|c12c8d9b-da21-4134-8d47-26418693657e|2A530611-FBD7-48F3-B8D6-CCC5CE54778D|AECC3969-F6E5-4DD7-939D-936EA85CFF57|3D259481-17A2-4E41-BCC6-64AF6184F7A5|A3D2F8BC-8DAB-4A38-82A0-E577AFD4B15E|d3858356-a965-454d-83d2-2cddb241ed75|f56087aa-c64d-4da0-8df2-46fe835536b2|99085CE5-F758-4CB3-AE06-7C75EB7E5B5E|D1A12E7B-3353-4026-9007-B8EC61629663|39242415-315E-41A4-93DE-4E6DC4C6B594|0C0A9FEF-9F84-492C-9B64-918A6F5F4EDD|885511E6-576E-4F80-BC2F-7D7F7E8AE2FD|22B0B701-88FE-4EED-A362-D6B591517F23|3652821C-E0DD-43A5-8187-BCF158C76AF1|4CE5471F-DD83-4FE2-8CE7-6935FA139418|50DAC69C-3094-45AE-92DE-6888EA1D6362|1F9AD442-C321-41BB-9BFA-30A21F36D649|3E48C71A-DF55-4D56-A883-2B4DB908BCC6|FF3DC2FD-B76B-40C4-9999-37926766755B|796e1fec-cfc8-427e-974f-e767909adacd|bd9f9dc3-e867-441c-ac92-b9aa7aae0b40|17197737-F404-4797-BAFE-00207DFFB5F8|64A0D6A9-5971-41E0-BA48-6AA00CE03980|FA677FB0-6010-4FAB-9EF5-10BDCE7804E9|DC706013-6D7E-49A6-9C71-DD1233A39BC6|FFBA3400-1AB7-4707-8836-E975247BAF80|9b51791e-6eb4-4553-ac86-363d9cf225b2|4356e3ad-6733-4a67-b910-3d5a7a037d8e|C60EA05C-A048-4028-808A-8B72422FEC7A|362009D7-6F5C-4CAD-9D3E-4DB31EA883BC|3BE4FA13-4155-4751-8C4C-BF32211C5BD8|966F3564-7B3F-4798-83C2-5544E6AB00DC|2B1089DA-F50F-40CC-A4BC-0D52AF987419|4C14431F-ED43-4AAD-9C3A-8F2D834D8D3D|D63D536B-8B6E-4474-BCDF-0D860F966BA1|39012505-B76D-4F47-9AB3-14DDEC811617|27DD0592-8BB7-4379-A6A1-C1CD5A6E3CDB|3C433951-7DCD-4484-8EF9-C1BFCA62CBBA|4EC01038-BC3A-4EBD-B0D7-CFB3D39DAC5B|21b3bd0b-12cd-4354-a337-65e98c7f876d|df0e2e0f-63c5-4d99-9493-ee2e9fd8dc9d|8f2f1da4-731d-4775-b2cb-65414811e29b|5E8BBC54-F153-46D3-B5A8-7CEBE253918F|186F4A14-13A8-40CA-AB9F-E18D2FEB66D6|FA6E8261-94DD-4D0D-A543-BDA09B76CB5D|D72CAD2D-0C37-4996-BF8A-97F096FB06DB|C99E6B63-5537-4A54-B29E-CCBD9AD64183|B328F4A9-D8EC-4773-8F5E-51A3B4A930DB|5CE89C79-9A0C-4E12-8442-F77604322373|63FF43DC-6276-40B5-8EAE-3BF8A35784C3|290CD48B-847D-46DB-A9CD-AFE0F470B4FB|4D458C76-6A1F-41C7-8E9E-FF457F868470|D5EF52FB-F0AD-4E58-8F96-7DCBC81B2BFC|20F07114-4EE8-406B-886D-3A06D716DEDC|918A9B26-7D57-43E3-8883-DF973CDFF27B|2087B0FE-F330-447A-B266-311B5F499714|F9EB6503-25AC-4A1F-AE9B-EE9B39B0C56B|9A9C78E9-64F7-42AA-89A4-7ADCFD6034FD|D65E63BF-6645-4CEB-A941-8D50CA15568E|7A4492E5-79CB-4FC8-A105-65707F665CB9|FA30D873-D0C9-461C-8161-D760DE2C7B85|0D12AEB9-8CE4-434A-8AD7-884BF759B8EB|2ADCEE66-E2CA-40AD-A4E3-29A1E32673EA|37BB645C-8859-4914-B4DC-18DC0202943B|81C4B090-B23B-4AB4-AD01-338B86FF5599|5DBF3F05-5DBF-4B95-8CDC-9EAA52D2D077|51E35EAF-171D-4CC2-93A0-2587A35C380C|EE0C4FFC-0704-48D5-A889-704E11EA1965|C105A97B-C1AA-44F1-BC85-6D99BEE4F96D|F88E3603-9E76-4B66-B437-8868E61E2815|8FAD1216-B914-43ED-A01B-DCF99C940BB1|087BAD9C-903A-43D5-9366-6745F22465F9|493554F1-EA87-4EAA-A741-6837301C04EB|5269D7F1-CE52-4BB8-80F3-E56666384B73|180B2551-4BF9-4A05-AF1B-34A190586667|2388CDE6-B30A-4CB7-BE97-105670740719|7B16B20D-9F17-4EB5-AFAD-6AAAEAE0A754|F882981C-4C2F-4DB1-8F78-483C3309C9AD|6F141B87-145A-413E-A837-D82ECB36327E|0769D7C1-A72A-45CD-B731-65F33253DA19|15CCB796-24C8-4C50-B1BA-A371B6FCD752|3910501F-EB10-4EF1-B3B4-D847FC8B5368|27C5E7FC-4062-4635-BC85-90197DFD8070|BF2CAC2A-8534-4F4F-A658-F983C046D698|73B17367-6E70-4DB0-A744-06B6A461BEE8|467B1846-1BE6-4466-AFB0-73F64BF89FC2|1d5af92c-205f-4dd6-942c-32cd4b236831|AC1DA840-5A42-4C90-A866-5354FD4EF22C|33B7BE14-299B-431D-B47A-6D4D3D675AE9|7BBEC088-ECE8-4965-B8F1-2440E3B12542|8846ab09-4230-4ef3-bd96-228ca9946a5a|5e432d3a-d55c-4443-bf6e-c91e8000bdb6|66563166-7e93-4f53-93dc-2cad3f7c3f46|62cb9041-ffa1-4890-84de-46660fe51e03|9605a01c-c03a-4521-b400-533054cabb3c|ebda9d64-8caf-42b6-91af-a92842c3d71f|a0f3aabb-86a0-4d73-9bfb-288118c6f8bf|fb49b1c9-1e9b-458c-95e3-1b5c6d3091e1|067c1a65-4424-4bea-b59f-ae4b0b143a22|7b930637-df07-4d1d-a51e-1784bea6c190|ff8b802b-971b-4395-b957-a8cd6a40fa32|4f76d46e-ca11-4ce2-9137-42bf6da10fa7|a34f5f1b-0dd9-40ba-8575-5534ec8bde0a|8d4e95f5-1d46-4a72-b8ad-b0ae52dd20ed|75ab0b43-ae2e-435c-b6e8-b12cc477fb27|b47a1ac9-c691-43ff-a2da-2ec046f77da1|6d0e965d-7e0f-4d6d-8fa0-8855e4be27b8|3eccc867-51c5-4210-848a-3eab5a1465fd|9247f852-3d3a-479a-8f46-56368bcb6910|dc98c25a-048e-4097-a196-3ed8514348be|04f13518-165c-4f41-beb1-f5ebb9516d68|790d8e60-2bf9-4609-98d3-8e0c606cfc17|dc25e153-9dde-4362-864d-a3fe060dab3e|2664db6d-4dfa-4f76-935a-efc498431d6b|65e8802b-773f-4f7c-ab57-0394f20e1b3b|83a1d723-5c22-4cf4-b81f-a20cf4d23b12|b1dccf8d-9ec4-4f97-bfd0-e7310fd583d4|2e00466d-82e8-4d96-9bbb-b07c25a34fc6|9237aba7-16a6-49ac-abdf-e57d686df422|bd2ed9d6-f6a0-4279-bc28-739540efb84b|f6c5af39-d796-4421-a206-7a671ce7bf8a|c2c575ce-00a0-4fca-bc4e-24bb715ec288|5c6fa811-2afb-4f29-93da-1583f8e9e944|402fffbb-8a24-43c8-b9aa-d6760ab68a04|81d8b732-fa53-413d-940d-99501ce70a01|1f280356-5536-4293-bf95-7bac080dfb14|d82b3a57-547c-411a-a57d-ff3aef46e262|cac65213-d614-464f-9811-67edcf878db7|16a7d4c9-ed94-43cb-bd19-8241c967cebd|b49d9bcd-116f-419b-9294-7e13b5c47ff2|7a7a49e0-0735-4ea9-a0b3-ff6c65eadb0b|e873bd51-566a-45b3-9426-e0d92d7d4da4|2f8286a4-13f1-4114-aded-ea1b65f323e0|301ae6fc-7373-4099-b110-09232a2a74c0|0be9846c-b133-4335-9ac5-a77dee6daf7c|b7cde7d9-0f27-410f-bb08-e98148072c89|937a1690-b5a7-4691-8101-b5f922ce220e|ace79c9d-18b1-4777-9f0e-987608cdecac|888d5d00-dace-4a22-b884-1087a972e0c3|ab2a29cb-a72c-41bb-ace0-327ad8b634ac|3d91652c-23ee-415e-ab76-bff64b26b3cc|1d2a7ac1-0b72-4f06-922e-0163b0ed3e8d|cd883d7c-0761-402d-86e9-97ed5e79c219|48a06627-2c90-4989-88df-2e5a02708997|396a72d3-0e9a-49ec-813f-935d0170e3ba|99149f40-0938-4ada-ae30-21d80ea39d28|db2870aa-23db-4966-8ce6-ab8414030297|43bfb251-b694-488f-a154-3d0e38bd81df|f5517b9f-3087-44ba-adb5-6ad3519da05a|9d391838-9c42-4203-ad76-eb2f48cb1683|6c9f5672-459e-459d-81af-7db8256113bc|6a298256-370d-4699-a9cd-3c6fe5b46268|43bbb1a9-9042-4bee-9578-977697928f85|55903d25-5a5d-44df-81f9-23fe8efc7990|139f46e0-e15f-45d5-af74-97708641d681|a07ce0a6-a253-4904-8577-6b0b40ffce58|5f615b43-2e6b-47eb-82d5-635880b6ccad|d9fad68e-22a9-4846-bf2c-6c4f2040f820|7d33d901-53a9-40a2-9fdd-86ebea6dc807|aaee426b-edda-4620-823f-99833611ad9f|fce4ad4c-c530-4930-8cd8-5f8b814b0189|168486fd-4407-430c-8225-ca14018e3495|49b2b015-3e51-4a2a-9651-4712d4179319|e5dcbdde-580b-44aa-aa97-4edf7e2da248|8f34c126-4ef9-44b3-93fe-8147a4ff5112|0701db26-4e1b-4340-ba61-5605a2890b07|9c30c297-bfc4-45dd-aa42-bdf58fb7497c|f49a62ab-a7ff-448a-a635-8e9efbf1a138|410f06ad-41a3-4bb1-b5de-3e38af459fca|b2dbb7c2-31f5-453b-b506-9d00751dd727|ab3fd3bd-d85f-4d9b-adff-5f59395b3576|7cd7e09c-8e29-4477-ad20-94a6655362e3|840eb8da-42be-481c-8449-2171e386c24c|b1eee337-0af9-4125-bdd2-1aeff6b82230|4b4e8cf0-07cc-415a-8e9d-7981c51088c5|f581e9d2-c5c3-4a72-8132-2635b46353a6|7021eabd-49d7-4fdb-9c4a-76b3c10e7257|c6defca9-af0e-4550-b441-dbf02963f206|e411813e-af01-4b64-be6c-4e2264591699|7686db96-6dd0-4198-988a-b66f4a985b23|f89dd08e-d2eb-49d9-a927-be4d4834a223|2fe03e6b-a714-439b-8c62-ef5092e34a29|6b1a4ff0-1b5d-4fc0-b82a-25cf71721bf3|17dcb43b-046f-4cdb-9b5a-bba7aea76c41|6a3c0536-f0f6-4c90-b21f-4faf9a609ae7|89b20020-37ea-40a8-a159-e7f6318b3dc9|ef671c2f-b120-4c23-89c1-879cb10cff27|c7aa0e76-956b-4fae-9e6e-85a1f505f3e4|6979c082-2ef6-4a8b-85d4-0e68702c6633|78c9a1dc-8fad-4a1c-a7dd-736a16e64243|f49b675e-ea73-4784-965a-8c19d36eff49|3EFC859C-5529-4D5C-B56A-C24538246F5B|53977608-35D4-488F-82E9-8B3C7DA040AA|8382F924-5334-40D0-97B7-4EC1BB8AC2FA|5EA59764-2BAC-4099-BCA0-D272C75E6CD5|43B69E65-49AF-41F6-9526-F8FD90014A25|38E30521-1950-489A-A611-5A8471EFA9E1|0F06980E-C11D-4DB8-9223-FF83457A25F4|D77AAF27-5C9B-4763-8965-7D3AAC447180|B38B8CB7-2183-48D6-BB34-64F910936343|876E5F3A-8468-4026-9877-FC3ED49EF1AC|6C7B01CC-D38C-40EC-AF36-1E35291FF7EB|141029E1-4092-483D-9535-BB9112B9C134|05AD3888-6F11-4312-921F-40FA7C7F3CF6|88FDDD7A-A499-4A86-8D0F-9439280AA0BE|30610BBC-1217-4CC2-98BC-DEBBFE6ED8F9
        //        ^04|8.25|7.8
        internal static string GetStoreString()
        {
            string us = keepMode.ToString();

            foreach (var s in countryViewSettings)
            {
                us += splitCountry + s.Key;
                us += splitSetting + markSystemWidths;
                foreach (var item in s.Value.systemWidths)
                {
                    us += splitList + item.Key + splitList + item.Value.ToString();
                }
                us += splitSetting + markHiddenSystems;
                foreach (string item in s.Value.hiddenSystems)
                {
                    us += splitList + item;
                }
                us += splitSetting + markHiddenNodes;
                foreach (string item in s.Value.hiddenNodes)
                {
                    us += splitList + item;
                }
                us += splitSetting + markTextSize + splitList + EM_Helpers.ConvertToString(s.Value.textSize.Item1) + splitList + EM_Helpers.ConvertToString(s.Value.textSize.Item2);
            }
            return(us);
        }
        void lstAddOnSystems_ItemCheck(object sender, ItemCheckEventArgs e)
        {   //for single selection mode
            if (e.CurrentValue != CheckState.Checked)
            {
                if (_lastCheckedAddOnSystem != -1)
                {
                    lstAddOnSystems.SetItemChecked(_lastCheckedAddOnSystem, false);
                }
            }
            _lastCheckedAddOnSystem = e.Index;

            //select the base systems which are supported by the checked add-on system
            lstBaseSystems.Items.Clear();
            if (e.CurrentValue == CheckState.Checked)
            {
                return; //currently checked add-on system is unchecked
            }
            foreach (AddOnSystemInfo addOnSystemInfo in AddOnInfoHelper.GetAddOnSystemInfo(cmbAddOns.Text))
            {
                if (addOnSystemInfo._addOnSystemName != lstAddOnSystems.SelectedItem.ToString())
                {
                    continue;
                }
                foreach (string supportedSystemName in addOnSystemInfo._supportedSystems)
                {
                    foreach (string baseSystemName in _baseSystemNames)
                    {
                        if (EM_Helpers.DoesValueMatchPattern(supportedSystemName, baseSystemName))
                        {
                            lstBaseSystems.Items.Add(baseSystemName);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        void AddYearColumn(string caption, bool manual = false)
        {
            DataColumn col = dgvDataTable.Columns.Add(_colYear + caption);

            //add before the comments-column
            col.SetOrdinal(dgvDataTable.Columns[colComment.Name] != null ? dgvDataTable.Columns[colComment.Name].Ordinal : dgvDataTable.Columns.Count - 1);
            DataGridViewColumn headerColumn = dgvIndices.Columns[_colYear + caption];

            headerColumn.FillWeight                 = 80F;
            headerColumn.SortMode                   = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
            headerColumn.HeaderText                 = caption;
            headerColumn.Name                       = _colYear + caption;
            headerColumn.DataPropertyName           = headerColumn.Name;
            headerColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            headerColumn.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
            headerColumn.DisplayIndex               = col.Ordinal;

            foreach (DataRow row in dgvDataTable.Rows)
            {
                row[headerColumn.Name] = "";                                        // this is to make sure the added column counts as a DataSet change...
            }
            //also add year to the combo-box that allows for selecting a year to delete
            cmbYearToDelete.Items.Add(caption);

            int nextYear = EM_Helpers.SaveConvertToInt(caption) + 1;

            if (updwnYearToAdd.Value < nextYear)
            {
                updwnYearToAdd.Value = nextYear;
            }
            dgvIndices.Refresh();
        }
        static System.Data.DataRow GetDataRowBySymbolicID(string symbolicID, CountryConfigFacade countryConfigFacade, string systemID, bool function)
        {
            string policyName            = string.Empty;
            string functionDisplayOrder  = string.Empty;
            string parameterDisplayOrder = string.Empty;

            CountryConfig.FunctionRow  functionRow  = null;
            CountryConfig.ParameterRow parameterRow = null;

            if (GetPolicyAndOrderFromSymbolicID(symbolicID, countryConfigFacade.GetCountryShortName(), ref policyName, ref functionDisplayOrder, ref parameterDisplayOrder))
            {
                if (EM_Helpers.IsNonNegInteger(functionDisplayOrder))
                {
                    functionRow = GetFunctionRowByPolicyNameAndDisplayOrder(countryConfigFacade, systemID, policyName, functionDisplayOrder);
                }
                else //take account of functions DefIL and DefTU, which use the (value of the) name parameter as identifier instead of the order
                {
                    functionRow = GetFunctionRowByPolicyNameAndValueOfSpecialParameter(countryConfigFacade, systemID, policyName,
                                                                                       DefPar.DefIl.Name, functionDisplayOrder);
                }
            }

            if (function)
            {
                return(functionRow);
            }

            if (functionRow != null)
            {
                parameterRow = GetParameterRowByDisplayOrder(countryConfigFacade, functionRow.ID, parameterDisplayOrder);
            }
            return(parameterRow);
        }
Exemplo n.º 8
0
        // get ids of policies in the country that match the pattern of the global switch policy (the rules say it ought to be one, but the old exe seems to work with more than one)
        // e.g. get id of Hungarian policy BTA_hu if sw.switchPolID points to global policy-switch with pattern 'BTA_??'
        // see "explanation wrt new handling of policy switches" in Explanations.cs
        private List <string> GetExtensionPolIDs(string extensionID,
                                                 List <List <MultiProp> > extensionInfo,
                                                 Dictionary <string, EM2Item> ctryPol)
        {
            string pattern = null;

            foreach (var ei in extensionInfo)
            {
                MultiProp idProp = (from g in ei where g.tag == EM2TAGS.ID select g).FirstOrDefault();
                if (idProp != null && idProp.content == extensionID)
                {
                    MultiProp patternProp = (from g in ei where g.tag == EM2TAGS.TAG_PATTERN select g).FirstOrDefault();
                    if (patternProp != null)
                    {
                        pattern = XmlHelpers.RemoveCData(patternProp.content);
                    }
                    break;
                }
            }
            List <string> polIds = new List <string>();

            if (pattern != null)
            {
                foreach (var pol in ctryPol)
                {
                    if (EM_Helpers.DoesValueMatchPattern(pattern, pol.Value.name))
                    {
                        polIds.Add(pol.Key);
                    }
                }
            }
            return(polIds);
        }
        static int GetSystemYear(string systemName) // assume that the 1st occurrence of 4 successive digits starting with 2 is the system year
        {
            List <string> digitSequences = new List <string>();
            string        dSeq           = string.Empty;

            for (int i = 0; i < systemName.Length; ++i)
            {
                if (EM_Helpers.IsDigit(systemName[i]))
                {
                    dSeq += systemName[i];
                }
                else
                {
                    if (dSeq == string.Empty)
                    {
                        continue;
                    }
                    digitSequences.Add(dSeq); dSeq = string.Empty;
                }
            }
            if (dSeq != string.Empty)
            {
                digitSequences.Add(dSeq);
            }

            foreach (string dS in digitSequences)
            {
                if (dS.Length == 4 && dS[0] == '2')
                {
                    return(Convert.ToInt32(dS));
                }
            }
            return(-1);
        }
        internal override void ProvideIndexInfo()
        {
            ParBase par = GetUniquePar <ParBase>(DefPar.Loop.Loop_Id); if (par == null)

            {
                return;                                                                        // error is issued by standard-check
            }
            loopID = par.xmlValue;
            if (!EM_Helpers.IsValidName(loopID, out string illegal))
            {
                infoStore.communicator.ReportError(new Communicator.ErrorInfo()
                {
                    isWarning = false,
                    message   = $"{par.description.Get()}: usage of illegal character(s): {illegal}"
                });
                return;
            }

            infoStore.operandAdmin.indexLoopIDs.Add(loopID, this); // used by Store-function, for checking if loop exists
            infoStore.operandAdmin.RegisterVar(name: DefVarName.LOOPCOUNT + loopID,
                                               creatorFun: DefFun.Loop,
                                               description: description,
                                               isMonetary: false,
                                               isGlobal: true,     // actually it is not global, as this would not work in parallel evironment
                                                                   // but by setting is Global to true, usage in RunCond is made possible
                                               isWriteable: false, // cannot be used as output-variable
                                               setInitialised: true);
        }
Exemplo n.º 11
0
        private static void Generate_BackgroundEventHandler(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            BackgroundWorker backgroundWorker = sender as BackgroundWorker;

            try
            {
                List <Country> countries = CountryAdministrator.GetCountries();
                for (int i = 0; i < countries.Count; ++i)
                {
                    if (backgroundWorker.CancellationPending)
                    {
                        e.Result = null; e.Cancel = true; return;
                    }

                    CountryConfigFacade ccf = countries[i].GetCountryConfigFacade(); if (ccf == null)
                    {
                        continue;
                    }
                    foreach (CountryConfig.SystemRow system in ccf.GetSystemRows())
                    {
                        system.Year = EM_Helpers.ExtractSystemYear(system.Name);
                    }

                    ccf.GetCountryConfig().AcceptChanges();
                    countries[i].WriteXML();

                    backgroundWorker.ReportProgress(Convert.ToInt32((i + 1.0) / (countries.Count * 1.0) * 100.0));
                }
            }
            catch (Exception exception) { e.Result = exception.Message; backgroundWorker.ReportProgress(100); }
        }
        private static void GetUpIndInfo(Dictionary <string, Dictionary <string, string> > upInds,
                                         Dictionary <string, Dictionary <string, string> > upIndYears,
                                         ExeXml.Country country)
        {
            foreach (Dictionary <string, string> ui in upIndYears.Values) // loop over <UPIND_YEARs>
            {
                if (ui.ContainsKey(TAGS.YEAR))
                {
                    string upIndId = ui.GetOrEmpty(TAGS.UPIND_ID);

                    string sVal = ui.GetOrEmpty(TAGS.VALUE);
                    if (upIndId == string.Empty || sVal == string.Empty ||
                        !double.TryParse(EM_Helpers.AdaptDecimalSign(sVal), out double val))
                    {
                        continue;
                    }

                    string facName = null; // get the name of the factor from <UPINDs>
                    if (upInds.ContainsKey(upIndId) && upInds[upIndId].ContainsKey(TAGS.NAME))
                    {
                        facName = upInds[upIndId][TAGS.NAME];
                    }

                    // Store all uprate indices
                    if (!country.upFacs.ContainsKey(facName))   // If uprating factor name does not exist, create a new entry
                    {
                        country.upFacs.Add(facName, new ExeXml.UpIndDict());
                    }
                    country.upFacs[facName].SetYear(ui[TAGS.YEAR], val);
                }
            }
        }
Exemplo n.º 13
0
        internal override void PerformAction()
        {
            TreeList treeList = _targetNode.TreeList;
            //-A- first move directly in treeview ...
            int targetIndex       = treeList.GetNodeIndex(_targetNode);
            int selectionTopIndex = treeList.GetNodeIndex(_moveNodes.First());
            int selectionBotIndex = treeList.GetNodeIndex(_moveNodes.Last());

            //move up (accomplished by moving the selection above target node - or above target node's next node, if move below target)
            if (targetIndex < selectionTopIndex)
            {
                int index = _moveAboveTarget ? targetIndex : targetIndex + 1;
                foreach (TreeListNode node in _moveNodes)
                {
                    treeList.SetNodeIndex(node, index++);
                }
            }

            //move down (accomplished by moving the nodes between selection and targetNode above selection - including target node itself, if move below target)
            else if (targetIndex > selectionBotIndex)
            {
                List <TreeListNode> shiftUpNodes = new List <TreeListNode>();
                foreach (TreeListNode node in _targetNode.ParentNode == null ? treeList.Nodes : _targetNode.ParentNode.Nodes)
                {
                    if (treeList.GetNodeIndex(node) > selectionBotIndex &&
                        (treeList.GetNodeIndex(node) < targetIndex || !_moveAboveTarget && treeList.GetNodeIndex(node) == targetIndex))
                    {
                        shiftUpNodes.Add(node);
                    }
                }
                foreach (TreeListNode node in shiftUpNodes)
                {
                    treeList.SetNodeIndex(node, selectionTopIndex++);
                }
            }

            //else: target inside selection: should not happen unless programming error (thus do nothing)

            //-B- then reenact in data: avoids flickering and saves time, compared to reorder in data and update tree, though the latter may be cleaner
            TreeListNodes nodes = _targetNode.ParentNode == null ? treeList.Nodes : _targetNode.ParentNode.Nodes;

            //this takes care of the "hidden" uprating-policy (which is in fact not hidden in the narrow sense, but only exists in data but not in the tree)
            int allowForNotDisplayedPolicy = 0;

            if (_targetNode.ParentNode == null) //moved node is a policy-node
            {                                   //re-order the policies starting with oder of hidden uprating-policy plus 1
                CountryConfig.PolicyRow firstPol = CountryConfigFacade.GetFirstPolicyRow((_targetNode.Tag as BaseTreeListTag).GetDefaultPolicyRow().SystemRow);
                if (firstPol.Name.StartsWith(EM_UI.UpratingIndices.UpratingIndicesForm._policyUprateFactors_Name))
                {
                    CountryAdministration.CountryAdministrator.GetCountryConfigFacade(EM_AppContext.Instance.GetActiveCountryMainForm().GetCountryShortName());
                }
                allowForNotDisplayedPolicy = EM_Helpers.SaveConvertToInt(firstPol.Order) + 1;
            }

            foreach (TreeListNode node in nodes)
            {
                (node.Tag as BaseTreeListTag).SetOrder(treeList.GetNodeIndex(node) + allowForNotDisplayedPolicy);
            }
        }
Exemplo n.º 14
0
        void cmbDatasets_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbDatasets.SelectedIndex == -1)
            {
                return; //no dataset selected
            }
            dgvFactors.Rows.Clear();

            //look up which dataset was selected to assess the data's income year, and put it into text-edit
            foreach (DataConfig.DataBaseRow dataset in _dataConfigFacade.GetDataBaseRows())
            {
                if (cmbDatasets.Text == dataset.Name)
                {
                    txtIncomeYear.Text = dataset.YearInc;
                    break;
                }
            }

            //check if the 'Raw Indices' table contains the data-year
            bool noIncomeYear = false;

            if (!GetExistingYears().Contains(txtIncomeYear.Text))
            {
                //UserInfoHandler.ShowError("Year " + txtIncomeYear.Text + " is not recorded in Raw Indices table. Factors cannot be calculated.");
                UserInfoHandler.ShowInfo("Year " + txtIncomeYear.Text + " is not recorded in Raw Indices table. Factors are set to " + _factorValueInvalid + ".");
                noIncomeYear = true;
                //return;
            }

            //fill the 'Factors ...' table for the selected dataset
            foreach (string indexName in GetIndicesNames()) //loop over all indices
            {
                //add one row to the 'Factors ...' table for each index
                DataGridViewRow factorRow = dgvFactors.Rows[dgvFactors.Rows.Add()];

                //put the name of the index (e.g. cpi) in the first column
                factorRow.Cells[colIndexName.Name].Value = indexName;

                foreach (DataGridViewColumn systemColumn in dgvFactors.Columns) //loop over the country's systems
                {
                    if (systemColumn == colIndexName)
                    {
                        continue; //name-column is already filled
                    }
                    if (noIncomeYear)
                    {
                        factorRow.Cells[systemColumn.Name].Value = _factorValueInvalid;
                    }
                    else
                    {
                        CountryConfig.SystemRow systemRow = systemColumn.Tag as CountryConfig.SystemRow;
                        string systemYear = systemRow.Year != null && systemRow.Year != string.Empty ? systemRow.Year
                                            : EM_Helpers.ExtractSystemYear((systemColumn.Tag as CountryConfig.SystemRow).Name);
                        // in the display, round the number to 4 digits - also make sure that you display dot regardless of the windows decimal separator. CalculateFactor takes care of all this...
                        factorRow.Cells[systemColumn.Name].Value = CalculateFactor(indexName, txtIncomeYear.Text, systemYear);
                    }
                }
            }
        }
 private string PreParse(string formula, FunBase fun)
 {
     formula = EM_Helpers.RemoveWhitespace(formula).ToLower();
     formula = HandleAmount(formula, fun);
     formula = HandleOldStyleAmount(formula, fun); // this takes care of (very) old style {xyz < amount}#1
     formula = BenCalcBase(formula, fun);          // BenCalc's conditions and formulas can contain "$Base"
     return(formula);
 }
Exemplo n.º 16
0
 static bool ValidateString(string value, SystemTreeListTag systemColumnTag, ref string errorText)
 {
     if (EM_Helpers.ContainsIllegalChar(value, ref errorText, _additionallyAllowedChar_TypeString))
     {
         return(false);
     }
     return(true);
 }
        internal void SearchVariable()
        {
            string searchedVariable = _variablesForm.txtSearchVariable.EditValue == null ? string.Empty : _variablesForm.txtSearchVariable.EditValue.ToString();

            if (searchedVariable == string.Empty)
            {
                Tools.UserInfoHandler.ShowError("Please enter a variable name to search for in the field above the search button.");
                return;
            }

            bool            useSearchPattern       = searchedVariable.Contains('?') || searchedVariable.Contains('*');
            DataGridViewRow rowToSelect            = null;
            List <string>   occurrences            = new List <string>();
            List <string>   occurrenceDescriptions = new List <string>();
            List <object>   occurrence_rows        = new List <object>();

            foreach (DataGridViewRow row in _dgvVariables.Rows)
            {
                string displayedVariable = row.Cells[_variablesForm.colVariableName.Name].Value.ToString();
                if (EM_Helpers.DoesValueMatchPattern(searchedVariable, displayedVariable))
                {
                    string displayedDescription = row.Cells[_variablesForm.colAutomaticLabel.Name].Value.ToString();

                    occurrence_rows.Add(row.Visible ? (object)row.Index : null);
                    occurrences.Add("Row " + (row.Index + 1).ToString() + ": " + displayedVariable +
                                    (row.Visible == false ? " (hidden!)" : string.Empty));
                    occurrenceDescriptions.Add(displayedDescription);
                    if (rowToSelect == null && row.Visible) //select (below) the first or single not hidden occurrence of the search-pattern
                    {
                        rowToSelect = row;
                    }
                    if (!useSearchPattern)
                    {
                        break; //if no search pattern is used, there cannot be more than one matching variable
                    }
                }
            }

            if (occurrences.Count == 0)
            {
                Tools.UserInfoHandler.ShowError("Variable '" + searchedVariable + "' does not exist.");
                return;
            }

            if (rowToSelect != null) //at least one visible match found
            {
                selectRow(_dgvVariables.Rows.IndexOf(rowToSelect));
                if (occurrences.Count == 1)
                {
                    return; //no list of occurrences needs to be displayed if only one match
                }
            }
            string title = occurrences.Count + " variable" + (occurrences.Count > 1 ? "s were" : " was") + " matched:";
            NumberedSearchResultsForm sr = new NumberedSearchResultsForm(title);

            sr.addResults(occurrences, occurrenceDescriptions, occurrence_rows, selectRow);
            sr.ShowDialog(_variablesForm);
        }
        void btnOK_Click(object sender, EventArgs e)
        {
            if (!CheckSystemYear())
            {
                return;
            }
            bool haveChanges = false;

            foreach (DataGridViewRow dataGridViewRow in dgvSystems.Rows)
            {
                CountryConfig.SystemRow systemRow = dataGridViewRow.Tag as CountryConfig.SystemRow;
                if (systemRow.CurrencyParam != dataGridViewRow.Cells[colCurrencyParameters.Name].Value.ToString())
                {
                    systemRow.CurrencyParam = dataGridViewRow.Cells[colCurrencyParameters.Name].Value.ToString();
                    haveChanges             = true;
                }
                if (systemRow.CurrencyOutput != dataGridViewRow.Cells[colCurrencyOutput.Name].Value.ToString())
                {
                    systemRow.CurrencyOutput = dataGridViewRow.Cells[colCurrencyOutput.Name].Value.ToString();
                    haveChanges = true;
                }
                if (EM_Helpers.SaveConvertToBoolean(dataGridViewRow.Cells[colPrivate.Name].Value) == true)
                {
                    if (systemRow.Private != DefPar.Value.YES)
                    {
                        systemRow.Private = DefPar.Value.YES;
                        haveChanges       = true;
                    }
                }
                else
                {
                    if (systemRow.Private != DefPar.Value.NO)
                    {
                        systemRow.Private = DefPar.Value.NO;
                        haveChanges       = true;
                    }
                }
                if (systemRow.HeadDefInc != dataGridViewRow.Cells[colHeadDefInc.Name].Value.ToString())
                {
                    systemRow.HeadDefInc = dataGridViewRow.Cells[colHeadDefInc.Name].Value.ToString();
                    haveChanges          = true;
                }
                if (systemRow.Year != dataGridViewRow.Cells[colYear.Name].Value.ToString())
                {
                    systemRow.Year = dataGridViewRow.Cells[colYear.Name].Value.ToString();
                    haveChanges    = true;
                }
                string comment = dataGridViewRow.Cells[colComment.Name].Value == null ? string.Empty : dataGridViewRow.Cells[colComment.Name].Value.ToString();
                if (systemRow.Comment != comment)
                {
                    systemRow.Comment = comment;
                    haveChanges       = true;
                }
            }
            DialogResult = haveChanges == true ? DialogResult.OK : DialogResult.Cancel;
            Close();
        }
 private bool ValidateTextBox(TextBox tb, out double val)
 {
     if (string.IsNullOrEmpty(tb.Text) || !EM_Helpers.TryConvertToDouble(tb.Text, out val) || tb.Text.Contains(','))
     {
         UserInfoHandler.ShowError(tb.Name.Replace("txt", string.Empty) + " must be a valid number.");
         val = 0; return(false);
     }
     return(true);
 }
Exemplo n.º 20
0
        internal void FromStoreFormat(string storeFormat)
        {
            List <string> descriptionAndSignificance = storeFormat.Split(new string[] { _separator }, StringSplitOptions.None).ToList <string>();

            if (descriptionAndSignificance.Count == 2)
            {
                _description = descriptionAndSignificance.ElementAt(0);
                _significant = EM_Helpers.SaveConvertToBoolean(descriptionAndSignificance.ElementAt(1));
            }
        }
Exemplo n.º 21
0
        public static double ReadExRate(string path, string country,
                                        string sysName,            // in future perhaps 'year'
                                        string exRateDate,         // supposed to be TAGS.EXRATE_AVERAGE or TAGS.EXRATE_1stSEMESTER or
                                        Communicator communicator) //                TAGS.EXRATE_2ndSEMESTER or TAGS.EXRATE_DEFAULT
        {
            try
            {
                if (!File.Exists(path))
                {
                    return(-1);
                }

                using (StreamReader sr = new StreamReader(path, Encoding.UTF8))
                    using (XmlReader reader = XmlReader.Create(sr))
                    {
                        // find the appropriate exchangerate for the system to run
                        foreach (var rate in XmlHelpers.GetXmlGroupItems(reader: reader, tag: TAGS.EXRATE,
                                                                         hasId: false, uniqueProperties: false).Values)
                        {
                            if (rate.GetOrEmpty(TAGS.EXRATE_COUNTRY).ToLower() != country.ToLower())
                            {
                                continue;
                            }

                            foreach (var prop in rate)                    // in future this could perhaps be 'if (rate.GetOrEmpty(TAGS.YEAR) == year)'
                            {
                                if (prop.Key.StartsWith(TAGS.SYS_NAME) && // (non-unique tags are stored as SysName1,SysName2,... in the Dictionary)
                                    prop.Value.ToLower() == sysName.ToLower())
                                {
                                    if (exRateDate == TAGS.EXRATE_DEFAULT)                                  // if the user didn't define a concrete date (e.g. June30) use <Default>xxx</Default>
                                    {
                                        exRateDate = rate.GetOrEmpty(TAGS.EXRATE_DEFAULT).Replace(" ", ""); // e.g. June 30 -> June30 (the former is the content of <Default>xxx</Default>, the latter the tag-name)
                                    }
                                    string sRate = EM_Helpers.AdaptDecimalSign(rate.GetOrEmpty(exRateDate));
                                    if (double.TryParse(sRate, out double exRate))
                                    {
                                        return(exRate);
                                    }

                                    ReportError(communicator, path, $"Exchange rate for {sysName} invalid" +
                                                (sRate != string.Empty ? $": {sRate}" : string.Empty));
                                    return(-1);
                                }
                            }
                        }
                    }
                return(-1); // note: -1 is also what's used in the file to indicate n/a (thus easier for the caller to just check for -1)
                            // also note: not finding must not be reported here, as the rate may not be required (actually quite likely that data/param/output are in same currency)
            }
            catch (Exception exception)
            {
                throw new Exception($"Failure reading file {path}{Environment.NewLine}{exception.Message}");
            }
        }
Exemplo n.º 22
0
 bool IsUnusedVariable(string variableName)
 {
     foreach (string parameterValue in _allCountriesParameters)
     {
         if (EM_Helpers.DoesFormulaContainComponent(parameterValue, variableName)) //use 'whole-word-search', i.e. avoid finding bun_s if bun is searched
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 23
0
 internal static Color GetColorFromDisplayText(string displayText)
 {
     if (displayText == _noSpecialColor || displayText == string.Empty)
     {
         return(Color.Empty);
     }
     if (EM_Helpers.IsNumeric(displayText, true))
     {
         return(Color.FromArgb(Convert.ToInt32(displayText, 16)));
     }
     return(Color.FromName(displayText));
 }
        private bool PreparePostPar()
        {
            ParBase parPostLoop = GetUniquePar <ParBase>(DefPar.Store.PostLoop);
            ParBase parPostFix  = GetUniquePar <ParBase>(DefPar.Store.PostFix);

            if (parPostLoop == null && parPostFix == null)
            {
                infoStore.communicator.ReportError(new Communicator.ErrorInfo()
                {
                    isWarning = false,
                    message   = $"{description.Get()}: neither {DefPar.Store.PostFix} nor {DefPar.Store.PostLoop} defined"
                });
                return(false);
            }
            if (parPostLoop != null && parPostFix != null)
            {
                infoStore.communicator.ReportError(new Communicator.ErrorInfo()
                {
                    isWarning = false,
                    message   = $"{description.Get()}: unclear specification - both {DefPar.Store.PostFix} and {DefPar.Store.PostLoop} defined"
                });
                return(false);
            }
            if (parPostLoop != null)
            {
                post = parPostLoop.xmlValue;
                if (!infoStore.operandAdmin.indexLoopIDs.ContainsKey(post))
                {
                    infoStore.communicator.ReportError(new Communicator.ErrorInfo()
                    {
                        isWarning = false,
                        message   = $"{parPostLoop.description.Get()}: no loop with {DefPar.Loop.Loop_Id} = {post} found"
                    });
                    return(false);
                }
                storeType = infoStore.operandAdmin.indexLoopIDs[post] is FunUnitLoop ? STORETYPE.UNITLOOP : STORETYPE.LOOP;
            }
            else
            {
                post = parPostFix.xmlValue; storeType = STORETYPE.FIX;
                if (!EM_Helpers.IsValidName(post, out string illegal))
                {
                    infoStore.communicator.ReportError(new Communicator.ErrorInfo()
                    {
                        isWarning = false,
                        message   = $"{parPostFix.description.Get()}: usage of illegal character(s): {illegal}"
                    });
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 25
0
        internal string CalculateFactor(string indexName, string dataYear, string systemYear)
        {
            //search row of the relevant index
            int iRow = -1;

            for (int r = 0; r < dgvIndices.Rows.Count; ++r)
            {
                if (dgvIndices.Rows[r].Cells[colReference.Name].Value != null &&
                    dgvIndices.Rows[r].Cells[colReference.Name].Value.ToString() == indexName)
                {
                    iRow = r;
                    break;  // if row found, exit loop
                }
            }
            //search for column of the relevant years (data-year and system-year)
            int iColData   = -1;
            int iColSystem = -1;

            for (int c = 0; c < dgvIndices.Columns.Count; ++c)
            {
                if (systemYear != string.Empty && dgvIndices.Columns[c].HeaderCell.Value.ToString() == systemYear)
                {
                    iColSystem = c;
                }
                if (dataYear != string.Empty && dgvIndices.Columns[c].HeaderCell.Value.ToString() == dataYear)
                {
                    iColData = c;
                }
            }

            //check if possible to calculate factor: may be impossible, because ...
            if (iRow == -1 ||                                          //... index-name not found in 'Raw Indeces' table (should not happen in fact)
                iColData == -1 || iColSystem == -1 ||                  //... data-year or system-year not available in 'Raw Indeces' table
                dgvIndices.Rows[iRow].Cells[iColData].Value == null || //... index-value for data-year is not valid
                dgvIndices.Rows[iRow].Cells[iColData].Value.ToString() == string.Empty ||
                !EM_Helpers.IsNumeric(dgvIndices.Rows[iRow].Cells[iColData].Value.ToString()) ||
                dgvIndices.Rows[iRow].Cells[iColSystem].Value == null || //... index-value for system-year is not valid
                dgvIndices.Rows[iRow].Cells[iColSystem].Value.ToString() == string.Empty ||
                !EM_Helpers.IsNumeric(dgvIndices.Rows[iRow].Cells[iColSystem].Value.ToString()))
            {
                return(_factorValueInvalid);
            }

            // Check the windows decimal separator and format the string accordingly before doing any conversions or operations
            string nval = dgvIndices.Rows[iRow].Cells[iColSystem].Value.ToString();
            string dval = dgvIndices.Rows[iRow].Cells[iColData].Value.ToString();

            double numerator   = EM_Helpers.SaveConvertToDouble(nval);
            double denominator = EM_Helpers.SaveConvertToDouble(dval);

            return((denominator == 0) ? _factorValueInvalid : EM_Helpers.ConvertToString(Math.Round(numerator / denominator, 4)));
        }
 // writes the hash-file, if the transformation was successfull
 internal static void WriteUpToDate(string em2FullFilePath, string em3Folder, string hashCode = null)
 {
     try
     {
         if (hashCode == null)
         {
             hashCode = EM_Helpers.GetFileMD5Hash(em2FullFilePath);
         }
         string hashFile = GetHashFilePath(em2FullFilePath, em3Folder);
         File.WriteAllText(hashFile, hashCode);
     }
     catch { }
 }
        void PerformImportVariables()
        {
            foreach (DataGridViewRow dgvRow in _dgvVariables.Rows)
            {
                if (EM_Helpers.SaveConvertToBoolean(dgvRow.Cells[_importVariablesForm.colPerformVariables.Name].Value) != true)
                {
                    continue; //checkbox to perform change not checked
                }
                //adapt variables
                VarConfig.VariableRow internalVariable = null;
                VarConfig.VariableRow externalVariable = null;

                switch (dgvRow.Cells[_importVariablesForm.colAction.Name].Value.ToString())
                {
                case ImportVariablesForm._actionAdd:
                    externalVariable = dgvRow.Tag as VarConfig.VariableRow;
                    internalVariable = _varConfigFacade.AddVariable(externalVariable.Name, externalVariable.Monetary, externalVariable.HHLevel, externalVariable.AutoLabel);
                    foreach (VarConfig.CountryLabelRow externalLabel in externalVariable.GetCountryLabelRows())
                    {
                        _varConfigFacade.SetCountrySpecificDescription(internalVariable, externalLabel.Country, externalLabel.Label);
                    }
                    _varConfigFacade.Commit();
                    break;

                case ImportVariablesForm._actionDelete:
                    internalVariable = dgvRow.Tag as VarConfig.VariableRow;
                    _varConfigFacade.DeleteVariable(internalVariable);
                    _varConfigFacade.Commit();
                    break;

                case ImportVariablesForm._actionChange:
                    internalVariable = (dgvRow.Tag as Dictionary <VarConfig.VariableRow, VarConfig.VariableRow>).Keys.ElementAt(0);
                    externalVariable = (dgvRow.Tag as Dictionary <VarConfig.VariableRow, VarConfig.VariableRow>).Values.ElementAt(0);

                    string info = dgvRow.Cells[_importVariablesForm.colInfo.Name].Value.ToString();
                    if (info == ImportVariablesForm._infoChangeCountryLabel)
                    {
                        foreach (VarConfig.CountryLabelRow externalLabel in externalVariable.GetCountryLabelRows())
                        {
                            _varConfigFacade.SetCountrySpecificDescription(internalVariable, externalLabel.Country, externalLabel.Label);
                        }
                    }
                    else
                    {
                        internalVariable.Monetary = externalVariable.Monetary;
                    }
                    _varConfigFacade.Commit();
                    break;
                }
            }
        }
        string GetSystemYear(string systemName)
        {
            if (!systemName.Contains("20"))
            {
                return(string.Empty);
            }
            int index = systemName.IndexOf("20");

            if (systemName.Length < index + 4 || !EM_Helpers.IsNonNegInteger(systemName.Substring(index, 4)))
            {
                return(string.Empty);
            }
            return(systemName.Substring(index, 4));
        }
 // tests whether a file is up-to-date or needs to be transformed
 // examples: IsFileUpToDate("C:\EuromodFiles\XMLParam\Countries\BG\BG.xml", "C:\EuromodFiles\EM3Translation\XMLParam\Countries\BG", out string hc)
 //           IsFileUpToDate("C:\EuromodFiles\XMLParam\Config\VarConfig.xml", "C:\EuromodFiles\EM3Translation\Config", out string hc)
 internal static bool IsFileUpToDate(string em2FullFilePath, string em3Folder, out string hashCode)
 {
     try
     {
         hashCode = EM_Helpers.GetFileMD5Hash(em2FullFilePath) + TRANSFORMER_VERSION;
         string hashFile = GetHashFilePath(em2FullFilePath, em3Folder);
         if (File.Exists(hashFile) && hashCode == File.ReadAllText(hashFile))
         {
             return(true);
         }
         return(false);
     }
     catch { hashCode = string.Empty;  return(false); }
 }
        private List <string> GetMatchingOperands(string pattern, bool il, bool regExpr)
        {
            List <string> matching = new List <string>();

            foreach (var op in indexOperands)
            {
                if (((il && op.Value.parType == DefPar.PAR_TYPE.IL) || (!il && op.Value.parType == DefPar.PAR_TYPE.VAR)) &&
                    EM_Helpers.DoesValueMatchPattern(pattern: pattern, value: op.Key, regExpr: regExpr))
                {
                    matching.Add(op.Key);
                }
            }
            return(matching);
        }