Esempio n. 1
0
 public AdomdConnection(string connectionString, AdomdType type)
 {
     _type = type;
     if (_type == AdomdType.AnalysisServices)
     {
         _conn = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection(connectionString);
     }
     else
     {
         ExcelAdoMdConnections.VoidDelegate f = delegate
         {
             _connExcel = new ExcelAdomdClientReference::Microsoft.AnalysisServices.AdomdClient.AdomdConnection(connectionString);
         };
         f();
     }
 }
Esempio n. 2
0
        /*
         * Load mining viewer for the selected structure
         */
        private void LoadViewer()
        {
            if (DropDownListStructures.SelectedItem == null)
                return;

            // clear all the controls in order to avoid adding the same control twice
            PanelViewer.Controls.Clear();

            // define objects
            DMHtmlViewer objViewer = null;
            Microsoft.AnalysisServices.AdomdClient.MiningModel objModel = null;
            Microsoft.AnalysisServices.AdomdClient.MiningService objService = null;

            string sConnString = "Data Source=" + sServer + "; Initial Catalog=" + sCatalog;
            Microsoft.AnalysisServices.AdomdClient.AdomdConnection objConn = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection(sConnString);

            objConn.Open();
            objModel = objConn.MiningModels[DropDownListStructures.SelectedItem.ToString()];
            objService = objConn.MiningServices[objModel.Algorithm];

            // switch mining service
            switch (objService.ViewerType)
            {
                case "Microsoft_Cluster_Viewer":
                    objViewer = new DMClusterViewer();
                    break;
                case "Microsoft_Tree_Viewer":
                    objViewer = new DMDecisionTreeViewer();
                    break;
                case "Microsoft_NaiveBayesian_Viewer":
                    objViewer = new DMNaiveBayesViewer();
                    break;
                default:
                    // if none of the above then return
                    return;
            }

            // init data for the current viewer type
            objViewer.Server = sServer;
            objViewer.Database = sCatalog;
            objViewer.Model = DropDownListStructures.SelectedItem.ToString();
            objViewer.DataBind();

            PanelViewer.Controls.Add(objViewer);
            PanelViewer.Visible = true;
        }
        public TabularActionsEditorForm(Microsoft.AnalysisServices.Cube cube, Microsoft.AnalysisServices.AdomdClient.AdomdConnection conn)
        {
            InitializeComponent();
            this.MinimumSize = this.Size;
            this.Icon = BIDSHelper.Resources.Common.BIDSHelper;
            this.cube = cube;
            this.conn = conn;
            arrEnabledControls = new Control[] { this.btnDelete, this.btnAdd, this.cmbAction, this.okButton, this.cancelButton, this.linkHelp };

            _listDrillthroughColumns = new List<TabularActionsEditorPlugin.DrillthroughColumn>();
            this.drillthroughColumnBindingSource.DataSource = _listDrillthroughColumns;

            _listReportParameters = new List<ReportParameter>();
            this.reportParameterBindingSource.DataSource = _listReportParameters;

            List<string> list = new List<string>();
            List<string> listAttributes = new List<string>();
            list.Add(string.Empty);
            listAttributes.Add(string.Empty);
            foreach (Microsoft.AnalysisServices.CubeDimension cd in cube.Dimensions)
            {
                list.Add(cd.Name);
                foreach (DimensionAttribute a in cd.Dimension.Attributes)
                {
                    listAttributes.Add(a.Name);
                }
            }
            DrillthroughDataGridCubeDimension.Items.AddRange(list.ToArray());
            DrillthroughDataGridAttribute.Items.AddRange(listAttributes.ToArray());

            long lngPerspectiveActionsCount = 0;
            listPerspectives.Items.Clear();
            foreach (Perspective p in cube.Perspectives)
            {
                listPerspectives.Items.Add(p.Name);
                lngPerspectiveActionsCount += p.Actions.Count;
            }

            this.cmbActionType.Items.AddRange(Enum.GetNames(typeof(ActionType)));

            this.cmbTargetType.Items.AddRange(Enum.GetNames(typeof(ActionTargetType)));
            this.cmbTargetType.Items.Remove(ActionTargetType.Set.ToString());

            this.cmbInvocation.Items.AddRange(Enum.GetNames(typeof(ActionInvocation)));

            TabularActionsAnnotation annotation = BIDSHelper.TabularActionsEditorPlugin.GetAnnotation(cube);

            bool bContainsPerspectiveListAnnotation = false;
            _listActionClones = new List<Microsoft.AnalysisServices.Action>();
            foreach (Microsoft.AnalysisServices.Action action in cube.Actions)
            {
                TabularAction actionAnnotation = annotation.Find(action.ID);
                if (actionAnnotation == null) actionAnnotation = new TabularAction();

                if (!string.IsNullOrEmpty(actionAnnotation.OriginalTarget)
                && !actionAnnotation.IsMasterClone)
                {
                    continue;
                }

                Microsoft.AnalysisServices.Action clone = action.Clone();
                _listActionClones.Add(clone);
                if (!string.IsNullOrEmpty(actionAnnotation.OriginalTarget))
                {
                    clone.Target = actionAnnotation.OriginalTarget;
                }

                List<string> lPerspectives = new List<string>();
                foreach (Perspective perspective in cube.Perspectives)
                {
                    if (perspective.Actions.Contains(action.ID))
                    {
                        lPerspectives.Add(perspective.Name);
                    }
                }
                if (!_dictActionPerspectives.ContainsKey(action.ID))
                    _dictActionPerspectives.Add(action.ID, lPerspectives.ToArray());
                else
                    _dictActionPerspectives[action.ID] = lPerspectives.ToArray();

                //see if this action is assigned to perspectives
                if (actionAnnotation.Perspectives != null && actionAnnotation.Perspectives.Length > 0)
                {
                    bContainsPerspectiveListAnnotation = true;
                }
            }

            if (bContainsPerspectiveListAnnotation && lngPerspectiveActionsCount == 0 && cube.Perspectives.Count > 0)
            {
                //we have a backup of the perspectives list, and no actions are assigned to perspectives currently
                if (MessageBox.Show("No actions are currently included in any perspectives, but BIDS Helper did retain a backup of the perspective assignments from the last actions editing session. Changes made to perspectives may have caused action assignments to be lost. Restoring action perspective assignments may be possible except when a perspective has been renamed.\r\n\r\nWould you like BIDS Helper to attempt restore the action perspective assignments now?", "BIDS Helper Tabular Actions Editor", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    foreach (Microsoft.AnalysisServices.Action action in _listActionClones)
                    {
                        TabularAction actionAnnotation = annotation.Find(action.ID);
                        if (actionAnnotation == null) actionAnnotation = new TabularAction();

                        if (actionAnnotation.Perspectives != null && actionAnnotation.Perspectives.Length > 0)
                        {
                            List<string> lPerspectives = new List<string>();
                            foreach (string sPerspectiveID in actionAnnotation.Perspectives)
                            {
                                if (cube.Perspectives.Contains(sPerspectiveID))
                                {
                                    lPerspectives.Add(cube.Perspectives[sPerspectiveID].Name);
                                }
                            }
                            _dictActionPerspectives[action.ID] = lPerspectives.ToArray();
                        }
                    }
                }
            }

            cmbAction.Items.AddRange(_listActionClones.ToArray());
            cmbAction.DisplayMember = "Name";
            cmbAction.ValueMember = "ID";
            cmbAction.ResumeLayout();
            if (_listActionClones.Count > 0)
                cmbAction.SelectedIndex = 0;
            else
                DisableControls(true, arrEnabledControls);

        }
Esempio n. 4
0
 public AdomdConnection(Microsoft.AnalysisServices.AdomdClient.AdomdConnection obj)
 {
     _type = AdomdType.AnalysisServices;
     _conn = obj;
 }
Esempio n. 5
0
        /*
         * Discover mining services; for future use
         */
        private void DiscoverServices()
        {
            Microsoft.AnalysisServices.AdomdClient.AdomdConnection connection = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection("Data Source=" + sServer + "; Initial Catalog=" + sCatalog);
            connection.Open();

            foreach (Microsoft.AnalysisServices.AdomdClient.MiningService ms in connection.MiningServices)
            {
                Console.WriteLine("Service: " + ms.Name);
                foreach (Microsoft.AnalysisServices.AdomdClient.MiningServiceParameter mp in ms.AvailableParameters)
                {
                    Console.WriteLine(" Parameter: " + mp.Name + " Default: " + mp.DefaultValue);
                }
            }
            connection.Close();
        }
Esempio n. 6
0
 public void SimplePredictionQuery()
 {
     Microsoft.AnalysisServices.AdomdClient.AdomdConnection connection = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection();
     connection.ConnectionString =
     "Data Source=localhost; Initial Catalog=Chapter 16";
     connection.Open();
     Microsoft.AnalysisServices.AdomdClient.AdomdCommand cmd = connection.CreateCommand();
     cmd.CommandText =
     "SELECT Predict(Generation) FROM [Generation Trees] " +
     "NATURAL PREDICTION JOIN " +
     "( SELECT " +
     " (SELECT ’Cinemax’ AS Channel UNION " +
     " SELECT ’Showtime’ AS Channel) AS PayChannels " +
     ") AS T ";
     // execute the command and display the prediction result
     Microsoft.AnalysisServices.AdomdClient.AdomdDataReader reader = cmd.ExecuteReader();
     if (reader.Read())
     {
         string predictedGeneration = reader.GetValue(0).ToString();
         Console.WriteLine(predictedGeneration);
     }
     reader.Close();
     connection.Close();
 }
Esempio n. 7
0
        /*
         * Return mining results from query
         */
        public Microsoft.AnalysisServices.AdomdClient.AdomdDataReader GetMiningResults(string sQuery)
        {
            try
            {
                string sConnString = "Data Source=" + sServer + "; Initial Catalog=" + sCatalog;
                Microsoft.AnalysisServices.AdomdClient.AdomdConnection objConn = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection(sConnString);
                objConn.Open();
                Microsoft.AnalysisServices.AdomdClient.AdomdCommand objCmd = objConn.CreateCommand();
                objCmd.CommandText = sQuery;

                /*
                "SELECT FLATTENED PredictHistogram(Generation) " +
                "FROM [Generation Trees] " +
                "NATURAL PREDICTION JOIN " +
                "( SELECT " +
                " (SELECT ’Cinemax’ AS Channel UNION " +
                " SELECT ’Showtime’ AS Channel) AS PayChannels " +
                ") AS T ";*/

                //Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objReader = objCmd.ExecuteReader();
                //Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter objDataAdaptor = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter(objCmd);

                Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objDataReader = objCmd.ExecuteReader(CommandBehavior.CloseConnection);

                /*
                try
                {
                    for (int i = 0; i < objDataReader.FieldCount; i++)
                    {
                        Console.Write(objDataReader.GetName(i) + "\t");
                    }
                    Console.WriteLine();
                    while (objDataReader.Read())
                    {
                        for (int i = 0; i < objDataReader.FieldCount; i++)
                        {
                            object value = objDataReader.GetValue(i);
                            string strValue = (value == null) ?
                            string.Empty : value.ToString();
                            Console.Write(strValue + "\t");
                        }
                        Console.WriteLine();
                    }
                }
                finally
                {
                    objDataReader.Close();
                }
                */

                return objDataReader;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            return null;
        }
Esempio n. 8
0
 public AdomdConnection(Microsoft.AnalysisServices.AdomdClient.AdomdConnection obj)
 {
     _type = AdomdType.AnalysisServices;
     _conn = obj;
 }
        private void InitASSPLabel()
        {
            try
            {
                Microsoft.AnalysisServices.AdomdClient.AdomdConnection conn = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection("Data Source=" + lblServer.Text + ";Initial Catalog=" + lblDatabase.Text);
                conn.Open();

                bool bASSPExists = AggManager.AggregationPerformanceTester.ASSPExists(conn);
                if (bASSPExists)
                {
                    lblASSPInstallStatus.Text = "           version 1.3.5 or later is installed on the server so the file system cache will be cleared between each test.";
                }

                conn.Close();
            }
            catch { }
        }