Пример #1
0
        void LoadDates()
        {
            if (String.IsNullOrEmpty(Connection))
            {
                // Сообщение в лог
                StringBuilder builder = new StringBuilder();
                if (String.IsNullOrEmpty(Connection))
                {
                    builder.Append(Localization.Connection_PropertyDesc);
                }
                LogManager.LogError(this, String.Format(Localization.ControlSettingsNotInitialized_Message, builder.ToString()));
                return;
            }

            if (!String.IsNullOrEmpty(DayLevelUniqueName))
            {
                String query = "Select {" + DayLevelUniqueName +
                               ".Members} on 0, {} on 1 from " + OlapHelper.ConvertToQueryStyle(CubeName);

                IsBusy = true;

                MdxQueryArgs args = CommandHelper.CreateMdxQueryArgs(Connection, query);
                OlapDataLoader.LoadData(args, null);
            }
        }
Пример #2
0
        void m_btnState_Click(object sender, RoutedEventArgs e)
        {
            if (Type != TransactionStateActionTypes.None)
            {
                MdxQueryArgs args = new MdxQueryArgs();
                args.Connection = Connection;

                switch (Type)
                {
                case TransactionStateActionTypes.Commit:
                    args.Queries.Add("COMMIT TRANSACTION");
                    args.Type = QueryTypes.CommitTransaction;
                    LogManager.LogInformation(this, this.Name + " - COMMIT TRANSACTION");
                    break;

                case TransactionStateActionTypes.Rollback:
                    args.Queries.Add("ROLLBACK TRANSACTION");
                    args.Type = QueryTypes.RollbackTransaction;
                    LogManager.LogInformation(this, this.Name + " - ROLLBACK TRANSACTION");
                    break;
                }

                OlapDataLoader.LoadData(args, args);
            }
        }
Пример #3
0
        void LoadMembers()
        {
            this.IsWaiting = true;
            if (String.IsNullOrEmpty(Connection))
            {
                // Сообщение в лог
                StringBuilder builder = new StringBuilder();
                if (String.IsNullOrEmpty(Connection))
                {
                    builder.Append(Localization.Connection_PropertyDesc);
                }
                LogManager.LogError(this, String.Format(Localization.ControlSettingsNotInitialized_Message, builder.ToString()));
                this.m_Clear.Visibility = System.Windows.Visibility.Collapsed;
                this.viewer.Content     = String.Format(Localization.ControlSettingsNotInitialized_Message,
                                                        builder.ToString());
                this.IsWaiting = false;
                return;
            }

            if (String.IsNullOrEmpty(this.Query))
            {
                if (!String.IsNullOrEmpty(LevelUniqueName))
                {
                    String query = "Select {" + LevelUniqueName +
                                   ".Members} on 0, {} on 1 from " + OlapHelper.ConvertToQueryStyle(CubeName);
                    MdxQueryArgs args = CommandHelper.CreateMdxQueryArgs(Connection, query);
                    OlapDataLoader.LoadData(args, null);
                }
            }
            else
            {
                MdxQueryArgs args = CommandHelper.CreateMdxQueryArgs(Connection, Query);
                OlapDataLoader.LoadData(args, null);
            }
        }
Пример #4
0
        public static MdxQueryArgs CreateMdxQueryArgs(String connectionString, String query)
        {
            MdxQueryArgs args = new MdxQueryArgs();

            args.Connection = connectionString;
            args.Query      = query;
            return(args);
        }
