コード例 #1
0
        void btnOK_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(txtProjectPath.Text))
            {
                UserInfoHandler.ShowInfo("Please indicate a valid 'Project Path' for storing the new project."); return;
            }

            if (txtProjectName.Text == string.Empty)
            {
                UserInfoHandler.ShowInfo("Please indicate a 'Project Name'."); return;
            }

            if (chkProjectOnDisk.Checked && !CountryAdministrator.ContainsEuromodFileStructure(txtBasePath.Text))
            {
                UserInfoHandler.ShowInfo($"Please indicate a folder containting the {DefGeneral.BRAND_TITLE} file structure as 'Project on Disk' (or check 'No Base Project')."); return;
            }

            if (chkProjectOnVC.Checked && cmbBaseProjects.SelectedIndex < 0)
            {
                UserInfoHandler.ShowInfo("Please select a Base Project from the list 'Project on VC' (or check 'No Base Project')."); return;
            }

            if (chkProjectOnVC.Checked && cmbSelectVersion.SelectedIndex < 0)
            {
                UserInfoHandler.ShowError("Please select a Version. If no version is available, this project cannot be selected as Base Project."); return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #2
0
        bool AssessVCBaseProjectContent(out ProjectContent projectContent)
        {
            EM_AppContext.Instance.GetActiveCountryMainForm().Cursor = Cursors.WaitCursor;
            ProjectNode project        = (cmbBaseProjects.Tag as List <ProjectNode>).ElementAt(cmbBaseProjects.SelectedIndex);
            ReleaseInfo projectVersion = (cmbSelectVersion.Tag as List <ReleaseInfo>).ElementAt(cmbSelectVersion.SelectedIndex);

            projectContent = new ProjectContent(project.Id);
            List <VersionControlUnitInfo> content;
            string releaseName = string.Empty;

            if (!_vcAdministrator.GetReleaseInfo(project.Id, projectVersion.Name, out content))
            {
                UserInfoHandler.ShowError(_vcAdministrator._vcAPI.GetErrorMessage());
                EM_AppContext.Instance.GetActiveCountryMainForm().Cursor = Cursors.Default;
                return(false);
            }

            foreach (VersionControlUnitInfo unit in content)
            {
                projectContent.projectUnits.Add(unit); projectContent.selections.Add(true);
            }

            projectContent.selectedRelease = cmbSelectVersion.SelectedItem.ToString();
            EM_AppContext.Instance.GetActiveCountryMainForm().Cursor = Cursors.Default;
            return(true);
        }
コード例 #3
0
        private bool AddYear(int year = -1)
        {
            try
            {
                bool showWarning = false;
                if (year == -1)
                {
                    showWarning = true;
                    year        = Convert.ToInt32(updwnYearToAdd.Value);
                    if (GetExistingYears().Contains(year))
                    {
                        UserInfoHandler.ShowError(year + " already exits."); return(false);
                    }
                }
                int preCount = GetExistingYears().Where(y => y < year).ToList().Count();

                if (!dgvHICP.AddColumn(showWarning, year.ToString(), typeof(double), preCount + 1))
                {
                    ShowGridLastError(); return(false);
                }
                dgvHICP.pasteableColumns.Add(year.ToString());
                updwnYearToAdd.Value = year + 1;
                cmbYearToDelete.Items.Add(year);

                FormatGridViewColumns(year.ToString());
                return(true);
            }
            catch (Exception exception) { UserInfoHandler.ShowException(exception); return(false); }
        }
コード例 #4
0
        private void lstCountries_SelectedIndexChanged(object sender = null, EventArgs e = null)
        {
            if (radShowYears.Checked)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;
            try
            {
                lstSystems.Items.Clear();
                foreach (string c in lstCountries.SelectedItems)
                {
                    if (!ccSystems.ContainsKey(c))
                    {
                        ccSystems.Add(c, (from s in CountryAdministrator.GetCountryConfigFacade(c).GetSystemRowsOrdered() select s.Name).ToList());
                    }
                    foreach (string s in ccSystems[c])
                    {
                        lstSystems.Items.Add(s);
                    }
                }
            }
            catch (Exception exception) { UserInfoHandler.ShowError(exception.Message); }
            Cursor = Cursors.Default;
        }
コード例 #5
0
        internal VCUsers(VCAPI vcAPI)
        {
            InitializeComponent();

            _vcAPI = vcAPI;

            colRefineRights.Visible  = false;
            colDefaultRight.ReadOnly = false;

            List <UserInfo> userInfos; List <bool> adminRights; List <VCAPI.VC_ACCESS_RIGHTS> defaultRights;

            if (!_vcAPI.GetProjectUserRights(_vcAPI.vc_projectInfo.ProjectId, out userInfos, out adminRights, out defaultRights))
            {
                UserInfoHandler.ShowError(_vcAPI.GetErrorMessage());
                return;
            }

            colDefaultRight.Items.Add(VC_ACCESS_DOWNLOAD); colDefaultRight.Items.Add(VC_ACCESS_UPLOAD);
            for (int i = 0; i < userInfos.Count; ++i)
            {
                ExtUserRightInfo tag = new ExtUserRightInfo {
                    userInfo = userInfos.ElementAt(i)
                };
                tag.defaultUnitRight     = defaultRights.ElementAt(i);
                tag.hasProjectAdminRight = adminRights.ElementAt(i);
                AddUserRow(tag);
            }
        }
コード例 #6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtImportFolder.Text == string.Empty)
            {
                UserInfoHandler.ShowError("Please select a version to compare with."); return;
            }

            Cursor = Cursors.WaitCursor;
            bool   hasInsertedPath = true;
            string insertedPath    = txtImportFolder.Text;
            string selectedPath    = String.Empty;

            if (CountryAdministrator.ConsiderOldAddOnFileStructure(_fromAddOn))
            {
                _importCountry = ImportExportAdministrator.GetImportAddOn_OldStyle(out selectedPath, hasInsertedPath, insertedPath);
            }
            else
            {
                _importCountry = ImportExportAdministrator.GetImportCountry(out selectedPath, _fromAddOn, hasInsertedPath, insertedPath);
            }
            if (_importCountry == null)
            {
                Cursor = Cursors.Default;
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #7
0
        void btnOK_Click(object sender, EventArgs e)
        {
            if (!dgvHICP.verifyNumericValues(out string problems))
            {
                UserInfoHandler.ShowError("There are cells with invalid values!" + Environment.NewLine + problems);
                return;
            }

            updatedHICPs = new List <Tuple <string, int, double, string> >();
            DataTable dtHICP = dgvHICP.GetDataTable();

            foreach (DataRow r in dtHICP.Rows)
            {
                foreach (DataColumn c in dtHICP.Columns)
                {
                    if (c.Caption == colCountry || c.Caption == colComment || c.Caption == colID || r.IsNull(c.Caption))
                    {
                        continue;
                    }
                    try
                    {
                        updatedHICPs.Add(new Tuple <string, int, double, string>(
                                             r.Field <string>(colCountry),          // country
                                             Convert.ToInt32(c.Caption),            // year
                                             double.Parse(r[c.Caption].ToString()), // value
                                             r.Field <string>(colComment)));        // comment
                    }
                    catch (Exception exception) { UserInfoHandler.ShowException(exception, $"{r.Field<string>(colCountry)} / {c.Caption}", false); return; }
                }
            }

            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #8
0
        void btnDeleteYear_Click(object sender, EventArgs e)
        {
            if (cmbYearToDelete.Text == string.Empty)
            {
                UserInfoHandler.ShowError("Please select a year.");
                return;
            }

            if (MessageBox.Show("Are you sure you want to delete this column?\n\nNote: you will not be able to undo this action or any action before this.", "Delete Year Column", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            for (int index = dgvIndices.Columns.Count - 1; index >= 0; --index)
            {
                if (dgvIndices.Columns[index].HeaderText == cmbYearToDelete.Text)
                {
                    dgvDataTable.Columns.Remove(dgvIndices.Columns[index].Name);
//                    dgvIndices.Columns.RemoveAt(index);
                    break;
                }
            }

            foreach (DataRow row in dgvDataTable.Rows)
            {
                row[0] = row[0];                                        // this is to make sure the deleted column counts as a DataSet change...
            }
            cmbYearToDelete.Items.RemoveAt(cmbYearToDelete.SelectedIndex);

            dgvDataSet.AcceptChanges();
            undoManager.Reset();
            columnsChanged = true;
        }
コード例 #9
0
        internal static void CleanLogFile()
        {
            string logFile = new EMPath(EM_AppContext.FolderEuromodFiles).GetEmLogFilePath();

            EM_UI_MainForm mainForm = EM_AppContext.Instance.GetActiveCountryMainForm();

            if (mainForm != null)
            {
                mainForm.Cursor = Cursors.WaitCursor;
            }
            string error = AdaptLogFile(logFile);

            if (mainForm != null)
            {
                mainForm.Cursor = Cursors.Default;
            }

            if (error == string.Empty)
            {
                UserInfoHandler.ShowSuccess("Successfully cleaned " + logFile + ".");
            }
            else
            {
                UserInfoHandler.ShowError("Failed to clean " + logFile + ":" + Environment.NewLine + error);
            }
        }
コード例 #10
0
 private void ShowGridLastError()
 {
     if (dgvRates.lastError != string.Empty)
     {
         UserInfoHandler.ShowError(dgvRates.lastError);
     }
 }
コード例 #11
0
        void btnOK_Click(object sender, EventArgs e)
        {
            if (txtRemoteVersion.Text == string.Empty)
            {
                UserInfoHandler.ShowError("Please select a Remote Version."); return;
            }
            if (!chkUseLocal.Checked && !chkUseRemote.Checked && txtParentVersion.Text == string.Empty)
            {
                UserInfoHandler.ShowError("Please select a Parent Version or check one of the 'Use ...' boxes."); return;
            }

            //Since users can also paste a path, the paths need to be validated and the remote and parent variables need to be populated

            if (!validateInsertedFields(txtRemoteVersion.Text, true))
            {
                return;
            }
            if (txtParentVersion.Text != string.Empty && !validateInsertedFields(txtParentVersion.Text, false))
            {
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #12
0
        void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (DataGridViewRow row in dgvSwitchablePolicies.Rows)
                {
                    object valueLongName    = row.Cells[colLongName.Name].Value;
                    object valueNamePattern = row.Cells[colNamePattern.Name].Value;
                    if (valueLongName == null || valueLongName.ToString().Trim() == string.Empty ||
                        valueNamePattern == null || valueNamePattern.ToString().Trim() == string.Empty)
                    {
                        UserInfoHandler.ShowError("Row " + row.Index.ToString() + " is not completely defined. Please complete or delete the row.");
                        return;
                    }
                }

                _varConfigFacade._varConfig.AcceptChanges();
                _varConfigFacade.WriteXML();
                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception exception)
            {
                UserInfoHandler.ShowException(exception);
            }
        }
コード例 #13
0
        void btnOK_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(txtCountryFolder.Text))
            {
                UserInfoHandler.ShowError("Import Country Folder does not exist.");
                return;
            }

            if (Directory.Exists(EMPath.Folder_Countries(EM_AppContext.FolderEuromodFiles) + txtShortName.Text))
            {
                UserInfoHandler.ShowError("Country folder '" + txtShortName.Text + "' already exists at '" + EMPath.Folder_Countries(EM_AppContext.FolderEuromodFiles) + "'.");
                return;
            }

            if (txtFlag.Text != string.Empty && !CountryAdministrator.IsValidFlagFilePath(txtFlag.Text))
            {
                return;
            }

            //out-commented as it does not really make sense to not allow for longer country-short-names
            //if (txtShortName.Text.Length != 2)
            //{
            //    if (UserInfoHandler.GetInfo("Short Name is supposed to have two characters. Do you want to correct?", MessageBoxButtons.YesNo) == DialogResult.Yes)
            //        return;
            //}

            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #14
0
 void btnOK_Click(object sender, EventArgs e)
 {
     if (txtPassword.Text == txtRetypePassword.Text)
     {
         DialogResult = DialogResult.OK; Close(); return;
     }
     UserInfoHandler.ShowError("Password does not correspond with retyped password. Please correct.");
 }
コード例 #15
0
        bool GetReleaseContent(out List <long> unitIds, out List <string> units, out List <string> types, out List <string> versions, out List <VCDownloadRelease.UIReleaseCompare> stati)
        {
            units   = new List <string>(); types = new List <string>(); versions = new List <string>();
            unitIds = new List <long>();
            stati   = new List <VCDownloadRelease.UIReleaseCompare>();

            ProjectNode projectInfo = _projectInfos.ElementAt(cmbProjects.SelectedIndex);
            ReleaseInfo releaseInfo = _releaseInfos.ElementAt(cmbReleases.SelectedIndex);

            if (!_vcAdministrator.GetReleaseInfo(projectInfo.Id, releaseInfo.Name, out _unitInfos))
            {
                UserInfoHandler.ShowError(_vcAdministrator._vcAPI.GetErrorMessage());
                return(false);
            }

            //prepare info for the table that displays differences between UI-version and Release-version
            List <string> listStati; if (!_vcAdministrator.CompareLocalProjectWithOnlineBundle(_unitInfos, out listStati))

            {
                return(false);
            }

            for (int i = 0; i < _unitInfos.Count; ++i)
            {
                units.Add(_unitInfos[i].Name);                                        //to be displayed in the 'Unit'-column
                types.Add(VCContentControl.UnitTypeToString(_unitInfos[i].UnitType)); //to be displayed in the 'Type'-column
                versions.Add(releaseInfo.Name);                                       //to be displayed in the 'Version'-column
                unitIds.Add(_unitInfos[i].UnitId);

                switch (listStati[i])
                {
                case VCAdministrator.VC_STATUS_MODIFIED:
                    stati.Add(VCDownloadRelease.UIReleaseCompare.differs);
                    break;

                case VCAdministrator.VC_STATUS_UPTODATE:
                    stati.Add(VCDownloadRelease.UIReleaseCompare.corresponds);
                    break;

                case VCAdministrator.VC_STATUS_OLD:
                    stati.Add(VCDownloadRelease.UIReleaseCompare.older);
                    break;

                case VCAdministrator.VC_STATUS_NEW:
                    stati.Add(VCDownloadRelease.UIReleaseCompare.newer);
                    break;

                case VCAdministrator.VC_STATUS_NOLOCAL:
                    stati.Add(VCDownloadRelease.UIReleaseCompare.missing);
                    break;

                default:
                    stati.Add(VCDownloadRelease.UIReleaseCompare.not_available);
                    break;
                }
            }
            return(true);
        }
 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);
 }
コード例 #17
0
        internal static bool RestoreCountry(EM_UI_MainForm mainForm, string backUpFolder = "")
        {
            bool reportSuccess = false;

            if (backUpFolder == string.Empty) //called via button in MainForm
            {
                FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
                folderBrowserDialog.SelectedPath = EMPath.Folder_BackUps(EM_AppContext.FolderEuromodFiles);
                folderBrowserDialog.Description  = "Please select the back-up folder";
                if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    return(true);
                }
                backUpFolder  = folderBrowserDialog.SelectedPath;
                reportSuccess = true;
            }
            else //called from a catch-branch, i.e. using just generated back-up in Temp/BackUp
            {
                backUpFolder = EMPath.Folder_BackUps(EM_AppContext.FolderEuromodFiles) + backUpFolder;
            }

            string countryShortName = mainForm.GetCountryShortName();
            bool   isAddOn          = CountryAdministrator.IsAddOn(countryShortName);

            try
            {
                //check if backUpFolder contains the necessary files and if the files actually contain a backup of the loaded country/add-on ...
                string errorMessage;
                if (!Country.DoesFolderContainValidXMLFiles(countryShortName, out errorMessage, backUpFolder, isAddOn,
                                                            true)) //check if countryShortName corresponds to country's short name as stored in the XML-file
                {
                    throw new System.ArgumentException(errorMessage);
                }

                //... if yes, copy files form backup-folder to Countries-folder
                if (!Country.CopyXMLFiles(countryShortName, out errorMessage, backUpFolder))
                {
                    throw new System.ArgumentException(errorMessage);
                }

                mainForm.ReloadCountry();

                if (reportSuccess) //report success only if called via button (and not if called by a failed function)
                {
                    UserInfoHandler.ShowSuccess("Successfully restored using back-up stored in" + Environment.NewLine + backUpFolder + ".");
                }

                return(true);
            }
            catch (Exception exception)
            {
                UserInfoHandler.ShowError("Restore failed because of the error stated below." + Environment.NewLine +
                                          "You may want to try a manual restore via the button in the ribbon 'Country Tools'." + Environment.NewLine + Environment.NewLine +
                                          exception.Message);
                return(false);
            }
        }
コード例 #18
0
 void btnOK_Click(object sender, EventArgs e)
 {
     if (!checkAllYears.Checked && listYears.Items.Count == 0)
     {
         UserInfoHandler.ShowError("Please select one or more years."); return;
     }
     DialogResult = System.Windows.Forms.DialogResult.OK;
     Close();
 }
コード例 #19
0
        private void RVHHLevelVarForm_Shown(object sender, EventArgs e)
        {
            try
            {
                // get all HH-level variables from the variables file
                List <string> hhVars = (from v in EM_AppContext.Instance.GetVarConfigFacade().GetVarConfig().Variable
                                        where VariablesManager.IsHHLevel(v) && v.Name.ToLower() != DefVarName.IDHH.ToLower()
                                        select v.Name.ToLower()).ToList();
                // gather the files to check: those fulfilling the pattern and the custom ones
                if (Directory.Exists(dataPath))
                {
                    foreach (string f in Directory.GetFiles(dataPath, namePattern))
                    {
                        dataToCheck.Add(Path.Combine(dataPath, f));
                    }
                }

                // do the checking, showing a progress bar
                // the background-worker gets 2 parameters:
                // - the list of HH-level variables and
                // - the list of files to check
                ProgressIndicator progressIndicator = new ProgressIndicator(CheckData_BackgroundEventHandler, "Checking Data ...",
                                                                            new Tuple <List <string>, List <string> >(hhVars, dataToCheck));
                if (progressIndicator.ShowDialog() != DialogResult.OK)
                {
                    Close(); return;
                }                                                                           // user pressed Cancel

                // interpret the results
                // the background-worker returns 2 results:
                // - the list of variables, each variable with a list of the file(s) that caused problems, and an empty list if there are no problems
                // - a (hopefully empty) list of critical errors, i.e. one for each file that could not be analysed
                Dictionary <string, List <string> > hhVarResults = (progressIndicator.Result as Tuple <Dictionary <string, List <string> >, List <string> >).Item1;
                List <string> problemData = (progressIndicator.Result as Tuple <Dictionary <string, List <string> >, List <string> >).Item2;

                if (problemData.Count > 0)
                {
                    UserInfoHandler.ShowError("The following data could not be checked:" + Environment.NewLine + string.Join(Environment.NewLine, problemData));
                    if (problemData.Count == dataToCheck.Count)
                    {
                        Close(); return;
                    }                                                                // checking failed for all data-files
                }

                // show the results in the grid
                foreach (var result in hhVarResults)
                {
                    string problems = result.Value.Count == 0 ? "No problems found for the checked files" : string.Join(SEPARATOR, result.Value);
                    dgvVar.Rows.Add(result.Key, problems);
                }
            }
            catch (Exception exception) { UserInfoHandler.ShowException(exception); Close(); }
        }
コード例 #20
0
        internal VCRemoveBundle(VCAPI vcAPI, bool removeRelease)
        {
            InitializeComponent();

            _vcAPI          = vcAPI;
            _removeReleases = removeRelease;

            Cursor = Cursors.WaitCursor;
            List <ReleaseInfo> bundles = new List <ReleaseInfo>();

            if (_removeReleases && !_vcAPI.GetReleases(out bundles))
            {
                Cursor = Cursors.Default;
                UserInfoHandler.ShowError(_vcAPI.GetErrorMessage());
                return;
            }

            lvBundles.Columns.Add("Generated");
            if (_removeReleases)
            {
                lvBundles.Columns.Add("Name");
            }
            lvBundles.Columns.Add("Info");
            lvBundles.Columns.Add("Author");
            foreach (ReleaseInfo bundle in bundles)
            {
                ListViewItem bundleDescription = new ListViewItem();
                bundleDescription.Text = bundle.Date.ToString();
                if (_removeReleases)
                {
                    bundleDescription.SubItems.Add(bundle.Name);
                }
                bundleDescription.SubItems.Add(bundle.Message);
                bundleDescription.SubItems.Add(bundle.Author);
                bundleDescription.Tag = bundle;
                lvBundles.Items.Add(bundleDescription);
            }
            lvBundles.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            int indexInfoCol = _removeReleases ? 2 : 1;

            lvBundles.AutoResizeColumn(indexInfoCol, ColumnHeaderAutoResizeStyle.HeaderSize);
            lvBundles.Columns[indexInfoCol].Width = 250;
            if (lvBundles.Items.Count > 0)
            {
                lvBundles.Items[0].Selected = true;
                lvBundles.Items[0].Focused  = true;
                lvBundles.Select();
                lvBundles.Focus();
            }

            Cursor = Cursors.Default;
        }
コード例 #21
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (!dgvRates.verifyNumericValues(out string problems))
                {
                    UserInfoHandler.ShowError("There are cells with invalid values!" + Environment.NewLine + problems);
                    return;
                }
                updatedExRates = new List <ExchangeRate>();
                DataTable dtExRates = dgvRates.GetDataTable();
                foreach (DataRow row in dtExRates.Rows)
                {
                    if (row[colValidFor.Name] == DBNull.Value || row.Field <string>(colValidFor.Name).ToString() == string.Empty)
                    {
                        continue;
                    }
                    string defaultCol = string.Empty;
                    switch (row.Field <string>(colDefault.Name))
                    {
                    case ExchangeRate.JUNE30: defaultCol = colJune30.Name; break;

                    case ExchangeRate.YEARAVERAGE: defaultCol = colYearAverage.Name; break;

                    case ExchangeRate.FIRSTSEMESTER: defaultCol = colFirstSemester.Name; break;

                    case ExchangeRate.SECONDSEMESTER: defaultCol = colSecondSemester.Name; break;
                    }
                    if (row[defaultCol] == DBNull.Value)
                    {
                        UserInfoHandler.ShowInfo(string.Format("{0} ({1}): Default ({2}) must not be empty.",
                                                               row.Field <string>(colCountry.Name), row.Field <string>(colValidFor.Name), defaultCol)); return;
                    }
                    updatedExRates.Add(new ExchangeRate()
                    {
                        Country        = row.Field <string>(colCountry.Name),
                        June30         = row[colJune30.Name] == DBNull.Value ? -1 : double.Parse(row[colJune30.Name].ToString()),
                        YearAverage    = row[colYearAverage.Name] == DBNull.Value ? -1 : double.Parse(row[colYearAverage.Name].ToString()),
                        FirstSemester  = row[colFirstSemester.Name] == DBNull.Value ? -1 : double.Parse(row[colFirstSemester.Name].ToString()),
                        SecondSemester = row[colSecondSemester.Name] == DBNull.Value ? -1 : double.Parse(row[colSecondSemester.Name].ToString()),
                        Default        = row.Field <string>(colDefault.Name),
                        ValidFor       = row.Field <string>(colValidFor.Name)
                    });
                }

                AssessChanges(); // check whether any country files need to be updated
            }
            catch (Exception exception) { UserInfoHandler.ShowException(exception); return; }

            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #22
