예제 #1
0
        /// <summary>
        /// Method checks is any BuildRoutes operation was started in other dates.
        /// </summary>
        /// <returns>True if no any BuildRoutes already started or application settings allows multiple BuildRoutes.</returns>
        /// <param name="info">Out param where method save AsyncOperationInfo with date where BuildRoutes is running.</param>
        private bool _CanBuildRoutesBeStarted(out AsyncOperationInfo outInfo)
        {
            bool canBuildRoutesBeStarted = true;

            // If "key" file allows multiple build routes - return "true".
            if (_isKeyToAllowMultipleBuildRoutesExist)
            {
                outInfo = null;
                return(true);
            }

            bool allowDisabledExecution = false;
            AsyncOperationInfo info     = null;

            foreach (Guid id in OperationsIds) // Check all running operations.
            {
                App.Current.Solver.GetAsyncOperationInfo(id, out info);
                if (info.OperationType == SolveOperationType.BuildRoutes && info.Schedule.PlannedDate != App.Current.CurrentDate)
                {
                    canBuildRoutesBeStarted = false; // "info" contains date where BuildRoutes is running.
                    allowDisabledExecution  = true;
                    break;
                }
                info = null; // Set out parameter to null if BuildRoutes operation was not found.
            }

            outInfo = info;

            AllowDisabledExecution = allowDisabledExecution;

            return(canBuildRoutesBeStarted);
        }
예제 #2
0
        public async Task FinishAsync(AsyncOperationInfo operationInfo)
        {
            await _partsProviderSupplier.ProvideLastPartAsync();// Provide last piece of data

            _parsingResult = await _parserFuture;
            _rawDumpStream.Dispose();
        }
            public async Task <byte[]> WaitAsync(int count, WaitMode mode, AsyncOperationInfo operationInfo)
            {
                throwIfDisposed();
                _responseReadTimeout.ThrowIfTimeout();
                operationInfo.CancellationToken.ThrowIfCancellationRequested();

                byte[] waitResult = null;
                try
                {
                    using (_waitTimeout.RestartMode)
                    {
                        switch (mode)
                        {
                        case WaitMode.EXACT:
                            var buffer = new List <byte>(count);
                            while (buffer.Count != count)
                            {
                                _responseReadTimeout.ThrowIfTimeout();

                                var result = await _pipe.ReadAsync(new PipeReadParameters(count - buffer.Count), _cancellation);

                                if (result.Status.IsOneOf(IOBase.ReadStatus.DONE, IOBase.ReadStatus.PATIALLY_DONE))
                                {
                                    buffer.AddRange(result.Data);
                                }
                                else
                                {
                                    throw new NotSupportedException();
                                }
                            }
                            waitResult = buffer.ToArray();
                            break;

                        case WaitMode.NO_MORE_THAN:
                        {
                            var result = await _pipe.ReadAsync(new PipeReadParameters(count), _cancellation);

                            if (result.Status.IsOneOf(IOBase.ReadStatus.DONE, IOBase.ReadStatus.PATIALLY_DONE))
                            {
                                waitResult = result.Data.ToArray();
                            }
                            else
                            {
                                throw new NotSupportedException();
                            }
                        }
                        break;

                        default:
                            throw new NotSupportedException();
                        }
                    }

                    return(waitResult);
                }
                finally
                {
                    await Logger.LogResponseAsync(waitResult ?? new byte[0], count);
                }
            }
예제 #4
0
 public override async Task DeactivateDeviceAsync(DeviceOperationScope scope, AsyncOperationInfo cancellation)
 {
     using (await _connectionInterface.LockAsync(cancellation))
     {
         await _base.DeactivateDeviceAsync(scope, cancellation);
     }
 }
