当前位置: 首页>>代码示例>>C#>>正文


C# Server.Disconnect方法代码示例

本文整理汇总了C#中Server.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# Server.Disconnect方法的具体用法?C# Server.Disconnect怎么用?C# Server.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server的用法示例。


在下文中一共展示了Server.Disconnect方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public IScriptReponse Execute(AbstractConnection connection, string script, int timeOut = 0) {
            var response = new ScriptResponse();
            var server = new Server();
            var logger = connection.Logger;

            try {
                logger.Debug("Connecting to {0} on {1}.", connection.Database, connection.Server);
                server.Connect(connection.GetConnectionString());

                var results = server.Execute(script);

                foreach (XmlaResult result in results) {
                    foreach (XmlaMessage message in result.Messages) {
                        response.Messages.Add(message.Description);
                    }
                }
                response.Success = response.Messages.Count == 0;
            } catch (Exception e) {
                logger.Debug(e.Message + (e.InnerException != null ? " " + e.InnerException.Message : string.Empty));
                response.Messages.Add(e.Message);
            } finally {
                if (server.Connected) {
                    logger.Debug("Disconnecting from {0} on {1}.", connection.Database, connection.Server);
                    server.Disconnect();
                }
            }
            return response;
        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:28,代码来源:AnalysisServicesScriptRunner.cs

示例2: ListDimensionErrors

        public static DataTable ListDimensionErrors(string DimensionName)
        {
            DataTable tableReturn = new DataTable();
            tableReturn.Columns.Add("Dimension");
            tableReturn.Columns.Add("ErrorNumber", typeof(int));
            tableReturn.Columns.Add("ErrorDescription");
            tableReturn.Columns.Add("NumColumns", typeof(int));
            int iNumPriorColumns = tableReturn.Columns.Count;
            int iMaxNumColumns = 9;
            for (int i = 1; i <= iMaxNumColumns; i++)
            {
                tableReturn.Columns.Add("Column" + i + "Name");
                tableReturn.Columns.Add("Column" + i);
            }

            if (AdomdServer.Context.ExecuteForPrepare) return tableReturn;

            Server server = new Server();
            server.Connect("*");
            Dimension d = server.Databases.GetByName(AdomdServer.Context.CurrentDatabaseName).Dimensions.GetByName(DimensionName);
            DimensionError[] errors = Check(d);
            server.Disconnect();

            for (int i = 0; i < errors.Length; i++)
            {
                DimensionError error = errors[i];
                if (error.ErrorTable == null || (error.ErrorTable != null && error.ErrorTable.Rows.Count == 0))
                {
                    DataRow row = tableReturn.NewRow();
                    row["Dimension"] = d.Name;
                    row["ErrorNumber"] = i + 1;
                    row["ErrorDescription"] = error.ErrorDescription;
                    row["NumColumns"] = 0;
                    tableReturn.Rows.Add(row);
                }
                else
                {
                    foreach (DataRow errorRow in error.ErrorTable.Rows)
                    {
                        DataRow row = tableReturn.NewRow();
                        row["Dimension"] = d.Name;
                        row["ErrorNumber"] = i + 1;
                        row["ErrorDescription"] = error.ErrorDescription;
                        row["NumColumns"] = error.ErrorTable.Columns.Count;
                        if (iMaxNumColumns < error.ErrorTable.Columns.Count)
                            throw new Exception("Dimension error dataset contained more than " + iMaxNumColumns + " columns which is not allowed with the current code. Change the code of the sproc to allow more, refresh the report dataset, and change the report layout to allow more.");
                        for (int j = 0; j < error.ErrorTable.Columns.Count; j++)
                        {
                            row[j * 2 + iNumPriorColumns] = error.ErrorTable.Columns[j].ColumnName;
                            if (!Convert.IsDBNull(errorRow[j]))
                                row[j * 2 + iNumPriorColumns + 1] = errorRow[j].ToString();
                        }
                        tableReturn.Rows.Add(row);
                    }
                }
            }
            return tableReturn;
        }
开发者ID:sergey-vdovin,项目名称:Slicing-and-dicing-over-data-differences-between-SSAS-databases,代码行数:58,代码来源:DimensionHealthCheck.cs

示例3: Check

 public bool Check(AbstractConnection connection) {
     bool isReady;
     var server = new Server();
     try {
         server.Connect(connection.GetConnectionString());
         isReady = server.Connected;
         server.Disconnect();
     } catch (Exception e) {
         _logger.Warn("Error checking {0} connection. {1}", connection.Name, e.Message);
         return false;
     }
     return isReady;
 }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:13,代码来源:AnalysisServicesConnectionChecker.cs

示例4: BackupSsasDatabases

        /// <summary>
        /// Backup SSAS Databases.
        /// </summary>
        /// <param name="_serverName"></param>
        public void BackupSsasDatabases(Hashtable args)
        {
            var _serverName = args["ServerName"].ToString();

            using(Server srv = new Server())
            {
                srv.Connect(_serverName);

                foreach(Database db in srv.Databases)
                {
                    Console.WriteLine("Backing up " + db.Name);
                    Console.WriteLine("Start " + DateTime.Now.ToShortTimeString());

                    var backupInfo = GetBackupInfo(db.Name, args);

                    db.Backup(backupInfo);

                    Console.WriteLine("Done " + DateTime.Now.ToShortTimeString());
                }

                srv.Disconnect();
            }
        }
开发者ID:mhenderson442,项目名称:ssas-backup,代码行数:27,代码来源:Processing.cs

示例5: testAggregationPerformanceToolStripMenuItem1_Click_1

        private void testAggregationPerformanceToolStripMenuItem1_Click_1(object sender, EventArgs e)
        {
            Server s = new Server();
            try
            {
                AggregationDesign aggD = ((MeasureGroup)treeView1.SelectedNode.Parent.Parent.Tag).AggregationDesigns.GetByName(treeView1.SelectedNode.Tag.ToString());
                if (aggD.Parent.IsLinked)
                {
                    MessageBox.Show("This measure group is linked.");
                    return;
                }

                string serverName = "";
                string databaseName = "";
                if (aggD.ParentServer != null)
                {
                    // if we are in Online mode there will be a parent server
                    serverName = aggD.ParentServer.Name;
                    databaseName = aggD.ParentDatabase.Name;
                    s.Connect(aggD.ParentServer.ConnectionString);
                }
                else
                {
                    // if we are in Project mode we will use the server name from 
                    // the deployment settings
                    DeploymentSettings deploySet = new DeploymentSettings(mProjItem);
                    serverName = deploySet.TargetServer;
                    databaseName = deploySet.TargetDatabase; //use the target database instead of selectedCube.Parent.Name because selectedCube.Parent.Name only reflects the last place it was deployed to, and we want the user to be able to use the deployment settings to control which deployed server/database to check against
                    s.Connect("Data Source=" + serverName);
                }

                Database db = s.Databases.FindByName(databaseName);
                if (db == null)
                {
                    MessageBox.Show("Database " + databaseName + " isn't deployed to server " + serverName + ".");
                    return;
                }

                Cube cube = db.Cubes.Find(realCube.ID);
                if (cube == null)
                {
                    MessageBox.Show("Cube " + realCube.Name + " isn't deployed to database " + databaseName + " on server " + serverName + ".");
                    return;
                }

                MeasureGroup liveMG = cube.MeasureGroups.Find(aggD.Parent.ID);
                if (liveMG == null)
                {
                    MessageBox.Show("Measure group " + aggD.Parent.Name + " in cube " + realCube.Name + " isn't deployed to database " + databaseName + " on server " + serverName + ".");
                    return;
                }

                AggregationDesign liveAggD = liveMG.AggregationDesigns.Find(aggD.ID);
                if (liveMG == null)
                {
                    MessageBox.Show("Agg design " + aggD.Name + " in measure group " + aggD.Parent.Name + " in cube " + realCube.Name + " isn't deployed to database " + databaseName + " on server " + serverName + ".");
                    return;
                }

                AggregationPerformanceProgress progressForm = new AggregationPerformanceProgress();
                progressForm.Init(liveAggD);
                progressForm.ShowDialog(this);

                if (progressForm.Results.Count > 0)
                {
                    OpenAggPerfReport(progressForm.Results, progressForm.MissingResults, progressForm.chkWithoutIndividualAggs.Checked);
                }
                else if (progressForm.Started)
                {
                    if (string.IsNullOrEmpty(progressForm.Errors))
                    {
                        MessageBox.Show("No processed aggregations found in agg design " + liveAggD.Name + " in measure group " + liveMG.Name + " in cube " + liveMG.Parent.Name + " on database " + liveMG.ParentDatabase.Name + " on server " + liveMG.ParentServer.Name + ".");
                    }
                    else
                    {
                        MessageBox.Show(progressForm.Errors);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    s.Disconnect();
                }
                catch { }
            }
        }
开发者ID:japj,项目名称:bidshelper,代码行数:92,代码来源:frmMain.cs

示例6: ListDimensionsWithErrors

        public static DataTable ListDimensionsWithErrors()
        {
            DataTable tableReturn = new DataTable();
            tableReturn.Columns.Add("Dimension");
            if (AdomdServer.Context.ExecuteForPrepare) return tableReturn;

            Server server = new Server();
            server.Connect("*");
            foreach (Dimension d in server.Databases.GetByName(AdomdServer.Context.CurrentDatabaseName).Dimensions)
            {
                DimensionError[] errors = Check(d);
                if (errors.Length > 0)
                {
                    tableReturn.Rows.Add(new object[] { d.Name });
                }
            }
            server.Disconnect();
            return tableReturn;
        }
开发者ID:sergey-vdovin,项目名称:Slicing-and-dicing-over-data-differences-between-SSAS-databases,代码行数:19,代码来源:DimensionHealthCheck.cs

示例7: TestConnection

        /// <summary>
        /// Test the connection on this server.  Will throw exception if connection is bad or if Microsoft.AnalysisServices.Samples.ActivityViewer DB is not installed on the server
        /// </summary>
        public void TestConnection()
        {
            Server test = new Server();
            test.Connect(ASMan.ConnectionString);

            if (double.Parse(test.Version.Substring(0,4)) < 10.0)
            {
                test.Disconnect();
                throw new ConnectionException("Server version must be at least 10.0");
            }
            test.Disconnect();
        }
开发者ID:johno4321,项目名称:SsasActivityViewer,代码行数:15,代码来源:ServerManager.cs

示例8: StartTest


//.........这里部分代码省略.........
                            + "    </Process>" + "\r\n"
                            + "  </Parallel>" + "\r\n"
                            + "</Batch>" + "\r\n");
                        if (!string.IsNullOrEmpty(_errors)) throw new Exception(_errors);

                        if (_cancelled) return;

                        foreach (AggregationPerformance aggP in _listAggPerf)
                        {
                            RaiseProgressEvent(10 + (int)(87.0 * i++ / dictAggRowCount.Count / _totalIterations), "Testing performance with no aggs " + ((i - 1) % dictAggRowCount.Count + 1) + " of " + dictAggRowCount.Count + " (" + aggP.AggregationName + ")...");

                            ServerExecute(s, "<ClearCache xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\">" + "\r\n"
                            + "    <Object>" + "\r\n"
                            + "      <DatabaseID>" + _currentAggD.ParentDatabase.ID + "</DatabaseID>" + "\r\n"
                            + "      <CubeID>" + _currentAggD.ParentCube.ID + "</CubeID>" + "\r\n"
                            + "    </Object>" + "\r\n"
                            + "  </ClearCache>");

                            if (_cancelled) return;

                            _queryEnded = false;

                            //initialize the MDX script with a no-op query
                            ServerExecuteMDX(db, "with member [Measures].[_Exec MDX Script_] as null select [Measures].[_Exec MDX Script_] on 0 from [" + _currentAggD.ParentCube.Name.Replace("]", "]]") + "]", _sessionID);

                            while (!this._queryEnded) //wait for session trace query end event
                            {
                                if (_cancelled) return;
                                System.Threading.Thread.Sleep(100);
                            }

                            aggP.ScriptPerformanceWithoutAggs = _queryDuration;

                            _queryEnded = false;

                            ServerExecuteMDX(db, aggP.PerformanceTestMDX, _sessionID);

                            while (!this._queryEnded) //wait for session trace query end event
                            {
                                if (_cancelled) return;
                                System.Threading.Thread.Sleep(100);
                            }

                            aggP.QueryPerformanceWithoutAggs = _queryDuration;
                        }
                    } //end of testing with no aggs

                    RaiseProgressEvent(100, "Finished measure group " + _currentAggD.Parent.Name);

                    if (!string.IsNullOrEmpty(_errors)) throw new Exception(_errors);
                }
                finally
                {
                    try
                    {
                        if (!s.Connected)
                        {
                            s.Connect("Data Source=" + _currentAggD.ParentServer.Name, _sessionID);
                        }
                    }
                    catch
                    {
                        try
                        {
                            if (!s.Connected)
                            {
                                s.Connect("Data Source=" + _currentAggD.ParentServer.Name); //can't connect to that session, so just reconnect
                            }
                        }
                        catch { }
                    }

                    try
                    {
                        s.RollbackTransaction();
                    }
                    catch { }

                    try
                    {
                        _trc.Drop();
                    }
                    catch { }

                    try
                    {
                        s.Disconnect();
                    }
                    catch { }
                }
            }
            catch (Exception ex)
            {
                if (!_cancelled)
                {
                    _errors += ex.Message + "\r\n" + ex.StackTrace + "\r\n";
                    System.Windows.Forms.MessageBox.Show(_errors);
                }
            }
        }
