Beispiel #1
0
        public void StringCompressTest()
        {
            const string source = "sdfwsf234349785423\\'dfg;5;425n\\фффыыыы```";

            byte[] zip    = BinaryCompressor.ZipString(source);
            string result = BinaryCompressor.UnzipString(zip);

            Assert.AreEqual(source, result);
        }
Beispiel #2
0
        private static DataSet GetPivotDataSet()
        {
            var dataSet = new LayoutDetailDataSet {
                EnforceConstraints = false
            };

            LayoutDetailDataSet.LayoutRow row = dataSet.Layout.NewLayoutRow();

            row.idflLayout = 1;
            row.idflQuery  = 1;
            row.idfPerson  = 1;

            row.strPivotGridSettings = "xxx";
            row.blbPivotGridSettings = BinaryCompressor.ZipString(row.strPivotGridSettings);
            row.strLayoutName        = Guid.NewGuid().ToString();
            row.strDefaultLayoutName = Guid.NewGuid().ToString();
            dataSet.Layout.AddLayoutRow(row);
            dataSet.AcceptChanges();
            return(dataSet);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public ViewDTO GetCachedView(string sessionId, long layoutId, string lang)
        {
            try
            {
                m_ViewSemaphore.Wait();

                var       layout = AvrDbHelper.GetLayoutDTO(layoutId);
                Stopwatch watch  = TraceMethodCall(sessionId, layoutId, layout.DefaultLayoutName, lang);
                EidssAvrServiceInitializer.CheckAndInitEidssCore();

                ViewDTO view         = null;
                var     cacheKey     = new QueryCacheKey(layout.QueryId, lang, layout.UseArchivedData);
                long?   queryCacheId = AvrDbHelper.GetQueryCacheId(cacheKey, RefreshedCacheOnUserCallAfterDays);
                if (queryCacheId.HasValue)
                {
                    var viewCacheId = AvrDbHelper.GetViewCacheId(queryCacheId.Value, layoutId, RefreshedCacheOnUserCallAfterDays);
                    if (viewCacheId.HasValue)
                    {
                        view = AvrDbHelper.GetViewCache(viewCacheId.Value, false);
                    }
                }

                if (view == null)
                {
                    AvrPivotViewModel model = VirtualPivot.CreateAvrPivotViewModel(layoutId, lang, m_Container);

                    string xmlViewHeader    = AvrViewSerializer.Serialize(model.ViewHeader);
                    byte[] zippedViewHeader = BinaryCompressor.ZipString(xmlViewHeader);

                    BaseTableDTO serializedDTO = BinarySerializer.SerializeFromTable(model.ViewData);
                    BaseTableDTO zippedDTO     = BinaryCompressor.Zip(serializedDTO);

                    view = new ViewDTO(zippedDTO, zippedViewHeader);

                    queryCacheId = AvrDbHelper.GetQueryCacheId(cacheKey, RefreshedCacheOnUserCallAfterDays);
                    if (queryCacheId.HasValue)
                    {
                        AvrDbHelper.SaveViewCache(queryCacheId.Value, layoutId, view);
                    }
                }
                TraceMethodCallFinished(watch, sessionId, layoutId, layout.DefaultLayoutName, lang);
                return(view);
            }
            catch (OutOfMemoryException ex)
            {
                m_Trace.TraceMethodException(ex, Utils.GetCurrentMethodName(), m_TraceTitle, sessionId, layoutId, lang);
                throw new AvrDataException(EidssMessages.Get("ErrAVROutOfMemory"), ex);
            }
            catch (Exception ex)
            {
                m_Trace.TraceMethodException(ex, Utils.GetCurrentMethodName(), m_TraceTitle, sessionId, layoutId, lang);
                string format = EidssMessages.Get("msgCouldNotGetViewData",
                                                  "Could not get View Data from Layout. LayoutID={0}, Lang={1}, SessionId={2}");
                string msg = String.Format(format, layoutId, lang, sessionId);
                throw new AvrDataException(msg, ex);
            }
            finally
            {
                m_ViewSemaphore.Release();
            }
        }
Beispiel #5
0
        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();
            }
        }