Exemple #1
0
        public void AddRecursiveKey()
        {
            PanelViewModel panel1 = new PanelViewModel(_model.RootPanel);
            panel1.FieldInDb = "fl1";
            _model.RootPanel.Children.Add(panel1);

            PanelViewModel panel2 = new PanelViewModel(panel1);
            panel2.FieldInDb = "fl2";
            panel1.Children.Add(panel2);

            PanelViewModel panel3 = new PanelViewModel(panel2);
            panel3.FieldInDb = "fl3";
            panel2.Children.Add(panel3);
            //Добавляем ключь, должны добавится в оба словаря
            _model.WriteResourses();
            //Проверяем
            ResXResourceReader reader = new ResXResourceReader(_model.ResourceFilePath);
            var dictionary = reader.Cast<DictionaryEntry>();
            Assert.IsNotNull(dictionary.FirstOrDefault(i => i.Key == "fl1"));
            Assert.IsNotNull(dictionary.FirstOrDefault(i => i.Key == "fl2"));
            Assert.IsNotNull(dictionary.FirstOrDefault(i => i.Key == "fl3"));
            Assert.AreEqual(4, dictionary.Count());
            reader.Close();

            reader = new ResXResourceReader(_model.ResourceFilePath.Replace(".resx", ".ru-RU.resx"));
            dictionary = reader.Cast<DictionaryEntry>();
            Assert.IsNotNull(dictionary.FirstOrDefault(i => i.Key == "fl1"));
            Assert.IsNotNull(dictionary.FirstOrDefault(i => i.Key == "fl2"));
            Assert.IsNotNull(dictionary.FirstOrDefault(i => i.Key == "fl3"));
            Assert.AreEqual(4, dictionary.Count());
            reader.Close();
        }
 public void SimpleViewTest()
 {
     _rootPanel.Children.Add(new ModalViewModel(_rootPanel) { Type = "int", FieldInDb = "field1", RuDescription = "Комент", ControlIdView = "lb1" });
     PanelViewModel panelViewModel = new PanelViewModel(_rootPanel) { RuDescription = "Комент", FieldInDb = "Id1" };
     _rootPanel.Children.Add(panelViewModel);
     panelViewModel.Children.Add(new ModalViewModel(_rootPanel) { Type = "varchar", FieldInDb = "field2", RuDescription = "Комент", ControlIdView = "lb2" });
     _helper.Visability = 1;
     string result = "DECLARE @id int;\n";
     //field1
     result += "--field1\n";
     result +=
         "INSERT INTO [ut_MenuField] (idpage,fld, idparent, fldbd, tabbd, isNotEdited, nam) VALUES (100, 'lb1', null, 'field1', null, 0, 'ru-RU:Комент;en-EN:Some text;');\n";
     result += "set @id  = scope_identity();\n";
     result += "insert into [ut_RoleField] (idrole, idfld,visability)\nvalues\n";
     result += "(3,@id,1)\n";
     //clId1
     result += "--Id1\n";
     result +=
         "INSERT INTO [ut_MenuField] (idpage,fld, idparent, fldbd, tabbd, isNotEdited, nam) VALUES (100, 'cpId1', null, 'Id1', null, 0, 'ru-RU:Комент;en-EN:Some text;');\n";
     result += "set @id  = scope_identity();\n";
     result += "insert into [ut_RoleField] (idrole, idfld,visability)\nvalues\n";
     result += "(3,@id,1)\n";
     //field2
     result += "--field2\n";
     result +=
         "INSERT INTO [ut_MenuField] (idpage,fld, idparent, fldbd, tabbd, isNotEdited, nam) VALUES (100, 'lb2', null, 'field2', null, 0, 'ru-RU:Комент;en-EN:Some text;');\n";
     result += "set @id  = scope_identity();\n";
     result += "insert into [ut_RoleField] (idrole, idfld,visability)\nvalues\n";
     result += "(3,@id,1)\n";
     _helper.Constructor(_rootPanel.Children, false, 100, 3);
     Assert.AreEqual(result, _helper.ToString());
 }
        public void ComplexTest3()
        {
            _helper.ResourceNamespace = "RefBook";
            PanelViewModel panelViewModel = new PanelViewModel(_rootPanel) { ControlIdView = "clId1", RuDescription = "Комент" };
            _rootPanel.Children.Add(panelViewModel);
            GridViewModel grid = new GridViewModel(panelViewModel);

            panelViewModel.Children.Add(grid);
            grid.Children.Add(new ModalViewModel(grid) { Type = "int", FieldInDb = "field1", RuDescription = "Комент", ControlIdView = "lb1" });
            _helper.Construct(_rootPanel.Children, false);
            string result =
                "<%--Комент--%>\n<gp:CollapsePanel ID=\"clId1\" runat=\"server\" Caption=\"<%$ Resources: RefBook, clId1 %>\" SkinID=\"CollapsePanel\">\n";
            result += "<%----%>\n";
            result += "<gp:GpGridView ID=\"gvObject\" Height=\"100%\" runat=\"server\" PageSize=\"10\" ShowWhenEmpty=\"False\" SkinID=\"gpGridView\" DataKeyNames=\"id\" PagerSettings-Visible=\"true\">\n";
            result += "<Columns>\n";
            result += "<%--Комент--%>\n";
            result += "<asp:TemplateField HeaderText=\"<%$ Resources: RefBook, field1 %>\" SortExpression=\"field1\" AccessibleHeaderText=\"field1\">\n";
            result += "<ItemTemplate>\n";
            result += "<asp:Label ID=\"lb1\" runat=\"server\"><%# Eval(\"field1\")%></asp:Label>\n";
            result += "</ItemTemplate>\n";
            result += "</asp:TemplateField>\n";
            result += "</Columns>\n";
            result += "</gp:GpGridView>\n";
            result += "</gp:CollapsePanel>\n";
            Assert.AreEqual(result, _helper.ToString());
        }
