Beispiel #1
0
        public override void Fill(System.Data.IDataReader dr)
        {
            base.FillInternal(dr);

            _KeyID    = Null.SetNullInteger(dr["KeyID"]);
            _PortalID = Null.SetNullInteger(dr["PortalID"]);
            if (!(Convert.IsDBNull(dr["Months"])))
            {
                _Months = new MonthArray(Convert.ToInt16(dr["Months"]));
            }
            else
            {
                _Months = MonthArray.Null;
            }
            if (!(Convert.IsDBNull(dr["Days"])))
            {
                _Days = new DayArray(Convert.ToInt32(dr["Days"]));
            }
            else
            {
                _Days = DayArray.Null;
            }
            if (!(Convert.IsDBNull(dr["DaysofWeek"])))
            {
                _DaysofWeek = new DayofWeekArray(Convert.ToByte(dr["DaysofWeek"]));
            }
            else
            {
                _DaysofWeek = DayofWeekArray.Null;
            }
            string currentYear = DateTime.Now.Year.ToString();

            if (!(Convert.IsDBNull(dr["StartDate"])))
            {
                _StartDate = new DateInteger(Convert.ToInt32(dr["StartDate"]));
            }
            if (!(Convert.IsDBNull(dr["EndDate"])))
            {
                _EndDate = new DateInteger(Convert.ToInt32(dr["EndDate"]));
            }
            if (!(Convert.IsDBNull(dr["StartTime"])))
            {
                _StartTime = Convert.ToInt32(dr["StartTime"]);
            }
            if (!(Convert.IsDBNull(dr["EndTime"])))
            {
                _EndTime = Convert.ToInt32(dr["EndTime"]);
            }
            _CategoryID           = Null.SetNullInteger(dr["CategoryID"]);
            _Category             = Null.SetNullString(dr["Category"]);
            _GroupID              = Null.SetNullInteger(dr["GroupID"]);
            _GroupName            = Null.SetNullString(dr["GroupName"]);
            _ProfilePropertyValue = Null.SetNullString(dr["ProfilePropertyValue"]);
            _Disabled             = Null.SetNullBoolean(dr["Disabled"]);
            _Title          = Null.SetNullString(dr["Title"]);
            _DesktopHTML    = Null.SetNullString(dr["DesktopHTML"]);
            _DesktopSummary = Null.SetNullString(dr["DesktopSummary"]);
        }
Beispiel #2
0
 private object GetNullDayArray(DayArray value, bool TreatAllorEmptyAsNull)
 {
     if (value.IsNull || (TreatAllorEmptyAsNull && (value.IsAllDays || value.IsEmpty)))
     {
         return(DBNull.Value);
     }
     else
     {
         return(value.Value);
     }
 }
Beispiel #3
0
 public override void UpdateContent(int KeyID, int ModuleID, int PortalID, int ContentItemID, MonthArray Months, DayArray Days, DayofWeekArray DaysofWeek, DateInteger StartDate, DateInteger EndDate, int StartTime, int EndTime, int CategoryID, int GroupID, string ProfilePropertyValue, bool Disabled, string Title, string DesktopHtml, string DesktopSummary, int UserID)
 {
     SqlHelper.ExecuteNonQuery(ConnectionString, GetFullyQualifiedName("UpdateContent"), KeyID, ModuleID, PortalID, GetNull(ContentItemID), GetNullMonthArray(Months), GetNullDayArray(Days), GetNullDayofWeekArray(DaysofWeek), GetNullDateInteger(StartDate), GetNullDateInteger(EndDate), GetNullTime(StartTime), GetNullTime(EndTime), GetNull(CategoryID), GetNull(GroupID), GetNull(ProfilePropertyValue), Disabled, GetNull(Title), DesktopHtml, GetNull(DesktopSummary), UserID);
 }
