Ejemplo n.º 1
0
        public static RvsSavedProperties GetFromJournal(BaseJournalUserControl journal)
        {
            journal.PrepareSettings();
            var properties =
                new RvsSavedProperties
            {
                Grouping             = journal.BaseJournal.GroupColumns.ToList(),
                PageUrl              = journal.Url.CreateUrl(true, true, true),
                ReportPluginName     = journal.ReportPluginName,
                IsFixedHeader        = journal.FixedHeader,
                FixedColumnsCount    = journal.FixedColumnsCount,
                FixedRowsCount       = journal.FixedRowsCount,
                ColumnHierarchy      = journal.BaseJournal.BaseInnerHeader.ColumnHierarchy,
                StorageValues        = journal.StorageValues,
                HeaderRowsProperties = journal.BaseJournal.BaseInnerHeader.RowsProperties,
                DataRowsProperties   = journal.BaseJournal.RowsProperties,
                DataCellProperties   = journal.BaseJournal.CellsProperties,
                ConcatenateColumns   = journal.BaseJournal.SelectingColumnControl != null
                                                 ? journal.BaseJournal.SelectingColumnControl.GetConcatenateColumnTransporters()
                                                 : null,
                NameRu          = journal.HeaderRu,
                NameKz          = journal.HeaderKz,
                JournalTypeName = GetJournalTypeName(journal),
                OrderByColumns  = journal.BaseJournal.DefaultOrder,
            };

            return(properties);
        }
Ejemplo n.º 2
0
        public Stream GetExcel(BaseJournalUserControl <TDataContext, TFilterControl, TKey, TTable, TDataSource, TRow, TJournal, TNavigatorControl, TNavigatorValues, TFilter> journalControl, RvsSavedProperties properties)
        {
            var page = new Page();

            _journalControl = journalControl;
            _journalControl.StorageValues = properties.StorageValues;
            _journalControl.InitializeControls(properties);
            page.TemplateControl.Controls.Add(_journalControl);
            var stream       = new MemoryStream();
            var streamWriter = new StreamWriter(stream);

            _writer = new XmlTextWriter(streamWriter)
            {
                Formatting = Formatting.Indented
            };
            _writer.WriteProcessingInstruction("xml", "version=\"1.0\"");
            _writer.WriteProcessingInstruction("mso-application", "progid=\"Excel.Sheet\"");
            _writer.WriteStartElement("Workbook");
            _writer.WriteAttributeString("xmlns", "urn:schemas-microsoft-com:office:spreadsheet");
            _writer.WriteAttributeString("xmlns:o", "urn:schemas-microsoft-com:office:office");
            _writer.WriteAttributeString("xmlns:x", "urn:schemas-microsoft-com:office:excel");
            _writer.WriteAttributeString("xmlns:ss", "urn:schemas-microsoft-com:office:spreadsheet");
            _writer.WriteAttributeString("xmlns:html", "http://www.w3.org/TR/REC-html40");

            RenderDocumentProperties();
            RenderStyles();
            RenderWorksheet();

            _writer.WriteEndElement();
            _writer.Flush();
            streamWriter.Flush();
            stream.Position = 0;
            return(stream);
        }
Ejemplo n.º 3
0
        public static string GetJournalTypeName(BaseJournalUserControl journal)
        {
            var type = journal.GetType();

            if (type.BaseType?.IsGenericType ?? true)
            {
                return(type.FullName + "," + type.Assembly.FullName);
            }
            return(type.BaseType.FullName + "," + type.BaseType.Assembly.FullName);
        }
Ejemplo n.º 4
0
        //// ReSharper restore InconsistentNaming

        public Stream GetExcel(BaseJournalUserControl <TDataContext, TFilterControl, TKey, TTable, TDataSource, TRow, TJournal, TNavigatorControl, TNavigatorValues, TFilter> journalControl, RvsSavedProperties properties)
        {
            if (HttpContext.Current != null)
            {
                foreach (var key in HttpContext.Current.Items.Keys.OfType <string>().ToList().Where(r => r.EndsWith(".FiltersCache")))
                {
                    HttpContext.Current.Items.Remove(key);
                }
            }

            var page = new Page();

            _journalControl = journalControl;
            _journalControl.StorageValues = properties.StorageValues;
            _journalControl.InitializeControls(properties);
            page.TemplateControl.Controls.Add(_journalControl);
            return(GetExcel());
        }
Ejemplo n.º 5
0
        public void SetToJournal(BaseJournalUserControl journal, bool skipFilters, bool skipNavigators)
        {
            journal.BaseJournal.GroupColumns.Clear();
            journal.BaseJournal.GroupColumns.AddRange(Grouping);
            journal.StorageValues = StorageValues;
            journal.ValuesLoaded  = true;
            if (!string.IsNullOrEmpty(PageUrl))
            {
                if (!skipNavigators && !skipFilters)
                {
                    journal.Url = new MainPageUrlBuilder(PageUrl);
                    journal.Url.ReportPluginName = ReportPluginName;
                    journal.Url.CheckUseSession();
                    if (journal.Url.UserControl.Equals(MainPageUrlBuilder.Current.UserControl))
                    {
                        MainPageUrlBuilder.Current = journal.Url;
                        MainPageUrlBuilder.ChangedUrl();
                    }
                }
                else
                {
                    var url  = journal.Url;
                    var lUrl = new MainPageUrlBuilder(PageUrl);
                    if (!skipNavigators)
                    {
                        foreach (var key in url.QueryParameters.Keys.ToList())
                        {
                            if (key.Contains("."))
                            {
                                url.QueryParameters.Remove(key);
                            }
                        }
                        foreach (var queryParameter in lUrl.QueryParameters)
                        {
                            if (queryParameter.Key.Contains("."))
                            {
                                url.QueryParameters[queryParameter.Key] = queryParameter.Value;
                            }
                        }
                    }
                    if (!skipFilters)
                    {
                        url.SetFilter(journal.BaseFilter.TableName, lUrl.GetFilterItemsDic(journal.BaseFilter.TableName));

                        /*foreach (var key in url.QueryParameters.Keys.ToList())
                         * {
                         *  if (!key.Contains(".")) url.QueryParameters.Remove(key);
                         * }
                         * foreach (var queryParameter in lUrl.QueryParameters)
                         * {
                         *  if (!queryParameter.Key.Contains("."))
                         *      url.QueryParameters[queryParameter.Key] = queryParameter.Value;
                         * }*/
                    }
                }
            }
            journal.FixedHeader       = IsFixedHeader;
            journal.FixedColumnsCount = FixedColumnsCount;
            journal.FixedRowsCount    = FixedRowsCount;
            journal.BaseJournal.BaseInnerHeader.ColumnHierarchy = ColumnHierarchy;
            journal.StorageValues = StorageValues;
            journal.BaseJournal.BaseInnerHeader.RowsProperties = HeaderRowsProperties;
            journal.BaseJournal.RowsProperties     = DataRowsProperties;
            journal.BaseJournal.CellsProperties    = DataCellProperties;
            journal.BaseJournal.ConcatenateColumns = ConcatenateColumns;
            if (journal.BaseJournal.SelectingColumnControl != null && ConcatenateColumns != null)
            {
                journal.BaseJournal.SelectingColumnControl.SetConcatenateColumnProperties(ConcatenateColumns);
            }
            if (OrderByColumns != null)
            {
                journal.BaseJournal.DefaultOrder = OrderByColumns;
            }
        }
Ejemplo n.º 6
0
 public void SetToJournal(BaseJournalUserControl journal)
 {
     SetToJournal(journal, false, false);
 }
Ejemplo n.º 7
0
        public static Stream GetExcel <TDataContext, TFilterControl, TKey, TTable, TDataSource, TRow, TJournal, TNavigatorControl, TNavigatorValues, TFilter>(
            BaseJournalUserControl <TDataContext, TFilterControl, TKey, TTable, TDataSource, TRow, TJournal, TNavigatorControl, TNavigatorValues, TFilter>
            journalControl,
            RvsSavedProperties properties,
            ILogMonitor logMonitor,
            bool checkPermit)

            where TDataContext : DataContext, new()
            where TKey : struct
            where TTable : class
            where TFilterControl : BaseFilterControl <TKey, TTable>, new()
            where TDataSource : BaseDataSource <TKey, TTable, TDataContext, TRow>
            where TRow : BaseRow, new()
            where TJournal : BaseJournalControl <TKey, TTable, TRow, TDataContext>
            where TNavigatorControl : BaseNavigatorControl <TNavigatorValues>
            where TNavigatorValues : BaseNavigatorValues, new()
            where TFilter : BaseFilter <TKey, TTable, TDataContext>, new()
        {
            Stream stream;

            journalControl.LogMonitor = logMonitor;
            journalControl.Url        = MainPageUrlBuilder.Current.Clone();
            if (checkPermit)
            {
                journalControl.CheckExportPermit();
            }
            if ("xml".Equals(properties.Format, StringComparison.OrdinalIgnoreCase))
            {
                var exporterXml = new ExporterXml <TDataContext, TFilterControl, TKey, TTable, TDataSource, TRow, TJournal,
                                                   TNavigatorControl, TNavigatorValues, TFilter> {
                    LogMonitor = logMonitor
                };
                stream = exporterXml.GetExcel(journalControl, properties);
            }
            else
            {
                var exporterXslx = new ExporterXslx <TDataContext, TFilterControl, TKey, TTable, TDataSource, TRow, TJournal,
                                                     TNavigatorControl, TNavigatorValues, TFilter> {
                    LogMonitor = logMonitor
                };
                stream = exporterXslx.GetExcel(journalControl, properties);
            }

            DBDataContext.AddViewReports(
                User.GetSID(),
                HttpContext.Current.User.Identity.Name,
                HttpContext.Current.User.Identity.Name,
                HttpContext.Current.Request.Url.PathAndQuery,
                HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority),
                Environment.MachineName,
                true,
                BuildManager.GetType(properties.ReportPluginName, false, true) ?? GetTypeByReportManager(properties.ReportPluginName));

            logMonitor.Log(
                new LogMessageEntry(
                    User.GetSID(),
                    journalControl.ExportLog,
                    properties.NameRu,
                    journalControl.OnExportNewSavedProperties ? RvsSavedProperties.GetFromJournal(journalControl) : properties));

            return(stream);
        }