0
 void btnOK_Click(object sender, EventArgs e)
 {
     if (!verifyNumericValues())
     {
         UserInfoHandler.ShowError("Cell(s) with invalid value found!");
     }
     else if (!haveEmptyCells() || UserInfoHandler.GetInfo("Empty cell(s) found; they will be treated as n/a when running the model." + Environment.NewLine +
                                                           "Do you want to correct?", MessageBoxButtons.YesNo) == DialogResult.No)
     {
         mainForm.PerformAction(new IndirectTaxesAction(this), false);
         DialogResult = DialogResult.OK;
         Close();
     }
 }
コード例 #23
0
        void UpdateSwitchTable(bool reportInvalid = true)
        {
            _selectedPolicyID = string.Empty;

            if (lvSwitchablePolicies.CheckedItems.Count == 0)
            {
                return; //leave table empty if no switchable policy is available
            }
            //find out which switchable policy is selected
            _selectedPolicyID            = (lvSwitchablePolicies.CheckedItems[0].Tag != null) ? lvSwitchablePolicies.CheckedItems[0].Tag.ToString() : string.Empty;
            txtSelectedSwitchPolicy.Text = lvSwitchablePolicies.CheckedItems[0].Text;

            string invalidDefaultSwiches = string.Empty;

            foreach (DataGridViewRow dgvRow in dgvSwitches.Rows)
            {
                for (int columnIndex = 0; columnIndex < dgvSwitches.Columns.Count; ++columnIndex)
                {
                    //run over available dataset-system combinations
                    dgvRow.Cells[columnIndex].Value    = string.Empty; //if dataset is not applicable for the system put an emtpy string, which is overwritten, if a db-system-combination is found
                    dgvRow.Cells[columnIndex].ReadOnly = true;
                    foreach (DataConfig.DBSystemConfigRow dbSystemConfigRow in from ds in _dataConfig.DBSystemConfig where ds.DataBaseID == dgvRow.Tag as string select ds)
                    {
                        //if dataset is applicable for the system, get (if exists) the policy-switch value for this switchable policy (i.e. the selected switchable policy), system and dataset
                        if (dbSystemConfigRow.SystemID == (dgvSwitches.Columns[columnIndex].Tag as CountryConfig.SystemRow).ID)
                        {
                            string defaultSwitch = GetExtensionDefaultSwitch(dbSystemConfigRow, _selectedPolicyID);
                            if (defaultSwitch != DefPar.Value.ON && defaultSwitch != DefPar.Value.OFF && defaultSwitch != DefPar.Value.NA)
                            {
                                invalidDefaultSwiches += Environment.NewLine + $"Invalid Switch: '{defaultSwitch}' for {txtSelectedSwitchPolicy.Text}/{dbSystemConfigRow.DataBaseRow.Name}/{dbSystemConfigRow.SystemName}";
                            }
                            else
                            {
                                dgvRow.Cells[columnIndex].Value = defaultSwitch;
                            }
                            dgvRow.Cells[columnIndex].ReadOnly = false;
                            dgvRow.Cells[columnIndex].Tag      = dbSystemConfigRow;
                            break;
                        }
                    }
                }
            }
            if (reportInvalid && !string.IsNullOrEmpty(invalidDefaultSwiches))
            {
                UserInfoHandler.ShowError(
                    $"{EMPath.GetEM2DataConfigFileName(_countryShortName)} contains invalid default switches!!!" + Environment.NewLine +
                    (invalidDefaultSwiches.Length > 1500 ? invalidDefaultSwiches.Substring(0, 1500) + "..." : invalidDefaultSwiches));
            }
        }
