Esempio n. 1
0
        public virtual void SaveDialogSettings(IProjectSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            settings[SavedSettingsKeys.DbContextDialogWidthKey] = DialogWidth.ToString(CultureInfo.InvariantCulture);
        }
        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();
            }
        }
Esempio n. 3
0
 public virtual void SaveDialogSettings(IProjectSettings settings)
 {
     settings[SavedSettingsKeys.ConfigDialogWidthKey] = DialogWidth.ToString();
 }
Esempio n. 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 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 void ApplySettings()
    {
        EnsureChildControls();

        if (!StopProcessing)
        {
            // Create controls by actual page mode
            switch (ViewMode)
            {
            case ViewModeEnum.Edit:
            case ViewModeEnum.EditDisabled:
            {
                // Edit mode
                if (DialogWidth > 0)
                {
                    pnlEditor.Style.Add(HtmlTextWriterStyle.Width, DialogWidth.ToString() + "px;");
                }

                // Display the region control based on the region type
                switch (RegionType)
                {
                case CMSEditableRegionTypeEnum.HtmlEditor:
                    // HTML Editor
                    if (IsDialogEdit)
                    {
                        htmlValue.Width           = new Unit(100, UnitType.Percentage);
                        htmlValue.Height          = new Unit(100, UnitType.Percentage);
                        htmlValue.ToolbarLocation = "out:CKToolbar";
                        htmlValue.Title           = Title;

                        // Maximize editor to fill entire dialog
                        htmlValue.RemoveButtons.Add("Maximize");

                        if (!DeviceContext.CurrentDevice.IsMobile)
                        {
                            // Desktop browsers
                            htmlValue.Config["on"] = "{ 'instanceReady' : function(e) { e.editor.execCommand( 'maximize' ); } }";
                        }
                    }
                    else
                    {
                        if (DialogWidth > 0)
                        {
                            htmlValue.Width = new Unit(DialogWidth);
                        }
                        if (DialogHeight > 0)
                        {
                            htmlValue.Height = new Unit(DialogHeight);
                        }
                    }

                    // Set toolbar location
                    if (HtmlAreaToolbarLocation != "")
                    {
                        // Show the toolbar
                        if (HtmlAreaToolbarLocation.ToLowerCSafe() == "out:cktoolbar")
                        {
                            mShowToolbar = true;
                        }

                        htmlValue.ToolbarLocation = HtmlAreaToolbarLocation;
                    }

                    // Set the visual appearance
                    if (HtmlAreaToolbar != "")
                    {
                        htmlValue.ToolbarSet = HtmlAreaToolbar;
                    }

                    // Get editor area css file
                    if (HTMLEditorCssStylesheet != "")
                    {
                        htmlValue.EditorAreaCSS = CSSHelper.GetStylesheetUrl(HTMLEditorCssStylesheet);
                    }
                    else if (SiteContext.CurrentSite != null)
                    {
                        htmlValue.EditorAreaCSS = CssStylesheetInfoProvider.GetHtmlEditorAreaCss(SiteContext.CurrentSiteName);
                    }

                    // Set "Insert image or media" dialog configuration
                    htmlValue.MediaDialogConfig.ResizeToHeight      = ResizeToHeight;
                    htmlValue.MediaDialogConfig.ResizeToWidth       = ResizeToWidth;
                    htmlValue.MediaDialogConfig.ResizeToMaxSideSize = ResizeToMaxSideSize;

                    // Set "Insert link" dialog configuration
                    htmlValue.LinkDialogConfig.ResizeToHeight      = ResizeToHeight;
                    htmlValue.LinkDialogConfig.ResizeToWidth       = ResizeToWidth;
                    htmlValue.LinkDialogConfig.ResizeToMaxSideSize = ResizeToMaxSideSize;

                    // Set "Quickly insert image" configuration
                    htmlValue.QuickInsertConfig.ResizeToHeight      = ResizeToHeight;
                    htmlValue.QuickInsertConfig.ResizeToWidth       = ResizeToWidth;
                    htmlValue.QuickInsertConfig.ResizeToMaxSideSize = ResizeToMaxSideSize;

                    break;

                case CMSEditableRegionTypeEnum.TextArea:
                case CMSEditableRegionTypeEnum.TextBox:
                    // TextBox
                    if (RegionType == CMSEditableRegionTypeEnum.TextArea)
                    {
                        txtValue.TextMode = TextBoxMode.MultiLine;
                    }
                    else
                    {
                        txtValue.TextMode = TextBoxMode.SingleLine;
                    }

                    if (DialogWidth > 0)
                    {
                        txtValue.Width = new Unit(DialogWidth - 8);
                    }
                    else
                    {
                        // Default width is 100%
                        txtValue.Width = new Unit(100, UnitType.Percentage);
                    }

                    if (DialogHeight > 0)
                    {
                        txtValue.Height = new Unit(DialogHeight);
                    }

                    txtValue.Wrap = WordWrap;

                    break;
                }
            }
            break;
            }
        }
    }
        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);
        }