Exemple #4
0
 public void FlattenTest()
 {
     PanelViewModel panel1 = new PanelViewModel(_rootPanel);
     _rootPanel.Children.Add(panel1);
     PanelViewModel panel2 = new PanelViewModel(panel1);
     panel1.Children.Add(panel2);
     PanelViewModel panel3 = new PanelViewModel(panel2);
     panel2.Children.Add(panel3);
     var count =_rootPanel.Children.Flatten(i => i.Children).Count();
     Assert.AreEqual(3,count);
 }
        /// <summary>
        /// Добавить панель
        /// </summary>
        public void AddPanel()
        {
            ModalView      window         = new ModalView();
            PanelViewModel panelViewModel = new PanelViewModel(_rootPanel);

            window.DataContext = panelViewModel;
            if (window.ShowDialog() == true)
            {
                _rootPanel.Children.Add(panelViewModel);
            }
        }
 public void ComplexTest1()
 {
     _rootPanel.Children.Add(new ModalViewModel(_rootPanel) { Type = "int", FieldInDb = "field1", RuDescription = "Комент", ControlIdView = "lb1" });
     PanelViewModel panelViewModel = new PanelViewModel(_rootPanel) { ControlIdView = "clId1", RuDescription = "Комент" };
     _rootPanel.Children.Add(panelViewModel);
     panelViewModel.Children.Add(new ModalViewModel(_rootPanel) { Type = "varchar", FieldInDb = "field2", RuDescription = "Комент", ControlIdView = "lb2" });
     string result = "<%--Комент--%>\n<gp:ValidatingLabel ID=\"lb1\" runat=\"server\" SkinID=\"ViewModeSkin\" Caption=\"<%$ Resources: , lb1 %>\" DataBoundField=\"field1\" EnableDate=\"true\" HistType=\"HISTORY_TYPE_UL\"/>\n";
     result +=
         "<%--Комент--%>\n<gp:CollapsePanel ID=\"clId1\" runat=\"server\" Caption=\"<%$ Resources: , clId1 %>\" SkinID=\"CollapsePanel\">\n";
     result +=
         "<%--Комент--%>\n<gp:ValidatingLabel ID=\"lb2\" runat=\"server\" SkinID=\"ViewModeSkin\" Caption=\"<%$ Resources: , lb2 %>\" DataBoundField=\"field2\" EnableDate=\"true\" HistType=\"HISTORY_TYPE_UL\"/>\n";
     result += "</gp:CollapsePanel>\n";
     _helper.Construct(_rootPanel.Children, false);
     Assert.AreEqual(result, _helper.ToString());
 }
