Exemple #1
0
        public static List <FilterableTreeViewItem> TreeViewTables(this ADOTabularModel model, IGlobalOptions options, IEventAggregator eventAggregator, IMetadataPane metadataPane)
        {
            var lst = new List <FilterableTreeViewItem>();

            foreach (var t in model.Tables)
            {
                if (t.Private && !metadataPane.ShowHiddenObjects)
                {
                    continue;                                               // skip Private tables
                }
                if (t.ShowAsVariationsOnly && !metadataPane.ShowHiddenObjects)
                {
                    continue;                                                            // skip Variation tables
                }
                if (!metadataPane.ShowHiddenObjects && !t.IsVisible)
                {
                    continue;                                                  // skip hidden tables
                }
                lst.Add(new TreeViewTable(t, t.TreeViewColumns, options, eventAggregator, metadataPane));
            }
            return(lst);
        }
Exemple #2
0
 public TreeViewColumn(ADOTabularColumn column, GetChildrenDelegate getChildren, IGlobalOptions options, IEventAggregator eventAggregator, IMetadataPane metadataPane) : base(column.Table, getChildren, options, eventAggregator, metadataPane)
 {
     _eventAggregator = eventAggregator;
     _sampleData      = new List <string>();
     Column           = column;
     _column          = column;
     Options          = options;
     Description      = column.Description;
     DataTypeName     = column.DataTypeName;
     MetadataImage    = column.MetadataImage;
     FormatString     = column.FormatString;
     MinValue         = column.MinValue;
     MaxValue         = column.MaxValue;
     DistinctValues   = column.DistinctValues;
 }
 public FunctionPaneViewModel(ADOTabularConnection connection, IEventAggregator eventAggregator, DocumentViewModel document, IGlobalOptions options) : base(connection, eventAggregator)
 {
     Document        = document;
     Connection      = connection;
     EventAggregator = eventAggregator;
     Options         = options;
 }
Exemple #4
0
        public static IEnumerable <FilterableTreeViewItem> TreeViewFolderChildren(this IADOTabularObjectReference objRef, ADOTabularTable table, IGlobalOptions options, IEventAggregator eventAggregator, IMetadataPane metadataPane)
        {
            var lst = new List <FilterableTreeViewItem>();

            var folder = objRef as IADOTabularFolderReference;

            if (folder != null)
            {
                foreach (var folderItem in folder.FolderItems)
                {
                    GetChildrenDelegate getChildren = null;
                    if (folderItem is IADOTabularFolderReference)
                    {
                        getChildren = ((IADOTabularObjectReference)folderItem).TreeViewFolderChildren;
                    }
                    lst.Add(new TreeViewColumn(folderItem, getChildren, table, options, eventAggregator, metadataPane));
                }
            }
            else
            {
                var col = table.Columns.GetByPropertyRef(objRef.InternalReference);
                lst.Add(new TreeViewColumn(col, null, options, eventAggregator, metadataPane));
            }


            return(lst);
        }
Exemple #5
0
 public ResultsTargetGrid(IEventAggregator eventAggregator, IGlobalOptions options)
 {
     _eventAggregator = eventAggregator;
     _options         = options;
 }
Exemple #6
0
 public BenchmarkViewModel(IEventAggregator eventAggregator, DocumentViewModel document, RibbonViewModel ribbon, IGlobalOptions options)
 {
     EventAggregator = eventAggregator;
     EventAggregator.Subscribe(this);
     Document           = document;
     Ribbon             = ribbon;
     Options            = options;
     ColdRunStyle       = Ribbon.RunStyles.FirstOrDefault(rs => rs.Icon == RunStyleIcons.ClearThenRun);
     WarmRunStyle       = Ribbon.RunStyles.FirstOrDefault(rs => rs.Icon == RunStyleIcons.RunOnly);
     TimerRunTarget     = Ribbon.ResultsTargets.FirstOrDefault(t => t.GetType() == typeof(ResultTargetTimer));
     ProgressIcon       = FontAwesomeIcon.ClockOutline;
     ProgressSpin       = false;
     ProgressMessage    = "Ready";
     ProgressPercentage = 0;
     ProgressColor      = "LightGray";
     RunSameWarmAndCold = true;
 }