Esempio n. 7
0
        protected override void Execute(NativeActivityContext context)
        {
            var width     = DialogWidth.Get(context);
            var height    = DialogHeight.Get(context);
            var modelType = typeof(ListViewModelBase <>).MakeGenericType(typeof(T));
            var model     = (IListViewModel <T>)IoC.Instance.Resolve(modelType);

            model.PanelCaption = Title;
            var modelBase = (ListViewModelBase <T>)model;

            modelBase.IsMainMenuEnable = false;
            if (ShowCustomizeMenu)
            {
                if (!string.IsNullOrEmpty(LayoutSettingsFileSuffix))
                {
                    modelBase.SetSuffix(LayoutSettingsFileSuffix);
                }
                modelBase.IsCustomizeBarEnabled = true;
                if (modelBase.Menu != null)
                {
                    modelBase.Menu.NotUseGlobalLayoutSettings = true;
                }

                //foreach (var bar in modelBase.Menu.Bars)
                //{
                //    if (!(bar != null && !string.IsNullOrEmpty(bar.Caption) && bar.Caption.Equals("Вид")))
                //        modelBase.Menu.Bars.Remove(bar);
                //}
            }
            else
            {
                //modelBase.Menu.Bars.Clear();
                modelBase.IsCustomizeBarEnabled = false;
            }

            var source = Source.Get(context);

            if (source == null)
            {
                var sqlFilter = Filter.Get(context);
                model.ApplySqlFilter(sqlFilter);
            }
            else
            {
                //model.SetSource(new EditableBusinessObjectCollection<T>(source));
                model.SetSource(new ObservableRangeCollection <T>(source));
            }

            model.IsSelectedFirstItem = IsSelectedFirstItem;

            if (IsCloseDoubleClick)
            {
                model.IsCloseDoubleClick = true;
            }

            modelBase.SuspendDispose = true;

            var viewService = IoC.Instance.Resolve <IViewService>();

            if (viewService.ShowDialogWindow(model, true, false, width, height, false, Buttons) == true)
            {
                Result.Set(context, model.SelectedItems.ToArray());
                modelBase.SuspendDispose = false;
                modelBase.Dispose();
                DialogResult.Set(context, MessageBoxResult.OK);
            }
            else
            {
                DialogResult.Set(context, MessageBoxResult.Cancel);
            }
        }
