示例#1
0
        /// <summary>
        /// —оздать и добавить поле
        /// </summary>
        /// <returns></returns>
        public ModalViewModel CreateField()
        {
            ModalViewModel obj = new ModalViewModel(this);

            Children.Add(obj);
            return(obj);
        }
示例#2
0
        /// <summary>
        /// Добавить свойство
        /// </summary>
        public void AddProperty()
        {
            ModalView      window = new ModalView();
            ModalViewModel model  = new ModalViewModel(_rootPanel);

            window.DataContext = model;
            if (window.ShowDialog() == true)
            {
                _rootPanel.Children.Add(model);
                NotifyOfPropertyChange(nameof(CanWriteResourses));
            }
        }
        public void OneGridTest()
        {
            GridViewModel grid = new GridViewModel(_rootPanel);
            grid.TableName = "GridTable";
            _rootPanel.Children.Add(grid);

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

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

            string tableContent = Utils.ReplaceSpaces(File.ReadAllText("../../GridTable.sql"));
            string expectedContent = Utils.ReplaceSpaces("CREATE TABLE [dbo].[GridTable] (\n" +
                                                         "[pkid] INT IDENTITY (1, 1)  NOT NULL,\n" +
                                                         "[fl_del] INT CONSTRAINT [DF_GridTable_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" +
                                                         "[externalId] INT NOT NULL,\n" +
                                                         "[Field1] INT,\n" +
                                                         "[Field2] varchar(max),\n" +
                                                         "[Field3] INT,\n" +
                                                         "CONSTRAINT [PK_GridTable] PRIMARY KEY CLUSTERED([pkid] ASC),\n" +
                                                         "CONSTRAINT [FK_GridTable_id] FOREIGN KEY (idRecord) REFERENCES [GridTable_id]([pkid]),\n" +
                                                         "CONSTRAINT [FK_GridTable_Field3_fl] FOREIGN KEY (Field3) REFERENCES [fl]([pkid])\n" +
                                                         ")");
            Assert.AreEqual(expectedContent, tableContent);

            //Ид таблица
            tableContent = Utils.ReplaceSpaces(File.ReadAllText("../../GridTable_id.sql"));
            expectedContent = Utils.ReplaceSpaces("CREATE TABLE [dbo].[GridTable_id] (\n" +
                                                  "[pkid] INT IDENTITY(1, 1) NOT NULL,\n" +
                                                  "[fl_del] INT CONSTRAINT[DF_GridTable_id_del] DEFAULT((0)) NULL,\n" +
                                                  "CONSTRAINT[PK_GridTable_id] PRIMARY KEY CLUSTERED([pkid] ASC)\n" +
                                                  ")\n");
            Assert.AreEqual(expectedContent, tableContent);
        }
示例#4
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);
 }
        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);
        }
示例#6
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);
        }
示例#7
0
 /// <summary>
 /// —оздать и добавить поле
 /// </summary>
 /// <returns></returns>
 public ModalViewModel CreateField()
 {
     ModalViewModel obj = new ModalViewModel(this);
     Children.Add(obj);
     return obj;
 }