Exemple #7
0
        public void Initialize(IGlobalOptions options)
        {
            foreach (PropertyDescriptor prop in TypeDescriptor.GetProperties(options))
            {
                //if (interfaceProps.Find(prop.Name, true)==null) continue;

                //JsonIgnoreAttribute ignoreAttr = prop.Attributes[typeof(JsonIgnoreAttribute)]
                //                                                 as JsonIgnoreAttribute;
                //if (ignoreAttr != null) continue; // go to next attribute if this prop is tagged as [JsonIgnore]

                // Set default value if DefaultValueAttribute is present
                DefaultValueAttribute attr = prop.Attributes[typeof(DefaultValueAttribute)]
                                             as DefaultValueAttribute;

                if (attr == null)
                {
                    continue;
                }
                // read the value from the registry or use the default value
                Object val = this.GetValue(prop.Name, attr.Value);
                // set the property value
                if (prop.PropertyType == typeof(SecureString))
                {
                    SecureString secStr = new SecureString();
                    foreach (char c in (string)val)
                    {
                        secStr.AppendChar(c);
                    }
                    prop.SetValue(options, secStr);
                }
                else if (prop.PropertyType == typeof(Version))
                {
                    var versionVal = val == null? new Version("0.0.0.0"):Version.Parse(val.ToString());
                    prop.SetValue(options, versionVal);
                }
                else if (prop.PropertyType == typeof(DateTime))
                {
                    var dateVal = val == null?DateTime.Parse(attr.Value.ToString()) : DateTime.Parse(val.ToString());

                    prop.SetValue(options, dateVal);
                }
                else if (prop.PropertyType == typeof(double))
                {
                    var doubleVal = val == null?Double.Parse(attr.Value.ToString()) : double.Parse(val.ToString());

                    prop.SetValue(options, doubleVal);
                }
                else if (prop.PropertyType == typeof(bool))
                {
                    var boolVal = val == null?bool.Parse(attr.Value.ToString()) : bool.Parse(val.ToString());

                    prop.SetValue(options, boolVal);
                }
                else if (prop.PropertyType.IsEnum)
                {
                    var enumVal = Enum.Parse(prop.PropertyType, val.ToString());
                    prop.SetValue(options, enumVal);
                }
                else
                {
                    prop.SetValue(options, val);
                }
            }
        }
Exemple #8
0
 public VertiPaqAnalyzerViewModel(Dax.ViewModel.VpaModel viewModel, IEventAggregator eventAggregator, DocumentViewModel currentDocument, IGlobalOptions options)
 {
     Log.Debug("{class} {method} {message}", "VertiPaqAnalyzerViewModel", "ctor", "start");
     this.ViewModel   = viewModel;
     _globalOptions   = options;
     _eventAggregator = eventAggregator;
     _eventAggregator.Subscribe(this);
     CurrentDocument = currentDocument;
     Log.Debug("{class} {method} {message}", "VertiPaqAnalyzerViewModel", "ctor", "end");
 }