예제 #5
0
        /// <summary>
        /// Method gets name of route which contains assigned orders.
        /// </summary>
        /// <param name="info">Operation information.</param>
        /// <returns>Route name.</returns>
        private static string _GetAssignedRouteName(AsyncOperationInfo info)
        {
            Debug.Assert(info != null);

            var inputParameters = (AssignOrdersParams)info.InputParams;
            ICollection <Route> targetRoutes = inputParameters.TargetRoutes;

            string routeName = null;

            if (targetRoutes.Count == 1)
            {
                // In most cases only one route is targeted.
                routeName = string.Format(
                    (string)App.Current.FindResource(OPTION_WITH_QUOTES),
                    targetRoutes.First().Name);
            }
            else
            {
                // Orders assigned to Best Route.
                routeName =
                    (string)App.Current.FindResource(BEST_ROUTES_RESOURCE_NAME);
            }

            return(routeName);
        }
예제 #6
0
        /// <summary>
        /// Method gets route name for assigned order.
        /// </summary>
        /// <param name="info">Operation info.</param>
        /// <param name="order">Assigned order.</param>
        /// <returns>Route name or empty string, in case order is unassigned.</returns>
        private static string _GetRouteNameForAssignedOrder(
            AsyncOperationInfo info, Order order)
        {
            Debug.Assert(info != null);
            Debug.Assert(order != null);

            var inputParameters = (AssignOrdersParams)info.InputParams;
            ICollection <Route> targetRoutes = inputParameters.TargetRoutes;

            // Search for stop associated with order, which was assigned to route.
            var assignedStops =
                from route in targetRoutes
                where route.Stops != null
                from stop in route.Stops
                where (stop.AssociatedObject == order)
                select stop;

            string routeName = string.Empty;

            if (assignedStops.Any())
            {
                Stop stop = assignedStops.First();
                routeName = stop.Route.Name;
            }

            return(routeName);
        }
예제 #7
0
        /// <summary>
        /// Method gets status message: unassign operation completed.
        /// </summary>
        /// <param name="info">Operation information.</param>
        /// <returns>Message.</returns>
        public static string GetUnassignOperationCompletedMessage(AsyncOperationInfo info)
        {
            Debug.Assert(info != null);

            string result = string.Empty;

            var    orders = ((UnassignOrdersParams)info.InputParams).OrdersToUnassign;
            int    unassignedOrdersCount = orders.Count;
            string unassignedOrdersName  =
                (string)App.Current.FindResource(UNASSIGNED_ORDERS_RESOURCE_NAME);

            if (unassignedOrdersCount == 1)
            {
                // Create message for only one unassigned order.
                Order order = orders.First();

                if (order != null)
                {
                    result = string.Format(
                        (string)App.Current.FindResource(ORDER_MOVED),
                        order.Name, unassignedOrdersName);
                }
            }
            else
            {
                // Create message for all unassigned orders.
                result = string.Format(
                    (string)App.Current.FindResource(ALL_ORDERS_MOVED),
                    unassignedOrdersCount, unassignedOrdersName);
            }

            return(result);
        }
예제 #8
0
        /// <summary>
        /// Method gets status message: unassign operation completed,
        /// for multiple unassign operation.
        /// </summary>
        /// <param name="schedule">Schedule where operation proceeded.</param>
        /// <param name="info">Operation information.</param>
        /// <returns>Message.</returns>
        public static string GetMultipleUnassignOperationCompletedMessage(
            Schedule schedule, AsyncOperationInfo info)
        {
            Debug.Assert(schedule != null);
            Debug.Assert(info != null);

            string result = string.Empty;

            var orders = ((UnassignOrdersParams)info.InputParams).OrdersToUnassign;
            int unassignedOrdersCount = orders.Count;

            if (unassignedOrdersCount == 1)
            {
                // Create message for only one unassigned order.
                Order order = orders.First();

                if (order != null)
                {
                    result = string.Format(
                        (string)App.Current.FindResource(ORDER_UNASSIGNED_FROM_SCHEDULES),
                        order.Name, schedule.Name);
                }
            }
            else
            {
                // Create message for all unassigned orders.
                result = string.Format(
                    (string)App.Current.FindResource(ORDERS_UNASSIGNED_FROM_SCHEDULES),
                    unassignedOrdersCount, schedule.Name);
            }

            return(result);
        }
        protected void Cmd_AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e)
        {
            // check is completed operation was started by this command
            if (OperationsIds.Contains(e.OperationId))
            {
                _operationsIds.Remove(e.OperationId);
                AsyncOperationInfo info     = null;
                Schedule           schedule = null;
                if (App.Current.Solver.GetAsyncOperationInfo(e.OperationId, out info))
                {
                    schedule = info.Schedule;
                }

                IsEnabled = true;

                if (e.Cancelled)
                {
                    App.Current.Messenger.AddInfo(_FormatCancelMsg(schedule));
                }
                else if (e.Error != null)
                {
                    _HandleSolveError(e.Error);
                }
                else
                {
                    SolveResult res = e.Result;
                    if (schedule != null)
                    {
                        _SaveSchedule(res, schedule, info);
                    }
                }
            }
        }
