Beispiel #1
0
        private void elementsImportButton_Click(object sender, EventArgs e)
        {
            var fileDialog = new OpenFileDialog();

            fileDialog.DefaultExt = ".xls";                   // Default file extension
            fileDialog.Filter     = "Excel documents|*.xlsx"; // Filter files by extension

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                //using (var file = new FileStream(fileDialog.FileName, FileMode.Open, FileAccess.Read)) {
                var file       = new FileInfo(fileDialog.FileName);
                var importForm = new ImportForm(file);

                if (importForm.ShowDialog() == DialogResult.OK)
                {
                    var progressForm = new ProgressForm(
                        (a, b) => SelectedDimension.ImportDimension(file, importForm.Sheet, importForm.IdColumn, importForm.ParentColumn, importForm.ParentSeparator, importForm.CaptionColumn, importForm.Columns),
                        handler => Dimension.StatusChanged += handler
                        );
                    progressForm.ShowDialog();
                    Elements = new ObservableCollection <Element>(SelectedDimension.Elements);
                }
                //}
            }
        }
        /// <summary>
        /// Gets the tablename at the selected granularity
        /// </summary>
        /// <param name="selectedDimension">The selected dimension (1 or 2)</param>
        /// <returns>The name of the table</returns>
        /// <author>Jannik Arndt</author>
        private string CreateWhereStatements(SelectedDimension selectedDimension)
        {
            if (selectedDimension.Dimension == null || selectedDimension.Dimension.DimensionColumnNames.Col_Content == null)
            {
                return("");
            }

            Dimension dimension = selectedDimension.Dimension;

            // Get dimension at selected granularity
            if (selectedDimension.LevelDepth > 1 && !selectedDimension.IsAllLevelSelected)
            {
                for (int i = 1; i < selectedDimension.LevelDepth; i++)
                {
                    dimension = dimension.GetCoarserDimensionLevel()[0];
                }
            }

            // Get the table name
            if (!selectedDimension.IsAllLevelSelected)
            {
                return(TableColumnFormatter(dimension.ToTable, dimension.DimensionColumnNames.Col_Content));
            }

            return("");
        }
Beispiel #3
0
        private void elementsExportButton_Click(object sender, EventArgs e)
        {
            var fileDialog = new SaveFileDialog();

            fileDialog.DefaultExt = ".xls";                   // Default file extension
            fileDialog.Filter     = "Excel documents|*.xlsx"; // Filter files by extension

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                //using (var stream = new FileStream(fileDialog.FileName, FileMode.Create, FileAccess.ReadWrite)) {
                var file         = new FileInfo(fileDialog.FileName);
                var progressForm = new ProgressForm(
                    (a, b) => SelectedDimension.ExportDimension(file),
                    handler => Dimension.StatusChanged += handler
                    );
                progressForm.ShowDialog();
                //}
            }
        }
        /// <summary>
        /// Creates a string from a SelectedDimension, formed like "(1, 2, 3, 4) ". Perfect to use for SQL's "IN" operation.
        /// </summary>
        /// <param name="selectedDimension"></param>
        /// <returns></returns>
        /// <author>Jannik Arndt, Bernd Nottbeck</author>
        public virtual string ListFilters(SelectedDimension selectedDimension)
        {
            List <string> temp = new List <string>();

            foreach (DimensionContent dimensionContent in selectedDimension.SelectedFilters)
            {
                String content = dimensionContent.Content;

                //check if apostrophe exists
                //an apostrophe leads to a problem in the sql statement
                //because it marks the end of a string instead of be part of the string
                if (content.Contains("'"))
                {
                    //make a double quote leads to a valid sql statement
                    content = content.Replace("'", "''");
                }

                temp.Add(content);
            }
            return("(" + StringMarker + "" + string.Join("" + StringMarker + ", " + StringMarker + "", temp) + "') ");
        }
Beispiel #5
0
        /// <summary>
        /// Update internal event selection model.
        /// </summary>
        /// <param Name="axis"></param>
        /// /// <param Name="dim"></param>
        /// /// <param Name="levelDepth"></param>
        /// /// <param Name="dimContent"></param>
        /// <param name="aggregationDepth"></param>
        public void Update(int axis, Dimension dim, int levelDepth, int aggregationDepth, List <DimensionContent> dimContent)
        {
            SelectedDimension showEmptyDimension = null;

            foreach (SelectedDimension selectedDimension in _instance.SelectedDimensions)
            {
                if (selectedDimension.Axis == axis)
                {
                    if (dim.IsEmptyDimension)
                    {
                        showEmptyDimension = selectedDimension;
                    }
                    else
                    {
                        selectedDimension.Dimension        = dim;
                        selectedDimension.LevelDepth       = levelDepth;
                        selectedDimension.AggregationDepth = aggregationDepth - 1; //-1 exclude the logical no aggregation dimension
                        selectedDimension.SelectedFilters  = dimContent;

                        if (allLevelSelected(selectedDimension.Dimension, selectedDimension.LevelDepth))
                        {
                            selectedDimension.IsAllLevelSelected = true;
                        }
                        else
                        {
                            selectedDimension.IsAllLevelSelected = false;
                        }
                    }
                    break;
                }
            }

            if (showEmptyDimension != null)
            {
                _instance.SelectedDimensions.Remove(showEmptyDimension);
            }
            _instance.SelectionHasChangedSinceLastLoading = true;
        }
Beispiel #6
0
 private void elementsShowSqlButton_Click(object sender, EventArgs e)
 {
     MessageBox.Show(SelectedDimension.ShowSQL());
     //Console.WriteLine(SelectedDimension.ShowSQL());
 }
Beispiel #7
0
 /// <summary>
 /// Add a selected dimension to the event selection model.
 /// </summary>
 /// <param Name="selectedDimension"></param>
 public void AddSelectedDimension(SelectedDimension selectedDimension)
 {
     _instance.SelectedDimensions.Add(selectedDimension);
 }