Esempio n. 8
0
        public override string Render()
        {
            if (Visiable)
            {
                AddAttributes();
                var texts = new List <string>();
                if (TextID.IsNullOrEmpty())
                {
                    TextID = "{0}_Text".FormatTo(Id);
                }
                if (!Value.IsNullOrEmpty() && !SelectType.IsNullOrEmpty())
                {
                    var page = PageBuilder.BuildPage(SelectType);
                    if (page != null && page.Controls.Count > 0)
                    {
                        IFieldConverter listDs = null;
                        page.Controls.ForEach((o) =>
                        {
                            if (o is IListDataSourceControl)
                            {
                                listDs = (o as IListDataSourceControl).DataSource as IFieldConverter;
                                return;
                            }
                            else if (o is ICascadeDataSourceControl)
                            {
                                listDs = (o as ICascadeDataSourceControl).DataSource as IFieldConverter;
                                return;
                            }
                        });
                        if (listDs != null)
                        {
                            if (IsMulitle)
                            {
                                foreach (var v in Value.Split(','))
                                {
                                    texts.Add(listDs.Converter(Id, v, null).ToString());
                                }
                            }
                            else
                            {
                                texts.Add(listDs.Converter(Id, Value, null).ToString());
                            }
                        }
                    }
                }
                string text = string.Empty;
                if (texts.Count > 0)
                {
                    text = string.Join(",", texts.ToArray());
                }
                var textBox = new TextBox()
                {
                    Id = TextID, Name = TextID, Value = text
                };
                if (!Attributes.IsNullOrEmpty())
                {
                    foreach (var attr in Attributes)
                    {
                        textBox.Attributes[attr.Key] = attr.Value;
                    }
                }
                textBox.Attributes["data-selector"]     = SelectType;
                textBox.Attributes["data-showtype"]     = ShowType.ToString();
                textBox.Attributes["data-multiple"]     = IsMulitle.ToString().ToLower();
                textBox.Attributes["data-target"]       = Id;
                textBox.Attributes["data-dialogheight"] = DialogHeight.ToString();
                textBox.Attributes["data-dialogwidth"]  = DialogWidth.ToString();

                var hidden = new HiddenField()
                {
                    Id = Id, Name = Id, Value = Value, Validator = Validator
                };
                string result = hidden.Render() + textBox.Render();
                return(ContainerTemplate.FormatTo(Id, Label, result, Description));
            }
            return(string.Empty);
        }
Esempio n. 9
0
        protected override void Execute(NativeActivityContext context)
        {
            var width    = DialogWidth.Get(context);
            var height   = DialogHeight.Get(context);
            var workings = WorkingProp.Get(context);

            if (workings == null)
            {
                workings = new List <Working>();
            }

            var vm = (InputPlPosListViewModel)IoC.Instance.Resolve(typeof(InputPlPosListViewModel));

            vm.PanelCaption       = Title.Get(context);
            vm.ActionWorkflowCode = ActionWorkflowCode.Get(context);

            var source = Source.Get(context);

            if (source != null)
            {
                source.ForEach(p => p.AcceptChanges());
            }
            ((IModelHandler)vm).SetSource(new ObservableCollection <InputPlPos>(source));

            var viewService  = IoC.Instance.Resolve <IViewService>();
            var dialogResult = viewService.ShowDialogWindow(viewModel: vm, isRestoredLayout: true, isNotNeededClosingOnOkResult: true, width: width, height: height);

            if (dialogResult == true)
            {
                var result = ((IModelHandler)vm).GetSource() as IEnumerable <InputPlPos>;
                if (result == null)
                {
                    throw new DeveloperException("Source type is not IEnumerable.");
                }

                Result.Set(context, result.ToList());
            }
            DialogResult.Set(context, dialogResult);

            workings.Clear();
            if (vm.Workings != null)
            {
                foreach (var w in vm.Workings)
                {
                    var working = new Working();

                    try
                    {
                        working.SuspendNotifications();
                        WMSBusinessObject.Copy(w, working);
                        working.AcceptChanges();
                    }
                    finally
                    {
                        working.ResumeNotifications();
                    }
                    workings.Add(working);
                }
            }
            WorkingProp.Set(context, workings);

            var disposable = vm as IDisposable;

            if (disposable != null)
            {
                disposable.Dispose();
            }
        }
Esempio n. 10
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);
            }
        }