예제 #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="from"></param>
        /// <param name="count"></param>
        /// <param name="operationInfo"></param>
        /// <returns></returns>
        public async Task <IPointsRow[]> GetDecimatedRangeAsync(int from, int count, AsyncOperationInfo operationInfo)
        {
#warning what if underlying collection is not thread safe? Or it decreases its size?!
            await ThreadingUtils.ContinueAtThreadPull(operationInfo);

            IPointsRow[] result;
            if (count > _maxRowsCount) // Decimation required
            {
                var coefficient = (double)count / _maxRowsCount;
                var sourceRows  = _maxRowsCount
                                  .Range()
                                  .AsParallel()
                                  .AsOrdered()
                                  .Select(i => (i * coefficient + from).Round())
                                  .Where(i => i < Source.RowsCount) // To handle possible rounding error
                                  .ToArray();
                return(await Source.ReadRowsAsync(from, sourceRows, operationInfo));
            }
            else
            {
                result = await Source.ReadRowsAsync(from, count, operationInfo);
            }

            return(result);
        }
예제 #11
0
        public async Task <byte[]> WaitAsync(int count, WaitMode waitMode, AsyncOperationInfo operationInfo)
        {
            var notYetReadBytes = _array.Count - _position;

            switch (waitMode)
            {
            case WaitMode.EXACT:
                if (notYetReadBytes < count)
                {
                    throw new TimeoutException();
                }
                else
                {
                    _position += count;

                    return(await _array.GetRangeAsync(_position - count, count, operationInfo));
                }

            case WaitMode.NO_MORE_THAN:
                var dataToRead = (int)Math.Min(notYetReadBytes, count);
                _position += dataToRead;

                return(await _array.GetRangeAsync(_position - dataToRead, dataToRead, operationInfo));

            default:
                throw new NotSupportedException();
            }
        }
예제 #12
0
        public async Task <byte[]> WaitAsync(int count, WaitMode waitMode, AsyncOperationInfo operationInfo)
        {
            var maxCount = _response.Count - _position;

            switch (waitMode)
            {
            case WaitMode.EXACT:
                if (maxCount < count)
                {
                    throw new TimeoutException();
                }
                else
                {
                    var result = _response.GetRange(_position, count).ToArray();
                    _position += count;

                    return(result);
                }

            case WaitMode.NO_MORE_THAN:
                var msxAvailableBytes = Math.Min(maxCount, _position + count) - _position;
                var bytesToRead       = Math.Min(count, msxAvailableBytes);
                _position += bytesToRead;
                return(_response.GetRange(_position, bytesToRead).ToArray());

            default:
                throw new NotSupportedException();
            }
        }
예제 #13
0
        async Task <Stream> openStream(Part part, StreamParameters parameters, AsyncOperationInfo operationInfo)
        {
            var baseStream = new FileStream(_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, parameters.ReadBufferSize);

            baseStream.Position = part.Position;
            return(new SectionedStreamProxy(baseStream, part.Length));
        }
