/// <summary>
        /// Обновление главного меню. Небезопасный код, т.к. изменяем визуальную состовляющую. При вызове из другого потока необходимо использовать DispatcherHelper.Invoke().
        /// </summary>
        private async void UpdateItems()
        {
            try
            {
                RefreshTileUpdate(true);

                if (!WMSEnvironment.Instance.SessionId.HasValue)
                {
                    throw new Exception("SessionId is null");
                }

                var transportTaskByTypes = await _api.GetAvailableTransportTaskCountAsync(Convert.ToInt32(WMSEnvironment.Instance.SessionId.Value)).ConfigureAwait(false);

                var inCount    = transportTaskByTypes.ContainsKey("IN") ? transportTaskByTypes["IN"] : 0;
                var moveCount  = transportTaskByTypes.ContainsKey("MOVE") ? transportTaskByTypes["MOVE"] : 0;
                var outCount   = transportTaskByTypes.ContainsKey("OUT") ? transportTaskByTypes["OUT"] : 0;
                var totalCount = transportTaskByTypes.Values.Sum();

                TileTTaskInTitle      = inCount > 0 ? inCount.ToString() : string.Empty;
                TileTTaskInBackground =
                    Application.Current.Resources[
                        inCount > 0 ? StyleKeys.TileBackgroundOrangeKey : StyleKeys.TileBackgroundDefaultKey] as Brush;
                TileTTaskOutputTitle      = outCount > 0 ? outCount.ToString() : string.Empty;
                TileTTaskOutputBackground =
                    Application.Current.Resources[
                        outCount > 0 ? StyleKeys.TileBackgroundOrangeKey : StyleKeys.TileBackgroundDefaultKey] as Brush;
                TileTTaskMoveTitle      = moveCount > 0 ? moveCount.ToString() : string.Empty;
                TileTTaskMoveBackground =
                    Application.Current.Resources[
                        moveCount > 0 ? StyleKeys.TileBackgroundOrangeKey : StyleKeys.TileBackgroundDefaultKey] as Brush;
                TileTTaskAllTitle      = totalCount > 0 ? totalCount.ToString() : string.Empty;
                TileTTaskAllBackground =
                    Application.Current.Resources[
                        totalCount > 0 ? StyleKeys.TileBackgroundOrangeKey : StyleKeys.TileBackgroundDefaultKey] as
                    Brush;
            }
            catch (Exception ex)
            {
                if (!ExceptionHandler(ex, Resources.ExceptionResources.TileMenuRefreshError))
                {
                    throw;
                }
            }
            finally
            {
                RefreshTileUpdate(false);
            }
        }
        /// <summary>
        /// Обновление главного меню. Небезопасный код, т.к. изменяем визуальную состовляющую. При вызове из другого потока необходимо использовать DispatcherHelper.Invoke().
        /// </summary>
        private async void UpdateItems()
        {
            try
            {
                RefreshTileUpdate(true);
                //PickingListUpdate();
                //await UpdateItemsAsync();

                if (!WMSEnvironment.Instance.SessionId.HasValue)
                {
                    throw new Exception("SessionId is null");
                }

                var transportTasksByTypeTask = _api.GetAvailableTransportTaskCountAsync(Convert.ToInt32(WMSEnvironment.Instance.SessionId.Value));
                var pickListCountTask        = _api.GetAvailablePickListCountAsync(WMSEnvironment.Instance.TruckCode);

                await Task.WhenAll(transportTasksByTypeTask, pickListCountTask);

                var transportTasksByType = transportTasksByTypeTask.Result;
                var pickListCount        = pickListCountTask.Result;

                var transportTaskCount = transportTasksByType.Values.Sum();
                TileTransportTaskTitle      = transportTaskCount > 0 ? transportTaskCount.ToString() : string.Empty;
                TileTransportTaskBackground = Application.Current.Resources[transportTaskCount > 0
                    ? StyleKeys.TileBackgroundOrangeKey
                    : StyleKeys.TileBackgroundDefaultKey] as Brush;

                TilePickingLisTitle       = pickListCount > 0 ? pickListCount.ToString() : string.Empty;
                TilePickingListBackground = Application.Current.Resources[
                    pickListCount > 0
                        ? StyleKeys.TileBackgroundOrangeKey
                        : StyleKeys.TileBackgroundDefaultKey] as Brush;

                RefreshMandant();
            }
            catch (Exception ex)
            {
                if (!ExceptionHandler(ex, Resources.ExceptionResources.TileMenuRefreshError))
                {
                    throw;
                }
            }
            finally
            {
                RefreshTileUpdate(false);
            }
        }
Beispiel #3
0
 public void GetAvailableTransportTaskCountTest()
 {
     var api = new WmsAPI(_manager);
     var res = api.GetAvailableTransportTaskCountAsync(65792).Result;
 }