Ejemplo n.º 1
0
 /// <summary>
 /// Gets the wikipedian age.
 /// </summary>
 /// <param name="userName">Name of the user.</param>
 /// <param name="channel">The channel the command is requested in. (Retrieves the relevant base wiki)</param>
 /// <returns></returns>
 public TimeSpan getWikipedianAge(string userName, string channel)
 {
     Registration regCommand = new Registration();
     DateTime regdate = regCommand.getRegistrationDate(userName, channel);
     TimeSpan age = DateTime.Now.Subtract(regdate);
     if (regdate.Equals(new DateTime(0001, 1, 1)))
     {
         age = new TimeSpan(0);
     }
     return age;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the wikipedian age.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="channel">The channel the command is requested in. (Retrieves the relevant base wiki)</param>
        /// <returns></returns>
        public TimeSpan getWikipedianAge(string userName, string channel)
        {
            Registration regCommand = new Registration();
            DateTime     regdate    = regCommand.getRegistrationDate(userName, channel);
            TimeSpan     age        = DateTime.Now.Subtract(regdate);

            if (regdate.Equals(new DateTime(0001, 1, 1)))
            {
                age = new TimeSpan(0);
            }
            return(age);
        }
Ejemplo n.º 3
0
        //TODO: tidy up! why return a value when it's passed by ref anyway?
// ReSharper disable UnusedMethodReturnValue.Local
        /// <summary>
        /// Retrieves the user information.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="initial">The initial.</param>
        /// <param name="channel">The channel.</param>
        /// <returns></returns>
        private static UserInformation retrieveUserInformation(string userName, ref UserInformation initial, string channel)
// ReSharper restore UnusedMethodReturnValue.Local
        {
            try{
                initial.userName = userName;

                if (initial.editCount == 0)
                {
                    Editcount countCommand = new Editcount();
                    initial.editCount = countCommand.getEditCount(userName, channel);
                }

                Rights rightsCommand = new Rights();
                initial.userGroups = rightsCommand.getRights(userName, channel);

                Registration registrationCommand = new Registration();
                initial.registrationDate = registrationCommand.getRegistrationDate(userName, channel);

                initial.userPage     = getUserPageUrl(userName, channel);
                initial.talkPage     = getUserTalkPageUrl(userName, channel);
                initial.userContribs = getUserContributionsUrl(userName, channel);
                initial.userBlockLog = getBlockLogUrl(userName, channel);

                Age ageCommand = new Age();
                initial.userAge = ageCommand.getWikipedianAge(userName, channel);

                initial.editRate = initial.editCount / initial.userAge.TotalDays;

                Blockinfo.BlockInformation bi = new Blockinfo().getBlockInformation(userName, channel);
                if (bi.id == null)
                {
                    initial.blockInformation = "";
                }
                else
                {
                    initial.blockInformation = bi.id.ToString();
                }

                return(initial);
            }
            catch (NullReferenceException ex)
            {
                GlobalFunctions.errorLog(ex);
                throw new InvalidOperationException();
            }
        }