Inheritance: ModelParameterArray, IExportableContainer
Esempio n. 1
0
        private void InitializeDatesPreviewThreadWorker(string startDate,
                                                        string endDate,
                                                        string frequency,
                                                        string skipPeriods,
                                                        bool followFrequency,
                                                        bool generateSequenceFromStartDate,
                                                        string vectorRefExpr,
                                                        string skipPeriodsArray)
        {
            if (Validation(true))
            {
                ModelParameterDateSequence preview;
                try
                {
                    preview = new ModelParameterDateSequence(startDate,
                                                             endDate,
                                                             frequency);
                }
                catch
                {
                    // Error, don't show the preview
                    InitializeUiEmptyPreview();
                    return;
                }

                preview.SkipPeriods     = skipPeriods;
                preview.FollowFrequency = followFrequency;
                preview.GenerateSequenceFromStartDate = generateSequenceFromStartDate;
                preview.VectorReferenceExpr           = vectorRefExpr;
                preview.SkipPeriodsArray = skipPeriodsArray;

                DateTime minDate = new DateTime(1900, 1, 1);
                DateTime maxDate = new DateTime(2100, 12, 31);
                try
                {
                    project.Initialize(true);
                    Engine.Parser.Parse("EffectiveDate");
                }
                catch
                {
                    // Ignore project initialization error during the preview
                }

                preview.ParsePreview(project, minDate, maxDate);

                int elements = Math.Min(50, preview.Values.Count);
                InitializeUiPreview(preview, minDate, maxDate, elements);
            }
        }