Exemple #7
0
        public void AddDoubleKey()
        {
            PanelViewModel panelViewModel = new PanelViewModel(_model.RootPanel) { RuDescription = "Комент", FieldInDb = "Key1" };
            _model.RootPanel.Children.Add(panelViewModel);
            //Добавляем ключь, должны добавится в оба словаря
            _model.WriteResourses();
            //Проверяем
            ResXResourceReader reader = new ResXResourceReader(_model.ResourceFilePath);
            var dictionary = reader.Cast<DictionaryEntry>();
            Assert.AreEqual(1, dictionary.Count());
            reader.Close();

            reader = new ResXResourceReader(_model.ResourceFilePath.Replace(".resx", ".ru-RU.resx"));
            dictionary = reader.Cast<DictionaryEntry>();
            Assert.AreEqual(1, dictionary.Count());
            reader.Close();
        }
Exemple #8
0
        public void AddNewKeyTest()
        {
            PanelViewModel panelViewModel = new PanelViewModel(_model.RootPanel) { RuDescription = "Комент", FieldInDb = "Id1" };
            _model.RootPanel.Children.Add(panelViewModel);
            //Добавляем ключь, должны добавится в оба словаря
            _model.WriteResourses();
            //Проверяем
            ResXResourceReader reader = new ResXResourceReader(_model.ResourceFilePath);
            var dictionary = reader.Cast<DictionaryEntry>();
            Assert.AreEqual(2, dictionary.Count());
            Assert.IsNotNull(dictionary.FirstOrDefault(i => (string) i.Key == "Id1"));
            reader.Close();

            reader = new ResXResourceReader(_model.ResourceFilePath.Replace(".resx", ".ru-RU.resx"));
            dictionary = reader.Cast<DictionaryEntry>();
            Assert.AreEqual(2, dictionary.Count());
            Assert.IsNotNull(dictionary.FirstOrDefault(i => (string) i.Key == "Id1"));
            reader.Close();
        }
Exemple #9
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 SimpleTest()
        {
            _rootPanel.Children.Add(new ModalViewModel(_rootPanel) { Type = "int", FieldInDb = "field1", RuDescription = "Комент", EnDescription = "Comment", ControlIdView = "lb1" });
            PanelViewModel panelViewModel = new PanelViewModel(_rootPanel) { ControlIdView = "clId1", RuDescription = "Комент", EnDescription = "Comment"};
            _rootPanel.Children.Add(panelViewModel);
            //Вторая панель вложена в первую
            PanelViewModel panel2 = new PanelViewModel(panelViewModel) { ControlIdView = "clId2", RuDescription = "Комент", EnDescription = "Comment" };
            panelViewModel.Children.Add(panel2);
            panel2.Children.Add(new ModalViewModel(_rootPanel) { Type = "varchar", FieldInDb = "field2", RuDescription = "Комент", EnDescription = "Comment", ControlIdView = "lb2" });
            _command.Execute("False");

            string result = "<data name=\"lb1\" xml:space=\"preserve\">\n";
            result += "<value>Комент</value>\n</data>\n";
            result += "<data name=\"clId1\" xml:space=\"preserve\">\n";
            result += "<value>Комент</value>\n</data>\n";
            result += "<data name=\"clId2\" xml:space=\"preserve\">\n";
            result += "<value>Комент</value>\n</data>\n";
            result += "<data name=\"lb2\" xml:space=\"preserve\">\n";
            result += "<value>Комент</value>\n</data>\n";

            //Assert.AreEqual(result,"");
        }
        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);
        }
 /// <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++;
     }
 }
Exemple #13
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++;
            }
        }
 /// <summary>
 /// Добавить панель
 /// </summary>
 public void AddPanel()
 {
     ModalView window = new ModalView();
     PanelViewModel panelViewModel = new PanelViewModel(_rootPanel);
     window.DataContext = panelViewModel;
     if (window.ShowDialog() == true)
     {
         _rootPanel.Children.Add(panelViewModel);
     }
 }