示例#1
0
        private void xCreateTemplateExcelButton_Click(object sender, RoutedEventArgs e)
        {
            mAddModelOptionalValuesWizard.ProcessStarted();
            ImportOptionalValuesForParameters im = new ImportOptionalValuesForParameters();
            List <AppParameters> parameters      = new List <AppParameters>();

            if (mAddModelOptionalValuesWizard.ImportOptionalValues.ParameterType == ImportOptionalValuesForParameters.eParameterType.Local)
            {
                foreach (var prms in mAddModelOptionalValuesWizard.mAAMB.AppModelParameters)
                {
                    im.AddNewParameterToList(parameters, prms);
                }
                xPathTextBox.Text = im.ExportParametersToExcelFile(parameters, string.Format("{0}_Parameters", mAddModelOptionalValuesWizard.mAAMB.Name), Convert.ToString(xPathTextBox.Text.Trim()));
            }
            else if (mAddModelOptionalValuesWizard.ImportOptionalValues.ParameterType == ImportOptionalValuesForParameters.eParameterType.Global)
            {
                foreach (var prms in mAddModelOptionalValuesWizard.mGlobalParamterList)
                {
                    im.AddNewParameterToList(parameters, prms);
                }
                xPathTextBox.Text = im.ExportParametersToExcelFile(parameters, "GlobalParameters", Convert.ToString(xPathTextBox.Text.Trim()));
            }

            mAddModelOptionalValuesWizard.ImportOptionalValues.ExcelFileName = xPathTextBox.Text;
            List <string> SheetsList = mAddModelOptionalValuesWizard.ImportOptionalValues.GetSheets();

            GingerCore.General.FillComboFromList(xSheetNameComboBox, SheetsList);
            mAddModelOptionalValuesWizard.ProcessEnded();
        }
        private void xCreateTemplateExcelButton_Click(object sender, RoutedEventArgs e)
        {
            mAddModelOptionalValuesWizard.ProcessStarted();

            string fileName = string.Empty;

            if (mAddModelOptionalValuesWizard.ImportOptionalValues.ParameterType == ImportOptionalValuesForParameters.eParameterType.Local)
            {
                fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), string.Format("{0}_Parameters", mAddModelOptionalValuesWizard.mAAMB.Name) + ".xlsx");
            }
            else
            {
                fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "GlobalParameters.xlsx");
            }

            bool overrideFile = true;

            if (File.Exists(fileName))
            {
                if (Reporter.ToUser(eUserMsgKey.FileAlreadyExistWarn) == eUserMsgSelection.Cancel)
                {
                    overrideFile = false;
                }
            }

            if (overrideFile)
            {
                ImportOptionalValuesForParameters im = new ImportOptionalValuesForParameters();
                List <AppParameters> parameters      = new List <AppParameters>();
                if (mAddModelOptionalValuesWizard.ImportOptionalValues.ParameterType == ImportOptionalValuesForParameters.eParameterType.Local)
                {
                    foreach (var prms in mAddModelOptionalValuesWizard.mAAMB.AppModelParameters)
                    {
                        im.AddNewParameterToList(parameters, prms);
                    }
                    xPathTextBox.Text = im.ExportParametersToExcelFile(parameters, string.Format("{0}_Parameters", mAddModelOptionalValuesWizard.mAAMB.Name), Convert.ToString(xPathTextBox.Text.Trim()));
                }
                else if (mAddModelOptionalValuesWizard.ImportOptionalValues.ParameterType == ImportOptionalValuesForParameters.eParameterType.Global)
                {
                    foreach (var prms in mAddModelOptionalValuesWizard.mGlobalParamterList)
                    {
                        im.AddNewParameterToList(parameters, prms);
                    }
                    xPathTextBox.Text = im.ExportParametersToExcelFile(parameters, "GlobalParameters", Convert.ToString(xPathTextBox.Text.Trim()));
                }

                mAddModelOptionalValuesWizard.ImportOptionalValues.ExcelFileName = xPathTextBox.Text;
                List <string> SheetsList = mAddModelOptionalValuesWizard.ImportOptionalValues.GetSheets(true);
                GingerCore.General.FillComboFromList(xSheetNameComboBox, SheetsList);
                if (xSheetNameComboBox.Items.Count >= 1)
                {
                    xSheetNameComboBox.SelectedIndex = 0;
                }
            }
            mAddModelOptionalValuesWizard.ProcessEnded();
        }