Exemple #1
0
        public static DataSet Analyze(string statement, int clearCacheMode, int queryResultRowLimit, string clientVersion, string clientType)
        {
            using (ProcedureMutex.TryAcquire())
            {
                EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureAnalyzeBegin);

                DataSet procedureResult;
                using (var procedureContext = ProcedureContext.CreateForLiveExecution(statement, (ClearCacheMode)clearCacheMode, queryResultRowLimit, clientVersion, clientType))
                    using (var analyzeResult = new AnalyzerResult(procedureContext))
                    {
                        if (AdomdServer.Context.ExecuteForPrepare)
                        {
                            procedureResult = analyzeResult.CalculateForPrepare();
                        }
                        else
                        {
                            procedureContext.ValidateStatement();
                            procedureContext.ClearCache();
                            procedureContext.LoadCubeScript();

                            AdomdServer.Context.CheckCancelled();

                            using (var analyzeTask = AnalyzerTask.StartAsync(procedureContext))
                            {
                                #region Pending outcome

                                while (!analyzeTask.Wait(100))
                                {
                                    try
                                    {
                                        AdomdServer.Context.CheckCancelled();
                                    }
                                    catch (AdomdServer.AdomdException)
                                    {
                                        procedureContext.Cancel();

                                        while (!analyzeTask.IsCompleted)
                                        {
                                            Thread.Sleep(50);
                                        }

                                        throw;
                                    }
                                }

                                #endregion

                                procedureResult = analyzeResult.Calculate(analyzeTask.Result);
                            }
                        }
                    }

                EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureAnalyzeEnd);
                return(procedureResult);
            }
        }
Exemple #2
0
        public static DataSet AnalyzeBatch(string statement, int clearCacheMode, string batchID, string batchConnectionString, string clientVersion, string clientType, string batchName, bool throwOnError)
        {
            using (ProcedureMutex.TryAcquire())
            {
                EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureAnalyzeBegin);

                var procedureResult = new DataSet();
                using (var procedureContext = ProcedureContext.CreateForBatchExecution(statement, (ClearCacheMode)clearCacheMode, batchID, batchConnectionString, clientVersion, clientType, batchName))
                    using (var analyzeResult = new AnalyzerResult(procedureContext))
                    {
                        AdomdServer.Context.CheckCancelled();

                        BatchHelper.Initialize(procedureContext);
                        try
                        {
                            procedureContext.ValidateStatement();
                            procedureContext.ClearCache();
                            procedureContext.LoadCubeScript();

                            AdomdServer.Context.CheckCancelled();

                            using (var analyzeTask = AnalyzerTask.StartAsync(procedureContext))
                            {
                                #region Pending outcome

                                while (!analyzeTask.Wait(100))
                                {
                                    try
                                    {
                                        AdomdServer.Context.CheckCancelled();
                                    }
                                    catch (AdomdServer.AdomdException)
                                    {
                                        procedureContext.Cancel();

                                        while (!analyzeTask.IsCompleted)
                                        {
                                            Thread.Sleep(50);
                                        }

                                        throw;
                                    }
                                }

                                #endregion

                                procedureResult = analyzeResult.Calculate(analyzeTask.Result);
                            }

                            BatchHelper.Finalize(procedureContext);
                        }
                        catch (Exception ex)
                        {
                            BatchHelper.TraceException(procedureContext, ex);

                            if (throwOnError)
                            {
                                throw ex;
                            }
                        }
                    }

                EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureAnalyzeEnd);
                return(procedureResult);
            }
        }