internal void DeserializeData(string DataStr) { var cellDatas = Jayrock.Json.Conversion.JsonConvert.Import(DataStr) as JsonArray; var Values = cellDatas.GetArray(0); var DisplayValues = cellDatas.GetArray(1); var Styles = cellDatas.GetArray(2); int axes0Len = this.Axes.Count > 0 ? this.Axes[0].Positions.Count : 0; int axes1Len = this.Axes.Count > 1 ? this.Axes[1].Positions.Count : 0; var PropNames = cellDatas[cellDatas.Length - 1] as JsonArray; int CellOrdinal = 0; int cellsCount = Values.Count; for (int j = 0; j < cellsCount; j++) { var cellData = new CellData(); cellData.Axis0_Coord = axes0Len > 0 ? j % axes0Len : -1; // axes0Len может быть 0 и при этом будет одна ячейка (дефолтная). И осей при этом в CellSet нету. cellData.Axis1_Coord = axes1Len > 0 ? j / axes0Len : -1; var cellValueData = new CellValueData(); var prop = new PropertyData("CellOrdinal", CellOrdinal); cellValueData.Properties.Add(prop); object val = ConvertFromJson(Values[CellOrdinal]); cellValueData.Value = val; prop = new PropertyData("VALUE", val); cellValueData.Properties.Add(prop); var props = cellDatas.GetArray(3 + Styles.GetInt32(CellOrdinal)); string FORMAT_STRING = null; for (int k = 0; k < PropNames.Length; k++) { var propName = PropNames[k].ToString(); //if (propName == "FORMAT_STRING") // FORMAT_STRING = (string)propval; prop = new PropertyData(propName, ConvertFromJson(props[k])); cellValueData.Properties.Add(prop); } //if (val == null) // cellValueData.DisplayValue = null; //else if (FORMAT_STRING != null) // cellValueData.DisplayValue = ((double)val).ToString(FORMAT_STRING); //else // cellValueData.DisplayValue = val.ToString(); cellValueData.DisplayValue = DisplayValues[CellOrdinal++].ToString(); prop = new PropertyData("FORMATTED_VALUE", cellValueData.DisplayValue); cellValueData.Properties.Add(prop); cellData.Value = cellValueData; Cells.Add(cellData); } }
public CellData(CellValueData value) { m_Value = value; }
public CellValueData GetValue(params int[] index) { if (CS == null) { return CellValueData.Empty; } int[] indexVector = new int[CS.Axes.Count]; for (int i = 0; i < indexVector.Length; i++) { indexVector[i] = 0; } index.CopyTo(indexVector, 0); Cell cell = null; try { cell = CS[indexVector]; } catch (ArgumentOutOfRangeException) { return CellValueData.Empty; } if (cell != null) { object value = null; string displayName = string.Empty; try { displayName = cell.FormattedValue; } catch (Exception exc) { displayName = CellValueData.ERROR; } try { value = cell.Value; } catch (Exception exc) { value = exc.ToString(); } if (string.IsNullOrEmpty(displayName)) { if (value == null) { displayName = String.Empty; } else { displayName = value.ToString(); } } CellValueData res = new CellValueData(value, displayName); foreach (CellProperty prop in cell.CellProperties) { PropertyData property = new PropertyData(prop.Name, null); try { property.Value = prop.Value; } catch (Microsoft.AnalysisServices.AdomdClient.AdomdErrorResponseException ex) { property.Value = ex.ToString(); } res.Properties.Add(property); } return res; } return null; }