/// <summary>
        /// Runs report core to real report creation (call after <c>CreateReportsAsync</c>).
        /// </summary>
        /// <param name="description">Created report description.</param>
        public void RunReport(ReportStateDescription description)
        {
            Debug.Assert(null != description);
            Debug.Assert(null == description.Report);

            using (WorkingStatusHelper.EnterBusyState(null))
            {
                try
                {
                    // load report structure
                    var rpt = _LoadReportStructure(description.ReportInfo.TemplatePath);

                    // update connection string
                    var ds = (DataDynamics.ActiveReports.DataSources.OleDBDataSource)rpt.DataSource;
                    ds.ConnectionString = _UpdateConnectionString(description.SourceFilePath,
                                                                  ds.ConnectionString);
                    string connectionString = ds.ConnectionString;

                    // set sub reports
                    Section section = rpt.Sections[REPORT_SECTION_NAME_DETAIL];
                    _InitSubReports(description.ReportInfo.SubReports, connectionString, section);

                    // run report building
                    rpt.Document.Name = description.ReportName;
                    rpt.Run();

                    description.Report = rpt;

                    GC.Collect();
                    GC.WaitForFullGCApproach();
                }
                catch
                {
                    DisposeReport(description);

                    throw; // exception
                }
            }
        }
        /// <summary>
        /// Executes command.
        /// </summary>
        /// <param name="args">Arguments passed to the command.</param>
        public void Execute(params object[] args)
        {
            Debug.Assert(this.IsEnabled);

            try
            {
                using (WorkingStatusHelper.EnterBusyState(_executionStatusMessage))
                {
                    if (_RoutesMustBeSent())
                    {
                        _sendRoutesTask.Execute();
                        _UpdateState();
                    }
                }
            }
            catch (Exception e)
            {
                var handler = _application.WorkflowManagementExceptionHandler;
                if (!handler.HandleException(e))
                {
                    throw;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Deletes mobile devices
        /// </summary>
        protected override void _Delete(IList <MobileDevice> selectedObjects)
        {
            Debug.Assert(selectedObjects != null);

            var deletionChecker = _Application.Project.DeletionCheckingService;

            var device = deletionChecker.QueryAssignedToDriver(selectedObjects)
                         .FirstOrDefault();

            if (device != null)
            {
                var message = _Application.GetString(ASSIGNED_TO_DRIVER_KEY, device);
                _Application.Messenger.AddError(message);

                return;
            }

            device = deletionChecker.QueryAssignedToVehicle(selectedObjects)
                     .FirstOrDefault();
            if (device != null)
            {
                var message = _Application.GetString(ASSIGNED_TO_VEHICLE_KEY, device);
                _Application.Messenger.AddError(message);

                return;
            }

            try
            {
                // cast to an array to detach enumerable from selected objects collection.
                var delettees = selectedObjects.ToArray();

                var busyMessage = _Application.FindString(COMMAND_EXECUTING_STATUS_NAME);
                using (WorkingStatusHelper.EnterBusyState(busyMessage))
                {
                    // Delete devices from the project.
                    var project = _Application.Project;
                    foreach (var item in delettees)
                    {
                        project.MobileDevices.Remove(item);
                    }

                    project.Save();

                    // Now we should have less devices locally than on WFMS so they should be
                    // deleted there also.
                    var syncService        = _Application.Tracker.SynchronizationService;
                    var deletedTrackingIds = delettees
                                             .Where(deletedDevice => deletedDevice.SyncType == SyncType.WMServer)
                                             .Select(deletedDevice => deletedDevice.TrackingId);
                    syncService.DeleteDevices(project, deletedTrackingIds);
                }
            }
            catch (Exception e)
            {
                if (!_exceptionHandler.HandleException(e))
                {
                    throw;
                }
            }
        }