예제 #14
0
        public override async Task <byte[]> WaitAsync(int count, WaitMode mode, AsyncOperationInfo operationInfo)
        {
            var data = await base.WaitAsync(count, mode, operationInfo);

            Storage.AddRange(data);

            return(data);
        }
        /// <summary>
        /// Handle contains logic to save changes, start new operation or process errors when solve conpleted.
        /// </summary>
        /// <param name="sender">Solver.</param>
        /// <param name="e">Solve completed event args.</param>
        private void Solver_AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e)
        {
            // If event came from any else solve operation - exit.
            if (e.OperationId != _currentOperationId)
            {
                return;
            }

            AsyncOperationInfo info = null;

            App.Current.Solver.GetAsyncOperationInfo(e.OperationId, out info); // Get operation info.

            // If operation complete successful.
            if (e.Error == null && !e.Cancelled && !e.Result.IsFailed)
            {
                Schedule changedSchedule = info.Schedule;
                _ProcessSaveSchedule(changedSchedule, info);                                           // Save edited schedule.
                _SetScheduleProcessed(changedSchedule);                                                // Set schedule Processed to "true".
                App.Current.Messenger.AddInfo(_FormatSuccessSolveCompletedMsg(changedSchedule, info)); // Add info message.
                _NotifyScheduleChanged(changedSchedule);

                UnassignScheduleInfo nextInfo = null;

                if (_GetNextScheduleToUnassign(out nextInfo))
                {
                    _StartNextScheduleUnassigning(nextInfo);
                    return;
                }

                _ProcessOrders(_args); // Call abstract method _ProcessOrders overrided in child command (to move orders to other date or delete them).
            }
            else if (e.Error != null)  // If Error occured during operation.
            {
                Logger.Error(e.Error);
                CommonHelpers.AddRoutingErrorMessage(e.Error);

                if (e.Result != null) // Result is "null" when connection failed.
                {
                    // Create violations collection.
                    ICollection <MessageDetail> details = _GetErrorFailedDetails(info, e.Result);
                    _ShowFailedMessage(e.Error, info.Schedule, details); // Show failed message.
                }
            }
            else if (e.Cancelled) // If operation was cancelled.
            {
                App.Current.Messenger.AddInfo(_FormatCancelMsg(info.Schedule));
            }
            else if (e.Result.IsFailed) // If operation's failed.
            {
                // Create violations collection.
                ICollection <MessageDetail> details = _GetErrorFailedDetails(info, e.Result);
                _ShowFailedMessage(e.Error, info.Schedule, details);
            }

            _UpdateOptimizeAndEditPageSchedules();  // Update optimize and edit page content.
            _CleanUp();
            _UnlockUI();
        }
예제 #16
0
 public Task SaveAsync(RUSDeviceId deviceId,
                       IDictionary <RUSDeviceId, IEnumerable <IDataEntity> > dataPacketFormats,
                       Stream rawDump,
                       Stream uncompressedParsedData,
                       Stream destination,
                       AsyncOperationInfo operationInfo)
 {
     return(FlashDump.SaveAsync(deviceId, dataPacketFormats, rawDump, uncompressedParsedData, destination, operationInfo));
 }
예제 #17
0
        public async Task DeactivateDeviceAsync(DeviceOperationScope scope, AsyncOperationInfo cancellation)
        {
            Logger.LogInfo(null, $"Деактивация устройства \"{Name}\"...");

            using (Logger.Indent)
            {
                await deactivateDeviceAsync(scope, cancellation);

                Logger.LogOK(null, $"Устройство \"{Name}\" деактивировано");
            }
        }
예제 #18
0
 public override async Task DeactivateDeviceAsync(DeviceOperationScope scope, AsyncOperationInfo cancellation)
 {
     try
     {
         await _base.DeactivateDeviceAsync(scope, cancellation);
     }
     catch (OperationCanceledException) { throw; }
     catch (Exception ex)
     {
         Logger.LogErrorEverywhere("Ошибка деактивации устройства", ex);
     }
 }
        /// <summary>
        /// Method saves schedule
        /// </summary>
        private void _ProcessSaveSchedule(Schedule schedule, AsyncOperationInfo info)
        {
            // set unassigned orders
            if (null != schedule.UnassignedOrders)
            {
                schedule.UnassignedOrders.Dispose();
            }
            schedule.UnassignedOrders = App.Current.Project.Orders.SearchUnassignedOrders(schedule, true);

            // save results
            App.Current.Project.Save();
        }