开发者ID:sgtgold,项目名称:bids-helper-extension,代码行数:101,代码来源:AggregationPerformance.cs

示例9: CreateStringDistinctCountPartitions


//.........这里部分代码省略.........

                    for (int iSubPartition = 1; iSubPartition <= NumSubPartitions; iSubPartition++)
                    {
                        string sGrouper = sOriginalGrouper + " - DistinctCountSegment" + iSubPartition;
                        if (!dictPartitions.ContainsKey(sGrouper))
                        {
                            string sPartitionName = mg.Name + " - " + sTupleName + " - DistinctCountSegment" + iSubPartition;
                            sPartitionName = sPartitionName.Trim();
                            if (String.IsNullOrEmpty(PartitionGrouperExpressionString))
                            {
                                //make sure partition name is unique
                                int i = 1;
                                while (listPartitionNames.Contains(sPartitionName))
                                {
                                    sPartitionName = mg.Name + " - " + sTupleName + " - DistinctCountSegment" + iSubPartition + " - " + (++i);
                                }
                            }
                            dictPartitions.Add(sGrouper, new PartitionMetadata(sPartitionName, t));
                            listPartitionNames.Add(sPartitionName);

                            DataColumn dc = distinctMeasure.ParentCube.DataSourceView.Schema.Tables[distinctColumnBinding.TableID].Columns[distinctColumnBinding.ColumnID];
                            if (!dc.ExtendedProperties.ContainsKey("ComputedColumnExpression"))
                            {
                                dictPartitions[sGrouper].DistinctCountColumn = "[" + distinctMeasure.ParentCube.DataSourceView.Schema.Tables[distinctColumnBinding.TableID].ExtendedProperties["FriendlyName"].ToString() + "].[" + GetColumnName(dc) + "]";
                            }
                            else
                            {
                                dictPartitions[sGrouper].DistinctCountColumn = dc.ExtendedProperties["ComputedColumnExpression"].ToString();
                            }

                            dictPartitions[sGrouper].DistinctCountRangeEndInclusive = false;
                            if (iSubPartition > 1)
                                dictPartitions[sGrouper].DistinctCountRangeStart = "'" + BoundaryValues[iSubPartition - 2].Replace("'", "''") + "'";
                            if (iSubPartition < NumSubPartitions)
                                dictPartitions[sGrouper].DistinctCountRangeEnd = "'" + BoundaryValues[iSubPartition - 1].Replace("'", "''") + "'";
                        }
                        else
                        {
                            dictPartitions[sGrouper].tuples.Add(t);
                        }
                    }
                }

                //remove all existing partitions except template
                for (int iPartition = mg.Partitions.Count - 1; iPartition > 0; iPartition--)
                {
                    mg.Partitions.RemoveAt(iPartition);
                }

                bool bNeedToDeleteTemplate = true;
                foreach (PartitionMetadata pm in dictPartitions.Values)
                {
                    AdomdServer.Context.CheckCancelled(); //could be a bit long running, so allow user to cancel

                    AdomdServer.Context.TraceEvent(0, 0, "Building Partition: " + pm.PartitionName);
                    if (template.ID == pm.PartitionName)
                    {
                        pm.Partition = template;
                        bNeedToDeleteTemplate = false;
                        pm.Partition.Process(ProcessType.ProcessClear); //unprocess it
                    }
                    else
                    {
                        pm.Partition = template.Clone();
                    }
                    pm.Partition.Slice = pm.PartitionSlice;
                    pm.Partition.Name = pm.PartitionName;
                    pm.Partition.ID = pm.PartitionName;
                    if (template.ID != pm.PartitionName) mg.Partitions.Add(pm.Partition);

                    //if we're only building one partition, it must be the All member
                    if (s.Tuples.Count == 1) pm.TupleMustBeOnlyAllMembers = true;

                    string sQuery = "";
                    sQuery = pm.OldQueryDefinition;
                    string sWhereClause = pm.NewPartitionWhereClause;
                    sQuery += "\r\n" + sWhereClause;
                    pm.Partition.Source = new QueryBinding(pm.Partition.DataSource.ID, sQuery);
                }
                if (bNeedToDeleteTemplate) mg.Partitions.Remove(template);

                AdomdServer.Context.TraceEvent(0, 0, "Saving changes");
                mg.Update(UpdateOptions.ExpandFull);
                AdomdServer.Context.TraceEvent(0, 0, "Done creating partitions");
            }
            finally
            {
                try
                {
                    conn.Close();
                }
                catch { }

                try
                {
                    server.Disconnect();
                }
                catch { }
            }
        }