Exemple #9
0
        public ShellViewModel(IEventAggregator eventAggregator
                              , RibbonViewModel ribbonViewModel
                              , StatusBarViewModel statusBar
                              , IConductor conductor
                              , IDaxStudioHost host
                              , IVersionCheck versionCheck
                              , IGlobalOptions options
                              , IAutoSaver autoSaver
                              , IThemeManager themeManager)
        {
            Log.Debug(Constants.LogMessageTemplate, nameof(ShellViewModel), "ctor", "Starting Constructor");
            _utcSessionStart = DateTime.UtcNow;
            Ribbon           = ribbonViewModel;
            Ribbon.Shell     = this;
            StatusBar        = statusBar;
            Options          = options;
            AutoSaver        = autoSaver;
            ThemeManager     = themeManager;
            _eventAggregator = eventAggregator;
            _eventAggregator.Subscribe(this);

            Tabs = (DocumentTabViewModel)conductor;
            Tabs.ConductWith(this);
            //Tabs.CloseStrategy = new ApplicationCloseStrategy();
            Tabs.CloseStrategy = IoC.Get <ApplicationCloseAllStrategy>();
            _host     = host;
            _username = UserHelper.GetUser();
            var recoveringFiles = false;

            // get master auto save indexes and only get crashed index files...
            var autoSaveInfo   = AutoSaver.LoadAutoSaveMasterIndex();
            var filesToRecover = autoSaveInfo.Values.Where(idx => idx.IsCurrentVersion && idx.ShouldRecover).SelectMany(entry => entry.Files);

            // check for auto-saved files and offer to recover them
            if (filesToRecover.Any())
            {
                Log.Debug(Constants.LogMessageTemplate, nameof(ShellViewModel), "ctor", "Found auto-save files, beginning recovery");
                recoveringFiles = true;
                RecoverAutoSavedFiles(autoSaveInfo);
            }
            else
            {
                // if there are no auto-save files to recover, start the auto save timer
                Log.Debug(Constants.LogMessageTemplate, nameof(ShellViewModel), "ctor", "Starting auto-save timer");
                eventAggregator.PublishOnUIThreadAsync(new StartAutoSaveTimerEvent());
            }

            // if a filename was passed in on the command line open it
            if (!string.IsNullOrEmpty(_host.CommandLineFileName))
            {
                Log.Debug(Constants.LogMessageTemplate, nameof(ShellViewModel), "ctor", $"Opening file from command line: '{_host.CommandLineFileName}'");
                Tabs.NewQueryDocument(_host.CommandLineFileName);
            }

            // if no tabs are open at this point and we are not recovering auto-save file then, open a blank document
            if (Tabs.Items.Count == 0 && !recoveringFiles)
            {
                Log.Debug(Constants.LogMessageTemplate, nameof(ShellViewModel), "ctor", "Opening a new blank query window");
                NewDocument();
            }


            VersionChecker = versionCheck;
            VersionChecker.UpdateCompleteCallback += VersionCheckComplete;

            DisplayName = AppTitle;

            Application.Current.Activated += OnApplicationActivated;


            AutoSaveTimer          = new Timer(Constants.AutoSaveIntervalMs);
            AutoSaveTimer.Elapsed += AutoSaveTimerElapsed;

            Log.Debug("============ Shell Started - v{version} =============", Version.ToString());
        }
Exemple #10
0
 public QueryBuilderViewModel(IEventAggregator eventAggregator, DocumentViewModel document, IGlobalOptions globalOptions)
 {
     EventAggregator          = eventAggregator;
     Document                 = document;
     Options                  = globalOptions;
     Filters                  = new QueryBuilderFilterList(GetModelCapabilities);
     IsVisible                = false;
     Columns                  = new QueryBuilderFieldList(EventAggregator);
     Columns.PropertyChanged += OnColumnsPropertyChanged;
     OrderBy                  = new QueryBuilderFieldList(EventAggregator);
     VisibilityChanged       += OnVisibilityChanged;
 }
Exemple #11
0
 public FilterableTreeViewItem(GetChildrenDelegate getChildren, IGlobalOptions options, IEventAggregator eventAggregator)
 {
     _eventAggregator = eventAggregator;
     _options         = options;
     _getChildren     = getChildren;
 }
Exemple #12
0
        public static IEnumerable <FilterableTreeViewItem> TreeViewColumns(this ADOTabularTable table, IGlobalOptions options, IEventAggregator eventAggregator)
        {
            var lst = new List <FilterableTreeViewItem>();

            foreach (var c in table.Columns)
            {
                lst.Add(new TreeViewColumn(c, c.TreeViewColumnChildren, options, eventAggregator));
            }
            return(lst);
        }
