Ejemplo n.º 1
0
        public static void DefineStreamFactories(ReactiveServiceContext context, SubjectManager manager)
        {
            Expression <Func <IReactiveQubject> > untypedExpr = () => manager.CreateUntyped().To <IMultiSubject, IReactiveQubject>();
            var untypedFactory = context.Provider.CreateQubjectFactory <T, T>(untypedExpr);

            context.DefineStreamFactory(PlatformConstants.Identifiers.Observable.FireHose.Uri, untypedFactory, null);
        }
Ejemplo n.º 2
0
        public ActionResult DeleteNode(long id)
        {
            try
            {
                SubjectManager subjectManager = new SubjectManager();
                //InteractionManager interactionManager = new InteractionManager();
                Node node = subjectManager.GetAllAsQueryable <Node>().Where(n => n.Id.Equals(Convert.ToInt64(id))).FirstOrDefault();

                //remove all dependend interacions
                //var interactions = subjectManager.GetAllDependingInteractions(node).ToList();

                //for (int i = 0; i < interactions.Count(); i++)
                //{
                //    interactionManager.Delete(interactions[i]);
                //}

                subjectManager.DeleteNode(node);

                return(Json(true));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get a dictionary with keys and count from the system
        /// Plants, Animals, Interactions, Beete, User
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, int> GetStatistics()
        {
            Dictionary <string, int> tmp                = new Dictionary <string, int>();
            SubjectManager           subjectManager     = new SubjectManager();
            InteractionManager       interactionManager = new InteractionManager();
            PatchManager             patchManager       = new PatchManager();

            int plantsCount  = subjectManager.GetAll <Plant>().Length;
            int animalsCount = subjectManager.GetAll <Animal>().Length;
            int actionsCount = interactionManager.GetAll <Interaction>().Length;
            int patchesCount = patchManager.GetAll <Patch>().Length;
            int usersCount   = 0;

            int varietiesPlantCount = subjectManager.GetAll <Plant>().Where(p => p.Rank.Equals(TaxonRank.SubSpecies)).Count();
            int animalSpeciesCount  = subjectManager.GetAll <Animal>().Where(p => p.Rank.Equals(TaxonRank.Species)).Count();


            tmp.Add("Pflanzen", plantsCount);
            tmp.Add("Sorten", varietiesPlantCount);
            tmp.Add("Tiere", animalsCount);
            tmp.Add("TierArten", animalSpeciesCount);
            tmp.Add("Interaktionen", actionsCount);
            tmp.Add("Gärten", patchesCount);
            tmp.Add("Nutzer", usersCount);

            return(tmp);
        }
Ejemplo n.º 4
0
        // transfer users to bpp; not all user data are provided in bpp
        // save usernames and passwords in file "passwords.txt"
        public void CreateOnBPP(List<UserProperties> transferUsers, string filePath, long groupId)
        {
            SubjectManager subjectManager = new SubjectManager();
            StreamWriter file = new StreamWriter(filePath + @"\passwords.txt");

            foreach (UserProperties transferUser in transferUsers)
            {
                // transfer user if not exist
                if (!subjectManager.ExistsUserName(transferUser.username))
                {
                    // create user
                    User user = subjectManager.CreateUser(
                        transferUser.username,
                        transferUser.password,
                        transferUser.firstname + " " + transferUser.lastname,
                        transferUser.email,
                        transferUser.securityQuestionId,
                        transferUser.securityAnswer,
                        transferUser.authenticatorId
                        );

                    // add user to group; the group "bexisUser" must be created manually
                    subjectManager.AddUserToGroup(user.Id, groupId);
                    // write username and generated password to file "passwords.txt"
                    file.WriteLine(transferUser.username + ",\t" + transferUser.password);
                }
            }

            file.Close();
        }
Ejemplo n.º 5
0
        public ActionResult AddPlant(long id, long patchId)
        {
            try
            {
                PatchManager patchManager = new PatchManager();
                Patch        patch        = patchManager.Get(patchId);

                SubjectManager subjectManager = new SubjectManager();

                long plantId = id;

                Plant p = subjectManager.GetAll <Plant>().Where(x => x.Id.Equals(plantId)).FirstOrDefault();

                Placement placement = new Placement();
                placement.Plant = p;
                placement.Patch = patch;

                PlacementModel model = PatchModelHelper.ConvertTo(placement);

                return(PartialView("Placement", model));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 6
0
        public ActionResult AddRandomPlant(long id)
        {
            PatchManager   patchManager   = new PatchManager();
            Patch          patch          = patchManager.Get(id);
            SubjectManager subjectManager = new SubjectManager();

            List <long> ids = subjectManager.GetAll <Plant>().Select(pa => pa.Id).ToList();


            Random random    = new Random();
            int    randomInt = random.Next(1, ids.Count - 1);

            long plantId = ids.ElementAt(randomInt);

            Plant p = subjectManager.Get(plantId) as Plant;

            Placement placement = new Placement();

            placement.Plant = p;
            placement.Patch = patch;

            patch.PatchElements.Add(placement);

            patchManager.Update(patch);

            PlacementModel model = PatchModelHelper.ConvertTo(placement);

            return(PartialView("Placement", model));
        }
Ejemplo n.º 7
0
        public ActionResult Subjects_Select(long entityId, long instanceId)
        {
            var subjectManager          = new SubjectManager();
            var entityPermissionManager = new EntityPermissionManager();

            try
            {
                var subjects = new List <EntityPermissionGridRowModel>();
                foreach (var subject in subjectManager.Subjects)
                {
                    var rights          = entityPermissionManager.GetRights(subject.Id, entityId, instanceId);
                    var effectiveRights = entityPermissionManager.GetEffectiveRights(subject.Id, entityId, instanceId);

                    subjects.Add(EntityPermissionGridRowModel.Convert(subject, rights, effectiveRights));
                }

                return(View(new GridModel <EntityPermissionGridRowModel> {
                    Data = subjects
                }));
            }
            finally
            {
                subjectManager.Dispose();
                entityPermissionManager.Dispose();
            }
        }
Ejemplo n.º 8
0
        private TreeElement GetTreeElement(Node node)
        {
            SubjectManager subjectManager = new SubjectManager();


            if (node != null)
            {
                TreeElement tmp = new TreeElement();

                tmp.id   = node.Id;
                tmp.name = node.Name;

                var children = subjectManager.GetAll <Node>().Where(c => c.Parent != null && c.Parent.Id.Equals(node.Id));
                if (children != null)
                {
                    foreach (var child in children)
                    {
                        tmp.children.Add(GetTreeElement(child));
                    }
                }

                return(tmp);
            }

            return(null);
        }
Ejemplo n.º 9
0
        public bool IsFeatureInEveryoneGroup(long featureId)
        {
            PermissionManager permissionManager = new PermissionManager();
            SubjectManager subjectManager = new SubjectManager();

            return permissionManager.ExistsFeaturePermission(subjectManager.GetGroupByName("everyone").Id, featureId);
        }
Ejemplo n.º 10
0
        public ActionResult Search(bool reset = false)
        {
            //ToDo think about setting sessions, is this the rigth place ?
            //load all names in session

            getAllNames();

            if (reset)
            {
                ResetSearchProvider();
            }

            SearchProvider sp             = GetSearchProvider();
            SubjectManager subjectManager = new SubjectManager();

            //Get all subjects
            var subjects = subjectManager.GetAll <Subject>();

            SearchModel Model = new SearchModel(subjects.ToList().OrderBy(s => s.Name).ToList());

            SearchManager searchManager = new SearchManager();

            var species = searchManager.Search(sp.SearchCriterias);

            if (species != null)
            {
                //convert all subjects to subjectModels
                species = species.OrderBy(p => p.Name);
                species.ToList().ForEach(s => Model.Species.Add(NodeModel.Convert(s)));
            }

            Model.SearchCriterias = sp.SearchCriterias;

            return(View("Search", Model));
        }
Ejemplo n.º 11
0
        private void testIntractions()
        {
            SubjectManager subjectManager = new SubjectManager();


            Subject subject = new Subject();

            subject.Name        = "ALTER FETTE SCHEIßE 3";
            subject.Description = "ES FUNKT 3";
            subjectManager.Create(subject);

            Subject Object = new Subject();

            Object.Name        = "ALTER FETTE SCHEIßE 3";
            Object.Description = "ES FUNKT 3";
            subjectManager.Create(Object);

            Predicate positive =
                subjectManager.GetAll <Predicate>().Where(p => p.Name.ToLower().Equals("positiv")).FirstOrDefault();

            Predicate predicate = new Predicate();

            predicate.Parent = positive;
            predicate.Name   = "X";

            InteractionManager interactionManager = new InteractionManager();
            Interaction        interaction        = new Interaction();

            interaction.Subject   = subject;
            interaction.Object    = Object;
            interaction.Predicate = predicate;

            interactionManager.Create(interaction);
            interactionManager.Delete(interaction);
        }
Ejemplo n.º 12
0
 public IActionResult AddG(GradeModel model)
 {
     if (ModelState.IsValid)
     {
         var student = StudentManager.GetAll().FirstOrDefault(c => c.Name == model.StudentName && c.Surname == model.StudentSurname);
         var subject = SubjectManager.GetAll().FirstOrDefault(c => c.Name == model.SubjectName);
         //model.Subject = SubjectController.Subjects.Find(s => s.Name == model.SubjectName);
         //model.Student = StudentController.Students.Find(s => s.Name == model.StudentName && s.Surname == model.StudentSurname);
         if (student == null)
         {
             ModelState.AddModelError("stu", "Skolnieks nav atrasts!");
         }
         else if (subject == null)
         {
             ModelState.AddModelError("sub", "Priekšmets nav atrasts!");
         }
         else if (model.Grade < 1 || model.Grade > 10)
         {
             ModelState.AddModelError("gra", "Atzīmei jābūt intervālā no 1 līdz 10!");
         }
         else
         {
             GradeManager.Create(model.Grade, model.Comment, student.Id, subject.Id);
             return(RedirectToAction(nameof(IndexG)));
         }
     }
     return(View(model));
 }
Ejemplo n.º 13
0
        public List <Subject> GetBestSubject()
        {
            List <Subject> best_subjects = new List <Subject> {
            };
            List <Subject> all_subjects  = SubjectManager.GetSubjects();

            all_subjects.RemoveAll(x => x.average == 0);
            all_subjects.Sort((x, y) => x.average.CompareTo(y.average));

            decimal last_average = 6;

            foreach (Subject subject in all_subjects)
            {
                if (subject.average < last_average)
                {
                    best_subjects.Clear();
                    best_subjects.Add(subject);
                }
                else if (subject.average == last_average)
                {
                    best_subjects.Add(subject);
                }
                last_average = subject.average;
            }

            return(best_subjects);
        }
Ejemplo n.º 14
0
        public double GetTotalAverage()
        {
            double all_averages       = 0;
            int    number_of_subjects = 0;
            double total_average;

            foreach (Subject subject in SubjectManager.GetSubjects())
            {
                all_averages += (double)subject.average;
                if (subject.average != 0)
                {
                    number_of_subjects += 1;
                }
            }

            if (number_of_subjects != 0)
            {
                total_average = (all_averages / number_of_subjects);
            }
            else
            {
                total_average = 0;
            }


            return(total_average);
        }
Ejemplo n.º 15
0
        public ActionResult Delete(long id)
        {
            if (id > 0)
            {
                InteractionManager interactionManager = new InteractionManager();
                SubjectManager     subjectManager     = new SubjectManager();
                PredicateManager   predicateManager   = new PredicateManager();

                //get all interaction with this predicate
                var interactions = interactionManager.GetAll().Where(i => i.Predicate.Id.Equals(id));

                // delete the interactions
                foreach (var interaction in interactions)
                {
                    interactionManager.Delete(interaction);
                }

                // delete the predictae

                var predicate = predicateManager.Get(id);
                if (predicate != null)
                {
                    predicateManager.Delete(predicate);
                }
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 16
0
        // GET api/<controller>/5
        public SubjectModel Get(int id)
        {
            SubjectManager manager = new SubjectManager();
            var            subject = manager.Get(id);

            return(SubjectModel.Convert(subject));
        }
Ejemplo n.º 17
0
        public ActionResult Subjects()
        {
            SubjectManager subjects_manager = new SubjectManager();
            List <Subject> subjects         = subjects_manager.Get_Data();

            return(View(subjects));
        }
Ejemplo n.º 18
0
 public Form1()
 {
     InitializeComponent();
     gr   = new GroupManager(uOW);
     sbj  = new SubjectManager(uOW);
     stud = new StudentManager(uOW);
     //grsbj = new GroupSubjectManager(uOW);
 }
Ejemplo n.º 19
0
        public ActionResult Edit(long id)
        {
            SubjectManager subjectManager = new SubjectManager();

            User user = subjectManager.GetUserById(id);

            return PartialView("_EditPartial", UserEditModel.Convert(user));
        }
Ejemplo n.º 20
0
        public ActionResult Edit(long id)
        {
            SubjectManager subjectManager = new SubjectManager();

            Group group = subjectManager.GetGroupById(id);

            return PartialView("_EditPartial", GroupEditModel.Convert(group));
        }
Ejemplo n.º 21
0
        public ActionResult Details(long id, string type)
        {
            SubjectManager sm = new SubjectManager();

            Subject s = sm.Get(id);

            //load by loading the page and store it in a session!!!!

            switch (type)
            {
            case "Plant":
            {
                Plant plant = sm.GetAll <Plant>().Where(p => p.Id.Equals(id)).FirstOrDefault();

                PlantModel Model = PlantModel.Convert(plant);
                //load interactions
                Model.Interactions = SubjectModel.ConverInteractionModels(sm.GetAllDependingInteractions(plant, true).ToList());

                return(View("PlantDetails", Model));
            }

            case "Animal":
            {
                Animal animal = sm.GetAll <Animal>().Where(a => a.Id.Equals(id)).FirstOrDefault();

                AnimalModel Model = AnimalModel.Convert(animal);
                Model.Interactions = SubjectModel.ConverInteractionModels(sm.GetAllDependingInteractions(animal, true).ToList());

                return(View("AnimalDetails", Model));
            }

            case "Taxon":
            {
                Taxon     taxon = sm.GetAll <Taxon>().Where(a => a.Id.Equals(id)).FirstOrDefault();
                NodeModel Model = NodeModel.Convert(taxon);

                return(View("TaxonDetails", Model));
            }

            case "Effect":
            {
                Effect effect = sm.GetAll <Effect>().Where(e => e.Id.Equals(id)).FirstOrDefault();

                return(View("EffectDetails"));
            }

            case "Unknow":
            {
                SubjectModel Model = SubjectModel.Convert(s);

                return(View("SubjectDetails", Model));
            }

            default: { break; }
            }

            return(RedirectToAction("Search", "Search"));;
        }
Ejemplo n.º 22
0
 public EvaluationsController(
     EvaluationManager <ApplicationDbContext> evaluationManager,
     SubjectManager <ApplicationDbContext> subjectManager,
     UserManager <Student> userManager)
 {
     _evaluationManager = evaluationManager;
     _subjectManager    = subjectManager;
     _userManager       = userManager;
 }
Ejemplo n.º 23
0
 public SubjectsController(
     ClassRoomManager <ApplicationDbContext> classRoomManager,
     SubjectManager <ApplicationDbContext> subjectManager,
     UserManager <Student> userManager)
 {
     _classRoomManager = classRoomManager;
     _subjectManager   = subjectManager;
     _userManager      = userManager;
 }
Ejemplo n.º 24
0
        public async void no_subjects_created()
        {
            var result = await SubjectManager.no_subject_created();

            if (result == ContentDialogResult.Primary)
            {
                Frame.Navigate(typeof(AddSubject));
            }
        }
Ejemplo n.º 25
0
        public void ConcealDataset(long entityId, long datasetId)
        {
            PermissionManager permissionManager = new PermissionManager();
            SubjectManager subjectManager = new SubjectManager();

            Group group = subjectManager.GetGroupByName("everyone");

            permissionManager.DeleteDataPermission(group.Id, entityId, datasetId, RightType.View);
        }
Ejemplo n.º 26
0
        private Node LoadParent(Node node, SubjectManager subjectManager)
        {
            if (node.Parent != null)
            {
                LoadParent(node.Parent, subjectManager);
            }

            return(subjectManager.GetAll <Node>().Where(n => n.Id.Equals(node.Id)).FirstOrDefault());
        }
Ejemplo n.º 27
0
        public IActionResult Add(SubjectModel model)
        {
            if (ModelState.IsValid)
            {
                SubjectManager.Create(model.Name);

                return(RedirectToAction(nameof(Index)));// vai arī tikai  "Index"?
            }
            return(View(model));
        }
Ejemplo n.º 28
0
 public ExamSheetManager(RepositoryWrapper repositoryWrapper, GroupManager groupManager, TeacherManager teacherManager,
                         FacultyManager facultyManager, SubjectManager subjectManager, RatingManager ratingManager)
     : base(repositoryWrapper)
 {
     GroupManager   = groupManager;
     TeacherManager = teacherManager;
     FacultyManager = facultyManager;
     SubjectManager = subjectManager;
     RatingManager  = ratingManager;
 }
Ejemplo n.º 29
0
        public ActionResult Subjects_Select(GridCommand command, long entityId, long instanceId)
        {
            var subjectManager          = new SubjectManager();
            var entityPermissionManager = new EntityPermissionManager();

            try
            {
                var subjectsDb = new List <Subject>();
                var count      = 0;
                if (command != null)// filter subjects based on grid filter settings
                {
                    FilterExpression  filter  = TelerikGridHelper.Convert(command.FilterDescriptors.ToList());
                    OrderByExpression orderBy = TelerikGridHelper.Convert(command.SortDescriptors.ToList());

                    subjectsDb = subjectManager.GetSubjects(filter, orderBy, command.Page, command.PageSize, out count);
                }
                else
                {
                    subjectsDb = subjectManager.Subjects.ToList();
                    count      = subjectsDb.Count();
                }

                var subjects = new List <EntityPermissionGridRowModel>();
                //using (PartyManager partyManager = new PartyManager())

                //foreach (var subject in subjectsDb)
                //{
                //    var rights = entityPermissionManager.GetRights(subject.Id, entityId, instanceId);
                //    var effectiveRights = entityPermissionManager.GetEffectiveRights(subject.Id, entityId, instanceId);

                //    subjects.Add(EntityPermissionGridRowModel.Convert(subject, rights, effectiveRights));
                //}

                var rightsDic          = entityPermissionManager.GetRights(subjectsDb, entityId, instanceId);
                var effectiveRightsDic = entityPermissionManager.GetEffectiveRights(subjectsDb, entityId, instanceId);

                foreach (var item in rightsDic)
                {
                    var subject         = subjectsDb.Where(s => s.Id.Equals(item.Key)).FirstOrDefault();
                    var rights          = item.Value;
                    var effectiveRights = effectiveRightsDic[item.Key];

                    subjects.Add(EntityPermissionGridRowModel.Convert(subject, rights, effectiveRights));
                }

                return(View(new GridModel <EntityPermissionGridRowModel> {
                    Data = subjects, Total = count
                }));
            }
            finally
            {
                subjectManager.Dispose();
                entityPermissionManager.Dispose();
            }
        }
 public TeacherSheetController(ExamSheetManager examSheetManager, TeacherManager teacherManager, FacultyManager facultyManager,
                               GroupManager groupManager, SubjectManager subjectManager, StudentManager studentManager, RatingManager ratingManager)
 {
     ExamSheetManager = examSheetManager;
     TeacherManager   = teacherManager;
     FacultyManager   = facultyManager;
     GroupManager     = groupManager;
     SubjectManager   = subjectManager;
     StudentManager   = studentManager;
     RatingManager    = ratingManager;
 }
Ejemplo n.º 31
0
        public IActionResult AddSubject(SubjectModel model)
        {
            if (ModelState.IsValid)
            {
                SubjectManager.CreateNewSubject(model.SubjectName);

                return(RedirectToAction(nameof(SubjectIndex)));
            }

            return(View(model));
        }
Ejemplo n.º 32
0
 public ChartController(ExamSheetManager examSheetManager, RatingManager ratingManager, GroupManager groupManager,
                        SubjectManager subjectManager, StudentManager studentManager, DeaneryManager deaneryManager, TeacherManager teacherManager)
 {
     ExamSheetManager = examSheetManager;
     RatingManager    = ratingManager;
     GroupManager     = groupManager;
     SubjectManager   = subjectManager;
     StudentManager   = studentManager;
     DeaneryManager   = deaneryManager;
     TeacherManager   = teacherManager;
 }
Ejemplo n.º 33
0
        // GET: Predicate
        public ActionResult Index()
        {
            SubjectManager        subjectManager = new SubjectManager();
            List <PredicateModel> Model          = new List <PredicateModel>();

            var predicates = subjectManager.GetAll <Predicate>();

            predicates.ToList().ForEach(p => Model.Add(PredicateModel.Convert(p)));

            return(View(Model));
        }
Ejemplo n.º 34
0
        // GET api/<controller>/5
        public AnimalModel Get(int id)
        {
            SubjectManager manager = new SubjectManager();
            var            animal  = manager.GetAll <Animal>().Where(p => p.Id.Equals(id)).FirstOrDefault();

            AnimalModel model = AnimalModel.Convert(animal);

            model.Interactions = AnimalModel.ConverInteractionModels(manager.GetAllDependingInteractions(animal, true).ToList());

            return(model);
        }
Ejemplo n.º 35
0
        public async Task Execute(IJobExecutionContext context)
        {
            DateTime       date           = DateTime.Now;
            SubjectManager subjectManager = new SubjectManager();
            AlertManager   alertManager   = new AlertManager();
            await subjectManager.WeeklyReview(date);

            await alertManager.ShowUserWeeklyAlerts();

            await Console.Out.WriteLineAsync("Weekly Review Updated");
        }
Ejemplo n.º 36
0
        public ActionResult Create(GroupCreateModel model)
        {
            if (ModelState.IsValid)
            {
                SubjectManager subjectManager = new SubjectManager();
                subjectManager.CreateGroup(model.GroupName, model.Description);

                return Json(new { success = true });
            }

            return PartialView("_CreatePartial", model);
        }
Ejemplo n.º 37
0
        public ActionResult Edit(UserEditModel model)
        {
            if (ModelState.IsValid)
            {
                SubjectManager subjectManager = new SubjectManager();

                User user = subjectManager.GetUserById(model.UserId);

                if (model.Password == model.ConfirmPassword && model.Password != null)
                {
                    subjectManager.ChangePassword(user.Id, model.Password);
                }

                user.FullName = model.FullName;
                user.Email = model.Email;

                user.IsApproved = model.IsApproved;
                user.IsBlocked = model.IsBlocked;
                user.IsLockedOut = model.IsLockedOut;

                // removing
                long[] groups = user.Groups.Select(g => g.Id).ToArray();

                foreach (long groupId in groups)
                {
                    subjectManager.RemoveUserFromGroup(user.Id, groupId);
                }

                //adding
                if (Session["Groups"] != null)
                {
                    foreach (UserMembershipGridRowModel group in (UserMembershipGridRowModel[]) Session["Groups"])
                    {
                        if (group.IsUserInGroup)
                        {
                            subjectManager.AddUserToGroup(user.Id, group.Id);
                        }
                    }
                }

                subjectManager.UpdateUser(user);

                return Json(new { success = true });
            }
            else
            {
                return PartialView("_EditPartial", model);
            }
        }
Ejemplo n.º 38
0
        public ActionResult Datasets_Select()
        {
            DatasetManager datasetManager = new DatasetManager();
            PermissionManager permissionManager = new PermissionManager();
            SubjectManager subjectManager = new SubjectManager();

            // DATA
            //var ids = datasetManager.GetDatasetLatestIds();
            List<DatasetVersion> data = datasetManager.GetDatasetLatestVersions(); // .GetDatasetLatestVersions(ids);

            List<DatasetGridRowModel> datasets = new List<DatasetGridRowModel>();
            data.ForEach(d => datasets.Add(DatasetGridRowModel.Convert(d, permissionManager.ExistsDataPermission(subjectManager.GetGroupByName("everyone").Id, 1, d.Id, RightType.View))));

            return View(new GridModel<DatasetGridRowModel> { Data = datasets });
        }
Ejemplo n.º 39
0
        // create or get and return the group named "bexisUser"
        public long bexisUserGroup()
        {
            SubjectManager subjectManager = new SubjectManager();

            string groupName = "bexisUser";
            string groupDescription = "user of old BExIS";

            Group group = subjectManager.GroupsRepo.Get(g => groupName.Equals(g.Name)).FirstOrDefault();

            if (group == null)
            {
                group = subjectManager.CreateGroup(groupName, groupDescription);
            }

            return group.Id;
        }
Ejemplo n.º 40
0
        public ActionResult Create(UserCreateModel model)
        {
            if (ModelState.IsValid)
            {
                SubjectManager subjectManager = new SubjectManager();
                User user = subjectManager.CreateUser(model.Username, model.Password, model.FullName, model.Email, model.SecurityQuestion, model.SecurityAnswer, model.AuthenticatorList.Id);

                // Feature
                FeatureManager featureManager = new FeatureManager();
                Feature feature = featureManager.FeaturesRepo.Get(f => f.Name == "Search").FirstOrDefault();

                // Permissions
                PermissionManager permissionManager = new PermissionManager();
                permissionManager.CreateFeaturePermission(user.Id, feature.Id);

                return Json(new { success = true });
            }

            return PartialView("_CreatePartial", model);
        }
Ejemplo n.º 41
0
        public ActionResult Edit(GroupEditModel model)
        {
            if (ModelState.IsValid)
            {
                SubjectManager subjectManager = new SubjectManager();

                Group group = subjectManager.GetGroupById(model.GroupId);

                group.Name = model.GroupName;
                group.Description = model.Description;

                long[] users = group.Users.Select(g => g.Id).ToArray();

                foreach (long userId in users)
                {
                    subjectManager.RemoveUserFromGroup(userId, group.Id);
                }

                if (Session["Users"] != null)
                {
                    foreach (GroupMembershipGridRowModel user in (GroupMembershipGridRowModel[]) Session["Users"])
                    {
                        if (user.IsUserInGroup)
                        {
                            subjectManager.AddUserToGroup(user.Id, group.Id);
                        }
                    }
                }

                subjectManager.UpdateGroup(group);

                return Json(new { success = true });
            }
            else
            {
                return PartialView("_EditPartial", model);
            }
        }
Ejemplo n.º 42
0
        public void queryAuthorAndVariables(ref User user, ref string variableNames, string dataSetID, string DataBase)
        {
            string mySelectQuery = "select X.* from explorer.datasets, XMLTABLE ('$METADATA/*:metaProfile' Columns " +
                                        "Author varchar(256) Path '*:general/*:metadataCreator'," +
                                        "VarNames varchar(1028) Path 'string-join(*:data/*:dataStructure/*:variables/*:variable/*:name,\",\")'" +
                                    ") as X where datasetid = " + dataSetID + ";";

            DB2Connection connect = new DB2Connection(DataBase);
            DB2Command myCommand = new DB2Command(mySelectQuery, connect);
            connect.Open();
            DB2DataReader myReader = myCommand.ExecuteReader();

            string author = "";
            while (myReader.Read())
            {
                author = myReader.GetString(0);
                variableNames = myReader.GetString(1);
            }
            myReader.Close();
            connect.Close();

            SubjectManager subjectManager = new SubjectManager();
            user = subjectManager.UsersRepo.Get(u => author.Equals(u.FullName)).FirstOrDefault();
        }
Ejemplo n.º 43
0
        public ActionResult Membership_Select(long id, long[] selectedGroups)
        {
            SubjectManager subjectManager = new SubjectManager();

            List<UserMembershipGridRowModel> groups = new List<UserMembershipGridRowModel>();

            if (selectedGroups != null)
            {
                groups = subjectManager.GetAllGroups().Select(g => UserMembershipGridRowModel.Convert(g, selectedGroups.Contains(g.Id))).ToList();
            }
            else
            {
                User user = subjectManager.GetUserById(id);

                groups = subjectManager.GetAllGroups().Select(g => UserMembershipGridRowModel.Convert(g, g.Users.Any(u => u.Id == id))).ToList();
            }

            return View(new GridModel<UserMembershipGridRowModel> { Data = groups });
        }
Ejemplo n.º 44
0
        public ActionResult LogOn(AccountLogOnModel model)
        {
            if (ModelState.IsValid)
            {
                #region Authenticator

                AuthenticatorManager authenticatorManager = new AuthenticatorManager();
                Authenticator authenticator = authenticatorManager.GetAuthenticatorById(model.AuthenticatorList.Id);
                Assembly assembly = Assembly.Load(authenticator.AssemblyPath);
                Type type = assembly.GetType(authenticator.ClassPath);

                #endregion Authenticator

                #region AuthenticationManager

                IAuthenticationManager authenticationManager = (IAuthenticationManager)Activator.CreateInstance(type, authenticator.ConnectionString);

                #endregion AuthenticationManager

                if (authenticationManager.ValidateUser(model.Username, model.Password))
                {
                    SubjectManager subjectManager = new SubjectManager();

                    if (!subjectManager.ExistsUsernameWithAuthenticatorId(model.Username, model.AuthenticatorList.Id))
                    {
                        subjectManager.CreateUser(model.Username, model.AuthenticatorList.Id);
                    }

                    FormsAuthentication.SetAuthCookie(model.Username, false);

                    return Json(new { success = true });
                }
                else
                {
                    ModelState.AddModelError("", "The Username or Password provided is incorrect.");
                }
            }

            return PartialView("_LogOnPartial", model);
        }
Ejemplo n.º 45
0
        public JsonResult ValidateEmail(string email, long userId = 0)
        {
            SubjectManager subjectManager = new SubjectManager();

            User user = subjectManager.GetUserByEmail(email);

            if (user == null)
            {
                return Json(true, JsonRequestBehavior.AllowGet);
            }
            else
            {
                if (user.Id == userId)
                {
                    return Json(true, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    string error = String.Format(CultureInfo.InvariantCulture, "The e-mail address already exists.", email);

                    return Json(error, JsonRequestBehavior.AllowGet);
                }
            }
        }
Ejemplo n.º 46
0
        public ActionResult Register(AccountRegisterModel model)
        {
            if (ModelState.IsValid)
            {
                SubjectManager subjectManager = new SubjectManager();

                User user = subjectManager.CreateUser(model.Username, model.Password, model.FullName, model.Email, model.SecurityQuestion, model.SecurityAnswer, model.AuthenticatorList.Id);
                LoggerFactory.LogData(user.Id.ToString(), typeof(User).Name, Vaiona.Entities.Logging.CrudState.Created);

                // Feature
                FeatureManager featureManager = new FeatureManager();
                Feature feature = featureManager.FeaturesRepo.Get(f => f.Name == "Search").FirstOrDefault();

                // Permissions
                PermissionManager permissionManager = new PermissionManager();
                permissionManager.CreateFeaturePermission(user.Id, feature.Id);

                FormsAuthentication.SetAuthCookie(model.Username, false);
                return Json(new { success = true });
            }

            return PartialView("_RegisterPartial", model);
        }
Ejemplo n.º 47
0
        public ActionResult MyAccount(MyAccountModel model)
        {
            if (!ModelState.IsValid) return View("MyAccount", model);

            SubjectManager subjectManager = new SubjectManager();

            User user = subjectManager.GetUserById(model.UserId);

            if (model.Password == model.ConfirmPassword && model.Password != null)
            {
                subjectManager.ChangePassword(user.Id, model.Password);
            }

            if (model.SecurityAnswer != null)
            {
                subjectManager.ChangeSecurityQuestionAndSecurityAnswer(user.Id, model.SecurityQuestionId, model.SecurityAnswer);
            }

            user.Email = model.Email;
            user.FullName = model.FullName;

            subjectManager.UpdateUser(user);

            return RedirectToAction("Index", "Home", new { area = "" });
        }
Ejemplo n.º 48
0
        /// <summary>
        /// return true if user has edit rights
        /// </summary>
        /// <returns></returns>
        private bool hasUserEditAccessRights(long entityId)
        {
            #region security permissions and authorisations check
            // set edit rigths
            PermissionManager permissionManager = new PermissionManager();
            SubjectManager subjectManager = new SubjectManager();
            Security.Services.Objects.TaskManager securityTaskManager = new Security.Services.Objects.TaskManager();

            bool hasAuthorizationRights = false;

            User user = subjectManager.GetUserByName(GetUsernameOrDefault());
            long userid = -1;

            if (user != null)
            {
                userid = subjectManager.GetUserByName(GetUsernameOrDefault()).Id;

                //User has Access to Features
                //Area DCM
                //Controller "Create Dataset"
                //Action "*"
                Task task = securityTaskManager.GetTask("DCM", "CreateDataset", "*");
                if (task != null)
                {
                    hasAuthorizationRights = permissionManager.HasSubjectFeatureAccess(userid, task.Feature.Id);
                }

                return (hasAuthorizationRights);
            }
            else
            {
                return false;
            }

            #endregion
        }
Ejemplo n.º 49
0
        public ActionResult Users_Select()
        {
            SubjectManager subjectManager = new SubjectManager();
            List<UserGridRowModel> users = subjectManager.GetAllUsers().Select(u => UserGridRowModel.Convert(u)).ToList();

            return View(new GridModel<UserGridRowModel> { Data = users });
        }
Ejemplo n.º 50
0
        public JsonResult ValidateGroupName(string groupName, long groupId = 0)
        {
            SubjectManager subjectManager = new SubjectManager();

            Group group = subjectManager.GetGroupByName(groupName);

            if (group == null)
            {
                return Json(true, JsonRequestBehavior.AllowGet);
            }
            else
            {
                if (group.Id == groupId)
                {
                    return Json(true, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    string error = String.Format(CultureInfo.InvariantCulture, "The group name already exists.", groupName);

                    return Json(error, JsonRequestBehavior.AllowGet);
                }
            }
        }
Ejemplo n.º 51
0
        public List<ListViewItem> LoadDatasetVersionViewList( DataStructureType dataStructureType)
        {
            PermissionManager permissionManager = new PermissionManager();
                SubjectManager subjectManager = new SubjectManager();

                // add security
                ICollection<long> datasetIDs = permissionManager.GetAllDataIds(subjectManager.GetUserByName(GetUsernameOrDefault()).Id, 1, RightType.Update).ToList();

                DataStructureManager dataStructureManager = new DataStructureManager();
                DatasetManager dm = new DatasetManager();

                Dictionary<long, XmlDocument> dmtemp = new Dictionary<long, XmlDocument>();
                dmtemp = dm.GetDatasetLatestMetadataVersions();

                List<ListViewItem> temp = new List<ListViewItem>();

                if (dataStructureType.Equals(DataStructureType.Structured))
                {
                    List<StructuredDataStructure> list = dataStructureManager.StructuredDataStructureRepo.Get().ToList();

                    foreach (StructuredDataStructure sds in list)
                    {
                        sds.Materialize();

                        foreach (Dataset d in sds.Datasets)
                        {
                            if (dm.IsDatasetCheckedIn(d.Id))
                            {
                                if (datasetIDs.Contains(d.Id))
                                {
                                    temp.Add(new ListViewItem(d.Id,
                                        XmlDatasetHelper.GetInformation(dm.GetDatasetLatestVersion(d),
                                            NameAttributeValues.title)));
                                }
                            }
                        }
                    }

                }
                else
                {
                    List<UnStructuredDataStructure> list = dataStructureManager.UnStructuredDataStructureRepo.Get().ToList();

                    foreach (UnStructuredDataStructure sds in list)
                    {
                        foreach (Dataset d in sds.Datasets)
                        {
                            if (datasetIDs.Contains(d.Id))
                            {
                                if (dm.IsDatasetCheckedIn(d.Id))
                                {
                                    DatasetVersion datasetVersion = dm.GetDatasetLatestVersion(d);
                                    temp.Add(new ListViewItem(d.Id,
                                        XmlDatasetHelper.GetInformation(datasetVersion, NameAttributeValues.title)));
                                }
                            }
                        }
                    }
                }

               return temp.OrderBy(p => p.Title).ToList();
        }
Ejemplo n.º 52
0
        /// <summary>
        /// Lists all exisiting datasets alongside with their current status
        /// </summary>
        /// <returns></returns>
        public ActionResult List()
        {
            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Maintain Datasets", this.Session.GetTenant());

            DatasetManager dm = new DatasetManager();
            PermissionManager permissionManager = new PermissionManager();
            SubjectManager subjectManager = new SubjectManager();

            User user = subjectManager.GetUserByName(HttpContext.User.Identity.Name);

            List<Dataset> datasets = dm.DatasetRepo.Query().OrderBy(p=>p.Id).ToList();

            List<long> datasetIds = new List<long>();
            if (user != null)
            {
                datasetIds.AddRange(permissionManager.GetAllDataIds(user.Id, 1, RightType.Delete));
            }

            ViewData["DatasetIds"] = datasetIds;

            return View(datasets);
        }
Ejemplo n.º 53
0
        public ActionResult ReloadMetadataEditor(bool locked = false, bool show = false)
        {
            ViewData["Locked"] = locked;
            ViewData["ShowOptional"] = show;

            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Create Dataset", this.Session.GetTenant());
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            List<StepModelHelper> stepInfoModelHelpers = new List<StepModelHelper>();

            foreach (var stepInfo in TaskManager.StepInfos)
            {

                StepModelHelper stepModelHelper = GetStepModelhelper(stepInfo.Id);

                if (stepModelHelper.Model == null)
                {
                    if (stepModelHelper.Usage is MetadataPackageUsage)
                        stepModelHelper.Model = CreatePackageModel(stepInfo.Id, false);

                    if (stepModelHelper.Usage is MetadataNestedAttributeUsage)
                        stepModelHelper.Model = CreateCompoundModel(stepInfo.Id, false);

                    getChildModelsHelper(stepModelHelper);
                }

                stepInfoModelHelpers.Add(stepModelHelper);

            }

            MetadataEditorModel Model = new MetadataEditorModel();
            Model.StepModelHelpers = stepInfoModelHelpers;

            #region security permissions and authorisations check
            // set edit rigths
            PermissionManager permissionManager = new PermissionManager();
            SubjectManager subjectManager = new SubjectManager();
            Security.Services.Objects.TaskManager securityTaskManager = new Security.Services.Objects.TaskManager();

            bool hasAuthorizationRights = false;
            bool hasAuthenticationRigths = false;

            User user = subjectManager.GetUserByName(GetUsernameOrDefault());
            long userid = -1;
            long entityId = -1;

            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.ENTITY_ID))
            {
                entityId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.ENTITY_ID]);
                Model.EditRight = hasUserEditRights(entityId);
                Model.EditAccessRight = hasUserEditAccessRights(entityId);

            }
            else
            {
                Model.EditRight = false;
                Model.EditAccessRight = false;
            }

            Model.FromEditMode = true;

            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATASTRUCTURE_ID))
            {
                long metadataStructureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]);
                Model.Import = IsImportAvavilable(metadataStructureId);
            }

            #endregion
            //set addtionaly functions
            Model.Actions = getAddtionalActions();

            return PartialView("MetadataEditor", Model);
        }
