Example #1
0
        private void _DoExport(Profile profile, ICollection <Schedule> exportedSchedule)
        {
            string statusMessage = (string)App.Current.FindResource("ExportStartMessage");

            WorkingStatusHelper.SetBusy(statusMessage);

            try
            {
                MapLayer currentMapLayer = null;
                foreach (MapLayer layer in App.Current.Map.Layers)
                {
                    if (layer.IsVisible && layer.IsBaseMap)
                    {
                        currentMapLayer = layer;
                        break;
                    }
                }

                App.Current.Exporter.DoExport(profile, exportedSchedule, currentMapLayer);

                string format = (string)App.Current.FindResource("ExportMessageFormatSucceded");
                statusMessage = string.Format(format, ExportProfilesEditPage.GetTypeFaceName(profile.Type), profile.FilePath);
                App.Current.Messenger.AddInfo(statusMessage);
            }
            catch (Exception ex)
            {
                string format = (string)App.Current.FindResource("ExportMessageFormatFailed");
                statusMessage = string.Format(format, ExportProfilesEditPage.GetTypeFaceName(profile.Type), profile.FilePath);

                if (ex is AuthenticationException || ex is CommunicationException)
                {
                    string service = (string)App.Current.FindResource("ServiceNameMap");
                    CommonHelpers.AddServiceMessageWithDetail(statusMessage, service, ex);
                    Logger.Error(ex);
                }
                else
                {
                    string message = string.Format("{0} {1}", statusMessage, ex.Message);
                    App.Current.Messenger.AddError(message);
                    Logger.Critical(ex);
                }
            }

            WorkingStatusHelper.SetReleased();
            App.Current.MainWindow.StatusBar.SetStatus(this, statusMessage);
        }