Exemple #13
0
 public TreeViewTable(ADOTabularTable table, GetChildrenDelegate getChildren, IGlobalOptions options, IEventAggregator eventAggregator) : base(getChildren, options, eventAggregator)
 {
     _table = table;
 }
Exemple #14
0
        public static List <FilterableTreeViewItem> TreeViewTables(this ADOTabularModel model, IGlobalOptions options, IEventAggregator eventAggregator)
        {
            var lst = new List <FilterableTreeViewItem>();

            foreach (var t in model.Tables)
            {
                lst.Add(new TreeViewTable(t, t.TreeViewColumns, options, eventAggregator));
            }
            return(lst);
        }
Exemple #15
0
 public MetadataPaneViewModel(ADOTabularConnection connection, IEventAggregator eventAggregator, DocumentViewModel document, IGlobalOptions globalOptions) : base(connection, eventAggregator)
 {
     ActiveDocument = document;
     ActiveDocument.PropertyChanged += ActiveDocumentPropertyChanged;
     //    _eventAggregator = eventAggregator;
     _options = globalOptions;
     NotifyOfPropertyChange(() => ActiveDocument);
     // TODO - is this a possible resource leak, should we unsubscribe when closing the document for this metadatapane??
     eventAggregator.Subscribe(this);
     ShowHiddenObjects          = _options.ShowHiddenMetadata;
     SortFoldersFirstInMetadata = _options.SortFoldersFirstInMetadata;
     PinSearchOpen = _options.KeepMetadataSearchOpen;
 }
 public DaxIntellisenseProvider(IDaxDocument activeDocument, IEventAggregator eventAggregator, IGlobalOptions options, ADOTabularModel model, ADOTabularDynamicManagementViewCollection dmvs, ADOTabularFunctionGroupCollection functions) : this(activeDocument, eventAggregator, options)
 {
     Model          = model;
     FunctionGroups = functions;
     DMVs           = dmvs;
 }
        public static IEnumerable <FilterableTreeViewItem> TreeViewColumns(this ADOTabularTable table, IADOTabularObject table2, IGlobalOptions options, IEventAggregator eventAggregator, IMetadataPane metadataPane)
        {
            var lst = new SortedList <string, FilterableTreeViewItem>();

            foreach (var c in table.Columns)
            {
                if (!metadataPane.ShowHiddenObjects && !c.IsVisible)
                {
                    continue;                                                  // skip hidden columns
                }
                if (!c.IsInDisplayFolder)
                {
                    var col = new TreeViewColumn(c, c.TreeViewColumnChildren, options, eventAggregator, metadataPane);

                    var lstItem = lst.FirstOrDefault(x => x.Value.Name == col.Name).Value;
                    if (lstItem != null && lstItem.ObjectType == lstItem.ObjectType)
                    {
                        // todo add this col as a child of lstItem
                        throw new NotSupportedException();
                    }
                    else
                    {
                        lst.Add(col.Caption, col);
                    }
                }
            }

            foreach (IADOTabularObjectReference f in table.FolderItems)
            {
                var folder = new TreeViewColumn(f, f.TreeViewFolderChildren, table, options, eventAggregator, metadataPane);
                try
                {
                    var sortKey = folder.Caption;
                    // add spaces as prefix to force sorting folders first
                    if (options.SortFoldersFirstInMetadata)
                    {
                        sortKey = "    " + folder.Caption;
                    }
                    lst.Add(sortKey, folder);
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "{class} {method} {message}", "TreeViewTable", "TreeViewColumns", ex.Message);
                }
            }
            return(lst.Values);
        }
