Tuesday, February 21, 2012

SharePoint 2010 User profile service


I was asked multiple times to help locate "User Profile Repository" for SharePoint 2010.

You can follow the steps below to access it. You need access SharePoint 2010 "Central admin site" for this purpose.

Select “SharePoint 2010 Central Administration” from start menu
Select “Application Management“
Select “Manage service applications“
Select “User Profile Service Application”
Select “Manage User Profiles”


Thursday, February 16, 2012

How do you “Divide Share Equally” among a number of people?


Easy isn't it.. 100% / number of people   100/2 = 50%

Now 100/3….=  33.33333333333333…….
One compromised solution is 33.33, 33.33 and 33.34.  so one of them will get a 0.01 percent more, if that is not a big deal.

I ended up writing some code for this and I hope it will be useful for you.

See C# sample code below

        private List<double> GetPercentages(double numberOfItems)
        {
            List<double> percentages = new List<double>(); 
            double totalPercentage = 100.00;
            double averagePercentage = Math.Round(totalPercentage / numberOfItems, 2);
            double reminder = Math.Round(100 - (averagePercentage * numberOfItems),2);

            for (int i = 0; i < numberOfItems; i++)
            {
                double percentageValue = averagePercentage;
                if (reminder != 0)
                {
                    if (reminder > 0)
                    {
                        reminder = Math.Round(reminder - 0.01,2);
                        percentageValue += 0.01;
                    }
                    else
                    {
                        reminder = Math.Round(reminder + 0.01,2);
                        percentageValue -= 0.01;
                    }
                }

                percentages.Add(Math.Round(percentageValue,2));
                percentages.Sort();
            }
            return percentages;
        }

Please add a comment if this is useful.