Esempio n. 1
0
        // *********************************************************************
        //  GetUserInfo
        //
        /// <summary>
        /// Вернуть информацию о конкретном форуме.
        /// </summary>
        /// <param name="username">The user whose information you are interested in.</param>
        /// <param name="updateIsOnline">Updates user's online datetime stamp.</param>
        /// <returns>Instance of User with details about a given forum user.</returns>
        /// <remarks>
        /// If the specified user is not found, a UserNotFoundException exception is thrown. Feel
        /// free to call this multiple times during the request as the value is stored in Context once
        /// read from the data source.
        /// </remarks>
        // ***********************************************************************/
        public static User GetUserInfo( String username )
        {
            User user = new User();
            UlterSystems.PortalLib.BusinessObjects.Person UlterUser = new UlterSystems.PortalLib.BusinessObjects.Person();
            UlterUser.Load( Int32.Parse( username ) );
            user.Username = username;
            user.DisplayName = UlterUser.FirstName.ToString() + "&nbsp;" + UlterUser.LastName.ToString();
            user.IsApproved = !UlterUser.IsInRole( "ForumBannedUser" );
            user.IsAdministrator = UlterUser.IsInRole( "ForumAdministrator" );

            return user;
        }
Esempio n. 2
0
        /// <summary>
        /// Отсылает пользовательскую статистику.
        /// </summary>
        /// <param name="curUser">Пользователь, которому отсылается статистика.</param>
        /// <param name="delivery">Описание рассылки.</param>
        private void SendUserStatistics(Person curUser, UserDelivery delivery)
        {
            if (curUser == null
                || curUser.ID == null
                || delivery == null)
                return;

            try
            {
                // Отослать статистику за неделю.
                DateTime end = DateTime.Today.AddDays(-1);
                DateTime begin = DateClass.WeekBegin(end);

                if (begin.Month < end.Month)
                    begin = new DateTime(end.Year, end.Month, 1, 0, 0, 0);

                MailItem item = new MailItem
                                    {
                                        FromAddress = FromAddress,
                                        ToAddress = curUser.PrimaryEMail,
                                        Subject = String.Format(Subject, curUser.FullName, begin, end),
                                        MessageType = ((int) MailTypes.UserStatistics)
                                    };

                // Узнать пользователя, чья статистика должна быть послана.
                Person statUser = curUser;
                if (delivery.StatisticsUserID != null)
                {
                    statUser = new Person();
                    if (!statUser.Load(delivery.StatisticsUserID.Value))
                        statUser = curUser;
                }

                PeriodUserStatistics stat = PeriodUserStatistics.GetUserStatistics(statUser, begin, end);
                switch (delivery.DeliveryPresentation)
                {
                    case DeliveryPresentation.XML:
                        item.IsHTML = false;
                        item.Body = stat.GetXMLPresentation();
                        break;

                    case DeliveryPresentation.HTML:
                        item.IsHTML = true;
                        item.Body = stat.GetHTMLPresentation();
                        break;
                }
                item.Save();

                // Отослать статистику за месяц.
                if (DateTime.Today.Day == 1)
                {
                    begin = new DateTime(end.Year, end.Month, 1, 0, 0, 0);
                    item.Subject = String.Format(Subject, curUser.FullName, begin, end);

                    stat = PeriodUserStatistics.GetUserStatistics(curUser, begin, end);
                    switch (delivery.DeliveryPresentation)
                    {
                        case DeliveryPresentation.XML:
                            item.IsHTML = false;
                            item.Body = stat.GetXMLPresentation();
                            break;

                        case DeliveryPresentation.HTML:
                            item.IsHTML = true;
                            item.Body = stat.GetHTMLPresentation();
                            break;
                    }

                    item.ID = null;
                    item.Save();
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Error("Can't send user " + curUser.FullName + " statistcs.", ex);
            }
        }
Esempio n. 3
0
        protected virtual Person GetUserDetailsFromReader(IDataReader reader)
        {
            int userID = (int) reader["ID"];
            Person user = new Person();
            user.Load(userID);

            return user;
        }