Exemple #18
0
        public MetadataPaneViewModel(IMetadataProvider metadataProvider, IEventAggregator eventAggregator, DocumentViewModel document, IGlobalOptions globalOptions)
            : base(eventAggregator)
        {
            _metadataProvider = metadataProvider;
            ActiveDocument    = document;

            _options = globalOptions;
            NotifyOfPropertyChange(() => ActiveDocument);
            // TODO - is this a possible resource leak, should we unsubscribe when closing the document for this metadatapane??
            //eventAggregator.Subscribe(this);
            ShowHiddenObjects          = _options.ShowHiddenMetadata;
            SortFoldersFirstInMetadata = _options.SortFoldersFirstInMetadata;
            PinSearchOpen = _options.KeepMetadataSearchOpen;
        }
        public TreeViewColumn(IADOTabularObjectReference reference, GetChildrenDelegate getChildren, ADOTabularTable table, IGlobalOptions options, IEventAggregator eventAggregator, IMetadataPane metadataPane)
            : base(table, getChildren, options, eventAggregator, metadataPane)
        {
            Options = options;
            IADOTabularFolderReference folder = reference as IADOTabularFolderReference;

            if (folder == null)
            {
                Column        = table.Columns.GetByPropertyRef(reference.InternalReference);
                MetadataImage = Column.GetMetadataImage();
            }
            else
            {
                _caption      = reference.Name;
                MetadataImage = MetadataImages.Folder;
            }
        }
Exemple #20
0
 public DaxIntellisenseProvider(IDaxDocument activeDocument, IEditor editor, IEventAggregator eventAggregator, IGlobalOptions options)
 {
     Document         = activeDocument;
     _editor          = editor;
     _eventAggregator = eventAggregator;
     _eventAggregator.Subscribe(this);
     _options = options;
 }
        public static IEnumerable <FilterableTreeViewItem> TreeViewColumnChildren(this ADOTabularColumn column, IADOTabularObject table, IGlobalOptions options, IEventAggregator eventAggregator, IMetadataPane metadataPane)
        {
            var lst  = new List <FilterableTreeViewItem>();
            var hier = column as ADOTabularHierarchy;

            if (hier != null)
            {
                foreach (var lvl in hier.Levels)
                {
                    lst.Add(new TreeViewColumn(lvl, options, eventAggregator, metadataPane));
                }
            }
            var kpi = column as ADOTabularKpi;

            if (kpi != null)
            {
                foreach (var comp in kpi.Components)
                {
                    lst.Add(new TreeViewColumn(comp, options, eventAggregator, metadataPane));
                }
            }
            return(lst);
        }
 public QueryHistoryPaneViewModel(GlobalQueryHistory globalHistory, IEventAggregator eventAggregator, DocumentViewModel currentDocument, IGlobalOptions options)
 {
     Log.Debug("{class} {method} {message}", "QueryHistoryPaneViewModel", "ctor", "start");
     _globalHistory   = globalHistory;
     _globalOptions   = options;
     _eventAggregator = eventAggregator;
     _eventAggregator.Subscribe(this);
     _queryHistory = new ListCollectionView(globalHistory.QueryHistory);
     //_queryHistory.PageSize = 50;
     _currentDocument     = currentDocument;
     _queryHistory.Filter = HistoryFilter;
     // sort by StartTime Desc by default
     _queryHistory.SortDescriptions.Add(new SortDescription("StartTime", ListSortDirection.Descending));
     Log.Debug("{class} {method} {message}", "QueryHistoryPaneViewModel", "ctor", "end");
 }
 public DocumentTabViewModel(IWindowManager windowManager, IEventAggregator eventAggregator, Func <IWindowManager, IEventAggregator, DocumentViewModel> documentFactory, IGlobalOptions options)
 {
     _documentFactory = documentFactory;
     _windowManager   = windowManager;
     _eventAggregator = eventAggregator;
     _options         = options;
     _eventAggregator.Subscribe(this);
 }
