private void ProcessAnalysisServicesDatabase() { var accessToken = GetAccessToken("https://" + AasService); var startTime = DateTime.UtcNow; using (Tab.Server aas = new Tab.Server()) { string connStr = $"Provider=MSOLAP;Data Source=asazure://{AasService}/{AasServer};Password={accessToken};Persist Security Info=True;Impersonation Level=Delegate;"; aas.Connect(connStr); Tab.Database db = null; if (!aas.Databases.ContainsName(AasDatabase)) { // note: in case database is not found, verify service principal has *admin* rights - read/process rights are insufficent throw new ApplicationException($"Database '{AasDatabase}' not found. Make sure service principal has database Admin rights."); } db = aas.Databases[AasDatabase]; db.Model.RequestRefresh(Tab.RefreshType.Full); db.Model.SaveChanges(); // commit executes the refresh aas.Disconnect(); } var processTime = DateTime.UtcNow.Subtract(startTime); _logger.LogInformation($"database processed in {processTime.TotalSeconds:n1} s"); }
public void TableCount1200() { using (Tom.Server server = new Tom.Server()) { server.Connect("localhost\\tb"); Tom.Database db = server.Databases.FindByName("Test1200_Target"); Assert.IsNotNull(db); Assert.AreEqual(6, db.Model.Tables.Count); server.Disconnect(); } }
public static void SaveModelMetadataBackup(string connectionString, string targetDatabaseID, string backupFilePath) { using (var s = new TOM.Server()) { s.Connect(connectionString); if (s.Databases.Contains(targetDatabaseID)) { var db = s.Databases[targetDatabaseID]; var dbcontent = TOM.JsonSerializer.SerializeDatabase(db); } s.Disconnect(); } }
public void SaveModelMetadataBackup(string connectionString, string targetDatabaseName, string backupFilePath) { using (var s = new TOM.Server()) { s.Connect(connectionString); var db = s.Databases.Find(targetDatabaseName) ?? s.Databases.FindByName(targetDatabaseName); if (db != null) { var dbcontent = TOM.JsonSerializer.SerializeDatabase(db); WriteZip(backupFilePath, dbcontent); } s.Disconnect(); } }
private void OnTimedEvent(Object source, ElapsedEventArgs e) { try { if (chartControl.InvokeRequired) { SetTimerCallback callback = new SetTimerCallback(OnTimedEvent); //todo safer invoke look up bism try { Invoke(callback, new object[] { source, e }); } catch { } } else { //Todo delete this once http stability fix is done if ((DateTime.Now - _connectionTime).TotalMinutes > 8) { _server.Disconnect(); _server.Connect(_serverConnectionString); _connectionTime = DateTime.Now; } _seriesData[0] = GetNewXAxisMarkerPointsFromAs(); //rebind chartControl.Series.Clear(); //for each X axis marker for (int i = _seriesData.Length - 1; i > 0; i--) { //push back one category _seriesData[i] = _seriesData[i - 1]; //foreach series for the X axis marker we are populating: ... foreach (KeyValuePair <string, SeriesPoint> entry in _seriesData[i]) { //add the series if not there yet if (chartControl.Series.FindByName(entry.Key) == null) { Series series = new Series(entry.Key); series.ChartType = SeriesChartType.StackedColumn; chartControl.Series.Add(series); } //add the data point for the series DataPoint point = new DataPoint(); point.SetValueXY(entry.Value.XAxisLabel, entry.Value.MemoryUsedMegabytes); point.ToolTip = string.Format($"{entry.Value.XAxisLabel} - {entry.Key}: {string.Format("{0:#,###0}", entry.Value.MemoryUsedMegabytes)} MB"); chartControl.Series[entry.Key].Points.Add(point); } } PaintChart(); } } catch (Exception exc) { //Workaround for timeout over HTTP. Try to reconnect - todo delete try { System.Diagnostics.Debug.WriteLine($"Exception occurred at {DateTime.Now}: {exc.Message}"); _server.Disconnect(); _server.Connect(_serverConnectionString); _connectionTime = DateTime.Now; } catch { _timer.Enabled = false; MessageBox.Show($"Error: {exc.Message}", "AS PerfMon", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }