Exemplo n.º 1
0
        /// <summary>
        /// Does exception routine.
        /// </summary>
        /// <param name="message">Head message text.</param>
        /// <param name="exception">Exception object.</param>
        /// <param name="generator">Report generator.</param>
        /// <param name="description">Report state description.</param>
        /// <returns>Exception status message.</returns>
        private MessageDetail _DoExceptionRoutine(string message,
                                                  Exception exception,
                                                  ReportsGenerator generator,
                                                  ReportStateDescription description)
        {
            Debug.Assert(!string.IsNullOrEmpty(message));
            Debug.Assert(null != exception);
            Debug.Assert(null != generator);
            Debug.Assert(null != description);

            Logger.Error(exception);

            generator.DisposeReport(description);

            string messageReason = (exception is OutOfMemoryException) ?
                                   App.Current.FindString("ReportPreviewReasonOutOfMemory") :
                                   exception.Message;

            if (!string.IsNullOrEmpty(messageReason))
            {
                message = string.Format(MESSAGE_FORMAT, message, messageReason);
            }

            return(new MessageDetail(MessageType.Error, message));
        }
Exemplo n.º 2
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Disposes report resources.
        /// </summary>
        private void _DisposeReports()
        {
            Debug.Assert(null != _reports);

            ReportsGenerator generator = App.Current.ReportGenerator;

            for (int index = 0; index < _reports.Count; ++index)
            {
                generator.DisposeReport(_reports[index]);
            }
        }
Exemplo n.º 3
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Starts reports operation.
        /// </summary>
        /// <param name="type">Selected reports operation.</param>
        /// <param name="reports">Reports to processing.</param>
        public void DoProcess(ProcessType type, IList <ReportStateDescription> reports)
        {
            Debug.Assert(null != _reports);
            Debug.Assert(null != reports);

            // dispose report only if it not selected for this operation and not loked
            ReportsGenerator generator = App.Current.ReportGenerator;

            for (int index = 0; index < _reports.Count; ++index)
            {
                ReportStateDescription report = _reports[index];
                if (!reports.Contains(report) && !report.IsLocked)
                {
                    generator.DisposeReport(report);
                }
            }

            // start process
            if (0 < _reports.Count)
            {
                switch (type)
                {
                case ProcessType.Preview:
                    _DoPreview(generator, reports);
                    break;

                case ProcessType.Print:
                    _DoPrint(generator, reports);
                    break;

                case ProcessType.Save:
                    _DoSave(generator, reports);
                    break;

                default:
                {
                    Debug.Assert(false);         // NOTE: not supported
                    break;
                }
                }
            }
        }
        /// <summary>
        /// Does exception routine.
        /// </summary>
        /// <param name="message">Head message text.</param>
        /// <param name="exception">Exception object.</param>
        /// <param name="generator">Report generator.</param>
        /// <param name="description">Report state description.</param>
        /// <returns>Exception status message.</returns>
        private MessageDetail _DoExceptionRoutine(string message,
                                                  Exception exception,
                                                  ReportsGenerator generator,
                                                  ReportStateDescription description)
        {
            Debug.Assert(!string.IsNullOrEmpty(message));
            Debug.Assert(null != exception);
            Debug.Assert(null != generator);
            Debug.Assert(null != description);

            Logger.Error(exception);

            generator.DisposeReport(description);

            string messageReason = (exception is OutOfMemoryException) ?
                                        App.Current.FindString("ReportPreviewReasonOutOfMemory") :
                                        exception.Message;

            if (!string.IsNullOrEmpty(messageReason))
                message = string.Format(MESSAGE_FORMAT, message, messageReason);

            return new MessageDetail(MessageType.Error, message);
        }