Exemple #24
0
        public static void MyClassInitialize(TestContext testContext)
        {
            mockOptions = new Mock <IGlobalOptions>().Object;
            //ConnectionString = @"Data Source=localhost\tab17;";
            //ConnectionString = @"Data Source=.\sql2014tb";
            keywordDataSet = new DataSet();
            keywordDataSet.Tables.Add(
                DmvHelpers.ListToTable(new List <Keyword> {
                new Keyword {
                    KEYWORD = "TABLE"
                },
                new Keyword {
                    KEYWORD = "EVALUATE"
                }
            })
                );

            functionDataSet = new DataSet();
            functionDataSet.Tables.Add(
                DmvHelpers.ListToTable(new List <Function> {
                new Function {
                    FUNCTION_NAME = "FILTER", ORIGIN = 4
                },
                new Function {
                    FUNCTION_NAME = "CALCULATE", ORIGIN = 3
                }
            })
                );

            measureDataSet = new DataSet();
            measureDataSet.Tables.Add(
                DmvHelpers.ListToTable(new List <MeasureMD> {
                new MeasureMD {
                    MEASURE_NAME = "MyMeasure", MEASURE_CAPTION = "MyMeasure", DESCRIPTION = "My Description", EXPRESSION = "1"
                }
            })
                );

            measureDataSetEmpty = new DataSet();
            measureDataSetEmpty.Tables.Add(DmvHelpers.ListToTable(new List <MeasureMD>()));

            cubesDataSet = new DataSet();
            cubesDataSet.Tables.Add(
                DmvHelpers.ListToTable(new List <Cube> {
                new Cube {
                    CUBE_NAME = "Adventure Works", CUBE_CAPTION = "Adventure Works", BASE_CUBE_NAME = "", DESCRIPTION = "Mock Cube"
                }
            })
                );
            var csdl = string.Join("\n", File.ReadAllLines(@"..\..\data\AdvWrksFoldersCSDL.xml"));

            csdlMetaDataRowset = new DataSet();
            csdlMetaDataRowset.Tables.Add(
                DmvHelpers.ListToTable(new List <CSDL_METADATA> {
                new CSDL_METADATA {
                    Metadata = csdl
                }
            })
                );
            emptyDataSet = new DataSet();
            emptyDataSet.Tables.Add(new DataTable());
        }