开发者ID:sergey-vdovin,项目名称:Slicing-and-dicing-over-data-differences-between-SSAS-databases,代码行数:101,代码来源:Partition.cs

示例10: CreatePartitions


//.........这里部分代码省略.........
                {
                    AdomdServer.Context.CheckCancelled(); //could be a bit long running, so allow user to cancel

                    AdomdClient.Tuple t = s.Tuples[iTuple];
                    string tostring = t.ToString();
                    string sTupleUniqueName = GetTupleUniqueName(t);
                    string sTupleName = GetTupleName(t);
                    string sGrouper = sTupleUniqueName;

                    if (!String.IsNullOrEmpty(PartitionGrouperExpressionString))
                    {
                        //if a partition grouper has been specified, then group by it
                        sTupleName = sGrouper = cs.Cells[0, iTuple].Value.ToString();
                    }
                    if (!dictPartitions.ContainsKey(sGrouper))
                    {
                        string sPartitionName = mg.Name + " - " + sTupleName;
                        sPartitionName = sPartitionName.Trim();
                        if (String.IsNullOrEmpty(PartitionGrouperExpressionString))
                        {
                            //make sure partition name is unique
                            int i = 1;
                            while (listPartitionNames.Contains(sPartitionName))
                            {
                                sPartitionName = mg.Name + " - " + sTupleName + " " + (++i);
                            }
                        }
                        dictPartitions.Add(sGrouper, new PartitionMetadata(sPartitionName, t));
                        listPartitionNames.Add(sPartitionName);
                    }
                    else
                    {
                        dictPartitions[sGrouper].tuples.Add(t);
                    }
                }

                //remove all existing partitions except template
                for (int iPartition = mg.Partitions.Count - 1; iPartition > 0; iPartition--)
                {
                    mg.Partitions.RemoveAt(iPartition);
                }

                bool bNeedToDeleteTemplate = true;
                foreach (PartitionMetadata pm in dictPartitions.Values)
                {
                    AdomdServer.Context.CheckCancelled(); //could be a bit long running, so allow user to cancel

                    AdomdServer.Context.TraceEvent(0, 0, "Building Partition: " + pm.PartitionName);
                    if (template.ID == pm.PartitionName)
                    {
                        pm.Partition = template;
                        bNeedToDeleteTemplate = false;
                        pm.Partition.Process(ProcessType.ProcessClear); //unprocess it
                        AdomdServer.Context.TraceEvent(0, 0, "ProcessClear partition");
                    }
                    else
                    {
                        pm.Partition = template.Clone();
                        AdomdServer.Context.TraceEvent(0, 0, "cloned partition");
                    }
                    pm.Partition.Slice = pm.PartitionSlice;
                    pm.Partition.Name = pm.PartitionName;
                    pm.Partition.ID = pm.PartitionName;
                    if (template.ID != pm.PartitionName) mg.Partitions.Add(pm.Partition);

                    //if we're only building one partition, it must be the All member
                    if (s.Tuples.Count == 1) pm.TupleMustBeOnlyAllMembers = true;

                    string sQuery = "";
                    sQuery = pm.OldQueryDefinition;
                    string sWhereClause = pm.NewPartitionWhereClause;
                    sQuery += "\r\n" + sWhereClause;
                    pm.Partition.Source = new QueryBinding(pm.Partition.DataSource.ID, sQuery);
                }
                if (bNeedToDeleteTemplate) mg.Partitions.Remove(template);

                AdomdServer.Context.TraceEvent(0, 0, "Saving changes");
                mg.Update(UpdateOptions.ExpandFull);
                AdomdServer.Context.TraceEvent(0, 0, "Done creating partitions");
            }
            catch (Exception ex)
            {
                AdomdServer.Context.TraceEvent(0, 0, "error: " + ex.Message + " - " + ex.StackTrace);
                throw ex;
            }
            finally
            {
                try
                {
                    conn.Close();
                }
                catch { }

                try
                {
                    server.Disconnect();
                }
                catch { }
            }
        }
