Esempio n. 1
0
        public void Should_return_true_for_multiple_monitors()
        {
            var someGroup = new UserGroup(null, null, "A");
            var someGroup1 = new UserGroup(null, null, "B");
            var someGroup2 = new UserGroup(null, null, "C");

            var userGroup = new UserGroups(buildCollection);
            userGroup.Add(someGroup);
            userGroup.Add(someGroup1);
            userGroup.Add(someGroup2);
            Assert.That(userGroup.IsMonitoring("A"), Is.EqualTo(true));
            Assert.That(userGroup.IsMonitoring("C"), Is.EqualTo(true));
        }
Esempio n. 2
0
        public void Should_not_send_second_message_to_group_as_it_does_not_exsist()
        {
            var message = "some message";
            var pipelineName = "A";
            var userGroup = MockRepository.GenerateMock<IUserGroup>();
            userGroup.Expect(x => x.Name).Return(pipelineName);
            userGroup.Expect(x => x.Send(message)).Repeat.Once();
            userGroup.Stub(x => x.Send(message)).Throw(new InvalidOperationException("Should not be called"));
            var projectMock = MockRepository.GenerateMock<IProject>();
            projectMock.Expect(x => x.PipelineName).Return(pipelineName);
            projectMock.Expect(x => x.GetMessage()).Return(message);

            buildCollection.Expect(x => x.ShouldAlert(projectMock)).Return(true).Repeat.Once();
            buildCollection.Expect(x => x.ShouldAlert(projectMock)).Return(false).Repeat.Once();

            var userGroups = new UserGroups(buildCollection);
            userGroups.Add(userGroup);
            //Test
            userGroups.Alert(projectMock);
            userGroups.Alert(projectMock);
            //Assert
            userGroup.VerifyAllExpectations();
            projectMock.VerifyAllExpectations();
            buildCollection.VerifyAllExpectations();
        }
Esempio n. 3
0
 public void Should_return_true_for_single_monitor()
 {
     var someGroup = new UserGroup(null,null,"ShouldFind");
     var userGroup = new UserGroups(buildCollection);
     userGroup.Add(someGroup);
     Assert.That(userGroup.IsMonitoring("ShouldFind"), Is.EqualTo(true));
 }
 public void PreLoadGroups(string userName)
 {
     lock (_memberLock)
     {
         UserGroups.Add(userName, new HashSet <string>(GetGroupNames(userName)));
     }
 }
Esempio n. 5
0
 public UserGroupListVM()
 {
     init();
     UserGroups.Add(new UserGroupDTOWithActions {
         PartyName = "ehsan"
     });
     BasicInfoAppLocalizedResources = new BasicInfoAppLocalizedResources();
 }
Esempio n. 6
0
        protected override void OnSaveEventHandler(VmOnSave obj)
        {
            var row = obj.GetRow <UserGroup>();

            if (row != null)
            {
                UserGroups.Add((UserGroup)row);
            }
            else
            {
                base.OnSaveEventHandler(obj);
            }
        }
Esempio n. 7
0
        private void Networking_GroupList(object sender, EventArgs e)
        {
            UserGroups.Clear();

            Group[] groups = (Group[])sender;

            if (groups != null)
            {
                foreach (Group group in groups)
                {
                    UserGroups.Add(group.name);
                }
            }
        }
        /// <summary>
        /// EnterpriseScenarioContract constructor.
        /// </summary>
        /// <param name="scenario">The EnterpriseScnenario.</param>
        /// <param name="version">The scenario version.</param>
        public EnterpriseScenarioContract(EnterpriseScenario scenario, string version)
            : this()
        {
            Company         = scenario.Company;
            Description     = scenario.Description;
            Name            = scenario.Name;
            Owner           = scenario.Owner;
            Vertical        = scenario.Vertical;
            ContractVersion = version;

            foreach (var group in scenario.UserGroups)
            {
                UserGroups.Add(group.GroupName);
            }
        }
Esempio n. 9
0
 private void ReloadUserGroups(List <UserGroup> userGroups)
 {
     UserGroups.Clear();
     foreach (var userGroup in userGroups)
     {
         UserGroups.Add(new UserGroupItemViewModel
         {
             GroupId    = userGroup.GroupId,
             GroupUsers = userGroup.GroupUsers,
             Logo       = userGroup.Logo,
             Name       = userGroup.Name,
             Owner      = userGroup.Owner,
             OwnerId    = userGroup.OwnerId,
         });
     }
 }