コード例 #24
0
        void btnAddYear_Click(object sender, EventArgs e)
        {
            keepUndoData = false;
            string year = updwnYearToAdd.Value.ToString();

            if (GetExistingYears().Contains(year))
            {
                UserInfoHandler.ShowError(year + " already exits."); return;
            }
            if (UserInfoHandler.GetInfo("Are you sure you want to add a new column?\n\nNote: you will not be able to undo this action or any action before this.",
                                        MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }
            AddYearColumn(year); keepUndoData = true; dataSet.AcceptChanges(); undoManager.Reset(); columnsChanged = true;
        }
        public static bool GetRangeValues(out List <double> rangeValues, double start, double end, double step, bool showResults = false)
        {
            rangeValues = new List <double>();

            if (start > end)
            {
                UserInfoHandler.ShowError("Start must not be higher than end (" + start.ToString() + ">" + end.ToString() + ")"); return(false);
            }

            int absMaxCount = showResults ? ALPHA_RANGE_MAX_SHOW // template allows for 50+2 (the 2 are for CPI+MII,
                                          : ALPHA_RANGE_MAX;     // thus in fact it'll be 52 if they are not selected)

            for (double d = start; d <= end && rangeValues.Count <= ALPHA_RANGE_MAX + 1; d += step)
            {
                if (d == 0)
                {
                    if (UserInfoHandler.GetInfo("The range contains zero." + Environment.NewLine + "Should zero be skipped?",
                                                MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return(false);
                    }
                }
                else
                {
                    rangeValues.Add(d);
                }
            }

            if (rangeValues.Count == 0)
            {
                UserInfoHandler.ShowError("The range contains no numbers."); return(false);
            }
            if (rangeValues.Count <= ALPHA_RANGE_MAX_SHOW)
            {
                return(true);                                           // consider 50 as 'reasonable' (?) and do not issue a warning
            }
            // if template is not shown, allow for 500, but still warn if more than 50; if template is shown 50 is max, as the template does not allow for more (see above)
            string cnt     = rangeValues.Count <= ALPHA_RANGE_MAX + 1 ? rangeValues.Count.ToString() : "too many";
            string message = "The range contains " + cnt + " numbers." + Environment.NewLine
                             + "Allowed are " + ALPHA_RANGE_MAX_SHOW + " for 'Run Only' and " + ALPHA_RANGE_MAX + " for 'Run & Show Results'.";

            if (rangeValues.Count > absMaxCount)
            {
                UserInfoHandler.ShowError(message); return(false);
            }
            return(UserInfoHandler.GetInfo(message + Environment.NewLine + "Do you want to continue?", MessageBoxButtons.YesNo) == DialogResult.Yes);
        }
コード例 #26
0
        void btnCompareVersions_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(txtFolderVersion.Text))
            {
                UserInfoHandler.ShowError("Please select an existing folder for the version to compare with."); return;
            }

            compareCountryFolder = EMPath.AddSlash(txtFolderVersion.Text) + EMPath.Folder_Countries_withoutPath();
            if (!Directory.Exists(compareCountryFolder))
            {
                UserInfoHandler.ShowError("Folder '" + txtFolderVersion.Text + "' does not contain folder 'Countries'."); return;
            }

            selectedFunction = COMPARE_VERSIONS;
            DialogResult     = System.Windows.Forms.DialogResult.OK;
            Close();
        }