Beispiel #4
0
 public override int AddContent(int ModuleID, int PortalID, MonthArray Months, DayArray Days, DayofWeekArray DaysofWeek, DateInteger StartDate, DateInteger EndDate, int StartTime, int EndTime, int CategoryID, int GroupID, string ProfilePropertyValue, bool Disabled, string Title, string DesktopHtml, string DesktopSummary, int UserID)
 {
     return(Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, GetFullyQualifiedName("AddContent"), ModuleID, PortalID, GetNullMonthArray(Months), GetNullDayArray(Days), GetNullDayofWeekArray(DaysofWeek), GetNullDateInteger(StartDate), GetNullDateInteger(EndDate), GetNullTime(StartTime), GetNullTime(EndTime), GetNull(CategoryID), GetNull(GroupID), GetNull(ProfilePropertyValue), Disabled, GetNull(Title), DesktopHtml, GetNull(DesktopSummary), UserID)));
 }
Beispiel #5
0
 public override IDataReader FindContents(int ModuleID, MonthArray Months, DayArray Days, DayofWeekArray DaysofWeek, DateInteger StartDate, DateInteger EndDate, int StartTime, int EndTime, int CategoryID, int GroupID, string ProfilePropertyValue, bool IncludeDisabled)
 {
     return(SqlHelper.ExecuteReader(ConnectionString, GetFullyQualifiedName("FindContents"), ModuleID, GetNullMonthArray(Months, true), GetNullDayArray(Days, true), GetNullDayofWeekArray(DaysofWeek, true), GetNullDateInteger(StartDate), GetNullDateInteger(EndDate), GetNullTime(StartTime), GetNullTime(EndTime), GetNull(CategoryID), GetNull(GroupID), GetNull(ProfilePropertyValue), IncludeDisabled));
 }