Esempio n. 10
0
        /// <summary>
        /// Assign / Remove groups
        /// </summary>
        /// <param name="groups">Groups id</param>
        /// <param name="groupEntities">Group entities</param>
        public void EditGroups(IEnumerable <int> groups, List <Group.Group> groupEntities)
        {
            if (Root)
            {
                throw new ForbiddenOperationDomainException("Root user");
            }

            var groupIds = groups as int[] ?? groups.ToArray();

            foreach (var groupId in groupIds)
            {
                var group = groupEntities.FirstOrDefault(g => g.Id == groupId);

                // Skip if the group to add no exists in the context
                if (group == null)
                {
                    continue;
                }

                // Skip if the group is just assigned
                if (UserGroups.Any(i => i.GroupId == groupId))
                {
                    continue;
                }

                UserGroups.Add(
                    new UserGroup
                {
                    GroupId = group.Id,
                    UserId  = Id
                });
            }

            // Remove deleted groups
            foreach (var userGroup in UserGroups.ToArray())
            {
                if (!groupIds.Contains(userGroup.GroupId))
                {
                    UserGroups.Remove(userGroup);
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Adds groups to this scenario based on the given user name
        /// </summary>
        /// <param name="entities">The entities.</param>
        /// <param name="userName">Name of the user.</param>
        /// <exception cref="System.ArgumentNullException">entities</exception>
        public void AddGroups(EnterpriseTestEntities entities, string userName)
        {
            if (entities == null)
            {
                throw new ArgumentNullException("entities");
            }

            var query =
                (
                    from g in entities.UserGroups
                    from u in g.Users
                    where u.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase)
                    select g
                );

            UserGroups.Clear();
            foreach (var item in query)
            {
                UserGroups.Add(item);
            }
        }
Esempio n. 12
0
        public void Should_not_send_message_to_group_as_it_does_not_exsist()
        {
            var message = "some message";
            var pipelineName = "A";
            var userGroup = MockRepository.GenerateMock<IUserGroup>();
            userGroup.Expect(x => x.Name).Return(pipelineName);
            userGroup.AssertWasNotCalled(x => x.Send(message));

            var projectMock = MockRepository.GenerateMock<IProject>();
            projectMock.Expect(x => x.PipelineName).Return("not found");

            var userGroups = new UserGroups(buildCollection );
            userGroups.Add(userGroup);

            //Test
            userGroups.Alert(projectMock);

            //Assert
            userGroup.VerifyAllExpectations();
            projectMock.VerifyAllExpectations();
        }
Esempio n. 13
0
        private void AddUserGroupCommandExecuted()
        {
            var group = new UserGroup()
            {
                ID       = Guid.NewGuid(),
                Name     = "New User Group",
                Colour   = "#808080",
                AuthCode = ""
            };

            _adminDataUnit.UserGroupsRepository.Add(group);
            _adminDataUnit.SaveChanges();

            var groupModel = new UserGroupModel(group);

            LoadPermissions(groupModel);
            LoadAuthorisationPermissions(groupModel);

            UserGroups.Add(groupModel);

            SelectedUserGroup = groupModel;
        }
Esempio n. 14
0
        protected void ButtonSubmit_Click(object sender, EventArgs e)
        {
            UserGroupsInfo userGroupById;
            GroupType      type = (GroupType)Enum.Parse(typeof(GroupType), this.DropGropType.SelectedValue);

            if (this.HdnAction.Value == "Modify")
            {
                userGroupById = UserGroups.GetUserGroupById(DataConverter.CLng(this.HdnGroupId.Value));
            }
            else
            {
                userGroupById = new UserGroupsInfo();
            }
            userGroupById.GroupName   = this.TxtGroupName.Text;
            userGroupById.Description = this.TxtDescription.Text;
            userGroupById.GroupType   = type;
            DataActionState unknown = DataActionState.Unknown;

            if (this.Page.IsValid)
            {
                if (this.HdnAction.Value == "Modify")
                {
                    unknown = DataActionState.Exist;
                    if ((userGroupById.GroupName != this.HdnGroupName.Value) && UserGroups.GroupNameIsExist(userGroupById.GroupName))
                    {
                        this.ShowMessage(unknown);
                    }
                    unknown = UserGroups.Update(userGroupById);
                }
                else
                {
                    unknown        = UserGroups.Add(userGroupById);
                    this.m_groupId = userGroupById.GroupId;
                }
                this.ShowMessage(unknown);
            }
        }
Esempio n. 15
0
        protected Database()
        {
            User user1 = new User("Tom", "password");
            User user2 = new User("Alex", "password");
            User user3 = new User("Lisa", "password");
            User user4 = new User("Mario", "password");
            User user5 = new User("Lucia", "password");

            Users.Add(user1.UserName, user1);
            Users.Add(user2.UserName, user2);
            Users.Add(user3.UserName, user3);
            Users.Add(user4.UserName, user4);
            Users.Add(user5.UserName, user5);

            Location route1 = new Location("Ostpark, Munich", 48.112242, 11.630701, 5);
            Location route2 = new Location("Parco di Villa Borghese, Rome", 41.914614, 12.481987, 6);
            Location route3 = new Location("Parco degli Acquedotti, Rome", 41.853406, 12.557115, 10);
            Location route4 = new Location("Englischer Garten, Munich", 48.164334, 11.605598, 8);
            Location route5 = new Location("Parco Sempione, Milan", 45.474371, 9.171659, 4);

            RunningLocations.Add(route1.RouteName, route1);
            RunningLocations.Add(route2.RouteName, route2);
            RunningLocations.Add(route3.RouteName, route3);
            RunningLocations.Add(route4.RouteName, route4);
            RunningLocations.Add(route5.RouteName, route5);

            Event jogging1 = new InPersonEvent(new DateTime(2020, 08, 01, 08, 30, 00),
                                               11.0, "Jogging in the park", route3);
            Event jogging2 = new InPersonEvent(new DateTime(2020, 08, 09, 19, 00, 00),
                                               11.5, "After work jogging", route5);
            Event jogging3 = new VirtualEvent(new DateTime(2020, 8, 21, 09, 00, 00),
                                              10.0, "Jogging as a virtual group", 7.0);
            Event jogging4 = new InPersonEvent(new DateTime(2020, 06, 01, 10, 00, 00),
                                               12.0, "Morning jogging on 1st June", route1);
            Event jogging5 = new VirtualEvent(new DateTime(2020, 7, 28, 19, 00, 00),
                                              11.5, "Jogging in different locations", 5.0);
            Event jogging6 = new InPersonEvent(new DateTime(2020, 5, 15, 11, 00, 00),
                                               10.0, "Speed challenge", route5);
            Event jogging7 = new VirtualEvent(new DateTime(2020, 7, 31, 18, 30, 00),
                                              13.0, "Evening jogging", 5.0);


            Events.Add(jogging1.EventTitle, jogging1);
            Events.Add(jogging2.EventTitle, jogging2);
            Events.Add(jogging3.EventTitle, jogging3);
            Events.Add(jogging4.EventTitle, jogging4);
            Events.Add(jogging5.EventTitle, jogging5);
            Events.Add(jogging6.EventTitle, jogging6);
            Events.Add(jogging7.EventTitle, jogging7);

            Participant part1  = new Participant(user1, jogging1);
            Participant part2  = new Participant(user1, jogging3);
            Participant part3  = new Participant(user1, jogging4);
            Participant part4  = new Participant(user2, jogging4);
            Participant part5  = new Participant(user3, jogging4);
            Participant part6  = new Participant(user4, jogging4);
            Participant part7  = new Participant(user1, jogging5);
            Participant part8  = new Participant(user1, jogging6);
            Participant part9  = new Participant(user2, jogging6);
            Participant part10 = new Participant(user4, jogging6);

            part7.SetRunningLocation(route4);
            part8.SetRunningLocation(route2);

            part3.CheckInAtEvent();
            part4.CheckInAtEvent();
            part5.CheckInAtEvent();
            part6.CheckInAtEvent();
            part8.CheckInAtEvent();
            part9.CheckInAtEvent();
            part10.CheckInAtEvent();

            EventResults results1 = part3.UploadEventResults(TimeSpan.Parse("00:32:15", CultureInfo.InvariantCulture), 10.5, 166);
            EventResults results2 = part4.UploadEventResults(TimeSpan.Parse("00:31:09", CultureInfo.InvariantCulture), null, 170);
            EventResults results3 = part5.UploadEventResults(TimeSpan.Parse("00:34:38", CultureInfo.InvariantCulture), 9.8, null);
            EventResults results4 = part6.UploadEventResults(TimeSpan.Parse("00:35:00", CultureInfo.InvariantCulture), null, null);

            UserGroup group1 = new UserGroup(user1, "Munich Joggers");
            UserGroup group2 = new UserGroup(user2, "Milan Joggers");
            UserGroup group3 = new UserGroup(user3, "City joggers");

            UserGroups.Add(group1.GroupName, group1);
            UserGroups.Add(group2.GroupName, group2);
            UserGroups.Add(group3.GroupName, group3);

            group1.AddMember(user3);
            group1.AddMember(user4);
            group2.AddMember(user4);
            group2.AddMember(user5);
            group3.AddMember(user1);
        }
Esempio n. 16
0
        public void Should_send_a_single_message_to_group()
        {
            var message = "some message";
            var pipelineName = "A";
            var userGroup = MockRepository.GenerateMock<IUserGroup>();

            userGroup.Expect(x => x.Name).Return(pipelineName);
            userGroup.Expect(x => x.Send(message));
            var projectMock = MockRepository.GenerateMock<IProject>();
            projectMock.Expect(x => x.GetMessage()).Return(message);
            projectMock.Expect(x => x.PipelineName).Return(pipelineName);

            var userGroups = new UserGroups(buildCollection);
            userGroups.Add(userGroup);

            buildCollection.Expect(x => x.ShouldAlert(projectMock)).Return(true).Repeat.Once();

            //Test
            userGroups.Alert(projectMock);

            //Assert
            userGroup.VerifyAllExpectations();
            projectMock.VerifyAllExpectations();
            buildCollection.VerifyAllExpectations();
        }
Esempio n. 17
0
        public void Done(object valuse)
        {
            var objs = valuse as object[];

            Password = (objs[0] as PasswordBox).Password;
            ConfPass = (objs[1] as PasswordBox).Password;
            var window = objs[2] as Window;

            if (Password.Equals(ConfPass))
            {
                IsInProgress = true;
                new Thread(() =>
                {
                    PersonsModel person = new PersonsModel()
                    {
                        PeId       = Person.PeId,
                        PeIdentity = PersonalId,
                        PeName     = FullName,
                        PeType     = (int)SelectedUserType.CId,
                        PeAddress  = ""
                    };
                    var personChangeValue = 0;
                    long personInsertId   = 0;
                    try { personChangeValue = DataAccess.UpdatePerson(Person.PeId, person); }
                    catch { MessageBox.Show("could not open connection with server!\nCheck your internet connection or server is connected", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); return; }
                    person.PeId = personInsertId;
                    if (personChangeValue == 1)
                    {
                        UsersModel user = new UsersModel()
                        {
                            CreatedBy = SystemValues.LoginUser,
                            UPIdFk    = personInsertId,
                            UEmail    = EmailAdress,
                            UUserName = Username,
                            UPassword = Password.GetPasswordHashSHA256(),
                            UIsActive = UserState.ToIntState(),
                            UpdatedBy = SystemValues.LoginUser
                        };
                        long userChangeValue = 0;
                        try { userChangeValue = DataAccess.UpdateUser((int)person.PeId, user); }
                        catch { MessageBox.Show("could not open connection with server!\nCheck your internet connection or server is connected", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); }
                        if (userChangeValue == 1)
                        {
                            try { DataAccess.DeletePersonCommunication(person.PeId); }
                            catch { MessageBox.Show("Filed to Edit user Communication, Address and Groups info"); return; }
                            foreach (var item in CommunicationSource)
                            {
                                item.CoPeIdFk = person.PeId;
                                try { var commValueChange = DataAccess.InsertPersonCommunication(out var id, item); AddedCommunication.Add(item); }
                                catch { MessageBox.Show($"Could not Add {item.CoNameCfk} to this user", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); }
                            }
                            var address = new PersonsAddressModel()
                            {
                                PeAdCity       = City,
                                PeAdStreetName = Adress,
                                PeAdPerIdFk    = person.PeId
                            };
                            try { DataAccess.DeletePersonAddress(person.PeId); }
                            catch { MessageBox.Show("Filed to Edit user Address and Groups info"); return; }
                            try { DataAccess.InsertPersonAddress(out var adressId, address); AddedAddress.Add(address); }
                            catch { MessageBox.Show($"Could not Add Addess to this user", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); }
                            try { DataAccess.DeleteUserGroups((int)person.PeId); }
                            catch { MessageBox.Show("Filed to Edit user Groups info"); return; }
                            foreach (var item in AddedGroupsSource)
                            {
                                var userGroup = new UserGroupModel()
                                {
                                    GroupId = item.GId,
                                    UserId  = (int)person.PeId
                                };
                                try { DataAccess.InsertUserGroups(out var n, userGroup); UserGroups.Add(userGroup); }
                                catch { MessageBox.Show($"Could not Add {item.GName} to this user", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); }
                            }
                            IsInProgress = false;
                            App.Current.Dispatcher.Invoke((Action) delegate
                            {
                                window.DialogResult = true;
                                window.Close();
                            });
                        }
                        else
                        {
                            MessageBox.Show("Field to add user !!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Field to add person !!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                })
                {
                    IsBackground = true
                }.Start();
Esempio n. 18
0
 public void AddGroup(string groupName, string groupID)
 {
     UserGroups.Add(new UserGroup(groupName, groupID));
 }
Esempio n. 19
0
        public void ConvertFromString(string valueString)
        {
            StringTable table = StringTable.Parse(valueString);

            if (table.ContainsKey("PrizeTypes"))
            {
                PrizeTypes = StringUtil.Split2 <MissionPrizeType>(table["PrizeTypes"]);
            }

            if (table.ContainsKey("Points"))
            {
                Points = StringUtil.Split <int>(table["Points"]);
            }

            Guid[] userGroupIDs = null;
            if (table.ContainsKey("UserGroupIDs"))
            {
                userGroupIDs = StringUtil.Split <Guid>(table["UserGroupIDs"]);
            }

            if (userGroupIDs != null && userGroupIDs.Length > 0 && table.ContainsKey("UserGroupActiveTimes"))
            {
                long[] times = StringUtil.Split <long>(table["UserGroupActiveTimes"]);
                for (int i = 0; i < userGroupIDs.Length; i++)
                {
                    long time;
                    if (times.Length > i)
                    {
                        time = times[i];
                    }
                    else
                    {
                        time = 0;
                    }
                    UserGroups.Add(userGroupIDs[i], time);
                }
            }

            int[] medalIDs = null, medalLevelIDs = null;
            if (table.ContainsKey("MedalIDs"))
            {
                medalIDs = StringUtil.Split <int>(table["MedalIDs"]);
            }
            if (table.ContainsKey("MedalLevelIDs"))
            {
                medalLevelIDs = StringUtil.Split <int>(table["MedalLevelIDs"]);
            }

            if (medalIDs != null && medalIDs.Length > 0 && medalLevelIDs != null && medalLevelIDs.Length > 0 && table.ContainsKey("MedalActiveTimes"))
            {
                long[] times = StringUtil.Split <long>(table["MedalActiveTimes"]);

                for (int i = 0; i < medalIDs.Length; i++)
                {
                    long time;
                    if (times.Length > i)
                    {
                        time = times[i];
                    }
                    else
                    {
                        time = 0;
                    }

                    int medalLevelID;
                    if (medalLevelIDs.Length > i)
                    {
                        medalLevelID = medalLevelIDs[i];
                    }
                    else
                    {
                        break;
                    }

                    PrizeMedal medal = new PrizeMedal();
                    medal.MedalID      = medalIDs[i];
                    medal.MedalLevelID = medalLevelID;
                    medal.Seconds      = time;

                    Medals.Add(medal);
                }
            }

            if (table.ContainsKey("InviteSerialCount"))
            {
                int.TryParse(table["InviteSerialCount"], out inviteSerialCount);
            }

            if (table.ContainsKey("Props"))
            {
                StringTable propCounts = StringTable.Parse(table["Props"]);

                foreach (string key in propCounts.Keys)
                {
                    props.Add(int.Parse(key), int.Parse(propCounts[key]));
                }
            }
        }