예제 #20
0
        public FlashDumpLoadVM(RUSDeviceId rusDevice, BusyObject isBusy)
        {
            IsBusy = isBusy;

            DataStorageVM = new FlashDataStorageVM(this);
            Load          = new ActionCommand(loadAsync, IsBusy);
            Cancel        = new ActionCommand(cancelAsync, () => _currentOperation != null, IsBusy);

            async Task loadAsync()
            {
                using (IsBusy.BusyMode)
                {
                    var path = IOUtils.RequestFileOpenPath("BIN (*.bin)|*.bin");
                    if (path == null)
                    {
                        return;
                    }

                    try
                    {
                        _currentOperation     = new AsyncOperationInfo().UseInternalCancellationSource();
                        _currentOperationTask = LoadAsync(path, _currentOperation);
                        Cancel.Update();
                        await _currentOperationTask;

                        Logger.LogOKEverywhere("Дамп Flash успешно загружен");
                    }
                    catch (OperationCanceledException)
                    {
                        Logger.LogInfoEverywhere("Чтение дампа Flash отменено");

                        PointsSource = null;
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError("Ошибка загрузки дампа", $"-MSG", ex);

                        PointsSource = null;
                    }
                    finally
                    {
                        _currentOperationTask = null;
                        _currentOperation     = null;
                    }
                }
            }

            async Task cancelAsync()
            {
                _currentOperation?.Cancel();
            }
        }
        /// <summary>
        /// Method gets details messages about successfully assigned orders during
        /// routing operation. Details message are expanded by route names.
        /// </summary>
        /// <param name="schedule">Schedule.</param>
        /// <param name="info">Operation info.</param>
        /// <returns>Collection of message details.</returns>
        private ICollection <MessageDetail> _GetSuccessfullyAssignedOrdersDetails(
            Schedule schedule, AsyncOperationInfo info)
        {
            var routedOrdersDetails            = new Collection <MessageDetail>();
            ICollection <Order> ordersToAssign = _GetOrdersToAssign(info);

            if (ordersToAssign == null)
            {
                return(routedOrdersDetails);
            }

            // Find all pairs Route & Order.
            var detailsPairs = new List <KeyValuePair <Route, Order> >();

            foreach (Order order in ordersToAssign)
            {
                foreach (Route route in schedule.Routes)
                {
                    foreach (Stop stop in route.Stops)
                    {
                        if (stop.AssociatedObject is Order &&
                            ((Order)stop.AssociatedObject).Equals(order))
                        {
                            var pair = new KeyValuePair <Route, Order>(
                                route, order);

                            detailsPairs.Add(pair);
                        }
                    }
                }
            }

            string formatString =
                (string)App.Current.FindResource(ORDERS_SUCCESSFULLY_ASSIGNED);

            // Add messages expanded by Routes.
            foreach (Route route in schedule.Routes)
            {
                foreach (KeyValuePair <Route, Order> pair in detailsPairs)
                {
                    if (pair.Key.Name == route.Name)
                    {
                        DataObject[]  parameters = new DataObject[] { pair.Value, pair.Key };
                        MessageDetail detail     = new MessageDetail(MessageType.Information,
                                                                     formatString, parameters);
                        routedOrdersDetails.Add(detail);
                    }
                }
            }

            return(routedOrdersDetails);
        }
        public override async Task <byte[]> WaitAsync(int count, WaitMode waitMode, AsyncOperationInfo operationInfo)
        {
            var result = await base.WaitAsync(count, waitMode, operationInfo);

            ReadCount += result.Length;
            var bytesToStore = Math.Min(Capacity - (ReadCount - result.Length), result.Length).NegativeToZero().ToInt32();

            if (bytesToStore != 0)
            {
                _storage.Add(result.Take(bytesToStore));
                StorageCount += bytesToStore;
            }

            return(result);
        }
예제 #23
0
        /// <summary>
        /// Occurs when solve operation completed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnAsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e)
        {
            AsyncOperationInfo info     = null;
            Schedule           schedule = null;

            if (App.Current.Solver.GetAsyncOperationInfo(e.OperationId, out info))
            {
                schedule = info.Schedule;
            }

            if (schedule != null && !_pendingDatesToUpdate.Contains((DateTime)schedule.PlannedDate))
            {
                _pendingDatesToUpdate.Add((DateTime)schedule.PlannedDate);
                _optimizeAndEditPage.Dispatcher.BeginInvoke(new DayStatusDelegate(_UpdateDayStatus), System.Windows.Threading.DispatcherPriority.Send);
            }
        }
