Example #1
0
 //Fetch Statuses
 private void fetchStatuses()
 {
     if (LogicServices.GetStatusesCount() > 0)
     {
         new Thread(fillListBoxStatuses).Start();
     }
 }
Example #2
0
 private void buttonEditFriendsNames_Click(object sender, EventArgs e)
 {
     panelBinding.Show();
     panelBinding.Enabled = true;
     LogicServices.buildEditAbleFriends();
     editAbleFriendBindingSource.DataSource = LogicServices.EditableFriends;
 }
Example #3
0
 public FormLikestPhotoInAlbum()
 {
     InitializeComponent();
     buttonExit.Enabled = true;
     m_ProxAlbums       = LogicServices.buildProxAlbumList(LogicServices.GetAlbums());
     fillListBoxWithProxyAlbums();
 }
Example #4
0
 private void fillPersonalInformation()
 {
     labelPrivateName.Invoke(new Action(() => labelPrivateName.Text = LogicServices.GetFirstName()));
     labelFamilyName.Invoke(new Action(() => labelFamilyName.Text   = LogicServices.GetLastName()));
     pictureBoxProfilePicture.Invoke(new Action(() => pictureBoxProfilePicture.LoadAsync(LogicServices.GetProfilePic())));
     labelBirthday.Invoke(new Action(() => labelBirthday.Text = LogicServices.GetBirthday()));
     labelEmail.Invoke(new Action(() => labelEmail.Text       = LogicServices.GetEmail()));
 }
        private void prepareFacade()
        {
            LogicServices.createFacadeTopCategories(LogicServices.GetFriends());

            textBoxFirst.Text  = LogicServices.Facade.First;
            textBoxSecond.Text = LogicServices.Facade.Second;
            textBoxthird.Text  = LogicServices.Facade.Third;
        }
Example #6
0
        private void fillListBoxLikedPages()
        {
            listBoxLikedPages.DisplayMember = "Name";

            foreach (Page page in LogicServices.GetLikedPages())
            {
                listBoxLikedPages.Invoke(new Action(() => listBoxLikedPages.Items.Add(page)));
            }
        }
Example #7
0
        public Photo CoverPhoto()
        {
            if (m_IndexOfTheLikestPhoto == -1)
            {
                m_IndexOfTheLikestPhoto = LogicServices.FindLikestPhotoIndex(m_OrgAlbum);
            }

            return(m_OrgAlbum.Photos[m_IndexOfTheLikestPhoto]);
        }
Example #8
0
        //Fetch Events
        private void fetchEventsList()
        {
            listBoxEvents.Items.Clear();

            if (LogicServices.GetEventsCount() > 0)
            {
                new Thread(fillListBoxEvents).Start();
            }
        }
Example #9
0
        /// <summary>
        ///     Get all person IDs that match a certain login token.
        /// </summary>
        /// <param name="loginToken">The login token to look for.</param>
        /// <returns>An array of person IDs.</returns>
        private static People GetPeopleByLoginToken(string loginToken)
        {
            People result = new People();

            SwarmDb database = SwarmDb.GetDatabaseForReading();

            // First, is the login token numeric? If so, add it as is and is a valid person.

            if (LogicServices.IsNumber(loginToken))
            {
                try
                {
                    int    personId = Int32.Parse(loginToken);
                    Person person   = Person.FromIdentity(personId);

                    // If we get here without exception, the login token is a valid person Id

                    result.Add(person);
                }
                catch (Exception)
                {
                    // Do nothing. In particular, do not add the person Id as a candidate.
                }
            }

            // Second, is the login token ten digits? If so, look for the person with this personal number.
            // This is specific to the Swedish PP.

            string cleanedNumber = LogicServices.CleanNumber(loginToken);

            if (cleanedNumber.Length == 10)
            {
                int[] personIds = database.GetObjectsByOptionalData(ObjectType.Person,
                                                                    ObjectOptionalDataType.PersonalNumber,
                                                                    cleanedNumber);

                foreach (int personId in personIds)
                {
                    result.Add(Person.FromIdentity(personId));
                }
            }

            // Third, look for a matching name. Expand the login token so that "R Falkv" will match "Rickard Falkvinge".
            // Only do this if the login token, excessive whitespace removed, is five characters or more.

            result = People.LogicalOr(result, People.FromNamePattern(loginToken));

            // Fourth, look for a matching email. Only do an exact match here.

            if (loginToken.Contains("@"))
            {
                result = People.LogicalOr(result, People.FromEmailPattern(loginToken));
            }

            return(result);
        }