示例#8
0
 /// <summary>
 /// Добавить в дерево
 /// </summary>
 public void Build(ObservableCollection<WebPageBaseViewModel> properties)
 {
     var description = GetGroupNames();
     RootPanel root = (RootPanel)properties.First();
     //Устанавливаем базовою таблицу
     root.TableName = BaseTable;
     var grids = Grids.Where(i => i.IsGrid);
     description.ForEach((i, c) =>
     {
         var grid = grids.FirstOrDefault(j => j.Description == i);
         if (grid != null)
         {
             GridViewModel model = new GridViewModel(root);
             model.FieldInDb = "grid" + c;
             model.RuDescription = i;
             model.TableName = grid.TableName;
             root.Children.Add(model);
         }
         else
         {
             PanelViewModel model = new PanelViewModel(root) { FieldInDb = "panel" + c, RuDescription = i };
             root.Children.Add(model);
         }
     });
     Table table = _tables.ElementAt(CurrentTable);
     //Загрузка полей
     var fields =
         table.Elements<TableRow>()
             .Skip(1)
             .Select(i => new DocProperty(i.Elements<TableCell>().ElementAt(DescriptionField.Key).InnerText, i.Elements<TableCell>().ElementAt(TypeField.Key).InnerText, i.Elements<TableCell>().ElementAt(GroupName.Key).InnerText));
     int count = 0;
     foreach (DocProperty field in fields)
     {
         ModalViewModel model;
         if (string.IsNullOrEmpty(field.Parent))
         {
             model = new ModalViewModel(root);
             root.Children.Add(model);
         }
         else
         {
             //Поиск панели
             var tmp = root.Children.FirstOrDefault(i => i.RuDescription == field.Parent && i.Type == "panel" || i.Type =="grid");
             if (tmp == null)
             {
                 model = new ModalViewModel(root);
                 root.Children.Add(model);
             }
             else
             {
                 model = new ModalViewModel(tmp);
                 tmp.Children.Add(model);
                 //model.TableName = (tmp as GridViewModel)?.TableName;
             }
         }
         model.FieldInDb = "field" + count.ToString();
         model.RuDescription = field.Description;
         model.Type = field.GetRightType();
         //model.TableName = model.TableName??BaseTable;
         count++;
     }
 }
示例#9
0
        /// <summary>
        /// Добавить в дерево
        /// </summary>
        public void Build(ObservableCollection <WebPageBaseViewModel> properties)
        {
            var       description = GetGroupNames();
            RootPanel root        = (RootPanel)properties.First();

            //Устанавливаем базовою таблицу
            root.TableName = BaseTable;
            var grids = Grids.Where(i => i.IsGrid);

            description.ForEach((i, c) =>
            {
                var grid = grids.FirstOrDefault(j => j.Description == i);
                if (grid != null)
                {
                    GridViewModel model = new GridViewModel(root);
                    model.FieldInDb     = "grid" + c;
                    model.RuDescription = i;
                    model.TableName     = grid.TableName;
                    root.Children.Add(model);
                }
                else
                {
                    PanelViewModel model = new PanelViewModel(root)
                    {
                        FieldInDb = "panel" + c, RuDescription = i
                    };
                    root.Children.Add(model);
                }
            });
            Table table = _tables.ElementAt(CurrentTable);
            //Загрузка полей
            var fields =
                table.Elements <TableRow>()
                .Skip(1)
                .Select(i => new DocProperty(i.Elements <TableCell>().ElementAt(DescriptionField.Key).InnerText, i.Elements <TableCell>().ElementAt(TypeField.Key).InnerText, i.Elements <TableCell>().ElementAt(GroupName.Key).InnerText));
            int count = 0;

            foreach (DocProperty field in fields)
            {
                ModalViewModel model;
                if (string.IsNullOrEmpty(field.Parent))
                {
                    model = new ModalViewModel(root);
                    root.Children.Add(model);
                }
                else
                {
                    //Поиск панели
                    var tmp = root.Children.FirstOrDefault(i => i.RuDescription == field.Parent && i.Type == "panel" || i.Type == "grid");
                    if (tmp == null)
                    {
                        model = new ModalViewModel(root);
                        root.Children.Add(model);
                    }
                    else
                    {
                        model = new ModalViewModel(tmp);
                        tmp.Children.Add(model);
                        //model.TableName = (tmp as GridViewModel)?.TableName;
                    }
                }
                model.FieldInDb     = "field" + count.ToString();
                model.RuDescription = field.Description;
                model.Type          = field.GetRightType();
                //model.TableName = model.TableName??BaseTable;
                count++;
            }
        }
 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);
 }
示例#11
0
 /// <summary>
 /// Добавить свойство
 /// </summary>
 public void AddProperty()
 {
     ModalView window = new ModalView();
     ModalViewModel model = new ModalViewModel(_rootPanel);
     window.DataContext = model;
     if (window.ShowDialog() == true)
     {
         _rootPanel.Children.Add(model);
         NotifyOfPropertyChange(nameof(CanWriteResourses));
     }
 }