开发者ID:sergey-vdovin,项目名称:Slicing-and-dicing-over-data-differences-between-SSAS-databases,代码行数:101,代码来源:Partition.cs

示例11: CreateDistinctCountPartitions


//.........这里部分代码省略.........
                    }

                    for (int iSubPartition = 1; iSubPartition <= NumSubPartitions; iSubPartition++)
                    {
                        string sGrouper = sOriginalGrouper + " - DistinctCountSegment" + iSubPartition;
                        if (!dictPartitions.ContainsKey(sGrouper))
                        {
                            string sPartitionName = mg.Name + " - " + sTupleName + " - DistinctCountSegment" + iSubPartition;
                            sPartitionName = sPartitionName.Trim();
                            if (String.IsNullOrEmpty(PartitionGrouperExpressionString))
                            {
                                //make sure partition name is unique
                                int i = 1;
                                while (listPartitionNames.Contains(sPartitionName))
                                {
                                    sPartitionName = mg.Name + " - " + sTupleName + " - DistinctCountSegment" + iSubPartition + " - " + (++i);
                                }
                            }
                            dictPartitions.Add(sGrouper, new PartitionMetadata(sPartitionName, t));
                            listPartitionNames.Add(sPartitionName);

                            DataColumn dc = distinctMeasure.ParentCube.DataSourceView.Schema.Tables[distinctColumnBinding.TableID].Columns[distinctColumnBinding.ColumnID];
                            if (!dc.ExtendedProperties.ContainsKey("ComputedColumnExpression"))
                            {
                                dictPartitions[sGrouper].DistinctCountColumn = "[" + distinctMeasure.ParentCube.DataSourceView.Schema.Tables[distinctColumnBinding.TableID].ExtendedProperties["FriendlyName"].ToString() + "].[" + GetColumnName(dc) + "]";
                            }
                            else
                            {
                                dictPartitions[sGrouper].DistinctCountColumn = dc.ExtendedProperties["ComputedColumnExpression"].ToString();
                            }

                            if (iSubPartition > 1)
                                dictPartitions[sGrouper].DistinctCountRangeStart = (((lngMaxDistinctValue - lngMinDistinctValue) / NumSubPartitions) * (iSubPartition - 1) + lngMinDistinctValue + 1).ToString();
                            if (iSubPartition < NumSubPartitions)
                                dictPartitions[sGrouper].DistinctCountRangeEnd = (((lngMaxDistinctValue - lngMinDistinctValue) / NumSubPartitions) * iSubPartition + lngMinDistinctValue).ToString();
                        }
                        else
                        {
                            dictPartitions[sGrouper].tuples.Add(t);
                        }
                    }
                }

                //remove all existing partitions except template
                for (int iPartition = mg.Partitions.Count - 1; iPartition > 0; iPartition--)
                {
                    mg.Partitions.RemoveAt(iPartition);
                }

                bool bNeedToDeleteTemplate = true;
                foreach (PartitionMetadata pm in dictPartitions.Values)
                {
                    AdomdServer.Context.CheckCancelled(); //could be a bit long running, so allow user to cancel

                    AdomdServer.Context.TraceEvent(0, 0, "Building Partition: " + pm.PartitionName);
                    if (template.ID == pm.PartitionName)
                    {
                        pm.Partition = template;
                        bNeedToDeleteTemplate = false;
                        pm.Partition.Process(ProcessType.ProcessClear); //unprocess it
                    }
                    else
                    {
                        pm.Partition = template.Clone();
                    }
                    pm.Partition.Slice = pm.PartitionSlice;
                    pm.Partition.Name = pm.PartitionName;
                    pm.Partition.ID = pm.PartitionName;
                    if (template.ID != pm.PartitionName) mg.Partitions.Add(pm.Partition);

                    //if we're only building one partition, it must be the All member
                    if (s.Tuples.Count == 1) pm.TupleMustBeOnlyAllMembers = true;

                    string sQuery = "";
                    sQuery = pm.OldQueryDefinition;
                    string sWhereClause = pm.NewPartitionWhereClause;
                    sQuery += "\r\n" + sWhereClause;
                    pm.Partition.Source = new QueryBinding(pm.Partition.DataSource.ID, sQuery);
                }
                if (bNeedToDeleteTemplate) mg.Partitions.Remove(template);

                AdomdServer.Context.TraceEvent(0, 0, "Saving changes");
                mg.Update(UpdateOptions.ExpandFull);
                AdomdServer.Context.TraceEvent(0, 0, "Done creating partitions");
            }
            finally
            {
                try
                {
                    conn.Close();
                }
                catch { }

                try
                {
                    server.Disconnect();
                }
                catch { }
            }
        }
开发者ID:sergey-vdovin,项目名称:Slicing-and-dicing-over-data-differences-between-SSAS-databases,代码行数:101,代码来源:Partition.cs

示例12: ConnectAnalysisServices

        /// <summary>
        ///     Connecting to the Analysis Services.
        /// </summary>
        /// <param name="AnalysisServicesConnectionString">Analysis Services Connection String.</param>
        /// <returns>Database Server instance.</returns>
        public static object ConnectAnalysisServices(string AnalysisServicesConnectionString)
        {
            try
            {
                //Console.WriteLine("Connecting to the Analysis Services ...");
                Server objServer = new Server();
                //Disconnect from current connection if it's currently connected.
                if (objServer.Connected)
                    objServer.Disconnect();
                else
                    objServer.Connect(AnalysisServicesConnectionString);

                return objServer;
            }
            catch (Exception ex)
            {
                throw new Exception("Error in Connecting to the Analysis Services. Error Message -> " + ex.Message);
            }
        }
开发者ID:khanhduy94,项目名称:jobzoom,代码行数:24,代码来源:MiningDatabaseGenerator.cs


注:本文中的Server.Disconnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。