コード例 #27
0
        internal VCDownloadLatestBundle(VCAdministrator vcAdministrator)
        {
            _vcAdministrator = vcAdministrator;
            InitializeComponent();

            if (!_vcAdministrator._vcAPI.GetProjectList(out _projectInfos, false))
            {
                UserInfoHandler.ShowError(_vcAdministrator._vcAPI.GetErrorMessage()); return;
            }

            List <VersionControlUnitInfo> units;

            foreach (ProjectNode projectInfo in _projectInfos)
            {
                if (projectInfo.Id == _vcAdministrator._vcAPI.vc_projectInfo.ProjectId)

                {
                    _projectNode     = projectInfo;
                    textProject.Text = projectInfo.Name; //select the current project
                    _projectId       = projectInfo.Id;


                    if (!_vcAdministrator._vcAPI.GetLatestReleaseUnitInfo(projectInfo.Id, out _releaseInfo))
                    {
                        UserInfoHandler.ShowError(_vcAdministrator._vcAPI.GetErrorMessage()); Cursor = Cursors.Default; return;
                    }

                    if (_releaseInfo != null)
                    {
                        _releaseId     = _releaseInfo.Id;
                        _bundleName    = _releaseInfo.Name;
                        txtBundle.Text = _releaseInfo.Name + " - " + _releaseInfo.Date.ToShortDateString();
                    }

                    AssessVCBaseProjectContent(out _projectContent);
                    units = _projectContent.projectUnits;

                    foreach (VersionControlUnitInfo unit in units)
                    {
                        ListViewItem item = listUnits.Items.Add(string.Format("{0} ({1})", unit.Name, VCContentControl.UnitTypeToString(unit.UnitType)));
                        item.Checked = true;
                        item.Tag     = unit;
                    }
                }
            }
        }
