Example #1
0
        private string GetDBType(ModalViewModel model)
        {
            switch (model.Type)
            {
            case "int":
            case "file":
            case "dictionary":
            case "hyperlink":
                return("int");

            case "decimal":
                return("decimal");

            case "bit":
                return("bit");

            case "varchar":
                return("varchar(max)");

            case "datetime":
                return("DATETIME");

            case "date":
                return("DATE");

            case "time":
                return("TIME");
            }

            return(model.Type);
        }
        public void ByIdProcedureTest()
        {
            SimpleInit();

            ModalViewModel model = new ModalViewModel(_rootPanel);

            model.FieldInDb     = "idfile";
            model.Type          = "file";
            model.RuDescription = "Поле 3";
            _rootPanel.Children.Add(model);

            model                     = new ModalViewModel(_rootPanel);
            model.FieldInDb           = "Field3";
            model.Type                = ControlTypes.Dictionary;
            model.DictionaryType      = DictionaryTypes.DictionaryTable;
            model.DictionaryTableName = "ter_NP_dic";
            model.RuDescription       = "Поле 4";
            _rootPanel.Children.Add(model);

            _helper.Construct(_properties, TestContext.CurrentContext.TestDirectory + "/../..");
            string tableContent    = File.ReadAllText(TestContext.CurrentContext.TestDirectory + "/../../MainTableById.sql");
            string expectedContent = FormattUtil.Format(File.ReadAllText(TestContext.CurrentContext.TestDirectory + "/../../ProcedureConstructorHelerTest/ByIdProcedureTest.sql"));

            Assert.AreEqual(expectedContent, tableContent);
        }
Example #3
0
        public void DropTest2()
        {
            ObservableCollection <WebPageBaseViewModel> properties = new ObservableCollection <WebPageBaseViewModel>();
            RootPanel      rootPanel = new RootPanel(properties);
            ModalViewModel control   = new ModalViewModel(rootPanel)
            {
                Type          = "varchar",
                FieldInDb     = "field2",
                RuDescription = "Комент",
                ControlIdView = "lb2"
            };

            rootPanel.Children.Add(control);
            PanelViewModel panelViewModel = new PanelViewModel(rootPanel)
            {
                ControlIdView = "clId1", RuDescription = "Комент"
            };

            rootPanel.Children.Add(panelViewModel);
            Assert.AreEqual(2, rootPanel.Children.Count);
            Assert.AreEqual(0, panelViewModel.Children.Count);
            //Перебрасываем контрол
            panelViewModel.Drop(control);
            Assert.AreEqual(1, panelViewModel.Children.Count);
            Assert.AreEqual(1, rootPanel.Children.Count);
            Assert.AreEqual(control.ParentCollection, panelViewModel.Children);
        }
