PageRenderTime 4150ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/UILibrary.Olap/Ranet.Olap.Core/Metadata/InfoHelper.cs

https://code.google.com/p/ranet-uilibrary-olap/
C# | 278 lines | 196 code | 28 blank | 54 comment | 34 complexity | 59b55c0d098b8c1cdacef11f8fcb4e4e MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0, CC-BY-SA-3.0, LGPL-2.0
  1. /*
  2. Copyright (C) 2009 Galaktika Corporation ZAO
  3. This file is a part of Ranet.UILibrary.Olap
  4. Ranet.UILibrary.Olap is a free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. You should have received a copy of the GNU General Public License
  9. along with Ranet.UILibrary.Olap. If not, see
  10. <http://www.gnu.org/licenses/>
  11. If GPL v.3 is not suitable for your products or company,
  12. Galaktika Corp provides Ranet.UILibrary.Olap under a flexible commercial license
  13. designed to meet your specific usage and distribution requirements.
  14. If you have already obtained a commercial license from Galaktika Corp,
  15. you can use this file under those license terms.
  16. */
  17. using System;
  18. using System.Collections.Generic;
  19. using System.Linq;
  20. using System.Text;
  21. using Ranet.Olap.Core.Metadata;
  22. using Microsoft.AnalysisServices.AdomdClient;
  23. namespace Ranet.Olap.Core.Metadata
  24. {
  25. public static class InfoHelper
  26. {
  27. public static CubeDefInfo CreateCubeInfo(CubeDef cube)
  28. {
  29. if (cube == null)
  30. return null;
  31. CubeDefInfo info = new CubeDefInfo();
  32. info.Caption = cube.Caption;
  33. info.Description = cube.Description;
  34. info.Name = cube.Name;
  35. info.LastProcessed = cube.LastProcessed;
  36. info.LastUpdated = cube.LastUpdated;
  37. info.Type = (CubeInfoType)(cube.Type);
  38. // ????????
  39. foreach (Property prop in cube.Properties)
  40. {
  41. //PropertyInfo pi = new PropertyInfo(prop.Name, prop.Type, prop.Value);
  42. PropertyInfo pi = new PropertyInfo(prop.Name, prop.Value);
  43. info.Properties.Add(pi);
  44. }
  45. return info;
  46. }
  47. public static NamedSetInfo CreateNamedSetInfo(NamedSet set)
  48. {
  49. if (set == null)
  50. return null;
  51. NamedSetInfo info = new NamedSetInfo();
  52. info.Caption = set.Caption;
  53. info.Description = set.Description;
  54. info.Name = set.Name;
  55. info.DisplayFolder = set.DisplayFolder;
  56. info.Expression = set.Expression;
  57. // ?????????? ? ???????
  58. if (set.ParentCube != null)
  59. {
  60. info.ParentCubeId = set.ParentCube.Name;
  61. info.CustomProperties.Add(new PropertyInfo(InfoBase.CUBE_CAPTION, set.ParentCube.Caption));
  62. }
  63. // ????????
  64. foreach (Property prop in set.Properties)
  65. {
  66. PropertyInfo pi = new PropertyInfo(prop.Name, prop.Value);
  67. info.Properties.Add(pi);
  68. }
  69. return info;
  70. }
  71. public static DimensionInfo CreateDimensionInfo(Dimension dim)
  72. {
  73. if (dim == null)
  74. return null;
  75. DimensionInfo info = new DimensionInfo();
  76. info.Caption = dim.Caption;
  77. info.Description = dim.Description;
  78. info.DimensionType = (DimensionInfoTypeEnum)(dim.DimensionType);
  79. info.Name = dim.Name;
  80. info.WriteEnabled = dim.WriteEnabled;
  81. info.UniqueName = dim.UniqueName;
  82. // ?????????? ? ???????
  83. if (dim.ParentCube != null)
  84. {
  85. info.ParentCubeId = dim.ParentCube.Name;
  86. info.CustomProperties.Add(new PropertyInfo(InfoBase.CUBE_CAPTION, dim.ParentCube.Caption));
  87. }
  88. // ????????
  89. foreach (Property prop in dim.Properties)
  90. {
  91. // PropertyInfo pi = new PropertyInfo(prop.Name, prop.Type, prop.Value);
  92. PropertyInfo pi = new PropertyInfo(prop.Name, prop.Value);
  93. info.Properties.Add(pi);
  94. }
  95. return info;
  96. }
  97. public static HierarchyInfo CreateHierarchyInfo(Hierarchy hierarchy)
  98. {
  99. if (hierarchy == null)
  100. return null;
  101. HierarchyInfo info = new HierarchyInfo();
  102. info.Caption = hierarchy.Caption;
  103. info.Description = hierarchy.Description;
  104. info.DefaultMember = hierarchy.DefaultMember;
  105. // ?????????? ? ???????
  106. if (hierarchy.ParentDimension != null)
  107. {
  108. info.ParentDimensionId = hierarchy.ParentDimension.UniqueName;
  109. info.CustomProperties.Add(new PropertyInfo(InfoBase.DIMENSION_CAPTION, hierarchy.ParentDimension.Caption));
  110. if (hierarchy.ParentDimension.ParentCube != null)
  111. {
  112. info.ParentCubeId = hierarchy.ParentDimension.ParentCube.Name;
  113. info.CustomProperties.Add(new PropertyInfo(InfoBase.CUBE_CAPTION, hierarchy.ParentDimension.ParentCube.Caption));
  114. }
  115. }
  116. try
  117. {
  118. info.DisplayFolder = hierarchy.DisplayFolder;
  119. }
  120. catch (System.NotSupportedException)
  121. {
  122. // ?? ?????????????? MSAS 2000
  123. info.DisplayFolder = String.Empty;
  124. }
  125. info.Name = hierarchy.Name;
  126. info.HierarchyOrigin = (HierarchyInfoOrigin)(hierarchy.HierarchyOrigin);
  127. info.UniqueName = hierarchy.UniqueName;
  128. // ????????
  129. foreach (Property prop in hierarchy.Properties)
  130. {
  131. //PropertyInfo pi = new PropertyInfo(prop.Name, prop.Type, prop.Value);
  132. PropertyInfo pi = new PropertyInfo(prop.Name, prop.Value);
  133. info.Properties.Add(pi);
  134. }
  135. return info;
  136. }
  137. public static LevelInfo CreateLevelInfo(Level level)
  138. {
  139. if (level == null)
  140. return null;
  141. LevelInfo info = new LevelInfo();
  142. info.Caption = level.Caption;
  143. info.Description = level.Description;
  144. info.LevelNumber = level.LevelNumber;
  145. info.LevelType = (LevelInfoTypeEnum)(level.LevelType);
  146. info.MemberCount = level.MemberCount;
  147. info.Name = level.Name;
  148. info.UniqueName = level.UniqueName;
  149. // ?????????? ? ???????
  150. if (level.ParentHierarchy != null)
  151. {
  152. info.ParentHirerachyId = level.ParentHierarchy.UniqueName;
  153. info.CustomProperties.Add(new PropertyInfo(InfoBase.HIERARCHY_CAPTION, level.ParentHierarchy.Caption));
  154. if (level.ParentHierarchy.ParentDimension != null)
  155. {
  156. info.ParentDimensionId = level.ParentHierarchy.ParentDimension.UniqueName;
  157. info.CustomProperties.Add(new PropertyInfo(InfoBase.DIMENSION_CAPTION, level.ParentHierarchy.ParentDimension.Caption));
  158. if (level.ParentHierarchy.ParentDimension.ParentCube != null)
  159. {
  160. info.ParentCubeId = level.ParentHierarchy.ParentDimension.ParentCube.Name;
  161. info.CustomProperties.Add(new PropertyInfo(InfoBase.CUBE_CAPTION, level.ParentHierarchy.ParentDimension.ParentCube.Caption));
  162. }
  163. }
  164. }
  165. // ????????
  166. foreach (Property prop in level.Properties)
  167. {
  168. //PropertyInfo pi = new PropertyInfo(prop.Name, prop.Type, prop.Value);
  169. PropertyInfo pi = new PropertyInfo(prop.Name, prop.Value);
  170. info.Properties.Add(pi);
  171. }
  172. //// ???????? ??????
  173. //foreach(LevelProperty lp in level.LevelProperties)
  174. //{
  175. // LevelPropertyInfo lpi = new LevelPropertyInfo();
  176. // lpi.Caption = lp.Caption;
  177. // lpi.Description = lp.Description;
  178. // lpi.Name = lp.Name;
  179. // if(lp.ParentLevel != null)
  180. // {
  181. // lpi.ParentLevelId = lp.ParentLevel.UniqueName;
  182. // }
  183. // lpi.UniqueName = lp...UniqueName;
  184. // info.LevelProperties.Add(lpi);
  185. //}
  186. return info;
  187. }
  188. public static MeasureInfo CreateMeasureInfo(Measure measure)
  189. {
  190. if (measure == null)
  191. return null;
  192. MeasureInfo info = new MeasureInfo();
  193. info.Caption = measure.Caption;
  194. info.Description = measure.Description;
  195. info.Name = measure.Name;
  196. info.UniqueName = measure.UniqueName;
  197. info.DisplayFolder = measure.DisplayFolder;
  198. info.Expression = measure.Expression;
  199. info.NumericPrecision = measure.NumericPrecision;
  200. info.NumericScale = measure.NumericScale;
  201. info.Units = measure.Units;
  202. // ?????????? ? ???????
  203. if (measure.ParentCube != null)
  204. {
  205. info.ParentCubeId = measure.ParentCube.Name;
  206. }
  207. // ????????
  208. foreach (Property prop in measure.Properties)
  209. {
  210. //PropertyInfo pi = new PropertyInfo(prop.Name, prop.Type, prop.Value);
  211. PropertyInfo pi = new PropertyInfo(prop.Name, prop.Value);
  212. info.Properties.Add(pi);
  213. }
  214. return info;
  215. }
  216. public static KpiInfo CreateKpiInfo(Kpi kpi)
  217. {
  218. if (kpi == null)
  219. return null;
  220. KpiInfo info = new KpiInfo();
  221. info.Caption = kpi.Caption;
  222. info.Description = kpi.Description;
  223. info.Name = kpi.Name;
  224. info.DisplayFolder = kpi.DisplayFolder;
  225. info.StatusGraphic = kpi.StatusGraphic;
  226. info.TrendGraphic = kpi.TrendGraphic;
  227. // ?????????? ? ???????
  228. if (kpi.ParentCube != null)
  229. {
  230. info.ParentCubeId = kpi.ParentCube.Name;
  231. }
  232. if (kpi.ParentKpi != null)
  233. {
  234. info.ParentKpiId = kpi.ParentKpi.Name;
  235. }
  236. // ????????
  237. foreach (Property prop in kpi.Properties)
  238. {
  239. //PropertyInfo pi = new PropertyInfo(prop.Name, prop.Type, prop.Value);
  240. PropertyInfo pi = new PropertyInfo(prop.Name, prop.Value);
  241. info.Properties.Add(pi);
  242. }
  243. return info;
  244. }
  245. }
  246. }