Example #10
0
        private void fillListBoxEvents()
        {
            listBoxEvents.DisplayMember = "Name";

            foreach (Event userEvent in LogicServices.GetEvents())
            {
                listBoxEvents.Invoke(new Action(() => listBoxEvents.Items.Add(userEvent)));
                userEvent.ReFetch(DynamicWrapper.eLoadOptions.Full);
            }
        }
Example #11
0
        private void fillListBoxFriends()
        {
            listBoxFriendsList.DisplayMember = "Name";

            foreach (User friend in LogicServices.GetFriends())
            {
                listBoxFriendsList.Invoke(new Action(() => listBoxFriendsList.Items.Add(friend)));
                friend.ReFetch(DynamicWrapper.eLoadOptions.Full);
            }
        }
Example #12
0
        //Browse through photos of the user
        private void FetchTaggedPhotos()
        {
            myButtonEndSlideShow.Invoke(new Action(() => myButtonEndSlideShow.Hide()));

            if (LogicServices.GetPhotosTaggedInCount() > 0)
            {
                myButtonSlideShow.Enabled = true;
                new Thread(fillPictureBoxTaggedPhotos).Start();
            }
        }
Example #13
0
 private void fillListBoxStatuses()
 {
     foreach (Status status in LogicServices.GetStatuses())
     {
         if (status.Message != null)
         {
             listBoxStatuses.Invoke(new Action(() => listBoxStatuses.Items.Add(status.Message)));
         }
     }
 }
Example #14
0
 private void fillListBoxTaggedPost()
 {
     listBoxTaggedPosts.DisplayMember = "Name";
     foreach (Post post in LogicServices.GetPostsTaggedIn())
     {
         if (post.Place != null)
         {
             listBoxTaggedPosts.Invoke(new Action(() => listBoxTaggedPosts.Items.Add(post)));
         }
     }
 }
Example #15
0
        //Fetch Liked Pages
        private void fetchLikedPages()
        {
            listBoxLikedPages.Items.Clear();

            if (LogicServices.GetLikedPagesCount() > 0)
            {
                new Thread(fillListBoxLikedPages).Start();
            }
            else
            {
            }
        }
Example #16
0
 private void logout()
 {
     if (LogicServices.Logout())
     {
         clearFormCommands();
         MessageBox.Show("You are Logged out");
     }
     else
     {
         MessageBox.Show("Error logging out");
     }
 }
Example #17
0
 //Fetch Tagged Posts
 private void fetchTaggedPosts()
 {
     listBoxTaggedPosts.Items.Clear();
     if (LogicServices.GetPostsTaggedInCount() > 0)
     {
         new Thread(fillListBoxTaggedPost).Start();
     }
     else
     {
         MessageBox.Show("No Posts Tagged In");
     }
 }
Example #18
0
 private void buttonLikestPhotoInAlbum_Click(object sender, EventArgs e)
 {
     if ((LogicServices.GetAlbums()).Count == 0)
     {
         MessageBox.Show("You don't have any albums, sorry");
     }
     else
     {
         FormLikestPhotoInAlbum formAlbumsListBox = new FormLikestPhotoInAlbum();
         formAlbumsListBox.StartPosition = FormStartPosition.CenterParent;
         formAlbumsListBox.ShowDialog();
     }
 }
Example #19
0
 private void buttonMostPopularPagesF_Click(object sender, EventArgs e)
 {
     if (LogicServices.GetFriendsCount() < 3)
     {
         MessageBox.Show("You have less then three friends, sorry");
     }
     else
     {
         FormTopCategories formCategory = new FormTopCategories();
         formCategory.StartPosition = FormStartPosition.CenterParent;
         formCategory.ShowDialog();
     }
 }
Example #20
0
        private void startSlideShow()
        {
            MyPhotoList photoSlideShow = new MyPhotoList();

            photoSlideShow.TaggedPhotos = LogicServices.GetPhotosTaggedIn().ToList();

            foreach (Photo photo in photoSlideShow)
            {
                pictureBoxMyPicture.LoadAsync(photo.PictureNormalURL);
                Thread.Sleep(2500);
            }
            FetchTaggedPhotos();
        }
Example #21
0
        //Fetch Friends
        private void fetchFriendsList()
        {
            listBoxFriendsList.Items.Clear();

            if (LogicServices.GetFriendsCount() > 0)
            {
                enabelFriendsCommands();
                new Thread(fillListBoxFriends).Start();
            }
            else
            {
                MessageBox.Show("No Friends");
            }
        }
Example #22
0
 private void buttonLogIn_Click(object sender, EventArgs e)
 {
     if (LogicServices.loginAndInit())
     {
         buttonLogIn.Enabled = false;
         fetchUserInfo();
         addLoginLogoutObservers();
         LogicServices.LoggedInUser.notifyLoginObservers();
     }
     else
     {
         MessageBox.Show("Error while trying to login");//Error while trying to login
     }
 }