Example #4
0
        /// <summary>
        /// Построить скрип авторизации
        /// </summary>
        /// <param name="collection">Колекция контролов</param>
        /// <param name="isEdit"></param>
        /// <param name="menupage">Ид меню</param>
        /// <param name="roles">Ид роли</param>
        public void Constructor(IEnumerable <WebPageBaseViewModel> collection, bool isEdit, int menupage, IEnumerable <int> roles)
        {
            foreach (WebPageBaseViewModel model in collection)
            {
                string description = string.Format("ru-RU:{0};en-EN:{1};", model.RuDescription, model.EnDescription);
                string table       = "null";
                if (model is ModalViewModel)
                {
                    ModalViewModel m = model as ModalViewModel;
                    if (!string.IsNullOrEmpty(m.TableName))
                    {
                        table = "'" + m.TableName + "'";
                    }
                }
                _stringBuilder.AppendFormat("--{0}\n", model.FieldInDb);
                _stringBuilder.AppendFormat(
                    "INSERT INTO [ut_MenuField] (idpage,fld, idparent, fldbd, tabbd, isNotEdited, nam) VALUES ({0}, '{1}', null, '{2}', {3}, 0, '{4}');\n",
                    menupage,
                    isEdit ? model.ControlIdEdit : model.ControlIdView,
                    model.FieldInDb ?? "null",
                    table,
                    description);

                _stringBuilder.AppendFormat("set @id  = scope_identity();\n");
                _stringBuilder.AppendFormat("insert into [ut_RoleField] (idrole, idfld,visability)\nvalues\n");

                string rs = roles.Aggregate("", (s, a) =>
                {
                    s += string.Format("({0},@id,{1}),\n", a, Visability);
                    return(s);
                }, (result) => result.TrimEnd(new char[] { ',', '\n' }));
                _stringBuilder.AppendFormat(rs + "\n");
                Constructor(model.Children, isEdit, menupage, roles);
            }
        }
        public void OneTableTest()
        {
            _rootPanel.TableName = "Table";
            ModalViewModel model = new ModalViewModel(_rootPanel);

            model.FieldInDb = "Field1";
            model.Type      = "int";
            _rootPanel.Children.Add(model);
            model           = new ModalViewModel(_rootPanel);
            model.FieldInDb = "Field2";
            model.Type      = "varchar";
            _rootPanel.Children.Add(model);
            model                = new ModalViewModel(_rootPanel);
            model.FieldInDb      = "Field3";
            model.Type           = ControlTypes.Dictionary;
            model.DictionaryType = DictionaryTypes.FlName;
            _rootPanel.Children.Add(model);
            model                     = new ModalViewModel(_rootPanel);
            model.FieldInDb           = "Field4";
            model.Type                = ControlTypes.Dictionary;
            model.DictionaryType      = DictionaryTypes.SimpleDictionary;
            model.DictionaryTableName = "MyDictionary";
            _rootPanel.Children.Add(model);

            _helper.Construct(_properties, "../..");

            string tableContent    = Utils.ReplaceSpaces(File.ReadAllText("../../Table.sql"));
            string expectedContent = Utils.ReplaceSpaces("CREATE TABLE [dbo].[Table] (\n" +
                                                         "[pkid] INT IDENTITY (1, 1)  NOT NULL,\n" +
                                                         "[fl_del] INT CONSTRAINT [DF_Table_del] DEFAULT ((0)) NULL,\n" +
                                                         "[idreq] INT NULL,\n" +
                                                         "[dats] datetime NOT NULL,\n" +
                                                         "[datf] datetime NOT NULL,\n" +
                                                         "[idcp] INT NULL,\n" +
                                                         "[fldchange] varchar(MAX) NULL,\n" +
                                                         "[idRecord] INT NOT NULL,\n" +
                                                         "[idul] INT NOT NULL,\n" +
                                                         "[Field1] INT,\n" +
                                                         "[Field2] varchar(max),\n" +
                                                         "[Field3] INT,\n" +
                                                         "[Field4] INT,\n" +
                                                         "CONSTRAINT [PK_Table] PRIMARY KEY CLUSTERED([pkid] ASC),\n" +
                                                         "CONSTRAINT [FK_Table_id] FOREIGN KEY (idRecord) REFERENCES [Table_id]([pkid]),\n" +
                                                         "CONSTRAINT [FK_Table_ul] FOREIGN KEY (idul) REFERENCES [ul]([pkid]),\n" +
                                                         "CONSTRAINT [FK_Table_Field3_fl] FOREIGN KEY (Field3) REFERENCES [fl]([pkid]),\n" +
                                                         "CONSTRAINT [FK_Table_Field4_MyDictionary] FOREIGN KEY (Field4) REFERENCES [MyDictionary]([pkid])\n" +
                                                         ")");

            Assert.AreEqual(expectedContent, tableContent);

            //Ид таблица
            tableContent    = Utils.ReplaceSpaces(File.ReadAllText("../../Table_id.sql"));
            expectedContent = Utils.ReplaceSpaces("CREATE TABLE [dbo].[Table_id] (\n" +
                                                  "[pkid] INT IDENTITY(1, 1) NOT NULL,\n" +
                                                  "[fl_del] INT CONSTRAINT[DF_Table_id_del] DEFAULT((0)) NULL,\n" +
                                                  "CONSTRAINT[PK_Table_id] PRIMARY KEY CLUSTERED([pkid] ASC)\n" +
                                                  ")\n");
            Assert.AreEqual(expectedContent, tableContent);
        }
Example #6
0
 public static void Show(Window modal, ModalViewModel viewModel)
 {
     AppViewModel.Current.HasOverlay = true;
     modal.Owner = MainWindow.Current;
     modal.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     modal.DataContext           = viewModel;
     modal.ShowDialog();
     AppViewModel.Current.HasOverlay = false;
 }
Example #7
0
        /// <summary>
        /// Register the event handlers for showing message boxes and modal windows.
        /// </summary>
        /// <param name="modalViewModel">The modal view model raising the events.</param>
        public void RegisterDialogEventsHandlers(ModalViewModel modalViewModel)
        {
            if (modalViewModel == null)
            {
                throw new ArgumentNullException(nameof(modalViewModel));
            }

            modalViewModel.ShowMessageWindow += ShowMessageBox;
            modalViewModel.ShowModalWindow   += ShowModalWindow;
        }
Example #8
0
        /// <summary>
        /// Shows how to use the WPF CustomMsgBox
        /// </summary>
        internal void ShowOtherCustomMessageBox()
        {
            ModalViewModel modalDataContext = new ModalViewModel("Mise à jour disponible", "No buttons have been added to this MsgBox", CustomMsgBoxIcon.Question, 1);

            CustomMsgBox b = new CustomMsgBox(ref modalDataContext);

            b.ShowDialog();

            Console.Out.WriteLine(String.Format("result : {0}", modalDataContext.ModalResult + " \r\n checkbox checked : " + modalDataContext.IsCheckboxChecked));
        }