Exemple #25
0
        //public static async Task FormatQuery(DocumentViewModel doc, DAXEditor.DAXEditor editor)
        //{
        //    Log.Debug("{class} {method} {event}", "DaxFormatter", "FormatQuery", "Start");
        //    int colOffset = 1;
        //    int rowOffset = 1;
        //    Log.Verbose("{class} {method} {event}", "DaxFormatter", "FormatQuery", "Getting Query Text");
        //    // todo - do I want to disable the editor control while formatting is in progress???
        //    string qry;
        //    // if there is a selection send that to daxformatter.com otherwise send all the text
        //    qry = editor.SelectionLength == 0 ? editor.Text : editor.SelectedText;

        //    Log.Debug("{class} {method} {event}", "DaxFormatter", "FormatQuery", "About to Call daxformatter.com");

        //    var res = await FormatDaxAsync(qry);

        //    Log.Debug("{class} {method} {event}", "DaxFormatter", "FormatQuery", "daxformatter.com call complete");

        //    try
        //    {
        //        if (res.errors == null)
        //        {
        //            if (editor.SelectionLength == 0)
        //            {
        //                editor.IsEnabled = false;
        //                editor.Document.BeginUpdate();
        //                editor.Document.Text = res.FormattedDax;
        //                editor.Document.EndUpdate();
        //                editor.IsEnabled = true;
        //            }
        //            else
        //            {
        //                var loc = editor.Document.GetLocation(editor.SelectionStart);
        //                colOffset = loc.Column;
        //                rowOffset = loc.Line;
        //                editor.SelectedText = res.FormattedDax;
        //            }
        //            Log.Debug("{class} {method} {event}", "DaxFormatter", "FormatQuery", "Query Text updated");
        //            doc.OutputMessage("Query Formatted via daxformatter.com");
        //        }
        //        else
        //        {

        //            foreach (var err in res.errors)
        //            {
        //                // write error
        //                // note: daxformatter.com returns 0 based coordinates so we add 1 to them
        //                int errLine = err.line + rowOffset;
        //                int errCol = err.column + colOffset;

        //                // if the error is at the end of text then we need to move in 1 character
        //                var errOffset = editor.Document.GetOffset(errLine, errCol);
        //                if (errOffset == editor.Document.TextLength && !editor.Text.EndsWith(" "))
        //                {
        //                    editor.Document.Insert(errOffset, " ");
        //                }

        //                // TODO - need to figure out if more than 1 character should be highlighted
        //                doc.OutputError(string.Format("(Ln {0}, Col {1}) {2} ", errLine, errCol, err.message), err.line + rowOffset, err.column + colOffset);
        //                doc.ActivateOutput();

        //                Log.Debug("{class} {method} {event}", "DaxFormatter", "FormatQuery", "Error markings set");
        //            }

        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        Log.Error("{Class} {Event} {Exception}", "DaxFormatter", "FormatQuery", ex.Message);
        //        doc.OutputError(string.Format("DaxFormatter.com Error: {0}", ex.Message));
        //    }
        //    finally
        //    {
        //        Log.Debug("{class} {method} {end}", "DaxFormatter", "FormatDax:End");
        //    }
        //}



        public static async Task <DaxFormatterResult> FormatDaxAsync(string query, ServerDatabaseInfo serverDbInfo, IGlobalOptions globalOptions, IEventAggregator eventAggregator, bool formatAlternateStyle)
        {
            Log.Verbose("{class} {method} {query}", "DaxFormatter", "FormatDaxAsync:Begin", query);
            string output = await CallDaxFormatterAsync(WebRequestFactory.DaxTextFormatUri, query, serverDbInfo, globalOptions, eventAggregator, formatAlternateStyle);

            var res2 = new DaxFormatterResult();

            JsonConvert.PopulateObject(output, res2);
            Log.Debug("{class} {method} {event}", "DaxFormatter", "FormatDaxAsync", "End");
            return(res2);
        }
Exemple #26
0
 public FilterableTreeViewItem(ADOTabularTable table, GetChildrenDelegate getChildren, IGlobalOptions options, IEventAggregator eventAggregator, IMetadataPane metadataPane)
 {
     _eventAggregator = eventAggregator;
     _options         = options;
     _table           = table;
     _getChildren     = getChildren;
     MetadataPane     = metadataPane;
 }