Esempio n. 2
0
        private void InitializeUiPreview(ModelParameterDateSequence preview, DateTime minDate, DateTime maxDate, int elements)
        {
            if (InvokeRequired)
            {
                Invoke(new MethodInvoker(() => InitializeUiPreview(preview, minDate, maxDate, elements)));
                return;
            }

            // Update the label
            if (preview.StartDate < minDate || preview.EndDate > maxDate)
            {
                this.labelElementsCount.Text = string.Format("Preview generated only between {0} and {1}",
                                                             minDate.ToShortDateString(),
                                                             maxDate.ToShortDateString());
            }
            else
            {
                this.labelElementsCount.Text = string.Format("{0} Elements", preview.Values.Count);
                if (elements != preview.Values.Count)
                {
                    this.labelElementsCount.Text += string.Format(", First {0} Shown", elements);
                }
            }

            if (previewAborted)
            {
                return;
            }

            this.dataGridViewDates.Rows.Clear();
            for (int i = 0; i < elements; i++)
            {
                if (previewAborted)
                {
                    return;
                }

                this.dataGridViewDates.Rows.Add(preview.Values[i]);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Based on the values of the form initializes the array of dates.
        /// </summary>
        private void InitializeModelParameter()
        {
            this.publishingInfoControl.DataExchange(false, this.editedObject);

            if (this.editedObject is ModelParameterDateSequence)
            {
                // Initialize the model parameter representing the sequence of dates
                ModelParameterDateSequence modelParameterDateSequence = (ModelParameterDateSequence)this.editedObject;
                modelParameterDateSequence.StartDateExpression           = this.expressionStartDate.Text;
                modelParameterDateSequence.SkipPeriods                   = this.expressionSkipPeriods.Text;
                modelParameterDateSequence.FollowFrequency               = this.checkBoxFollowFrequency.Checked;
                modelParameterDateSequence.EndDateExpression             = this.expressionEndDate.Text;
                modelParameterDateSequence.FrequencyExpression           = this.comboBoxFrequency.Text;
                modelParameterDateSequence.GenerateSequenceFromStartDate = this.comboBoxDatesGeneration.SelectedIndex == 0;
                modelParameterDateSequence.VarName             = this.textBoxName.Text;
                modelParameterDateSequence.Tag                 = null;
                modelParameterDateSequence.VectorReferenceExpr = this.expressionVectorRef.Text;
                modelParameterDateSequence.SkipPeriodsArray    = this.expressionSkipPeriodsArray.Text;

                // Parse the object to generate the array of dates
                modelParameterDateSequence.Parse(this.project);
            }
            else
            {
                // Initialize the array to the sequence of dates
                ModelParameterDateSequence modelParameterDateSequence = new ModelParameterDateSequence(this.expressionStartDate.Text,
                                                                                                       this.expressionEndDate.Text,
                                                                                                       this.comboBoxFrequency.Text);

                modelParameterDateSequence.SkipPeriods                   = this.expressionSkipPeriods.Text;
                modelParameterDateSequence.VectorReferenceExpr           = this.expressionVectorRef.Text;
                modelParameterDateSequence.GenerateSequenceFromStartDate = this.comboBoxDatesGeneration.SelectedIndex == 0;
                modelParameterDateSequence.Parse(this.project);
                this.editedObject.Values = modelParameterDateSequence.Values;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Based on the values of the form initializes the array of dates.
        /// </summary>
        private void InitializeModelParameter()
        {
            this.publishingInfoControl.DataExchange(false, this.editedObject);

            if (this.editedObject is ModelParameterDateSequence)
            {
                // Initialize the model parameter representing the sequence of dates
                ModelParameterDateSequence modelParameterDateSequence = (ModelParameterDateSequence)this.editedObject;
                modelParameterDateSequence.StartDateExpression = this.expressionStartDate.Text;
                modelParameterDateSequence.ExcludeStartDate = this.excludeStartDate;
                modelParameterDateSequence.EndDateExpression = this.expressionEndDate.Text;
                modelParameterDateSequence.FrequencyExpression = this.comboBoxFrequency.Text;
                modelParameterDateSequence.VarName = this.textBoxName.Text;
                modelParameterDateSequence.Tag = null;

                // Parse the object to generate the array of dates
                modelParameterDateSequence.Parse(this.project);
            }
            else
            {
                // Initialize the array to the sequence of dates
                ModelParameterDateSequence modelParameterDateSequence = new ModelParameterDateSequence(this.expressionStartDate.Text,
                                                                                                       this.expressionEndDate.Text,
                                                                                                       this.comboBoxFrequency.Text);

                modelParameterDateSequence.ExcludeStartDate = this.excludeStartDate;
                modelParameterDateSequence.Parse(this.project);
                this.editedObject.Values = modelParameterDateSequence.Values;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes the edited object in order to show its preview.
        /// </summary>
        private void InitializeDatesPreview()
        {
            if (Validation(true))
            {
                ModelParameterDateSequence preview = new ModelParameterDateSequence(this.expressionStartDate.Text,
                                                                                    this.expressionEndDate.Text,
                                                                                    this.comboBoxFrequency.Text);

                preview.ExcludeStartDate = this.excludeStartDate;
                preview.Parse(project);
                this.dataGridViewDates.Rows.Clear();

                this.labelElementsCount.Text = preview.Values.Count + " Elements";
                for (int i = 0; i < preview.Values.Count; i++)
                {
                    this.dataGridViewDates.Rows.Add(preview.Values[i]);
                }
            }
        }
Esempio n. 6
0
        private void InitializeUiPreview(ModelParameterDateSequence preview, DateTime minDate, DateTime maxDate, int elements)
        {
            if (InvokeRequired)
            {
                Invoke(new MethodInvoker(() => InitializeUiPreview(preview, minDate, maxDate, elements)));
                return;
            }

            // Update the label
            if (preview.StartDate < minDate || preview.EndDate > maxDate)
            {
                this.labelElementsCount.Text = string.Format("Preview generated only between {0} and {1}",
                                                             minDate.ToShortDateString(),
                                                             maxDate.ToShortDateString());
            }
            else
            {
                this.labelElementsCount.Text = string.Format("{0} Elements", preview.Values.Count);
                if (elements != preview.Values.Count)
                {
                    this.labelElementsCount.Text += string.Format(", First {0} Shown", elements);
                }
            }

            if (previewAborted)
                return;

            this.dataGridViewDates.Rows.Clear();
            for (int i = 0; i < elements; i++)
            {
                if (previewAborted)
                    return;

                this.dataGridViewDates.Rows.Add(preview.Values[i]);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Based on the values of the form initializes the array of dates.
        /// </summary>
        private void InitializeModelParameter()
        {
            this.publishingInfoControl.DataExchange(false, this.editedObject);

            if (this.editedObject is ModelParameterDateSequence)
            {
                // Initialize the model parameter representing the sequence of dates
                ModelParameterDateSequence modelParameterDateSequence = (ModelParameterDateSequence)this.editedObject;
                modelParameterDateSequence.StartDateExpression = this.expressionStartDate.Text;
                modelParameterDateSequence.SkipPeriods = this.expressionSkipPeriods.Text;
                modelParameterDateSequence.FollowFrequency = this.checkBoxFollowFrequency.Checked;
                modelParameterDateSequence.EndDateExpression = this.expressionEndDate.Text;
                modelParameterDateSequence.FrequencyExpression = this.comboBoxFrequency.Text;
                modelParameterDateSequence.GenerateSequenceFromStartDate = this.comboBoxDatesGeneration.SelectedIndex == 0;
                modelParameterDateSequence.VarName = this.textBoxName.Text;
                modelParameterDateSequence.Tag = null;

                // Parse the object to generate the array of dates
                modelParameterDateSequence.Parse(this.project);
            }
            else
            {
                // Initialize the array to the sequence of dates
                ModelParameterDateSequence modelParameterDateSequence = new ModelParameterDateSequence(this.expressionStartDate.Text,
                                                                                                       this.expressionEndDate.Text,
                                                                                                       this.comboBoxFrequency.Text);

                modelParameterDateSequence.SkipPeriods = this.expressionSkipPeriods.Text;
                modelParameterDateSequence.Parse(this.project);
                modelParameterDateSequence.GenerateSequenceFromStartDate = this.comboBoxDatesGeneration.SelectedIndex == 0;
                this.editedObject.Values = modelParameterDateSequence.Values;
            }
        }
Esempio n. 8
0
        private void InitializeDatesPreviewThreadWorker(string startDate, 
                                                        string endDate, 
                                                        string frequency, 
                                                        string skipPeriods, 
                                                        bool followFrequency, 
                                                        bool generateSequenceFromStartDate)
        {
            if (Validation(true))
            {
                ModelParameterDateSequence preview;
                try
                {
                    preview = new ModelParameterDateSequence(startDate,
                                                             endDate,
                                                             frequency);
                }
                catch
                {
                    // Error, don't show the preview
                    InitializeUiEmptyPreview();
                    return;
                }

                preview.SkipPeriods = skipPeriods;
                preview.FollowFrequency = followFrequency;
                preview.GenerateSequenceFromStartDate = generateSequenceFromStartDate;

                DateTime minDate = new DateTime(1900, 1, 1);
                DateTime maxDate = new DateTime(2100, 12, 31);
                try
                {
                    project.Initialize(true);
                    Engine.Parser.Parse("EffectiveDate");
                }
                catch
                {
                    // Ignore project initialization error during the preview
                }

                preview.ParsePreview(project, minDate, maxDate);

                int elements = Math.Min(50, preview.Values.Count);
                InitializeUiPreview(preview, minDate, maxDate, elements);
            }
        }