コード例 #1
0
        protected override void Execute(NativeActivityContext context)
        {
            var width         = DialogWidth.Get(context);
            var height        = DialogHeight.Get(context);
            var placeFilter   = PlaceFilter.Get(context);
            var operationCode = OperationCode.Get(context);
            var place         = InvoicePlace.Get(context);
            var obj           = (IWBPosInputWithPlaceListViewModel)IoC.Instance.Resolve(typeof(IWBPosInputWithPlaceListViewModel));
            var mandantId     = MandantID.Get(context);

            obj.PrintTE       = CheckPrintTE(mandantId);
            obj.PlaceFilter   = placeFilter;
            obj.OperationCode = operationCode;
            obj.MandantId     = mandantId;
            var isMigration = IsMigration.Get(context);

            obj.IsMigration = isMigration;

            obj.BatchcodeWorkflowCode   = BatchcodeWorkflowCode.Get(context);
            obj.SkuChangeMpWorkflowCode = SkuChangeMpWorkflowCode.Get(context);

            var model = obj as ICustomListViewModel <IWBPosInput>;

            if (model == null)
            {
                throw new DeveloperException("ViewModel doesn't implement ICustomListViewModel.");
            }
            model.PanelCaption = Title;
            var source = Source.Get(context).Select(p => new IwbPosInputErrorInfo(p)
            {
                IsSelected = false
            });

            model.SetSource(new ObservableCollection <IWBPosInput>(source));
            obj.CurrentPlace = place;
            var viewService = IoC.Instance.Resolve <IViewService>();

            if (viewService.ShowDialogWindow(model, true, false, width, height) == true)
            {
                var result = model.GetSource() as IEnumerable <IWBPosInput>;
                if (result == null)
                {
                    throw new DeveloperException("Source type is not IEnumerable.");
                }

                if (obj.SelectedItems != null && obj.SelectedItems.Any())
                {
                    // пометим выбранные записи
                    foreach (var r in result)
                    {
                        r.IsSelected = obj.SelectedItems.Contains(r);
                    }
                }

                Result.Set(context, result.ToArray());
                InvoicePlace.Set(context, obj.SelectedPlace);
                DialogResult.Set(context, true);
            }
            else
            {
                DialogResult.Set(context, false);
            }
            PrintTE.Set(context, ((IWBPosInputWithPlaceListViewModel)model).PrintTE);
            var disposable = model as IDisposable;

            if (disposable != null)
            {
                disposable.Dispose();
            }
        }
コード例 #2
0
        protected override void Execute(NativeActivityContext context)
        {
            var width         = DialogWidth.Get(context);
            var height        = DialogHeight.Get(context);
            var placeFilter   = PlaceFilter.Get(context);
            var operationCode = OperationCode.Get(context);
            var place         = InvoicePlace.Get(context);
            var iwb           = IWB.Get(context);
            var mandantId     = MandantID.Get(context);

            using (var viewModel = (AcceptanceViewModel)IoC.Instance.Resolve(typeof(AcceptanceViewModel)))
            {
                viewModel.PrintTE                 = CheckPrintTE(mandantId);
                viewModel.PlaceFilter             = placeFilter;
                viewModel.OperationCode           = operationCode;
                viewModel.MandantId               = mandantId;
                viewModel.CurrentIWB              = iwb;
                viewModel.IsMigration             = IsMigration.Get(context);
                viewModel.BatchcodeWorkflowCode   = BatchcodeWorkflowCode.Get(context);
                viewModel.SkuChangeMpWorkflowCode = SkuChangeMpWorkflowCode.Get(context);
                viewModel.PanelCaption            = Title;
                viewModel.IsProductsShown         = IsNeedShowProducts.Get(context);
                viewModel.DisplayFieldsFormat     = DisplayFieldsFormat.Get(context);
                if (place != null)
                {
                    viewModel.AcceptancePlace = new EntityReference(place.PlaceCode, Place.EntityType,
                                                                    new[]
                    {
                        new EntityReferenceFieldValue("PlaceCode", place.PlaceCode),
                        new EntityReferenceFieldValue("PlaceName", place.PlaceName)
                    });
                }

                ((IModelHandler)viewModel).SetSource(Source.Get(context));
                var viewService = IoC.Instance.Resolve <IViewService>();
                if (viewService.ShowDialogWindow(viewModel, true, false, width, height, noButtons: true) == true && viewModel.IsAllowAccept == true)
                {
                    if (viewModel.SelectedItems != null && viewModel.SelectedItems.Any())
                    {
                        // пометим выбранные записи
                        foreach (var r in viewModel.Source)
                        {
                            r.IsSelected = viewModel.SelectedItems.Contains(r);
                        }
                    }

                    Result.Set(context, viewModel.Source.Cast <IWBPosInput>().ToArray());

                    var acceptancePlace = GetAcceptancePlace(viewModel);
                    InvoicePlace.Set(context, acceptancePlace);
                    IsNeedShowProducts.Set(context, viewModel.IsProductsShown);
                    DialogResult.Set(context, true);
                }
                else
                {
                    DialogResult.Set(context, false);
                }

                PrintTE.Set(context, viewModel.PrintTE);
            }
        }