Beispiel #6
0
 private object GetNullDayArray(DayArray value)
 {
     return(GetNullDayArray(value, false));
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            int    i       = -1;
            string content = string.Empty;
            string title   = string.Empty;

            DateTime todayAdjusted = Utilities.GetCurrentPortalTime();

            if (MyConfiguration.EnableUserTimeConversion)
            {
                todayAdjusted = Utilities.ConvertPortalToUserTime(todayAdjusted);
            }

            try
            {
                ContentDejourController cdc = new ContentDejourController();
                if (!(string.IsNullOrEmpty(Request.QueryString["KeyID"])))
                {
                    int keyID = 0;
                    if (int.TryParse(Request.QueryString["KeyID"], out keyID))
                    {
                        CurrentItem = cdc.GetContent(keyID, ModuleId);
                    }
                }

                if (CurrentItem.KeyID == -1)
                {
                    switch (MyConfiguration.SelectBy)
                    {
                    case Enums.SelectBy.Month:
                        Months = (new MonthArray()).AddMonth(todayAdjusted.Month);
                        break;

                    case Enums.SelectBy.DayofMonth:
                        Days = (new DayArray()).AddDay(todayAdjusted.Day);
                        break;

                    case Enums.SelectBy.DayofYear:
                        Days = new DayArray(todayAdjusted.DayOfYear | DayArray.ModeFlag);
                        break;

                    case Enums.SelectBy.MonthAndDayofMonth:
                        Months = (new MonthArray()).AddMonth(todayAdjusted.Month);
                        Days   = (new DayArray()).AddDay(todayAdjusted.Day);
                        break;

                    case Enums.SelectBy.DayofWeek:
                        DaysofWeek = (new DayofWeekArray()).AddDay(Convert.ToInt32(todayAdjusted.DayOfWeek));
                        break;

                    case Enums.SelectBy.MonthAndDayofWeek:
                        Months     = (new MonthArray()).AddMonth(todayAdjusted.Month);
                        DaysofWeek = (new DayofWeekArray()).AddDay(Convert.ToInt32(todayAdjusted.DayOfWeek));
                        break;

                    case Enums.SelectBy.TimeSpan:
                        Time = Convert.ToInt32(todayAdjusted.TimeOfDay.TotalMinutes);
                        break;

                    case Enums.SelectBy.DateSpan:
                        Today = new DateInteger(todayAdjusted.Date, false);
                        break;

                    case Enums.SelectBy.DateAndTimeSpan:
                        Today = new DateInteger(todayAdjusted.Date, false);
                        Time  = Convert.ToInt32(todayAdjusted.TimeOfDay.TotalMinutes);
                        break;

                    case Enums.SelectBy.Random:
                        //Do nothing as they will be handled below
                        break;
                    }

                    if (!(string.IsNullOrEmpty(MyConfiguration.ProfilePropertyName)))
                    {
                        string tmp = null;
                        if (UserId == -1)
                        {
                            tmp = "<Unauthenticated>";
                        }
                        else
                        {
                            ProfilePropertyDefinition ppd = UserInfo.Profile.GetProperty(MyConfiguration.ProfilePropertyName);
                            if (ppd == null)
                            {
                                tmp = string.Empty;
                            }
                            else
                            {
                                tmp = ppd.PropertyValue;
                                if (tmp == null)
                                {
                                    if (string.IsNullOrEmpty(ppd.DefaultValue))
                                    {
                                        tmp = "<Default>";
                                    }
                                    else
                                    {
                                        tmp = ppd.DefaultValue;
                                    }
                                }
                            }
                        }
                        ProfilePropertyValue = tmp;
                    }

                    if (!(string.IsNullOrEmpty(Request.QueryString["GroupId"])))
                    {
                        int.TryParse(Request.QueryString["GroupId"], out _GroupID);
                    }

                    if (MyConfiguration.MultipleHandling == Enums.MultipleHandling.TimeSpan)
                    {
                        Time = Convert.ToInt32(todayAdjusted.TimeOfDay.TotalMinutes);
                    }

                    // get ContentDejourInfo object(s)
                    ContentsDejour = cdc.GetContents(ModuleId, Months, Days, DaysofWeek, Today, Time, MyConfiguration.CategoryID, GroupID, ProfilePropertyValue, MyConfiguration.IncludeDisabled);

                    if (ContentsDejour.Count > 1)
                    {
                        int minViews    = int.MaxValue;
                        int leastViewed = 0;
                        switch (MyConfiguration.MultipleHandling)
                        {
                        case Enums.MultipleHandling.Random:
                            i = (new Random()).Next(0, ContentsDejour.Count);
                            break;

                        case Enums.MultipleHandling.First:
                            i = 0;
                            break;

                        case Enums.MultipleHandling.Sequential:
                        case Enums.MultipleHandling.LeastViewed:
                            System.Web.HttpCookie cookie = Request.Cookies["ContentDejour" + TabModuleId.ToString()];
                            int[] views = new int[ContentsDejour.Count + 1];
                            if (cookie != null)
                            {
                                i = int.Parse(cookie.Values["LastViewed"]);
                                for (int j = 0; j < ContentsDejour.Count; j++)
                                {
                                    string v = cookie.Values[j.ToString()];
                                    if (string.IsNullOrEmpty(v))
                                    {
                                        views[j] = 0;
                                    }
                                    else
                                    {
                                        views[j] = int.Parse(v);
                                    }
                                    if (views[j] < minViews)
                                    {
                                        leastViewed = j;
                                        minViews    = views[j];
                                    }
                                }
                            }
                            if (MyConfiguration.MultipleHandling == Enums.MultipleHandling.Sequential)
                            {
                                i = (i + 1) % ContentsDejour.Count;
                            }
                            else
                            {
                                i = leastViewed;
                            }
                            views[i]++;
                            cookie = new HttpCookie("ContentDejour" + TabModuleId.ToString());
                            cookie.Values["LastViewed"] = i.ToString();
                            for (int j = 0; j < views.Length; j++)
                            {
                                cookie.Values[j.ToString()] = views[j].ToString();
                            }
                            cookie.Expires = todayAdjusted.Date.AddMinutes(Convert.ToDouble(ContentsDejour[i].EndTime));
                            Response.Cookies.Add(cookie);
                            break;

                        case Enums.MultipleHandling.Last:
                            i = ContentsDejour.Count - 1;
                            break;

                        case Enums.MultipleHandling.TimeSpan:
                            ContentsDejour.Sort(new ContentDejourInfoComparer("TimeDuration ASC"));
                            i = 0;
                            break;
                        }
                    }
                    else if ((ContentsDejour.Count == 1) && ContentsDejour[0].IsWithinTimeSpan(todayAdjusted.TimeOfDay))
                    {
                        i = 0;
                    }
                }
                else
                {
                    ContentsDejour.Add(CurrentItem);
                    if (ContentsDejour.Count == 1)
                    {
                        i = 0;
                    }
                }

                if (i == -1)
                {
                    if (MyConfiguration.HideWhenNoContent && !IsEditable)
                    {
                        ContainerControl.Visible = false;
                    }
                    else
                    {
                        lnkEdit.Visible      = false;
                        divContent.InnerHtml = LocalizeSharedResource("NO_CONTENT");
                    }
                }
                else
                {
                    KeyID   = ContentsDejour[i].KeyID;
                    title   = Server.HtmlDecode(ContentsDejour[i].Title);
                    content = HttpUtility.HtmlDecode(ContentsDejour[i].DesktopHTML);
                    TokenReplace tr = null;
                    if (MyConfiguration.ReplaceTokens)
                    {
                        tr               = new TokenReplace(ContentsDejour[i]);
                        tr.ModuleId      = ModuleId;
                        tr.AccessingUser = UserInfo;
                        tr.DebugMessages = !(PortalSettings.UserMode == PortalSettings.Mode.View);
                        content          = tr.ReplaceEnvironmentTokens(content);
                        title            = tr.ReplaceEnvironmentTokens(title);
                    }
                    // set edit link
                    if (IsEditable)
                    {
                        lnkEdit.NavigateUrl = EditUrl("KeyID", KeyID.ToString());
                        lnkEdit.Visible     = true;
                    }
                    else
                    {
                        lnkEdit.Visible = false;
                    }
                    // add content to module
                    divContent.InnerHtml = Globals.ManageUploadDirectory(content, PortalSettings.HomeDirectory);
                    // replace module title if so specified in settings
                    if (MyConfiguration.ReplaceTitle && !(string.IsNullOrEmpty(title)))
                    {
                        ModuleConfiguration.ModuleTitle = title;
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Beispiel #8
0
 public string GetDaysString(DayArray days)
 {
     return(days.ToString(CultureInfo.CurrentCulture));
 }
 public System.Collections.Generic.List <ContentDejourInfo> FindContents(int ModuleId, MonthArray Months, DayArray Days, DayofWeekArray DaysofWeek, DateInteger StartDate, DateInteger EndDate, int StartTime, int EndTime, int CategoryID, int GroupID, string ProfilePropertyValue, bool IncludeDisabled)
 {
     return(CBO.FillCollection <ContentDejourInfo>(DataProvider.Instance().FindContents(ModuleId, Months, Days, DaysofWeek, StartDate, EndDate, StartTime, EndTime, CategoryID, GroupID, ProfilePropertyValue, IncludeDisabled)));
 }
 public List <ContentDejourInfo> GetContents(int ModuleId, MonthArray Months, DayArray Days, DayofWeekArray DaysofWeek, DateInteger Today, int Time, int CategoryID, int GroupID, string ProfilePropertyValue, bool IncludeDisabled)
 {
     return(CBO.FillCollection <ContentDejourInfo>(DataProvider.Instance().GetContents(ModuleId, Months, Days, DaysofWeek, Today, Time, CategoryID, GroupID, ProfilePropertyValue, IncludeDisabled)));
 }
Beispiel #11
0
 public abstract void UpdateContent(int KeyID, int ModuleID, int PortalID, int ContentItemID, MonthArray Months, DayArray Days, DayofWeekArray DaysofWeek, DateInteger StartDate, DateInteger EndDate, int StartTime, int EndTime, int CategoryID, int GroupID, string ProfilePropertyValue, bool Disabled, string Title, string DesktopHtml, string DesktopSummary, int UserID);
Beispiel #12
0
 public abstract IDataReader FindContents(int ModuleId, MonthArray Months, DayArray Days, DayofWeekArray DaysofWeek, DateInteger StartDate, DateInteger EndDate, int StartTime, int EndTime, int CategoryID, int GroupID, string ProfilePropertyValue, bool IncludeDisabled);
Beispiel #13
0
 public abstract IDataReader GetContents(int ModuleId, MonthArray Months, DayArray Days, DayofWeekArray DaysofWeek, DateInteger Today, int Time, int CategoryID, int GroupID, string ProfilePropertyValue, bool IncludeDisabled);