예제 #24
0
        private void _AsyncSolveCompleted(object sender, AsyncSolveCompletedEventArgs e)
        {
            Schedule           schedule = null;
            AsyncOperationInfo info     = null;

            if (App.Current.Solver.GetAsyncOperationInfo(e.OperationId, out info))
            {
                schedule = info.Schedule;
            }

            if (!IsEnabled)
            {
                IsEnabled = ((null == _schedulePage.CurrentSchedule) ||
                             (schedule.PlannedDate == _schedulePage.CurrentSchedule.PlannedDate));
            }
        }
예제 #25
0
        public static ICollection <Route> GetRoutingCommandRoutes(Schedule schedule, AsyncOperationInfo info)
        {
            ICollection <Route> routes = null;

            switch (info.OperationType)
            {
            case SolveOperationType.BuildRoutes:
                routes = GetBuildRoutes(schedule);
                break;

            case SolveOperationType.SequenceRoutes:
            {
                Debug.Assert(null != info.InputParams);
                SequenceRoutesParams param = info.InputParams as SequenceRoutesParams;
                routes = param.RoutesToSequence;
                break;
            }

            case SolveOperationType.UnassignOrders:
            {
                UnassignOrdersParams param = info.InputParams as UnassignOrdersParams;
                routes = ViolationsHelper.GetRouteForUnassignOrders(schedule, param.OrdersToUnassign);
                break;
            }

            case SolveOperationType.AssignOrders:
            {
                AssignOrdersParams param = info.InputParams as AssignOrdersParams;
                routes = param.TargetRoutes;
                break;
            }

            case SolveOperationType.GenerateDirections:
            {
                GenDirectionsParams param = info.InputParams as GenDirectionsParams;
                routes = param.Routes;
                break;
            }

            default:
                Debug.Assert(false);     // NOTE: not supported
                break;
            }

            return(routes);
        }
예제 #26
0
        /// <summary>
        /// Method check is command enabled.
        /// </summary>
        private void _CheckEnabled()
        {
            Schedule schedule  = _optimizeAndEditPage.CurrentSchedule;
            bool     hasOrders = ((schedule != null) && (schedule.UnassignedOrders != null) &&
                                  ((schedule.UnassignedOrders.Count > 0) || ScheduleHelper.DoesScheduleHaveBuiltRoutes(schedule)));

            AsyncOperationInfo info = null;

            bool canBuildRoutesBeStarted = _CanBuildRoutesBeStarted(out info);

            bool isPageStateAllowRouting = (hasOrders && (schedule.Routes.Count > 0) &&
                                            !_optimizeAndEditPage.IsEditingInProgress && !_optimizeAndEditPage.IsLocked && !_DoesAllRoutesLocked());

            // AllowDisabledExecution should be "false" if editing in progress.
            AllowDisabledExecution = isPageStateAllowRouting;

            IsEnabled = (isPageStateAllowRouting && canBuildRoutesBeStarted);
        }
        /// <summary>
        /// Method returns collection of violation message details.
        /// </summary>
        /// <param name="schedule">Schedule to be checked.</param>
        /// <param name="info">Solver's asyncrone operation info.</param>
        /// <param name="violations">Founded violations.</param>
        /// <returns>Message detail with description for violations.</returns>
        public static ICollection <MessageDetail> GetViolationDetails(Schedule schedule,
                                                                      AsyncOperationInfo info,
                                                                      ICollection <Violation> violations)
        {
            Debug.Assert(null != schedule);
            Debug.Assert(0 < violations.Count);

            // special case
            bool  isSpecialCase = false;
            Order orderToAssign = null;

            if (SolveOperationType.AssignOrders == info.OperationType)
            {
                AssignOrdersParams param = (AssignOrdersParams)info.InputParams;
                if (null != param.TargetSequence)
                {
                    isSpecialCase = param.TargetSequence.HasValue;
                }

                if (isSpecialCase)
                {
                    Debug.Assert(1 == param.OrdersToAssign.Count);
                    orderToAssign = param.OrdersToAssign.First();
                }
            }

            ICollection <MessageDetail> details = null;

            if (!isSpecialCase && _IsRouteRelatedViolationPresent(violations))
            {
                details = _GetRouteViolationDetails(violations);
            }
            else
            {
                ICollection <Route> routes = ViolationsHelper.GetRoutingCommandRoutes(schedule, info);
                Debug.Assert((null != routes) && (0 < routes.Count));

                details = _GetViolationDetails(routes, isSpecialCase, orderToAssign, violations);
            }

            return(details);
        }