Example #9
0
        /// <summary>
        /// Shows how to use the WPF CustomMsgBox
        /// </summary>
        internal void ShowCustomMessageBox()
        {
            ModalViewModel modalDataContext = new ModalViewModel("Mise à jour disponible", String.Format("Testing TextWrapping to make sure that the window {0}won't end up extremely wide.", Environment.NewLine), true, "Remember my choice test", CustomMsgBoxIcon.Question, 1);

            modalDataContext.Buttons.Add(new ModalButton(modalDataContext, "OK", null, ModalResult.Ok));
            modalDataContext.Buttons.Add(new ModalButton(modalDataContext, "Cancel", () => Console.Out.WriteLine("Testing Cancel"), ModalResult.Cancel));

            CustomMsgBox b = new CustomMsgBox(ref modalDataContext);

            b.ShowDialog();

            Console.Out.WriteLine(String.Format("result : {0}", modalDataContext.ModalResult + " \r\n checkbox checked : " + modalDataContext.IsCheckboxChecked));
        }
        private void SimpleInit()
        {
            ModalViewModel model = new ModalViewModel(_rootPanel);

            model.FieldInDb     = "Field1";
            model.Type          = "int";
            model.RuDescription = "Поле 1";
            _rootPanel.Children.Add(model);
            model               = new ModalViewModel(_rootPanel);
            model.FieldInDb     = "Field2";
            model.Type          = "varchar";
            model.RuDescription = "Поле 2";
            _rootPanel.Children.Add(model);
        }
Example #11
0
        public PartialViewResult Modal()
        {
            var currentPage = _umbracoHelper.CurrentPage;
            var cultureName = GetCultureNameForPublishedContent(currentPage);

            var modalViewModel = new ModalViewModel();

            var dictionaryTerms = new ModalDictionaryViewModel();

            _umbracoMapper.MapUsingDictionary(dictionaryTerms);
            modalViewModel.SetDictionary(dictionaryTerms);

            return(PartialView("Modal", modalViewModel));
        }
Example #12
0
        private void WriteField(ModalViewModel model, string tableName)
        {
            switch (model.Type)
            {
            case "int":
                _stringBuilder.AppendFormat("[{0}] INT,\n", model.FieldInDb);
                break;

            case "decimal":
                _stringBuilder.AppendFormat("[{0}] decimal,\n", model.FieldInDb);
                break;

            case "bit":
                _stringBuilder.AppendFormat("[{0}] bit,\n", model.FieldInDb);
                break;

            case "varchar":
                _stringBuilder.AppendFormat("[{0}] varchar(max),\n", model.FieldInDb);
                break;

            case "file":
                //Констрейн
                _stringBuilder.AppendFormat("[{0}] INT,\n", model.FieldInDb);
                break;

            case "dictionary":
                //Констрейн
                _stringBuilder.AppendFormat("[{0}] INT,\n", model.FieldInDb);
                _indexes.Add(GetIndexForDictionary(model, tableName));
                break;

            //Констрейн
            case "hyperlink":
                _stringBuilder.AppendFormat("[{0}] INT,\n", model.FieldInDb);
                break;

            case "datetime":
                _stringBuilder.AppendFormat("[{0}] DATETIME,\n", model.FieldInDb);
                break;

            case "date":
                _stringBuilder.AppendFormat("[{0}] DATE,\n", model.FieldInDb);
                break;

            case "time":
                _stringBuilder.AppendFormat("[{0}] TIME,\n", model.FieldInDb);
                break;
            }
        }
Example #13
0
        public ActionResult Delete(ModalViewModel viewModel)
        {
            var id            = viewModel.Id;
            var eventToDelete = eventRepository.GetById(id);

            if (eventToDelete == null)
            {
                this.AddNotification(string.Format("Cannot delete event #{0}", id), NotificationType.ERROR);
                return(RedirectToAction("My"));
            }

            eventRepository.Delete(id);
            eventRepository.Save();
            this.AddNotification("Event deleted.", NotificationType.INFO);
            return(RedirectToAction("My"));
        }
Example #14
0
        private string GetIndexForDictionary(ModalViewModel model, string tableName)
        {
            switch (model.DictionaryType)
            {
            case DictionaryTypes.FlName:
                return($"CONSTRAINT [FK_{tableName}_{model.FieldInDb}_fl] FOREIGN KEY ({model.FieldInDb}) REFERENCES [fl]([pkid]),\n");

            case DictionaryTypes.UlName:
                return($"CONSTRAINT [FK_{tableName}_{model.FieldInDb}_ul] FOREIGN KEY ({model.FieldInDb}) REFERENCES [ul]([pkid]),\n");

            case DictionaryTypes.SimpleDictionary:
            case DictionaryTypes.DictionaryTable:
                return($"CONSTRAINT [FK_{tableName}_{model.FieldInDb}_{model.DictionaryTableName}] FOREIGN KEY ({model.FieldInDb}) REFERENCES [{model.DictionaryTableName}]([pkid]),\n");
            }
            return("");
        }