Пример #5
0
        public static MdxQueryArgs CreateMdxQueryArgs(String connectionString, String query)
        {
            MdxQueryArgs args = new MdxQueryArgs();

            args.Connection = connectionString;
            args.Type       = QueryTypes.Select;
            args.Queries.Add(query);
            return(args);
        }
        void LoadDates()
        {
            if (!String.IsNullOrEmpty(DayLevelUniqueName))
            {
                String query = "Select {" + DayLevelUniqueName +
                               ".Members} on 0, {} on 1 from " + OlapHelper.ConvertToQueryStyle(CubeName);

                IsBusy = true;

                MdxQueryArgs args = CommandHelper.CreateMdxQueryArgs(Connection, query);
                OlapDataLoader.LoadData(args, null);
            }
        }
        void OlapDataLoader_DataLoaded(object sender, DataLoaderEventArgs e)
        {
            bool stopWaiting = true;

            try
            {
                if (e.Error != null)
                {
                    LogManager.LogError(this, e.Error.ToString());
                    return;
                }

                if (e.Result.ContentType == InvokeContentType.Error)
                {
                    LogManager.LogError(this, e.Result.Content);
                    return;
                }

                MdxQueryArgs mdx_args = e.UserState as MdxQueryArgs;
                if (mdx_args != null)
                {
                    CellSetData cs_descr = CellSetData.Deserialize(e.Result.Content);
                    InitializeTuple(cs_descr);

                    // Зачитываем метаданные куба в целом
                    stopWaiting = false;
                    LogManager.LogInformation(this, this.Name + " - Loading cube metadata.");
                    MetadataQuery args = CommandHelper.CreateGetCubeMetadataArgs(Connection, CubeName, MetadataQueryType.GetCubeMetadata_AllMembers);
                    OlapDataLoader.LoadData(args, args);
                }

                MetadataQuery metadata_args = e.UserState as MetadataQuery;
                if (metadata_args != null)
                {
                    CubeDefInfo cs_descr = XmlSerializationUtility.XmlStr2Obj <CubeDefInfo>(e.Result.Content);
                    m_CopyControl.InitializeMetadata(cs_descr);
                }
            }
            finally
            {
                if (stopWaiting)
                {
                    IsWaiting = false;
                }
            }
        }
        public void Initialize()
        {
            m_CopyControl.CubeName           = CubeName;
            m_CopyControl.ConnectionID       = Connection;
            m_CopyControl.GetOlapDataLoader += new EventHandler <GetIDataLoaderArgs>(m_CopyControl_GetOlapDataLoader);

            IsWaiting = true;
            LogManager.LogInformation(this, this.Name + " - Calculating Tuple form cell.");
            // MDX запрос может служить источником Tuple. Если запрос задан, то пытаемся его выполнить и в качестве Tuple будем использовать координаты первой ячейки.
            if (!String.IsNullOrEmpty(Query))
            {
                MdxQueryArgs args = CommandHelper.CreateMdxQueryArgs(Connection, Query);
                OlapDataLoader.LoadData(args, args);
            }
            else
            {
                // Зачитываем метаданне куба в целом
                MetadataQuery args = CommandHelper.CreateGetCubeMetadataArgs(Connection, CubeName, MetadataQueryType.GetCubeMetadata_AllMembers);
                OlapDataLoader.LoadData(args, args);
            }
        }
        void ValueCopyDialog_OkButtonClick(object sender, DialogResultArgs e)
        {
            ModalDialog dlg = sender as ModalDialog;

            if (dlg != null)
            {
                ValueCopyControl copyControl = dlg.Content as ValueCopyControl;
                if (copyControl != null)
                {
                    String query = copyControl.BuildCopyScript();
                    if (!String.IsNullOrEmpty(query))
                    {
                        MdxQueryArgs args = CommandHelper.CreateMdxQueryArgs(Connection, query);
                        args.Type = QueryTypes.Update;
                        OlapDataLoader.LoadData(args, sender);
                    }
                    else
                    {
                        e.Cancel = true;
                    }
                }
            }
        }
