示例#1
0
 public ILNode(string name, string fullname, object value, StructureView visibleMembers)
 {
     Value          = value;
     Name           = name;
     FullName       = fullname;
     VisibleMembers = visibleMembers;
 }
        public void Delete(StructureView structureView)
        {
            _dbContext.Structures.Remove(_dbContext.Structures.Find(structureView.Id));
            //_dbContext.Entry(_dbContext.Structures.Find(structureView.Id)).State = EntityState.Deleted;

            _dbContext.SaveChanges();
        }
示例#3
0
        public ILNode Add(string name, string fullname, object value, StructureView visibleMembers)
        {
            var node = new ILNode(name, fullname, value, visibleMembers)
            {
                Parent = this
            };

            children.Add(node);
            return(node);
        }
示例#4
0
        /// <summary>Shows the Memberpicker and automatically initializes it with the structureViever rebuild and the given specifications.</summary>
        /// <param name="fF">FilterElements: Enumeration to choose which Membertypes should be shown only.</param>
        /// <param name="fP">FilterPredicate: Method to check if the currently selected member could be chosen.</param>
        /// <param name="cb">Callback: Method that gets called when a member has been chosen.</param>
        /// <param name="mainmodonly">True if only the maindoule from the own assembly should be listed, false to show all.</param>
        public static MultiPicker <T> ShowStructure(DataStruct dataStruct, StructureView fE, Predicate <T> fP, Action <T> cb, bool mainmodonly = false)
        {
            MultiPicker <T> mp = new MultiPicker <T>(dataStruct);

            mp.structureViever.ContextAssemblyLoad = !mainmodonly;
            mp.filterPredicate = fP;
            mp.callback        = cb;
            mp.structureViever.FilterElements = fE;
            mp.structureViever.RebuildAsync(mainmodonly);
            mp.Show();
            return(mp);
        }
        public ActionResult Delete(long id, StructureView structureView, FormCollection formCollection)
        {
            try
            {
                var dataBaseManager = HttpContext.Items["DataBaseManager"] as DataBaseManager;

                dataBaseManager.Structure.Delete(structureView);

                return RedirectToAction("Index", "User");
            }
            catch
            {
                return View();
            }
        }
        public void Create(StructureView structureView, string user)
        {
            if (structureView == null) throw new ArgumentNullException("structureView");

            var structure = structureView.Convert();

            var userObj = UserManager.Get(_dbContext, user);
            if (user == null) throw new ArgumentException("\"user\" is a invalid argument");

            structure.Administrators.Add(userObj);

            structure.CreatedOn = DateTime.Now;

            _dbContext.Structures.Add(structure);
            _dbContext.SaveChanges();

            //TODO return structure view
            structureView.Id = structure.Id;
        }