コード例 #28
0
        internal VCUserUnitRights(VCAPI vcAPI, UserInfo userInfo, VCAPI.VC_ACCESS_RIGHTS defaultRight, Dictionary <long, VCAPI.VC_ACCESS_RIGHTS> initialRights)
        {
            InitializeComponent();

            _userId        = userInfo.userId;
            _vcAPI         = vcAPI;
            _defaultRight  = defaultRight;
            _initialRights = initialRights;

            this.Text = this.Text + userInfo.username;

            List <VersionControlUnitInfo> units;

            if (!_vcAPI.GetRemoteUnits(_vcAPI.vc_projectInfo.ProjectId, out units))
            {
                UserInfoHandler.ShowError(_vcAPI.GetErrorMessage());
                return;
            }

            if (defaultRight == VCAPI.VC_ACCESS_RIGHTS.UPLOAD)
            {
                colWrite.HeaderText = btnAllWrite.Text = "Default";
            }
            if (defaultRight == VCAPI.VC_ACCESS_RIGHTS.DOWNLOAD)
            {
                colRead.HeaderText = btnAllRead.Text = "Default";
            }
            if (defaultRight == VCAPI.VC_ACCESS_RIGHTS.NONE)
            {
                colNone.HeaderText = btnAllNone.Text = "Default";
            }

            foreach (VersionControlUnitInfo unit in units)
            {
                long unitId = unit.UnitId;
                VCAPI.VC_ACCESS_RIGHTS right = (_initialRights != null && _initialRights.ContainsKey(unitId)) ? _initialRights[unitId] : defaultRight;
                int index = dgvUnits.Rows.Add(unit.Name, unit.UnitType,
                                              right == VCAPI.VC_ACCESS_RIGHTS.UPLOAD,
                                              right == VCAPI.VC_ACCESS_RIGHTS.DOWNLOAD,
                                              right != VCAPI.VC_ACCESS_RIGHTS.UPLOAD && right != VCAPI.VC_ACCESS_RIGHTS.DOWNLOAD);
                dgvUnits.Rows[index].Tag = unit.UnitId;
                dgvUnits.Rows[index].Cells[colWrite.Index].ReadOnly = //to handle ticking manually (see dgvUnits_CellContentClick)
                                                                      dgvUnits.Rows[index].Cells[colRead.Index].ReadOnly = dgvUnits.Rows[index].Cells[colNone.Index].ReadOnly = true;
            }
        }