예제 #28
0
        public async Task LoadAsync(string dumpPath, AsyncOperationInfo operationInfo)
        {
            if (dumpPath != null)
            {
                await NetFrameworkUtils.ContinueAtUIThread();

                var dump = await FlashDump.OpenAsync(dumpPath, operationInfo);

                var dataParser = new SectionedDataPacketParser(
                    dump.DataRowDescriptors.Select(ds => new SectionedDataPacketParser.Section(
                                                       ds.Key,
                                                       new DataPacketParser(ds.Value))).ToArray());
                var dumpReader = await FlashDumpDataParser.CreateParserAsync(dump, dataParser, operationInfo);

                var rowsReader = await dumpReader.InstantiateReaderAsync(operationInfo);

                var rowsCollection = new FileMappedPointsRowsReadOnlyCollection(rowsReader);
                PointsSource = new DataPointsSource(new EnhancedObservableCollection <ICurveInfo>(dataParser.Curves, new CollectionOptions(true)), rowsCollection);
            }
        }
        /// <summary>
        /// Method shows that Order was assigned to that Route
        /// in message window.
        /// </summary>
        /// <param name="schedule">Schedule.</param>
        /// <param name="info">Operation info.</param>
        protected void _ShowSuccessfullyAssignedOrders(Schedule schedule, AsyncOperationInfo info)
        {
            var assignOrdersDetails =
                _GetSuccessfullyAssignedOrdersDetails(schedule, info);

            // Add success details only in case of more than 1 orders assigned,
            // otherwise head message is good enough.
            if (assignOrdersDetails.Count > 1)
            {
                App.Current.Messenger.AddInfo(
                    _FormatSuccessSolveCompletedMsg(schedule, info),
                    assignOrdersDetails);
            }
            else
            {
                assignOrdersDetails.Clear();
                App.Current.Messenger.AddInfo(
                    _FormatSuccessSolveCompletedMsg(schedule, info),
                    assignOrdersDetails);
            }
        }
예제 #30
0
        public async static Task <FlashStreamReader> CreateAsync(RUSDeviceId device,
                                                                 IDictionary <RUSDeviceId, IEnumerable <IDataEntity> > formats,
                                                                 IFlashDumpDataParserFactory parserFactory,
                                                                 AsyncOperationInfo operationInfo)
        {
            var flashDumpPath         = Storaging.GetTempFilePath();
            var baseStream            = new FileStream(flashDumpPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);
            var flashDumpWriteStream  = new FillNotifiableWriteOnlyStreamDecorator(CHUNK_SIZE, baseStream);
            var partsProvider         = new DumpParserPartsProvider(flashDumpPath);
            var partsProviderSupplier = new StreamPartsProviderSupplier(flashDumpWriteStream, partsProvider);
            var scope    = new DeviceOperationScope(new FlashDumpStreamParameter(flashDumpWriteStream));
            var sections = formats.Select(f =>
                                          new SectionedDataPacketParser.Section(
                                              f.Key,
                                              new DataPacketParser(EntitiesDeserializer.ExtractDataPacketDescriptors(f.Value))))
                           .ToArray();
            var dataParser   = new SectionedDataPacketParser(sections);
            var parserFuture = parserFactory.CreateFromRawPartsAsync(partsProvider.RawDumpParts(), dataParser, operationInfo);

            return(new FlashStreamReader(scope, device, formats, parserFuture, partsProviderSupplier, flashDumpWriteStream, flashDumpPath));
        }