示例#7
0
        private void InitializeComponent()
        {
            this.components = (IContainer) new Container();
            ResourceManager resourceManager = new ResourceManager(typeof(StructurePage));

            this.Images                     = new ImageList(this.components);
            this.ToolBar                    = new ToolBar();
            this.PropertiesBtn              = new ToolBarButton();
            this.Sep1                       = new ToolBarButton();
            this.AddLinkBtn                 = new ToolBarButton();
            this.ShowLinksPanelBtn          = new ToolBarButton();
            this.ShowArrowsBtn              = new ToolBarButton();
            this.ShowTextBtn                = new ToolBarButton();
            this.Sep2                       = new ToolBarButton();
            this.PrintBtn                   = new ToolBarButton();
            this.PrintPreviewBtn            = new ToolBarButton();
            this.ExportBtn                  = new ToolBarButton();
            this.LinkList                   = new ListView();
            this.FromHdr                    = new ColumnHeader();
            this.ToHdr                      = new ColumnHeader();
            this.LinkTextHdr                = new ColumnHeader();
            this.LinkContextMenu            = new ContextMenu();
            this.LinkReverseLink            = new MenuItem();
            this.LinkDeleteLink             = new MenuItem();
            this.LinkLinkProperties         = new MenuItem();
            this.ListSplitter               = new Splitter();
            this.StructureView              = new StructureView();
            this.StructureContextMenu       = new ContextMenu();
            this.StructureOpenElement       = new MenuItem();
            this.StructureDeleteNode        = new MenuItem();
            this.StructureElementProperties = new MenuItem();
            this.StructurePanel             = new Panel();
            this.Sep3                       = new ToolBarButton();
            this.ZoomInBtn                  = new ToolBarButton();
            this.ZoomOutBtn                 = new ToolBarButton();
            this.StructurePanel.SuspendLayout();
            this.SuspendLayout();
            this.Images.ColorDepth       = ColorDepth.Depth8Bit;
            this.Images.ImageSize        = new Size(16, 16);
            this.Images.ImageStream      = (ImageListStreamer)resourceManager.GetObject("Images.ImageStream");
            this.Images.TransparentColor = Color.Magenta;
            this.ToolBar.Appearance      = ToolBarAppearance.Flat;
            this.ToolBar.Buttons.AddRange(new ToolBarButton[13]
            {
                this.PropertiesBtn,
                this.Sep1,
                this.AddLinkBtn,
                this.ShowLinksPanelBtn,
                this.ShowArrowsBtn,
                this.ShowTextBtn,
                this.Sep2,
                this.PrintBtn,
                this.PrintPreviewBtn,
                this.ExportBtn,
                this.Sep3,
                this.ZoomInBtn,
                this.ZoomOutBtn
            });
            this.ToolBar.DropDownArrows   = true;
            this.ToolBar.ImageList        = this.Images;
            this.ToolBar.Name             = "ToolBar";
            this.ToolBar.ShowToolTips     = true;
            this.ToolBar.Size             = new Size(448, 25);
            this.ToolBar.TabIndex         = 0;
            this.ToolBar.ButtonClick     += new ToolBarButtonClickEventHandler(this.ToolBar_ButtonClick);
            this.PropertiesBtn.ImageIndex = 0;
            this.Sep1.Style                    = ToolBarButtonStyle.Separator;
            this.AddLinkBtn.ImageIndex         = 3;
            this.AddLinkBtn.ToolTipText        = "Add Link";
            this.ShowLinksPanelBtn.ImageIndex  = 4;
            this.ShowLinksPanelBtn.ToolTipText = "Show Links Panel";
            this.ShowArrowsBtn.ImageIndex      = 5;
            this.ShowArrowsBtn.ToolTipText     = "Show Arrows";
            this.ShowTextBtn.ImageIndex        = 6;
            this.ShowTextBtn.ToolTipText       = "Show Link Text";
            this.Sep2.Style                    = ToolBarButtonStyle.Separator;
            this.PrintBtn.ImageIndex           = 1;
            this.PrintBtn.ToolTipText          = "Print";
            this.PrintPreviewBtn.ImageIndex    = 2;
            this.PrintPreviewBtn.ToolTipText   = "Print Preview";
            this.ExportBtn.ImageIndex          = 7;
            this.ExportBtn.ToolTipText         = "Export Structure";
            this.LinkList.Columns.AddRange(new ColumnHeader[3]
            {
                this.FromHdr,
                this.ToHdr,
                this.LinkTextHdr
            });
            this.LinkList.ContextMenu    = this.LinkContextMenu;
            this.LinkList.Dock           = DockStyle.Bottom;
            this.LinkList.FullRowSelect  = true;
            this.LinkList.Location       = new Point(0, 176);
            this.LinkList.Name           = "LinkList";
            this.LinkList.Size           = new Size(448, 88);
            this.LinkList.SmallImageList = this.Images;
            this.LinkList.Sorting        = SortOrder.Ascending;
            this.LinkList.TabIndex       = 3;
            this.LinkList.View           = View.Details;
            this.LinkList.MouseDown     += new MouseEventHandler(this.LinkList_MouseDown);
            this.LinkList.DoubleClick   += new EventHandler(this.LinkList_DoubleClick);
            this.LinkList.ColumnClick   += new ColumnClickEventHandler(this.LinkList_ColumnClick);
            this.FromHdr.Text            = "From";
            this.FromHdr.Width           = 120;
            this.ToHdr.Text        = "To";
            this.ToHdr.Width       = 120;
            this.LinkTextHdr.Text  = "Link Text";
            this.LinkTextHdr.Width = 180;
            this.LinkContextMenu.MenuItems.AddRange(new MenuItem[3]
            {
                this.LinkReverseLink,
                this.LinkDeleteLink,
                this.LinkLinkProperties
            });
            this.LinkReverseLink.Index            = 0;
            this.LinkReverseLink.Text             = "Reverse Link";
            this.LinkReverseLink.Click           += new EventHandler(this.LinkReverseLink_Click);
            this.LinkDeleteLink.Index             = 1;
            this.LinkDeleteLink.Text              = "Delete Link";
            this.LinkDeleteLink.Click            += new EventHandler(this.LinkDeleteLink_Click);
            this.LinkLinkProperties.Index         = 2;
            this.LinkLinkProperties.Text          = "Link Properties";
            this.LinkLinkProperties.Click        += new EventHandler(this.LinkLinkProperties_Click);
            this.ListSplitter.Dock                = DockStyle.Bottom;
            this.ListSplitter.Location            = new Point(0, 173);
            this.ListSplitter.Name                = "ListSplitter";
            this.ListSplitter.Size                = new Size(448, 3);
            this.ListSplitter.TabIndex            = 2;
            this.ListSplitter.TabStop             = false;
            this.StructureView.AddingLink         = false;
            this.StructureView.AllowDrop          = true;
            this.StructureView.BackColor          = SystemColors.ControlDark;
            this.StructureView.ContextMenu        = this.StructureContextMenu;
            this.StructureView.Location           = new Point(8, 8);
            this.StructureView.Name               = "StructureView";
            this.StructureView.ShowArrows         = true;
            this.StructureView.ShowText           = true;
            this.StructureView.Size               = new Size(328, 103);
            this.StructureView.Structure          = (Structure)null;
            this.StructureView.TabIndex           = 1;
            this.StructureView.StructureModified += new EventHandler(this.StructureView_StructureModified);
            this.StructureView.DragDrop          += new DragEventHandler(this.StructureView_DragDrop);
            this.StructureView.DoubleClick       += new EventHandler(this.StructureView_DoubleClick);
            this.StructureView.DragOver          += new DragEventHandler(this.StructureView_DragOver);
            this.StructureContextMenu.MenuItems.AddRange(new MenuItem[3]
            {
                this.StructureOpenElement,
                this.StructureDeleteNode,
                this.StructureElementProperties
            });
            this.StructureOpenElement.Index        = 0;
            this.StructureOpenElement.Text         = "Open Element";
            this.StructureOpenElement.Click       += new EventHandler(this.StructureOpenElement_Click);
            this.StructureDeleteNode.Index         = 1;
            this.StructureDeleteNode.Text          = "Remove Element";
            this.StructureDeleteNode.Click        += new EventHandler(this.StructureDeleteNode_Click);
            this.StructureElementProperties.Index  = 2;
            this.StructureElementProperties.Text   = "Element Properties";
            this.StructureElementProperties.Click += new EventHandler(this.StructureElementProperties_Click);
            this.StructurePanel.AutoScroll         = true;
            this.StructurePanel.Controls.AddRange(new Control[1]
            {
                (Control)this.StructureView
            });
            this.StructurePanel.Dock     = DockStyle.Fill;
            this.StructurePanel.Location = new Point(0, 25);
            this.StructurePanel.Name     = "StructurePanel";
            this.StructurePanel.Size     = new Size(448, 148);
            this.StructurePanel.TabIndex = 4;
            this.StructurePanel.Layout  += new LayoutEventHandler(this.StructurePanel_Layout);
            this.Sep3.Style             = ToolBarButtonStyle.Separator;
            this.ZoomInBtn.ImageIndex   = 8;
            this.ZoomInBtn.ToolTipText  = "Zoom In";
            this.ZoomOutBtn.ImageIndex  = 9;
            this.ZoomOutBtn.ToolTipText = "Zoom Out";
            this.Controls.AddRange(new Control[4]
            {
                (Control)this.StructurePanel,
                (Control)this.ListSplitter,
                (Control)this.LinkList,
                (Control)this.ToolBar
            });
            this.Font = new Font("Tahoma", 11f, FontStyle.Regular, GraphicsUnit.World);
            this.Name = nameof(StructurePage);
            this.Size = new Size(448, 264);
            this.StructurePanel.ResumeLayout(false);
            this.ResumeLayout(false);
        }