Ejemplo n.º 54
0
        /// <summary>
        /// return true if user has edit rights
        /// </summary>
        /// <returns></returns>
        private bool hasUserEditRights(long entityId)
        {
            #region security permissions and authorisations check
            // set edit rigths
            PermissionManager permissionManager = new PermissionManager();
            SubjectManager subjectManager = new SubjectManager();
            Security.Services.Objects.TaskManager securityTaskManager = new Security.Services.Objects.TaskManager();

            bool hasAuthenticationRigths = false;

            User user = subjectManager.GetUserByName(GetUsernameOrDefault());
            long userid = -1;

            if (user != null)
            {
                userid = subjectManager.GetUserByName(GetUsernameOrDefault()).Id;

                hasAuthenticationRigths = permissionManager.HasUserDataAccess(userid, 1, entityId, RightType.Update);

                return (hasAuthenticationRigths);
            }
            else
            {
               return false;
            }

            #endregion
        }
Ejemplo n.º 55
0
        public JsonResult ValidateUsername(string username, long id = 0)
        {
            SubjectManager subjectManager = new SubjectManager();

            User user = subjectManager.GetUserByName(username);

            if (user == null)
            {
                return Json(true, JsonRequestBehavior.AllowGet);
            }
            else
            {
                if (user.Id == id)
                {
                    return Json(true, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    string error = String.Format(CultureInfo.InvariantCulture, "The Username exists already.", username);

                    return Json(error, JsonRequestBehavior.AllowGet);
                }
            }
        }
Ejemplo n.º 56
0
        public ActionResult Membership_Select(long id, long[] selectedUsers)
        {
            SubjectManager subjectManager = new SubjectManager();

            List<GroupMembershipGridRowModel> users = new List<GroupMembershipGridRowModel>();

            if (selectedUsers != null)
            {
                users = subjectManager.GetAllUsers().Select(u => GroupMembershipGridRowModel.Convert(u, selectedUsers.Contains(u.Id))).ToList();
            }
            else
            {
                Group group = subjectManager.GetGroupById(id);

                users = subjectManager.GetAllUsers().Select(u => GroupMembershipGridRowModel.Convert(u, u.Groups.Any(g => g.Id == id))).ToList();
            }

            return View(new GridModel<GroupMembershipGridRowModel> { Data = users });
        }
Ejemplo n.º 57
0
 public void Delete(long id)
 {
     SubjectManager subjectManager = new SubjectManager();
     subjectManager.DeleteUserById(id);
 }
Ejemplo n.º 58
0
        public ActionResult MyAccount()
        {
            ViewBag.Title = PresentationModel.GetViewTitleForTenant("My Account", this.Session.GetTenant());

            SubjectManager subjectManager = new SubjectManager();
            User user = subjectManager.GetUserByName(HttpContext.User.Identity.Name);

            if (user != null)
            {
                return View("MyAccount", MyAccountModel.Convert(user));
            }
            else
            {
                return View("MyAccount");
            }
        }
Ejemplo n.º 59
0
        public long createDataset(string dataSetID, XmlDocument metadataXml, long metadataStructureId, DataStructure dataStructure, string researchPlanName)
        {
            Dataset dataset = new Dataset();

            DatasetManager datasetManager = new DatasetManager();
            DataStructureManager dataStructureManager = new DataStructureManager();
            ResearchPlanManager researchPlanManager = new ResearchPlanManager();
            MetadataStructureManager metadataStructureManager = new MetadataStructureManager();
            PermissionManager permissionManager = new PermissionManager();
            SubjectManager subjectManager = new SubjectManager();

            // get existing researchPlan
            ResearchPlan researchPlan = researchPlanManager.Repo.Get(r => researchPlanName.Equals(r.Title)).FirstOrDefault();

            // get existing metadataStructure (created manualy by using edited Bexis1_XSD)
            MetadataStructure metadataStructure = metadataStructureManager.Repo.Get(metadataStructureId);

            // update verwendet, da bei unstructured structures im dataset constructor dataset(dataStructure) nullexception
            dataset = datasetManager.CreateEmptyDataset(dataStructure, researchPlan, metadataStructure);
            long datasetId = dataset.Id;

            // dataPermission
            List<string> usersWithDataPerm = new List<string>();

            // create dataPermission for originalDatasetManager
            string originalDatasetManager = metadataXml.SelectSingleNode("Metadata/general/general/originalDatasetManager/originalDatasetManager").InnerText;
            User userODM = subjectManager.UsersRepo.Get(u => originalDatasetManager.Equals(u.FullName)).FirstOrDefault();
            permissionManager.CreateDataPermission(userODM.Id, 1, dataset.Id, RightType.Create);
            permissionManager.CreateDataPermission(userODM.Id, 1, dataset.Id, RightType.View);
            permissionManager.CreateDataPermission(userODM.Id, 1, dataset.Id, RightType.Update);
            permissionManager.CreateDataPermission(userODM.Id, 1, dataset.Id, RightType.Download);
            usersWithDataPerm.Add(originalDatasetManager);

            // create dataPermissions for metadataAuthor
            string metadataAuthor = metadataXml.SelectSingleNode("Metadata/general/general/metadataCreator/metadataCreator").InnerText;
            if (!usersWithDataPerm.Contains(metadataAuthor))
            {
                User userMA = subjectManager.UsersRepo.Get(u => metadataAuthor.Equals(u.FullName)).FirstOrDefault();
                permissionManager.CreateDataPermission(userMA.Id, 1, dataset.Id, RightType.Create);
                permissionManager.CreateDataPermission(userMA.Id, 1, dataset.Id, RightType.View);
                permissionManager.CreateDataPermission(userMA.Id, 1, dataset.Id, RightType.Update);
                permissionManager.CreateDataPermission(userMA.Id, 1, dataset.Id, RightType.Download);
                usersWithDataPerm.Add(metadataAuthor);
            }

            // create dataPermissions for designatedDatasetManager
            string designatedDatasetManager = metadataXml.SelectSingleNode("Metadata/general/general/designatedDatasetManager/contactType/designatedDatasetManagerName/designatedDatasetManagerName").InnerText;
            if (!usersWithDataPerm.Contains(designatedDatasetManager))
            {
                User userDDM = subjectManager.UsersRepo.Get(u => designatedDatasetManager.Equals(u.FullName)).FirstOrDefault();
                permissionManager.CreateDataPermission(userDDM.Id, 1, dataset.Id, RightType.Create);
                permissionManager.CreateDataPermission(userDDM.Id, 1, dataset.Id, RightType.View);
                permissionManager.CreateDataPermission(userDDM.Id, 1, dataset.Id, RightType.Update);
                permissionManager.CreateDataPermission(userDDM.Id, 1, dataset.Id, RightType.Download);
                usersWithDataPerm.Add(designatedDatasetManager);
            }

            // create dataPermissions for owners
            XmlNodeList ownerNodes = metadataXml.SelectNodes("Metadata/general/general/owners/ownerType/owner/owner");
            foreach (XmlNode ownerNode in ownerNodes)
            {
                string owner = ownerNode.InnerText;
                if (!usersWithDataPerm.Contains(owner))
                {
                    User userO = subjectManager.UsersRepo.Get(u => owner.Equals(u.FullName)).FirstOrDefault();
                    if (userO != null)
                    {
                        permissionManager.CreateDataPermission(userO.Id, 1, dataset.Id, RightType.Create);
                        permissionManager.CreateDataPermission(userO.Id, 1, dataset.Id, RightType.View);
                        permissionManager.CreateDataPermission(userO.Id, 1, dataset.Id, RightType.Update);
                        permissionManager.CreateDataPermission(userO.Id, 1, dataset.Id, RightType.Download);
                        usersWithDataPerm.Add(owner);
                    }
                }
            }

            // integrate metadataXml to dataset
            // checkOut
            if (datasetManager.IsDatasetCheckedOutFor(datasetId, userODM.Name) || datasetManager.CheckOutDataset(datasetId, userODM.Name))
            {
                DatasetVersion workingCopy = datasetManager.GetDatasetWorkingCopy(datasetId); // get dataset
                workingCopy.Metadata = metadataXml; // set metadata to dataset
                datasetManager.EditDatasetVersion(workingCopy, null, null, null); // edit dataset
                datasetManager.CheckInDataset(datasetId, "Metadata was submited.", userODM.Name); // check in
            }

            return dataset.Id;
        }
Ejemplo n.º 60
0
        //
        // GET: /DIM/Import/
        public ActionResult Index()
        {
            //xml metadata for import
            string metadataForImportPath = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DIM"), "MetadataIDIV_EXAMPLE.xml");

            XmlDocument metadataForImport = new XmlDocument();
            metadataForImport.Load(metadataForImportPath);

            // metadataStructure DI
            long metadataStructureId = 3;

            MetadataStructureManager metadataStructureManager = new MetadataStructureManager();
            string metadataStructrueName = metadataStructureManager.Repo.Get(metadataStructureId).Name;

            // loadMapping file
            string path_mappingFile = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DIM"), XmlMetadataImportHelper.GetMappingFileName(metadataStructureId, TransmissionType.mappingFileImport, metadataStructrueName));

            // XML mapper + mapping file
            XmlMapperManager xmlMapperManager = new XmlMapperManager(TransactionDirection.InternToExtern);
            xmlMapperManager.Load(path_mappingFile, "IDIV");

            // generate intern metadata
            XmlDocument metadataResult = xmlMapperManager.Generate(metadataForImport,1);

            // generate intern template
            XmlMetadataWriter xmlMetadatWriter = new XmlMetadataWriter(BExIS.Xml.Helpers.XmlNodeMode.xPath);
            XDocument metadataXml = xmlMetadatWriter.CreateMetadataXml(metadataStructureId);
            XmlDocument metadataXmlTemplate = XmlMetadataWriter.ToXmlDocument(metadataXml);

            XmlDocument completeMetadata = XmlMetadataImportHelper.FillInXmlAttributes(metadataResult, metadataXmlTemplate);

            // create Dataset

            //load datastructure
            DataStructureManager dsm = new DataStructureManager();
            ResearchPlanManager rpm = new ResearchPlanManager();
            MetadataStructureManager msm = new MetadataStructureManager();

            DatasetManager dm = new DatasetManager();
            Dataset dataset = dm.CreateEmptyDataset(dsm.UnStructuredDataStructureRepo.Get(1), rpm.Repo.Get(1), msm.Repo.Get(3));

            if (dm.IsDatasetCheckedOutFor(dataset.Id, GetUsernameOrDefault()) || dm.CheckOutDataset(dataset.Id, GetUsernameOrDefault()))
            {
                DatasetVersion workingCopy = dm.GetDatasetWorkingCopy(dataset.Id);
                workingCopy.Metadata = completeMetadata;

                string title = XmlDatasetHelper.GetInformation(workingCopy, NameAttributeValues.title);
                if (String.IsNullOrEmpty(title)) title = "No Title available.";

                dm.EditDatasetVersion(workingCopy, null, null, null);
                dm.CheckInDataset(dataset.Id, "Metadata was submited.", GetUsernameOrDefault());

                // add security
                if (GetUsernameOrDefault() != "DEFAULT")
                {
                    PermissionManager pm = new PermissionManager();
                    SubjectManager sm = new SubjectManager();

                    BExIS.Security.Entities.Subjects.User user = sm.GetUserByName(GetUsernameOrDefault());

                    foreach (RightType rightType in Enum.GetValues(typeof(RightType)).Cast<RightType>())
                    {
                        pm.CreateDataPermission(user.Id, 1, dataset.Id, rightType);
                    }
                }
            }

            return View();
        }