Пример #10
0
        private String ExportToExcel(String schema)
        {
            InvokeResultDescriptor result = new InvokeResultDescriptor();
            String res = String.Empty;

            try
            {
                String sessionId  = String.Empty;
                String connection = String.Empty;
                try
                {
                    MdxQueryArgs args = XmlSerializationUtility.XmlStr2Obj <MdxQueryArgs>(schema);
                    if (args != null)
                    {
                        sessionId  = args.SessionId;
                        connection = args.Connection;
                        DefaultQueryExecuter queryExecuter = new DefaultQueryExecuter(GetConnection(args.Connection));
                        if (args.Queries.Count > 0)
                        {
                            res = queryExecuter.GetCellSetDescription(args.Queries[0], ref sessionId);
                        }
                    }
                }
                catch (AdomdConnectionException connection_ex)
                {
                    result.Content     = connection_ex.Message;
                    result.ContentType = InvokeContentType.Error;
                }
                catch (AdomdErrorResponseException response_ex)
                {
                    result.Content     = response_ex.Message;
                    result.ContentType = InvokeContentType.Error;
                }
                catch (AdomdUnknownResponseException unknown_ex)
                {
                    result.Content     = unknown_ex.Message;
                    result.ContentType = InvokeContentType.Error;
                }
                catch (InvalidOperationException invalid_ex)
                {
                    result.Content     = invalid_ex.Message;
                    result.ContentType = InvokeContentType.Error;
                }

                if (!String.IsNullOrEmpty(res))
                {
                    CellSetData       cs            = CellSetData.Deserialize(res);
                    PivotDataProvider pivotProvider = new PivotDataProvider(new CellSetDataProvider(cs));
                    res = ExportHelper.ExportToExcel(pivotProvider);
                }

                result.Content = res;
                if (UseCompress)
                {
                    // Архивация строки
                    String compesed = ZipCompressor.CompressAndConvertToBase64String(res);
                    result.Content   = compesed;
                    result.IsArchive = true;
                }
                result.ContentType = InvokeContentType.MultidimData;
                result.Headers.Add(new Header(InvokeResultDescriptor.SESSION_ID, sessionId));
                result.Headers.Add(new Header(InvokeResultDescriptor.CONNECTION_ID, connection));
            }
            catch (Exception)
            {
                throw;
            }
            return(InvokeResultDescriptor.Serialize(result));
        }
Пример #11
0
        String ExecuteQuery(String schema)
        {
            InvokeResultDescriptor result = new InvokeResultDescriptor();
            String res = String.Empty;

            try
            {
                String       sessionId = String.Empty;
                MdxQueryArgs args      = XmlSerializationUtility.XmlStr2Obj <MdxQueryArgs>(schema);
                if (args != null)
                {
                    sessionId = args.SessionId;
                    DefaultQueryExecuter queryExecuter = new DefaultQueryExecuter(GetConnection(args.Connection));
                    if (args.Queries.Count > 0)
                    {
                        result.ContentType = InvokeContentType.MultidimData;

                        switch (args.Type)
                        {
                        case QueryTypes.Update:
                        case QueryTypes.CommitTransaction:
                        case QueryTypes.RollbackTransaction:
                            List <String> results = new List <String>();
                            result.ContentType = InvokeContentType.UpdateResult;
                            foreach (var query in args.Queries)
                            {
                                try
                                {
                                    // Method return a value of one (1).
                                    queryExecuter.ExecuteNonQuery(query, ref sessionId);
                                    results.Add(String.Empty);
                                }
                                catch (AdomdConnectionException connection_ex)
                                {
                                    results.Add(connection_ex.Message);
                                }
                                catch (AdomdErrorResponseException response_ex)
                                {
                                    results.Add(response_ex.Message);
                                }
                                catch (AdomdUnknownResponseException unknown_ex)
                                {
                                    results.Add(unknown_ex.Message);
                                }
                                catch (InvalidOperationException invalid_ex)
                                {
                                    results.Add(invalid_ex.Message);
                                }
                            }
                            res = XmlSerializationUtility.Obj2XmlStr(results, Common.Namespace);
                            break;

                        case QueryTypes.Select:
                            try
                            {
                                res = queryExecuter.GetCellSetDescription(args.Queries[0], ref sessionId);
                            }
                            catch (AdomdConnectionException connection_ex)
                            {
                                res = connection_ex.Message;
                                result.ContentType = InvokeContentType.Error;
                            }
                            catch (AdomdErrorResponseException response_ex)
                            {
                                res = response_ex.Message;
                                result.ContentType = InvokeContentType.Error;
                            }
                            catch (AdomdUnknownResponseException unknown_ex)
                            {
                                res = unknown_ex.Message;
                                result.ContentType = InvokeContentType.Error;
                            }
                            catch (InvalidOperationException invalid_ex)
                            {
                                res = invalid_ex.Message;
                                result.ContentType = InvokeContentType.Error;
                            }
                            break;

                        case QueryTypes.DrillThrough:
                            try
                            {
                                var table = queryExecuter.ExecuteReader(args.Queries[0], ref sessionId);
                                if (table != null)
                                {
                                    res = XmlSerializationUtility.Obj2XmlStr(DataTableHelper.Create(table));
                                }
                            }
                            catch (AdomdConnectionException connection_ex)
                            {
                                res = connection_ex.Message;
                                result.ContentType = InvokeContentType.Error;
                            }
                            catch (AdomdErrorResponseException response_ex)
                            {
                                res = response_ex.Message;
                                result.ContentType = InvokeContentType.Error;
                            }
                            catch (AdomdUnknownResponseException unknown_ex)
                            {
                                res = unknown_ex.Message;
                                result.ContentType = InvokeContentType.Error;
                            }
                            catch (InvalidOperationException invalid_ex)
                            {
                                res = invalid_ex.Message;
                                result.ContentType = InvokeContentType.Error;
                            }
                            break;
                        }
                    }
                }
                result.Content = res;
                System.Diagnostics.Debug.WriteLine("CellSetData size: " + res.Length);

                if (UseCompress)
                {
                    DateTime start = DateTime.Now;
                    // Архивация строки
                    String compesed = ZipCompressor.CompressAndConvertToBase64String(res);
                    System.Diagnostics.Debug.WriteLine("CellSetData compression time: " + (DateTime.Now - start).ToString());
                    System.Diagnostics.Debug.WriteLine("CellSetData compressed size: " + compesed.Length);

                    result.Content   = compesed;
                    result.IsArchive = true;
                }

                result.Headers.Add(new Header(InvokeResultDescriptor.SESSION_ID, sessionId));
                result.Headers.Add(new Header(InvokeResultDescriptor.CONNECTION_ID, args.Connection));
            }
            catch (Exception ex)
            {
                throw;
            }
            return(InvokeResultDescriptor.Serialize(result));
        }