Example #15
0
        public void TurnGridTest()
        {
            PanelViewModel panelViewModel = new PanelViewModel(_model.RootPanel)
            {
                RuDescription = "Комент", FieldInDb = "Id1"
            };

            _model.RootPanel.Children.Add(panelViewModel);
            ModalViewModel panel1 = new ModalViewModel(panelViewModel)
            {
                Type          = "varchar",
                FieldInDb     = "field2",
                RuDescription = "Комент",
                ControlIdView = "lb2"
            };

            panelViewModel.Children.Add(panel1);
            ModalViewModel panel2 = new ModalViewModel(panelViewModel)
            {
                Type          = "varchar",
                FieldInDb     = "field3",
                RuDescription = "Комент",
                ControlIdView = "lb3"
            };

            panelViewModel.Children.Add(panel2);

            _model.CurrentProperty = panelViewModel;

            int index         = _model.RootPanel.Children.IndexOf(panelViewModel);
            int childrenCount = panelViewModel.Children.Count;

            _model.TurnGrid();

            //Проверяем тип
            WebPageBaseViewModel newModel = _model.RootPanel.Children[index];

            Assert.IsTrue(newModel is GridViewModel);
            //Количество детей
            Assert.AreEqual(childrenCount, newModel.Children.Count);
            //Проверяем родительские колекции
            Assert.AreEqual(childrenCount, panel1.ParentCollection.Count);
            Assert.AreEqual(childrenCount, panel2.ParentCollection.Count);
        }
Example #16
0
        public void ShowModalView(ModalViewModel vm, Action onClosedCallBack = null)
        {
            if (vm == null)
            {
                throw new ArgumentNullException(nameof(vm));
            }

            if (!IsModalOpened)
            {
                CurrentModalViewModel = vm;
                CurrentModalView      = vm.View as IModalView;
                SetOpened();
                _onModalClosedCallBack = onClosedCallBack;
                WeakEventManager <ModalViewModel, EventArgs>
                .AddHandler(CurrentModalViewModel, "Closed", ModalVm_Closed);

                CurrentModalViewModel.OnOpened();
            }
        }
Example #17
0
        public ActionResult DeleteModal(int id)
        {
            var eventToDelete = eventRepository.GetById(id);

            if (eventToDelete == null)
            {
                return(Content(""));
            }

            ModalViewModel viewModel = new ModalViewModel()
            {
                Title      = "Delete",
                Body       = string.Format("Are you sure want to delete \"{0}\"?", eventToDelete.Title),
                FormAction = "/Event/Delete",
                Id         = eventToDelete.Id
            };

            return(PartialView("_Modal", viewModel));
        }
Example #18
0
        public IViewComponentResult Invoke(string title, string body, string action, string controller, bool formSubmit, string buttonText, string buttonClass, Dictionary <string, string> arguments, string dataTarget = "modal")
        {
            ModalViewModel modal = new ModalViewModel
            {
                Title = title,
                Body  = body,

                Action     = action,
                Controller = controller,

                FormSubmit = formSubmit,
                DataTarget = dataTarget,

                ButtonText  = buttonText,
                ButtonClass = buttonClass,

                Arguments = arguments
            };

            return(View("_Modal", modal));
        }
Example #19
0
        async public Task <IViewComponentResult> InvokeAsync(TransactionResult Transaction)
        {
            var model = new ModalViewModel()
            {
                ReturnUrl = Transaction.ReturnUrl,
                Message   = Transaction.Message
            };

            switch (Transaction.Type)
            {
            case TransactionType.Success:
                model.Type = "success";
                break;

            case TransactionType.Error:
                model.Type = "error";
                break;
            }

            return(View(model));
        }
Example #20
0
 /// <summary>
 /// Register the event handlers for showing message boxes and modal windows.
 /// </summary>
 /// <param name="modalViewModel">The modal view model raising the events.</param>
 public void RegisterDialogEventsHandlers(ModalViewModel modalViewModel)
 {
     modalViewModel.ShowMessageWindow += ShowMessageBox;
     modalViewModel.ShowModalWindow   += ShowModalWindow;
 }
 public ModalPage()
 {
     BindingContext = new ModalViewModel();
     CreateLayout();
 }
Example #22
0
 public DetailedMovieView()
 {
     this.InitializeComponent();
     modalViewModel = new ModalViewModel <Movie>();
 }
        public ModalActionResult ModalPartial(ModalViewModel model)
        {
            ModalActionResult modal = new ModalActionResult(model);

            return(modal);
        }