public void StringCompressTest() { const string source = "sdfwsf234349785423\\'dfg;5;425n\\фффыыыы```"; byte[] zip = BinaryCompressor.ZipString(source); string result = BinaryCompressor.UnzipString(zip); Assert.AreEqual(source, result); }
public void ZlibLayoutTest() { string streamXml; using (PresenterFactory.BeginSharedPresenterTransaction(m_Container, new BaseForm())) { using (var pivotGrid = new AvrPivotGrid()) { var dataTable = new AvrDataTable(DataHelper.GenerateTestTable()); pivotGrid.SetDataSourceAndCreateFields(dataTable); streamXml = ViewReportTests.GetLayoutXml(pivotGrid); } } byte[] bytes = BinaryCompressor.ZipString(streamXml); string uncompressed = BinaryCompressor.UnzipString(bytes); Assert.AreEqual(streamXml, uncompressed); }
public AvrView(DataSet ds, string tableView, string tableBands, string tableColumns) { var row = ds.Tables[tableView].Rows[0]; m_ViewID = (long)row["idflLayout"]; QueryID = (long)row["idflQuery"]; var ids = row["ChartXAxisViewColumn"]; if (!Utils.IsEmpty(ids)) { m_ChartXAxisViewColumn = (string)ids; } ids = row["MapAdminUnitViewColumn"]; if (!Utils.IsEmpty(ids)) { m_MapAdminUnitViewColumn = (string)ids; } ids = row["idfGlobalView"]; if (!Utils.IsEmpty(ids)) { m_GlobalView = (long?)ids; } ids = row["intGisLayerPosition"]; if (!Utils.IsEmpty(ids)) { m_GisLayerPosition = (int?)ids; } var readOnly = row["blnReadOnly"]; IsReadOnly = readOnly is bool && (bool)readOnly; ids = row["blbChartLocalSettings"]; if (!Utils.IsEmpty(ids)) { ChartLocalSettingsZip = (byte[])ids; } ids = row["blbGisLayerLocalSettings"]; if (!Utils.IsEmpty(ids)) { GisLayerLocalSettingsZip = (byte[])ids; } ids = row["blbGisMapLocalSettings"]; if (!Utils.IsEmpty(ids)) { GisMapLocalSettingsZip = (byte[])ids; } ids = row["blbViewSettings"]; if (!Utils.IsEmpty(ids)) { ViewSettingsZip = (byte[])ids; } if (m_ChartLocalSettingsZip != null) { m_ChartLocalSettingsXml = BinaryCompressor.UnzipString(m_ChartLocalSettingsZip); } if (m_GisLayerLocalSettingsZip != null) { m_GisLayerLocalSettingsXml = BinaryCompressor.UnzipString(m_GisLayerLocalSettingsZip); } if (m_GisMapLocalSettingsZip != null) { m_GisMapLocalSettingsXml = BinaryCompressor.UnzipString(m_GisMapLocalSettingsZip); } if (m_ViewSettingsZip != null) { m_ViewSettingsXml = BinaryCompressor.UnzipString(m_ViewSettingsZip); } var drTop = ds.Tables[tableBands].Select("idfParentViewBand is null", "intOrder", DataViewRowState.CurrentRows); foreach (var r in drTop) { Bands.Add(new AvrViewBand(r, ds, tableBands, tableColumns) { Owner = this }); } var drChildCols = ds.Tables[tableColumns].Select("idfViewBand is null", "intOrder", DataViewRowState.CurrentRows); if (drChildCols.Length > 0) { foreach (var r in drChildCols) { AddColumn(r); } } }
public void UpdateLayoutDetailTest() { lock (m_LayoutDB.Connection) { OpenConnection(); using (new CultureInfoTransaction(new CultureInfo("ru-RU"))) { long layoutId = CreateLayout(); var layoutDetail = (LayoutDetailDataSet)m_LayoutDB.GetDetail(layoutId); var row = (LayoutDetailDataSet.LayoutRow)layoutDetail.Layout.Rows[0]; m_LayoutDB.SetQueryID(m_TestQueryId); Assert.IsFalse(row.blnApplyPivotGridFilter); Assert.IsFalse(row.blnReadOnly); Assert.IsFalse(row.blnShareLayout); Assert.IsFalse(row.blnShowColGrandTotals); Assert.IsFalse(row.blnShowColsTotals); Assert.IsFalse(row.blnShowForSingleTotals); Assert.IsFalse(row.blnShowRowGrandTotals); Assert.IsFalse(row.blnShowRowsTotals); Assert.AreEqual(layoutId, row.idflLayout); Assert.AreEqual((long)DBGroupInterval.gitDateYear, row.idfsDefaultGroupDate); Assert.AreEqual(EidssUserContext.User.EmployeeID, row.idfPerson); row.blnApplyPivotGridFilter = true; row.blnReadOnly = true; row.blnShareLayout = true; row.blnShowColGrandTotals = true; row.blnShowColsTotals = true; row.blnShowForSingleTotals = true; row.blnShowRowGrandTotals = true; row.blnShowRowsTotals = true; row.idfsDefaultGroupDate = (long)DBGroupInterval.gitDateMonth; row.strPivotGridSettings = string.Empty; row.blbPivotGridSettings = BinaryCompressor.ZipString(row.strPivotGridSettings); row.strDefaultLayoutName = "English name"; row.strLayoutName = "russian"; row.strDescription = "descr aaa"; UpdateLayout(layoutDetail); var newLayoutDetail = (LayoutDetailDataSet)m_LayoutDB.GetDetail(layoutId); var newRow = (LayoutDetailDataSet.LayoutRow)newLayoutDetail.Layout.Rows[0]; Assert.AreEqual(row.blnApplyPivotGridFilter, newRow.blnApplyPivotGridFilter); Assert.AreEqual(row.blnReadOnly, newRow.blnReadOnly); Assert.AreEqual(row.blnShareLayout, newRow.blnShareLayout); Assert.AreEqual(row.blnShowColGrandTotals, newRow.blnShowColGrandTotals); Assert.AreEqual(row.blnShowColsTotals, newRow.blnShowColsTotals); Assert.AreEqual(row.blnShowForSingleTotals, newRow.blnShowForSingleTotals); Assert.AreEqual(row.blnShowRowGrandTotals, newRow.blnShowRowGrandTotals); Assert.AreEqual(row.blnShowRowsTotals, newRow.blnShowRowsTotals); Assert.AreEqual(row.idfsDefaultGroupDate, newRow.idfsDefaultGroupDate); Assert.AreEqual(row.strPivotGridSettings, newRow.strPivotGridSettings); Assert.AreEqual(BinaryCompressor.UnzipString(row.blbPivotGridSettings), BinaryCompressor.UnzipString(newRow.blbPivotGridSettings)); Assert.AreEqual(row.strDefaultLayoutName, newRow.strDefaultLayoutName); Assert.AreEqual(row.strLayoutName, newRow.strLayoutName); Assert.AreEqual(row.strDescription, newRow.strDescription); Assert.AreEqual(row.idflLayout, newRow.idflLayout); Assert.AreEqual(row.idflQuery, newRow.idflQuery); Assert.AreEqual(row.idflDescription, newRow.idflDescription); Assert.AreEqual(row.IsidflLayoutFolderNull(), newRow.IsidflLayoutFolderNull()); if (!row.IsidflLayoutFolderNull()) { Assert.AreEqual(row.idflLayoutFolder, newRow.idflLayoutFolder); } DeleteLayout(layoutId); } CloseConnection(); } }
public static void GetAvrStyles (long layoutId, out string gradLayerName, out ITheme gradLayerTheme, out string chartLayerName, out ITheme chartLayerTheme) { gradLayerTheme = null; chartLayerTheme = null; gradLayerName = chartLayerName = string.Empty; #region Get layer settings const string TasLayout = "tasLayout"; byte[] GisLayerLocalSettingsZip; string GisLayerLocalSettingsXml; XmlDocument xmlSetting = null; try { var ds = new DataSet(); //IDbCommand cmd = CreateSPCommand("spAsMapSettingsSelectDetail"); var cmd = new SqlCommand("spAsMapSettingsSelectDetail", (SqlConnection)ConnectionManager.DefaultInstance.Connection) { CommandTimeout = 300, CommandType = CommandType.StoredProcedure }; cmd.Parameters.Add(new SqlParameter("@LangID", ModelUserContext.CurrentLanguage)); cmd.Parameters.Add(new SqlParameter("@LayoutID", layoutId)); DbDataAdapter adapter = new SqlDataAdapter(cmd); adapter.Fill(ds, TasLayout); ds.EnforceConstraints = false; if (ds.Tables[TasLayout].Rows.Count > 0) { DataRow row = ds.Tables[TasLayout].Rows[0]; if (bv.common.Core.Utils.IsEmpty(row["blbGisLayerGeneralSettings"])) { return; } GisLayerLocalSettingsZip = (byte[])row["blbGisLayerGeneralSettings"]; GisLayerLocalSettingsXml = BinaryCompressor.UnzipString(GisLayerLocalSettingsZip); xmlSetting = new XmlDocument(); xmlSetting.LoadXml(GisLayerLocalSettingsXml); ds.EnforceConstraints = true; } } catch (Exception ex) { Dbg.Debug(ex.ToString()); return; } #endregion if (xmlSetting == null) { return; } var tmpGroup = GIS_V4.Serializers.LayerSerializers.LayerGroupSerializer.Instance.Deserialize( (XmlElement)xmlSetting.ChildNodes[0]); foreach (var layer in tmpGroup.Layers) { if (layer is LabelLayer) { continue; } ((EventLayer)layer).Theme = ReplaceColumnName((EventLayer)layer); if ((string)layer.Tag == "event_gradient") { gradLayerName = layer.LayerName; gradLayerTheme = ((VectorLayer)layer).Theme; } if ((string)layer.Tag == "event_chart") { chartLayerName = layer.LayerName; chartLayerTheme = ((VectorLayer)layer).Theme; } } }