Пример #12
0
        void OlapDataLoader_DataLoaded(object sender, DataLoaderEventArgs e)
        {
            // Exception
            if (e.Error != null)
            {
                LogManager.LogError(this, e.Error.ToString());
                return;
            }

            // Exception or Message from Olap-Service
            if (e.Result.ContentType == InvokeContentType.Error)
            {
                LogManager.LogError(this, e.Result.Content);
                return;
            }

            if (e.Result != null)
            {
                String connectionId = String.Empty;
                if (e.Result.Headers.Contains(InvokeResultDescriptor.CONNECTION_ID))
                {
                    Header connection_header = e.Result.Headers[InvokeResultDescriptor.CONNECTION_ID];
                    if (connection_header != null)
                    {
                        connectionId = connection_header.Value;
                    }
                }

                if (connectionId == Connection)
                {
                    // Commit or Rollback Transaction
                    MdxQueryArgs query_args = e.UserState as MdxQueryArgs;
                    if (query_args != null)
                    {
                        if (query_args.Type == QueryTypes.CommitTransaction ||
                            query_args.Type == QueryTypes.RollbackTransaction)
                        {
                            if (e.Result.ContentType == InvokeContentType.UpdateResult)
                            {
                                List <String> results = XmlSerializationUtility.XmlStr2Obj <List <String> >(e.Result.Content);
                                if (results != null)
                                {
                                    var           errors = results.Where(res => !String.IsNullOrEmpty(res));
                                    StringBuilder sb     = new StringBuilder();
                                    //if (errors.Count() == 0)
                                    //    AnalysisTransactionManager.CloseTransaction(Connection);
                                    //else
                                    //{
                                    foreach (var error in errors)
                                    {
                                        sb.AppendLine(error);
                                    }
                                    if (!String.IsNullOrEmpty(sb.ToString()))
                                    {
                                        LogManager.LogError(this, sb.ToString());
                                    }
                                    //}

                                    // В случае ошибки считаем что транзакция закрыта. И кэш чистим.
                                    OlapTransactionManager.CloseTransaction(Connection);
                                }
                            }
                        }
                    }
                }
            }
        }