コード例 #29
0
        void FillUnitList()
        {
            EM_AppContext.Instance.GetActiveCountryMainForm().Cursor = Cursor = Cursors.WaitCursor;
            lvUnits.Items.Clear();
            List <VersionControlUnitInfo> units;

            if (!_vcAdministrator._vcAPI.GetLocalUnits(out units) || units == null)
            {
                UserInfoHandler.ShowError(_vcAdministrator._vcAPI.GetErrorMessage());
                EM_AppContext.Instance.GetActiveCountryMainForm().Cursor = Cursor = Cursors.Default;
                return;
            }
            foreach (VersionControlUnitInfo unitInfo in units)
            {
                lvUnits.Items.Add(string.Format("{0} ({1})", unitInfo.Name, VCContentControl.UnitTypeToString(unitInfo.UnitType)));
            }
            EM_AppContext.Instance.GetActiveCountryMainForm().Cursor = Cursor = Cursors.Default;
        }
コード例 #30
0
 internal bool CloseAnythingOpen()
 {
     if (IsAnythingOpen() || IsVariablesFormOpen())
     {
         if (UserInfoHandler.GetInfo("All open countries/add-ons/variables need to be closed. Proceed?", MessageBoxButtons.YesNo) == DialogResult.No)
         {
             return(false);
         }
         EM_AppContext.Instance.CloseVariablesForm();
         EM_AppContext.Instance.CloseAllMainForms(false);
         if (IsAnythingOpen() || IsVariablesFormOpen()) // check again in case something was not closed
         {
             UserInfoHandler.ShowError("Problems with automatic closing - please close all countries/add-ons/variables manually.");
             return(false);
         }
     }
     return(true);
 }