示例#8
0
        public void ShouldTestBasicFeatures()
        {
            DataBaseManager.Initializer();
            using (var dataBaseManager = new DataBaseManager())
            {
                #region CREATE_SERVICES

                var serviceManager = new ServiceManager(dataBaseManager);

                var serviceGit = new ServiceView()
                                     {
                                         Name = "Git",
                                         Description = "System Version Control (decentralized)"
                                     };

                serviceManager.Create(serviceGit, new[] {"r", "rw"});

                var serviceSvn = new ServiceView()
                                     {
                                         Name = "Svn",
                                         Description = "System Version Control (Centralized)"
                                     };

                serviceManager.Create(serviceSvn, new[] {"r", "rw"});

                #endregion

                #region CREATE_USERS

                var userManager = new UserManager(dataBaseManager);

                var userFaustino = new UserView()
                                       {
                                           Name = "FaustinoLeiras",
                                           Email = "*****@*****.**",
                                           Password = "******"
                                       };

                userManager.Create(userFaustino);

                var userSamir = new UserView()
                                    {
                                        Name = "SamirHafez",
                                        Email = "*****@*****.**",
                                        Password = "******"
                                    };

                userManager.Create(userSamir);

                var userRicardo = new UserView()
                                      {
                                          Name = "Ricardo",
                                          Email = "*****@*****.**",
                                          Password = "******"
                                      };

                userManager.Create(userRicardo);

                var userGeada = new UserView()
                                    {
                                        Name = "Gueada",
                                        Email = "*****@*****.**",
                                        Password = "******"
                                    };

                userManager.Create(userGeada);

                var userFelix = new UserView()
                                    {
                                        Name = "Felix",
                                        Email = "*****@*****.**",
                                        Password = "******"
                                    };

                userManager.Create(userFelix);

                var userGuedes = new UserView()
                                     {
                                         Name = "Guedes",
                                         Email = "*****@*****.**",
                                         Password = "******"
                                     };

                userManager.Create(userGuedes);

                #endregion

                #region CREATE_STRUCTURE

                var structureManager = new StructureManager(dataBaseManager);

                var structure = new StructureView()
                                    {
                                        Name = "AcademicStructure",
                                        Description = "My Academic Structure :)"
                                    };

                structureManager.Create(structure, userFaustino.Name);

                #endregion

                #region CREATE_WORKSPACE_TYPE

                var workspaceType = new WorkSpaceTypeManager(dataBaseManager);

                var workspacePublic = new WorkSpaceTypeView()
                                          {
                                              Name = "public"
                                          };

                workspaceType.Create(workspacePublic, structure.Id, new[] {serviceGit.Name, serviceSvn.Name});

                var workspacePrivate = new WorkSpaceTypeView()
                                           {
                                               Name = "private"
                                           };

                workspaceType.Create(workspacePrivate, structure.Id, new[] {serviceGit.Name, serviceSvn.Name});

                #endregion

                #region CREATE_CONTAINER_PROTOTYPE

                var containerPrototype = new ContainerPrototypeManager(dataBaseManager);

                var prototypeGraduation = new ContainerPrototypeView()
                                              {
                                                  Name = "Graduation"
                                              };

                containerPrototype.Create(prototypeGraduation, structure.Id);

                var prototypeCourse = new ContainerPrototypeView()
                                          {
                                              Name = "Course"
                                          };

                containerPrototype.Create(prototypeCourse, structure.Id, prototypeGraduation.Name);

                var prototypeClass = new ContainerPrototypeView()
                                         {
                                             Name = "Class"
                                         };

                containerPrototype.Create(prototypeClass, structure.Id, prototypeCourse.Name);

                var prototypeGroup = new ContainerPrototypeView()
                                         {
                                             Name = "Group"
                                         };

                containerPrototype.Create(prototypeGroup, structure.Id, prototypeClass.Name);

                #endregion

                #region ADD_WORKSPACE_TYPES_INTO_CONTAINER_PROTOTYPE

                containerPrototype.AddWorkSpaceType(structure.Id, prototypeGraduation.Name, workspacePublic.Name);

                containerPrototype.AddWorkSpaceType(structure.Id, prototypeCourse.Name, workspacePublic.Name);

                containerPrototype.AddWorkSpaceType(structure.Id, prototypeClass.Name, workspacePublic.Name);
                containerPrototype.AddWorkSpaceType(structure.Id, prototypeClass.Name, workspacePrivate.Name);

                containerPrototype.AddWorkSpaceType(structure.Id, prototypeGroup.Name, workspacePublic.Name);

                #endregion

                #region CREATE_ROLETYPE

                var roleType = new RoleTypeManager(dataBaseManager);

                var roleTypeTeacher = new RoleTypeView()
                                          {
                                              Name = "teacher"
                                          };

                roleType.Create(roleTypeTeacher, structure.Id);

                var roleTypeDirector = new RoleTypeView()
                                           {
                                               Name = "director"
                                           };

                roleType.Create(roleTypeDirector, structure.Id);

                var roleTypeStudant = new RoleTypeView()
                                          {
                                              Name = "studant"
                                          };

                roleType.Create(roleTypeStudant, structure.Id);

                #endregion

                #region CREATE_RULE

                var rule = new RuleManager(dataBaseManager);

                var ruleReaders = new RuleView()
                                      {
                                          Name = "readers"
                                      };

                rule.Create(ruleReaders, structure.Id, new[]
                                                           {
                                                               new KeyValuePair<string, string>(serviceGit.Name, "r"),
                                                               new KeyValuePair<string, string>(serviceSvn.Name, "r")
                                                           });

                var ruleReadersAndWriters = new RuleView()
                                                {
                                                    Name = "ReadersAndWriters"
                                                };

                rule.Create(ruleReadersAndWriters, structure.Id, new[]
                                                                     {
                                                                         new KeyValuePair<string, string>(
                                                                             serviceGit.Name,
                                                                             "rw"),
                                                                         new KeyValuePair<string, string>(
                                                                             serviceSvn.Name,
                                                                             "rw")
                                                                     });

                #endregion

                #region CREATE_ROLE

                var role = new RoleManager(dataBaseManager);

                #region ADD_ROLES_COURSE_WORKSPACE_PUBLIC

                role.Create(
                    structure.Id,
                    prototypeCourse.Name,
                    workspacePublic.Name,
                    roleTypeDirector.Name,
                    ruleReadersAndWriters.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeCourse.Name,
                    workspacePublic.Name,
                    roleTypeTeacher.Name,
                    ruleReaders.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeCourse.Name,
                    workspacePublic.Name,
                    roleTypeStudant.Name,
                    ruleReaders.Name
                    );

                #endregion

                #region ADD_ROLES_CLASS_WORKSPACE_PUBLIC

                role.Create(
                    structure.Id,
                    prototypeClass.Name,
                    workspacePublic.Name,
                    roleTypeDirector.Name,
                    ruleReaders.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeClass.Name,
                    workspacePublic.Name,
                    roleTypeTeacher.Name,
                    ruleReadersAndWriters.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeClass.Name,
                    workspacePublic.Name,
                    roleTypeStudant.Name,
                    ruleReaders.Name
                    );

                #endregion

                #region ADD_ROLES_CLASS_WORKSPACE_PRIVATE

                role.Create(
                    structure.Id,
                    prototypeClass.Name,
                    workspacePrivate.Name,
                    roleTypeDirector.Name,
                    ruleReaders.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeClass.Name,
                    workspacePrivate.Name,
                    roleTypeTeacher.Name,
                    ruleReadersAndWriters.Name
                    );

                #endregion

                #region ADD_ROLES_GROUP_WORKSPACE_PUBLIC

                role.Create(
                    structure.Id,
                    prototypeGroup.Name,
                    workspacePublic.Name,
                    roleTypeDirector.Name,
                    ruleReaders.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeGroup.Name,
                    workspacePublic.Name,
                    roleTypeTeacher.Name,
                    ruleReadersAndWriters.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeGroup.Name,
                    workspacePublic.Name,
                    roleTypeStudant.Name,
                    ruleReadersAndWriters.Name
                    );

                #endregion

                #endregion

                #region CREATE_CONTAINERS

                var container = new ContainerManager(dataBaseManager);

                var containerLeic = new ContainerView()
                                        {
                                            Name = "LEIC",
                                            Description = "Licencitura Egenharia informatica e de computadores"
                                        };

                container.Create(containerLeic, structure.Id, prototypeGraduation.Name);

                #region CREATE_COURSE_MPD

                var containerMpd = new ContainerView()
                                       {
                                           Name = "MPD",
                                           Description = "Modelo de padoes de desenho"
                                       };

                container.Create(containerMpd, structure.Id, prototypeCourse.Name, containerLeic.Id);

                var containerMpdLi31D = new ContainerView()
                                            {
                                                Name = "LI31D",
                                                Description = "Turma 1 de terceiro semestre diurno"
                                            };

                container.Create(containerMpdLi31D, structure.Id, prototypeClass.Name, containerMpd.Id);

                var containerMpdG1 = new ContainerView()
                                         {
                                             Name = "Grupo1",
                                             Description = "Grupo de MPD"
                                         };

                container.Create(containerMpdG1, structure.Id, prototypeGroup.Name, containerMpdLi31D.Id);

                var containerMpdG2 = new ContainerView()
                                         {
                                             Name = "Grupo2",
                                             Description = "Grupo de MPD"
                                         };

                container.Create(containerMpdG2, structure.Id, prototypeGroup.Name, containerMpdLi31D.Id);

                #endregion

                #region CREATE_COURSE_SD

                var containerSd = new ContainerView()
                                      {
                                          Name = "SD",
                                          Description = "Sistemas distribuidos"
                                      };

                container.Create(containerSd, structure.Id, prototypeCourse.Name, containerLeic.Id);

                var containerSdLi31D = new ContainerView()
                                           {
                                               Name = "LI31D",
                                               Description = "Turma 1 de terceiro semestre diurno"
                                           };

                container.Create(containerSdLi31D, structure.Id, prototypeClass.Name, containerSd.Id);

                var containerSdG1 = new ContainerView()
                                        {
                                            Name = "Grupo1",
                                            Description = "Grupo de SD"
                                        };

                container.Create(containerSdG1, structure.Id, prototypeGroup.Name, containerSdLi31D.Id);

                var containerSdG2 = new ContainerView()
                                        {
                                            Name = "Grupo2",
                                            Description = "Grupo de SD"
                                        };

                container.Create(containerSdG2, structure.Id, prototypeGroup.Name, containerSdLi31D.Id);

                #endregion

                #endregion

                #region ENROLL_USER

                userManager.Enroll(userFelix.Name, structure.Id, containerLeic.Id, roleTypeDirector.Name);

                userManager.Enroll(userFelix.Name, structure.Id, containerMpd.Id, roleTypeDirector.Name);
                userManager.Enroll(userGuedes.Name, structure.Id, containerSd.Id, roleTypeDirector.Name);

                userManager.Enroll(userFelix.Name, structure.Id, containerSdLi31D.Id, roleTypeTeacher.Name);
                userManager.Enroll(userGuedes.Name, structure.Id, containerMpdLi31D.Id, roleTypeTeacher.Name);

                userManager.Enroll(userFaustino.Name, structure.Id, containerMpdG1.Id, roleTypeStudant.Name);
                userManager.Enroll(userSamir.Name, structure.Id, containerMpdG1.Id, roleTypeStudant.Name);

                userManager.Enroll(userRicardo.Name, structure.Id, containerMpdG2.Id, roleTypeStudant.Name);
                userManager.Enroll(userGeada.Name, structure.Id, containerMpdG2.Id, roleTypeStudant.Name);

                userManager.Enroll(userFaustino.Name, structure.Id, containerSdG1.Id, roleTypeStudant.Name);
                userManager.Enroll(userRicardo.Name, structure.Id, containerSdG1.Id, roleTypeStudant.Name);

                userManager.Enroll(userGeada.Name, structure.Id, containerSdG2.Id, roleTypeStudant.Name);
                userManager.Enroll(userSamir.Name, structure.Id, containerSdG2.Id, roleTypeStudant.Name);

                #endregion

                //AuthorizationTestes aut = new AuthorizationTestes();
                //AuthorizationManager authorizationManager = new AuthorizationManager(dataBaseManager);

                //authorizationManager.CreateServiceAuthorizationStruct(aut, serviceSvn.Name);
            }
        }
        //
        // GET: /Admin/
        public void Populate()
        {
            DataBaseManager.DropAndCreate();

            using (var dataBaseManager = new DataBaseManager())
            {
                #region CREATE_SERVICES

                var serviceManager = new ServiceManager(dataBaseManager);

                var serviceSvn = new ServiceView()
                                     {
                                         Name = "Svn",
                                         Description = "System Version Control (Centralized)"
                                     };

                serviceManager.Create(serviceSvn, new[] {"r", "rw"});

                #endregion

                #region CREATE_USERS

                var userManager = new UserManager(dataBaseManager);

                var userFaustino = new UserView()
                                       {
                                           Name = "FaustinoLeiras",
                                           Email = "*****@*****.**",
                                           Password = "******"
                                       };

                userManager.Create(userFaustino);

                var userSamir = new UserView()
                                    {
                                        Name = "SamirHafez",
                                        Email = "*****@*****.**",
                                        Password = "******"
                                    };

                userManager.Create(userSamir);

                var userRicardo = new UserView()
                                      {
                                          Name = "Ricardo",
                                          Email = "*****@*****.**",
                                          Password = "******"
                                      };

                userManager.Create(userRicardo);

                var userGeada = new UserView()
                                    {
                                        Name = "Gueada",
                                        Email = "*****@*****.**",
                                        Password = "******"
                                    };

                userManager.Create(userGeada);

                var userFelix = new UserView()
                                    {
                                        Name = "Felix",
                                        Email = "*****@*****.**",
                                        Password = "******"
                                    };

                userManager.Create(userFelix);

                var userGuedes = new UserView()
                                     {
                                         Name = "Guedes",
                                         Email = "*****@*****.**",
                                         Password = "******"
                                     };

                userManager.Create(userGuedes);

                #endregion

                #region CREATE_STRUCTURE

                var structureManager = new StructureManager(dataBaseManager);

                var structure = new StructureView()
                                    {
                                        Name = "AcademicStructure",
                                        Description = "My Academic Structure :)"
                                    };

                structureManager.Create(structure, userFaustino.Name);

                #endregion

                #region CREATE_WORKSPACE_TYPE

                var workspaceType = new WorkSpaceTypeManager(dataBaseManager);

                var workspacePublic = new WorkSpaceTypeView()
                                          {
                                              Name = "public"
                                          };

                workspaceType.Create(workspacePublic, structure.Id, new[] {serviceSvn.Name});

                var workspacePrivate = new WorkSpaceTypeView()
                                           {
                                               Name = "private"
                                           };

                workspaceType.Create(workspacePrivate, structure.Id, new[] {serviceSvn.Name});

                #endregion

                #region CREATE_CONTAINER_PROTOTYPE

                var containerPrototype = new ContainerPrototypeManager(dataBaseManager);

                var prototypeGraduation = new ContainerPrototypeView()
                                              {
                                                  Name = "Graduation"
                                              };

                containerPrototype.Create(prototypeGraduation, structure.Id);

                var prototypeCourse = new ContainerPrototypeView()
                                          {
                                              Name = "Course"
                                          };

                containerPrototype.Create(prototypeCourse, structure.Id, prototypeGraduation.Name);

                var prototypeClass = new ContainerPrototypeView()
                                         {
                                             Name = "Class"
                                         };

                containerPrototype.Create(prototypeClass, structure.Id, prototypeCourse.Name);

                var prototypeGroup = new ContainerPrototypeView()
                                         {
                                             Name = "Group"
                                         };

                containerPrototype.Create(prototypeGroup, structure.Id, prototypeClass.Name);

                #endregion

                #region ADD_WORKSPACE_TYPES_INTO_CONTAINER_PROTOTYPE

                containerPrototype.AddWorkSpaceType(structure.Id, prototypeGraduation.Name, workspacePublic.Name);

                containerPrototype.AddWorkSpaceType(structure.Id, prototypeCourse.Name, workspacePublic.Name);

                containerPrototype.AddWorkSpaceType(structure.Id, prototypeClass.Name, workspacePublic.Name);
                containerPrototype.AddWorkSpaceType(structure.Id, prototypeClass.Name, workspacePrivate.Name);

                containerPrototype.AddWorkSpaceType(structure.Id, prototypeGroup.Name, workspacePublic.Name);

                #endregion

                #region CREATE_ROLETYPE

                var roleType = new RoleTypeManager(dataBaseManager);

                var roleTypeTeacher = new RoleTypeView()
                                          {
                                              Name = "teacher"
                                          };

                roleType.Create(roleTypeTeacher, structure.Id);

                var roleTypeDirector = new RoleTypeView()
                                           {
                                               Name = "director"
                                           };

                roleType.Create(roleTypeDirector, structure.Id);

                var roleTypeStudant = new RoleTypeView()
                                          {
                                              Name = "studant"
                                          };

                roleType.Create(roleTypeStudant, structure.Id);

                #endregion

                #region CREATE_RULE

                var rule = new RuleManager(dataBaseManager);

                var ruleReaders = new RuleView()
                                      {
                                          Name = "readers"
                                      };

                rule.Create(ruleReaders, structure.Id, new[]
                                                           {
                                                               new KeyValuePair<string, string>(serviceSvn.Name, "r")
                                                           });

                var ruleReadersAndWriters = new RuleView()
                                                {
                                                    Name = "ReadersAndWriters"
                                                };

                rule.Create(ruleReadersAndWriters, structure.Id, new[]
                                                                     {
                                                                         new KeyValuePair<string, string>(
                                                                             serviceSvn.Name,
                                                                             "rw")
                                                                     });

                #endregion

                #region CREATE_ROLE

                var role = new RoleManager(dataBaseManager);

                #region ADD_ROLES_COURSE_WORKSPACE_PUBLIC

                role.Create(
                    structure.Id,
                    prototypeCourse.Name,
                    workspacePublic.Name,
                    roleTypeDirector.Name,
                    ruleReadersAndWriters.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeCourse.Name,
                    workspacePublic.Name,
                    roleTypeTeacher.Name,
                    ruleReaders.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeCourse.Name,
                    workspacePublic.Name,
                    roleTypeStudant.Name,
                    ruleReaders.Name
                    );

                #endregion

                #region ADD_ROLES_CLASS_WORKSPACE_PUBLIC

                role.Create(
                    structure.Id,
                    prototypeClass.Name,
                    workspacePublic.Name,
                    roleTypeDirector.Name,
                    ruleReaders.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeClass.Name,
                    workspacePublic.Name,
                    roleTypeTeacher.Name,
                    ruleReadersAndWriters.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeClass.Name,
                    workspacePublic.Name,
                    roleTypeStudant.Name,
                    ruleReaders.Name
                    );

                #endregion

                #region ADD_ROLES_CLASS_WORKSPACE_PRIVATE

                role.Create(
                    structure.Id,
                    prototypeClass.Name,
                    workspacePrivate.Name,
                    roleTypeDirector.Name,
                    ruleReaders.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeClass.Name,
                    workspacePrivate.Name,
                    roleTypeTeacher.Name,
                    ruleReadersAndWriters.Name
                    );

                #endregion

                #region ADD_ROLES_GROUP_WORKSPACE_PUBLIC

                role.Create(
                    structure.Id,
                    prototypeGroup.Name,
                    workspacePublic.Name,
                    roleTypeDirector.Name,
                    ruleReaders.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeGroup.Name,
                    workspacePublic.Name,
                    roleTypeTeacher.Name,
                    ruleReadersAndWriters.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeGroup.Name,
                    workspacePublic.Name,
                    roleTypeStudant.Name,
                    ruleReadersAndWriters.Name
                    );

                #endregion

                #endregion
            }
        }
示例#10
0
 public StructureViewDragDropHandler(StructureView structureView)
 {
     this.StructureView = structureView;
 }