protected override void Execute(NativeActivityContext context)
        {
            var width     = DialogWidth.Get(context);
            var height    = DialogHeight.Get(context);
            var modelType = typeof(CustomObjectListViewModelBase <>).MakeGenericType(typeof(T));
            var model     = (ICustomListViewModel <T>)IoC.Instance.Resolve(modelType);
            var detail    = ObjectViewModel.Get(context);

            model.PanelCaption    = Title;
            model.ObjectViewModel = detail;
            var source = Source.Get(context);

            model.SetSource(new ObservableCollection <T>(source));
            ((ICustomDisposable)model).SuspendDispose = true;
            var viewService = IoC.Instance.Resolve <IViewService>();

            if (viewService.ShowDialogWindow((IViewModel)model, true, false, width, height) == true)
            {
                var result = model.GetSource() as IEnumerable <T>;
                if (result == null)
                {
                    throw new DeveloperException("Source type is not IEnumarable");
                }
                Result.Set(context, result.ToArray());
                ((ICustomDisposable)model).SuspendDispose = false;
                ((IDisposable)model).Dispose();
                DialogResult.Set(context, true);
            }
            else
            {
                DialogResult.Set(context, false);
            }
            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 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();
            }
        }
        protected override void Execute(NativeActivityContext context)
        {
            var width              = DialogWidth.Get(context);
            var height             = DialogHeight.Get(context);
            var model              = Model.Get(context);
            var panelViewModelBase = model as PanelViewModelBase;

            if (panelViewModelBase != null)
            {
                panelViewModelBase.PanelCaption = Title.Get(context);
            }

            var customModelHandler = model as ICustomModelHandler;

            if (customModelHandler != null)
            {
                if (Layout != null)
                {
                    customModelHandler.LayoutValue = Layout.Get(context);
                    if (InsertFromAvailableItems != null)
                    {
                        customModelHandler.InsertFromAvailableItems = InsertFromAvailableItems.Get(context);
                    }
                }

                customModelHandler.CreateCustomMenu();
            }

            var viewService = IoC.Instance.Resolve <IViewService>();
            var iObj        = model as IViewModel;

            if (iObj == null)
            {
                throw new DeveloperException("Model is not IViewModel.");
            }

            var  required     = true;
            bool?dialogresult = true;

            while (required && dialogresult == true)
            {
                dialogresult = viewService.ShowDialogWindow(iObj, !DoNotLoadSettings, true, width, height, NoButtons, Buttons);
                if (dialogresult != true)
                {
                    break;
                }
                var exModel = model as ExpandoObjectViewModelBase;
                if (exModel == null)
                {
                    break;
                }
                required = exModel.Fields.Any(f => f.IsRequired && (exModel[f.Name] == null || string.IsNullOrEmpty(exModel[f.Name].ToString())));
                if (!required)
                {
                    break;
                }
                var requiredFields = string.Join(", ", exModel.Fields.Where(f => f.IsRequired && (exModel[f.Name] == null || string.IsNullOrEmpty(exModel[f.Name].ToString()))).Select(x => x.Caption));
                dialogresult = Equals(viewService.ShowDialog("Ошибка",
                                                             string.Format("Не заполнены обязательные поля: {0}\r\nПовторить ввод?", requiredFields),
                                                             MessageBoxButton.YesNo,
                                                             MessageBoxImage.Error,
                                                             MessageBoxResult.Yes), MessageBoxResult.Yes);
            }

            Model.Set(context, model);
            DialogResult.Set(context, dialogresult == true);
        }
示例#4
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);
            }
        }