Exemple #1
0
        /// <summary>
        /// Creates a database that can be used as a report source (asynchronous).
        /// </summary>
        /// <param name="filePath">Path to Access database file where data will be exported.</param>
        /// <param name="schedules">Collection of schedules to export.</param>
        /// <param name="extendedFields">Collection of extended fields that have to be generated.</param>
        /// <param name="routes">Collection of routes from the <c>schedule</c> to export.</param>
        /// <param name="mapLayer"><see cref="P:ESRI.ArcLogistics.MapLayer" /> that has to be used
        /// for images generation.</param>
        /// <param name="options"><see cref="P:ESRI.ArcLogistics.Export.ExportOptions" /> that has to be used
        /// for export.</param>
        public void DoReportSourceAsync(string filePath,
                                        ICollection <Schedule> schedules,
                                        ICollection <string> extendedFields,
                                        ICollection <Route> routes,
                                        MapLayer mapLayer,
                                        ExportOptions options)
        {
            // create copy all elements (schedules, routes)
            ICollection <Schedule> schedulesCopy = _DoCopy(schedules);

            ICollection <Route> routesCopy = null;

            if (null != routes)
            {   // need select routes from selected schedule
                Debug.Assert(1 == schedulesCopy.Count);
                Schedule schedule = schedulesCopy.First();

                routesCopy = _GetScheduleRoutes(schedule, routes);
            }

            // start export
            _DoReportSource(filePath, extendedFields, schedulesCopy, routesCopy, mapLayer, options, true);
        }
Exemple #2
0
            /// <summary>
            /// Creates and init a new instance of the <c>ExportDescriptionProvider</c> class.
            /// </summary>
            /// <param name="filePath">Path to Access database file where data will be exported.</param>
            /// <param name="type">Export type.</param>
            /// <param name="tables">Table definitions.</param>
            /// <param name="schedules">Collection of schedules to export.</param>
            /// <param name="routes">Collection of routes from <c>schedules</c> to export
            /// (can be null).</param>
            /// <param name="mapLayer"><see cref="P:ESRI.ArcLogistics.MapLayer" /> that has to be
            /// used for images generation (can be null if not needed).</param>
            /// <param name="options"><see cref="P:ESRI.ArcLogistics.Export.ExportOptions" /> that has to be
            /// used for export.</param>
            public ExportSettings(string filePath,
                                  ExportType type,
                                  ICollection <ITableDefinition> tables,
                                  ICollection <Schedule> schedules,
                                  ICollection <Route> routes,
                                  MapLayer mapLayer,
                                  ExportOptions options)
            {
                // check input values
                if (string.IsNullOrEmpty(filePath))
                {
                    throw new ArgumentNullException("filePath"); // exception
                }
                if (null == tables)
                {
                    throw new ArgumentNullException("tables"); // exception
                }
                if (null == schedules)
                {
                    throw new ArgumentNullException("schedules"); // exception
                }
                if (null == options)
                {
                    throw new ArgumentNullException("options"); // exception
                }
                // routes and mapLayer - can be null

                // init internal state
                FilePath  = filePath;
                Type      = type;
                Tables    = tables;
                Schedules = schedules;
                Routes    = routes;
                MapLayer  = mapLayer;
                Options   = options;
            }
        /// <summary>
        /// Creates reports for all routes in selected scdedules (Asynchronous).
        /// </summary>
        /// <param name="reportInfos">Report template info to creation.</param>
        /// <param name="schedules">Schedules for data reports.</param>
        /// <param name="routes">Selected routes from schedule (can be null).</param>
        /// <returns>List of created reports.</returns>
        /// <remarks>Routes must belong to the <c>schedule</c>. If <c>routes</c> collection
        /// is empty, Generator will use all the routes from the <c>schedules</c>.</remarks>
        public void CreateReportsAsync(IDictionary<string, ReportInfo> reportInfos,
                                       ICollection<Schedule> schedules,
                                       ICollection<Route> routes)
        {
            Debug.Assert(null != reportInfos);
            Debug.Assert(null != schedules);

            Debug.Assert(null == _reportInfos);
            Debug.Assert(string.IsNullOrEmpty(_sourceFileName));

            Debug.Assert(null != _exporter);
            Debug.Assert(null != reportInfos);
            Debug.Assert(null != schedules);

            ICollection<string> extendedFields = GetReportsExtendedFields(reportInfos.Values);

            // store state
            _reportInfos = reportInfos;
            _sourceFileName = _PrepareSourceFilePath();

            _exporter.AsyncExportCompleted +=
                new AsyncExportCompletedEventHandler(_exporter_AsyncExportCompleted);

            try
            {
                ExportOptions options = new ExportOptions();
                options.ShowLeadingStemTime = App.Current.MapDisplay.ShowLeadingStemTime;
                options.ShowTrailingStemTime = App.Current.MapDisplay.ShowTrailingStemTime;

                // start process
                _exporter.DoReportSourceAsync(_sourceFileName,
                                              schedules,
                                              extendedFields,
                                              routes,
                                              CommonHelpers.GetCurrentLayer(),
                                              options);
            }
            catch
            {
                _ClearState();

                throw;
            }
        }
        /// <summary>
        /// Starts export process.
        /// </summary>
        /// <param name="profile">Ecport profile.</param>
        /// <param name="schedules">Schedules to export.</param>
        private void _DoExport(Profile profile, ICollection<Schedule> schedules)
        {
            Debug.Assert(null != profile);
            Debug.Assert(null != schedules);

            try
            {
                App.Current.UIManager.Lock(true);

                _InitStatusStack();

                Exporter exporter = App.Current.Exporter;
                exporter.AsyncExportCompleted +=
                    new AsyncExportCompletedEventHandler(exporter_AsyncExportCompleted);

                ExportOptions options = new ExportOptions();
                options.ShowLeadingStemTime = App.Current.MapDisplay.ShowLeadingStemTime;
                options.ShowTrailingStemTime = App.Current.MapDisplay.ShowTrailingStemTime;

                MapLayer currentMapLayer = CommonHelpers.GetCurrentLayer();
                exporter.DoExportAsync(profile, schedules, currentMapLayer, options);
            }
            catch (Exception ex)
            {
                _PopulateReportError(ex);

                string statusMessage = App.Current.GetString("ExportMessageFormatFailed",
                                                             _GetTypeFaceName(profile.Type),
                                                             profile.FilePath);
                App.Current.MainWindow.StatusBar.SetStatus(this, statusMessage);
                App.Current.UIManager.Unlock();
            }
        }