Example #1
0
        public virtual String PerformOlapServiceAction(String schemaType, String schema)
        {
            DateTime start = DateTime.Now;

            try
            {
                System.Diagnostics.Trace.TraceInformation("{0} PerformOlapServiceAction \r\n SCHEMA_TYPE: {1} \r\n SCHEMA: {2} \r\n",
                                                          DateTime.Now.ToString(), schemaType, schema);

                object type = OlapActionTypes.Parse(typeof(OlapActionTypes), schemaType, true);
                if (type != null)
                {
                    OlapActionTypes actionType = (OlapActionTypes)type;
                    switch (actionType)
                    {
                    case OlapActionTypes.GetMetadata:
                        return(GetMetaData(schema));

                    case OlapActionTypes.StorageAction:
                        return(PerformStorageAction(schema));

                    case OlapActionTypes.ExportToExcel:
                        return(ExportToExcel(schema));

                    case OlapActionTypes.ExecuteQuery:
                        return(ExecuteQuery(schema));
                    }
                }

                InvokeResultDescriptor result = new InvokeResultDescriptor();
                return(InvokeResultDescriptor.Serialize(result));
            }
            catch (Exception ex)
            {
                InvokeResultDescriptor result = new InvokeResultDescriptor();
                result.Content     = ex.ToString();
                result.ContentType = InvokeContentType.Error;
                System.Diagnostics.Trace.TraceError("{0} PerformOlapServiceAction ERROR: {1}\r\n",
                                                    DateTime.Now.ToString(), ex.ToString());
                return(InvokeResultDescriptor.Serialize(result));
            }
            finally {
                System.Diagnostics.Trace.TraceInformation("{0} PerformOlapServiceAction: {1} completed \r\n time: {2} \r\n",
                                                          DateTime.Now.ToString(), schemaType, (DateTime.Now - start).ToString());
            }
        }
Example #2
0
        String PerformStorageAction(String schema)
        {
            InvokeResultDescriptor result = new InvokeResultDescriptor();
            String res = String.Empty;

            try
            {
                StorageActionArgs args = XmlSerializationUtility.XmlStr2Obj <StorageActionArgs>(schema);
                if (args != null)
                {
                    FileStorageProvider storageProvider = new FileStorageProvider();
                    switch (args.ActionType)
                    {
                    case StorageActionTypes.Save:
                        args.FileDescription.ContentFileName = args.FileDescription.Description.Name + ".content." + FileStorageProvider.GetFilteExtension(args.ContentType);
                        storageProvider.Save(HttpContext.Current.User, args.FileDescription.Description.Name + "." + FileStorageProvider.GetFilteExtension(args.ContentType), XmlSerializationUtility.Obj2XmlStr(args.FileDescription));
                        storageProvider.Save(HttpContext.Current.User, args.FileDescription.ContentFileName, args.Content);
                        break;

                    case StorageActionTypes.Load:
                        res = storageProvider.Load(HttpContext.Current.User, args.FileDescription.ContentFileName);
                        break;

                    case StorageActionTypes.GetList:
                        res = XmlSerializationUtility.Obj2XmlStr(storageProvider.GetList(HttpContext.Current.User, "*." + FileStorageProvider.GetFilteExtension(args.ContentType)), Common.Namespace);
                        break;

                    case StorageActionTypes.Clear:
                        res = XmlSerializationUtility.Obj2XmlStr(storageProvider.Clear(HttpContext.Current.User, "*." + FileStorageProvider.GetFilteExtension(args.ContentType)));
                        break;

                    case StorageActionTypes.Delete:
                        storageProvider.Delete(HttpContext.Current.User, args.FileDescription.Description.Name + "." + FileStorageProvider.GetFilteExtension(args.ContentType));
                        storageProvider.Delete(HttpContext.Current.User, args.FileDescription.ContentFileName);
                        res = XmlSerializationUtility.Obj2XmlStr(storageProvider.GetList(HttpContext.Current.User, "*." + FileStorageProvider.GetFilteExtension(args.ContentType)), Common.Namespace);
                        break;
                    }
                }
                result.Content = res;
            }
            catch (Exception)
            {
                throw;
            }
            return(InvokeResultDescriptor.Serialize(result));
        }
Example #3
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));
        }
Example #4
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));
        }
Example #5
0
        String GetMetaData(String schema)
        {
            InvokeResultDescriptor result = new InvokeResultDescriptor();
            String res = null;

            try
            {
                MetadataQuery args = XmlSerializationUtility.XmlStr2Obj <MetadataQuery>(schema);

                if (args != null)
                {
                    switch (args.QueryType)
                    {
                    case MetadataQueryType.GetCubes:
                        res = GetCubes(args);
                        break;

                    case MetadataQueryType.GetMeasures:
                        res = GetMeasures(args);
                        break;

                    case MetadataQueryType.GetKPIs:
                        res = GetKPIs(args);
                        break;

                    case MetadataQueryType.GetLevels:
                        res = GetLevels(args);
                        break;

                    case MetadataQueryType.GetDimensions:
                        res = GetDimensions(args);
                        break;

                    case MetadataQueryType.GetHierarchies:
                        res = GetHierarchies(args);
                        break;

                    case MetadataQueryType.GetDimension:
                        res = GetDimension(args);
                        break;

                    case MetadataQueryType.GetHierarchy:
                        res = GetHierarchy(args);
                        break;

                    case MetadataQueryType.GetMeasureGroups:
                        res = GetMeasureGroups(args);
                        break;

                    case MetadataQueryType.GetLevelProperties:
                        res = GetLevelProperties(args);
                        break;

                    case MetadataQueryType.GetCubeMetadata:
                    case MetadataQueryType.GetCubeMetadata_AllMembers:
                        res = GetCubeMetadata(args);
                        break;
                    }
                }
                result.Content = res;
                if (UseCompress)
                {
                    // Архивация строки
                    String compesed = ZipCompressor.CompressAndConvertToBase64String(res);
                    result.Content   = compesed;
                    result.IsArchive = true;
                }
                result.ContentType = InvokeContentType.MultidimData;
            }
            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 (OlapMetadataResponseException metadata_ex)
            {
                result.Content     = metadata_ex.Message;
                result.ContentType = InvokeContentType.Error;
            }
            catch (Exception)
            {
                throw;
            }
            return(InvokeResultDescriptor.Serialize(result));
        }