Example #23
0
        public static Person Create(string name, string email, string password, string phone, string street,
                                    string postal, string city, string countryCode, DateTime dateOfBirth,
                                    PersonGender gender)
        {
            BasicCountry country = null;

            if (countryCode.Length > 0)
            {
                country = Country.FromCode(countryCode);
            }

            // Clean data

            while (name.Contains("  "))
            {
                name = name.Replace("  ", " ");
            }

            name   = name.Trim();
            email  = email.ToLower().Trim();
            phone  = LogicServices.CleanNumber(phone);
            postal = postal.Replace(" ", "").Trim();

            int personId = SwarmDb.GetDatabaseForWriting().CreatePerson(name, email, phone, street, postal, city,
                                                                        country == null ? 0 : country.Identity, dateOfBirth, gender);


            // Resolve the geography

            Person newPerson = FromIdentityAggressive(personId);

            // aggressive bypasses replication lag, avoids race condition
            newPerson.ResolveGeography();

            // Generate the salted password hash and set it

            if (password.Length > 0)
            {
                newPerson.PasswordHash = Authentication.GenerateNewPasswordHash(personId, password);
            }
            else
            {
                newPerson.PasswordHash = string.Empty; // if no password, prevent matching to anything
            }

            // Return the finished Person object

            return(newPerson);
        }
Example #24
0
        private static People FilterByMembership(BasicPerson[] candidates, Organization organization)
        {
            // Get the organization tree

            Organizations orgTree = organization.ThisAndBelow();

            // Build a lookup table of this organization tree. For each person in 'people'
            // that has at least one membership in an organization in the lookup table,
            // add that person to the final result.

            Dictionary <int, BasicOrganization> lookup = new Dictionary <int, BasicOrganization>();

            foreach (Organization org in orgTree)
            {
                lookup[org.Identity] = org;
            }

            // Get the list of all memberships

            Dictionary <int, List <BasicParticipation> > memberships =
                SwarmDb.GetDatabaseForReading()
                .GetParticipationsForPeople(LogicServices.ObjectsToIdentifiers(candidates));

            People result = new People();

            foreach (BasicPerson basicPerson in candidates)
            {
                bool memberOfOrganization = false;

                if (memberships.ContainsKey(basicPerson.Identity))
                {
                    foreach (BasicParticipation membership in memberships[basicPerson.Identity])
                    {
                        if (lookup.ContainsKey(membership.OrganizationId))
                        {
                            memberOfOrganization = true;
                        }
                    }
                }

                if (memberOfOrganization)
                {
                    result.Add(Person.FromBasic(basicPerson));
                }
            }

            return(result);
        }
Example #25
0
 private void PostStatus()
 {
     if (textBoxPostStatus.Text != string.Empty)
     {
         if (LogicServices.PostStatus(textBoxPostStatus.Text))
         {
             MessageBox.Show("Status Posted!");
             textBoxPostStatus.Invoke(new Action(() => textBoxPostStatus.Text = string.Empty));
         }
         else
         {
             MessageBox.Show("Error while posting status");
         }
     }
     else
     {
         MessageBox.Show("Status is empty, write something");
     }
 }
        public void Search()
        {
            foreach (User friend in LogicServices.GetFriends())
            {
                bool searchOK = true;

                foreach (ISearchBy searcher in m_SearchByList)
                {
                    if (!searcher.SearchSucceded(friend, m_FriendToLookFor))
                    {
                        searchOK = false;
                    }
                }

                if (searchOK)
                {
                    m_FilteredFriends.Add(friend);
                }
            }
        }
Example #27
0
        private void search()
        {
            listBoxFriendsListConditon.Items.Clear();
            listBoxFriendsListConditon.DisplayMember = "Name";

            initializeSearchParams();

            if (LogicServices.GetFriendsCount() == 0)
            {
                MessageBox.Show("Have no friends in list");
            }
            else
            {
                StrategySearchFriends searchStrategy = new StrategySearchFriends(m_friendToLookFor, m_SearchByList);
                searchStrategy.Search();

                foreach (User friend in searchStrategy.GetFilteredFriends())
                {
                    listBoxFriendsListConditon.Items.Add(friend);
                }
            }
        }
Example #28
0
 private void fillPictureBoxTaggedPhotos()
 {
     TaggedPhotos = LogicServices.GetPhotosTaggedIn().ToList();
     pictureBoxMyPicture.Invoke(new Action(() => pictureBoxMyPicture.LoadAsync(TaggedPhotos[TaggedPhotosIndex].PictureNormalURL)));
 }
Example #29
0
 public HomeController(LogicServices services)
 {
     this.service = services;
 }
Example #30
0
 public Tests(LogicServices services)
 {
     this.Services = services;
 }