Exemple #27
0
        private static async Task <string> CallDaxFormatterAsync(string uri, string query, ServerDatabaseInfo serverDbInfo, IGlobalOptions globalOptions, IEventAggregator eventAggregator, bool formatAlternateStyle)
        {
            Log.Verbose("{class} {method} {uri} {query}", "DaxFormatter", "CallDaxFormatterAsync:Begin", uri, query);
            try
            {
                DaxFormatterRequest req = new DaxFormatterRequest();
                req.Dax = query;

                req.ServerName                 = Crypto.SHA256(serverDbInfo.ServerName);
                req.ServerEdition              = serverDbInfo.ServerEdition;
                req.ServerType                 = serverDbInfo.ServerType;
                req.ServerMode                 = serverDbInfo.ServerMode;
                req.ServerLocation             = serverDbInfo.ServerLocation;
                req.ServerVersion              = serverDbInfo.ServerVersion;
                req.DatabaseName               = Crypto.SHA256(serverDbInfo.DatabaseName);
                req.DatabaseCompatibilityLevel = serverDbInfo.DatabaseCompatibilityLevel;
                if ((globalOptions.DefaultDaxFormatStyle == DaxStudio.Interfaces.Enums.DaxFormatStyle.ShortLine && !formatAlternateStyle)
                    ||
                    (globalOptions.DefaultDaxFormatStyle == DaxStudio.Interfaces.Enums.DaxFormatStyle.LongLine && formatAlternateStyle)
                    )
                {
                    req.MaxLineLenght = 1;
                }

                var data = JsonConvert.SerializeObject(req);

                var enc   = System.Text.Encoding.UTF8;
                var data1 = enc.GetBytes(data);

                // this should allow DaxFormatter to work through http 1.0 proxies
                // see: http://stackoverflow.com/questions/566437/http-post-returns-the-error-417-expectation-failed-c
                //System.Net.ServicePointManager.Expect100Continue = false;



                await PrimeConnectionAsync(uri, globalOptions, eventAggregator);

                Uri    originalUri = new Uri(uri);
                string actualUrl   = new UriBuilder(originalUri.Scheme, redirectHost, originalUri.Port, originalUri.PathAndQuery).ToString();

                //var webRequestFactory = IoC.Get<WebRequestFactory>();
                var webRequestFactory = await WebRequestFactory.CreateAsync(globalOptions, eventAggregator);

                var wr = webRequestFactory.Create(new Uri(actualUrl));

                wr.Timeout     = globalOptions.DaxFormatterRequestTimeout.SecondsToMilliseconds();
                wr.ContentType = "application/json";
                wr.Method      = "POST";
                wr.Accept      = "application/json, text/javascript, */*; q=0.01";
                wr.Headers.Add("Accept-Encoding", "gzip,deflate");
                wr.Headers.Add("Accept-Language", "en-US,en;q=0.8");
                wr.ContentType            = "application/json; charset=UTF-8";
                wr.AutomaticDecompression = DecompressionMethods.GZip;

                string output = "";
                using (var strm = await wr.GetRequestStreamAsync())
                {
                    strm.Write(data1, 0, data1.Length);

                    using (var resp = wr.GetResponse())
                    {
                        //var outStrm = new System.IO.Compression.GZipStream(resp.GetResponseStream(), System.IO.Compression.CompressionMode.Decompress);
                        var outStrm = resp.GetResponseStream();
                        using (var reader = new System.IO.StreamReader(outStrm))
                        {
                            output = await reader.ReadToEndAsync();
                        }
                    }
                }

                return(output);
            }
            catch (Exception ex)
            {
                Log.Error("{class} {method} {message}", "DaxFormatter", "CallDaxFormatterAsync", ex.Message);
                throw;
            }
            finally
            {
                Log.Debug("{class} {method}", "DaxFormatter", "CallDaxFormatterAsync:End");
            }
        }
Exemple #28
0
 //private readonly ADOTabularTable _table;
 public TreeViewTable(ADOTabularTable table, GetChildrenDelegate getChildren, IGlobalOptions options, IEventAggregator eventAggregator, IMetadataPane metadataPane) : base(table, getChildren, options, eventAggregator, metadataPane)
 {
     _table = table;
 }
Exemple #29
0
 public static async Task PrimeConnectionAsync(IGlobalOptions globalOptions, IEventAggregator eventAggregator)
 {
     await PrimeConnectionAsync(WebRequestFactory.DaxTextFormatUri, globalOptions, eventAggregator);
 }
Exemple #30
0
 private BitArray OptionsArray(IGlobalOptions options)
 {
     return new BitArray(new bool[] {
         IncludeProperties,
         IncludeFields,
         IncludePrivate,
         CaseSensitive,
         FailOnMismatchedTypes,
         DeclaredOnly,
         ParseValues,
         UpdateSource,
         CanAlterProperties,
         CanAccessMissingProperties,
         IsReadOnly});
 }
Exemple #31
0
 public VoteCounter(IGlobalOptions globalOptions, ILogger <VoteCounter> logger)
 {
     this.logger        = logger;
     this.globalOptions = globalOptions;
 }