public string ExportModule(int ModuleID)
        {
            StringBuilder           strXML = new StringBuilder();
            ContentDejourController cdc    = new ContentDejourController();

            strXML.AppendLine("<contentdejour>");

            Configuration MyConfiguration = new Configuration(ModuleID);

            AppendSerializedObject(strXML, "configuration", MyConfiguration);

            strXML.AppendLine("<categories>");
            System.Collections.Generic.List <CategoryInfo> objCategories = cdc.GetCategories(ModuleID);
            foreach (CategoryInfo objCategory in objCategories)
            {
                AppendSerializedObject(strXML, "category", objCategory);
            }
            strXML.AppendLine("</categories>");

            System.Collections.Generic.List <ContentDejourInfo> objContents = cdc.GetContents(ModuleID, MonthArray.Null, DayArray.Null, DayofWeekArray.Null, DateInteger.Null, Null.NullInteger, Null.NullInteger, Null.NullInteger, "", true);
            if (objContents.Count > 0)
            {
                strXML.AppendLine("<contents>");
                foreach (ContentDejourInfo objContent in objContents)
                {
                    AppendSerializedObject(strXML, "content", objContent);
                }
                strXML.AppendLine("</contents>");
                strXML.AppendLine("</contentdejour>");
            }

            return(strXML.ToString());
        }
Beispiel #2
0
        private void PopulateListControls()
        {
            var monthNames = CultureInfo.CurrentCulture.DateTimeFormat.MonthNames;

            cblMonths.Items.Clear();
            for (int i = 0; i < monthNames.Length; i++)
            {
                cblMonths.Items.Add(new ListItem(monthNames[i], i.ToString()));
            }

            var weekdayNames = CultureInfo.CurrentCulture.DateTimeFormat.DayNames;

            cblDaysofWeek.Items.Clear();
            for (int i = 0; i <= 6; i++)
            {
                cblDaysofWeek.Items.Add(new ListItem(weekdayNames[i], i.ToString()));
            }

            PopulateTimeControl(ddlStartTime, MyConfiguration.Interval);
            PopulateTimeControl(ddlEndTime, MyConfiguration.Interval);

            ContentDejourController cdc = new ContentDejourController();

            ddlCategory.DataSource = cdc.GetCategories(ModuleId);
            ddlCategory.DataBind();
            ddlCategory.Items.Insert(0, new ListItem(LocalizeSharedResource("ANY"), "-1"));

            Func <RoleInfo, bool> groupPredicate = r => r.SecurityMode != SecurityMode.SecurityRole && r.Status == RoleStatus.Approved && (r.IsPublic || UserInfo.IsInRole(r.RoleName));
            var groups = TestableRoleController.Instance.GetRoles(PortalId, groupPredicate).Select(r => new { GroupName = r.RoleName, GroupID = r.RoleID });

            ddlGroup.DataSource = groups;
            ddlGroup.DataBind();
            ddlGroup.Items.Insert(0, new ListItem(LocalizeSharedResource("ANY"), "-1"));
        }
Beispiel #3
0
        private void BindCategories()
        {
            ContentDejourController cdc = new ContentDejourController();

            ddlCategory.DataSource = cdc.GetCategories(ModuleId);
            ddlCategory.DataBind();
            ddlCategory.Items.Insert(0, new ListItem(Localization.GetString("ANY", _MyConfiguration.LocalSharedResourceFile), "-1"));
        }
Beispiel #4
0
 protected void gvList_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e)
 {
     if (gvList.DataKeys.Count > e.RowIndex)
     {
         int ID = Convert.ToInt32(gvList.DataKeys[e.RowIndex].Value);
         ContentDejourController cdc = new ContentDejourController();
         cdc.DeleteCategory(ID);
         BindList();
         OnDataChanged(new System.EventArgs());
     }
 }
Beispiel #5
0
        private void BindList()
        {
            var cdc = new ContentDejourController();

            gvList.DataKeyNames = new [] { "CategoryID", "ViewOrder" };
            gvList.DataSource   = cdc.GetCategories(ModuleId);
            gvList.DataBind();
            if (gvList.Rows.Count > 0 && gvList.EditIndex == -1)
            {
                gvList.Rows[gvList.Rows.Count - 1].FindControl("btnDown").Visible = false;
            }
        }
Beispiel #6
0
        private void BindGrid(bool PerformSorting)
        {
            var cdc = new ContentDejourController();
            List <ContentDejourInfo> objContents = null;

            objContents = cdc.FindContents(ModuleId, Months, Days, DaysofWeek, StartDate, EndDate, StartTime, EndTime, CategoryID, GroupID, ProfilePropertyValue, !Disabled);

            if (PerformSorting)
            {
                objContents.Sort(new ContentDejourInfoComparer(SortColumns));
            }

            dgSelectContent.DataSource = objContents;
            dgSelectContent.DataBind();
        }
Beispiel #7
0
 private void DeleteCurrentItem()
 {
     if (KeyID > 0)
     {
         if (CurrentItem.ContentItemId != Null.NullInteger)
         {
             ContentController cc = new ContentController();
             cc.DeleteContentItem(CurrentItem);
         }
         ContentDejourController cdc = new ContentDejourController();
         cdc.DeleteContent(KeyID);
         KeyID = 0;
         Mode  = "Select";
         BindGrid(SortColumns.Count > 0);
         InvalidateCurrentItem();
     }
 }
Beispiel #8
0
        private void Save(int ID, string Name, int ModuleID, int ViewOrder)
        {
            var cdc             = new ContentDejourController();
            var objCategoryInfo = new CategoryInfo();

            objCategoryInfo.ModuleID   = ModuleID;
            objCategoryInfo.CategoryID = ID;
            objCategoryInfo.Category   = Name;
            objCategoryInfo.ViewOrder  = ViewOrder;
            if (ID == -1)
            {
                cdc.AddCategory(objCategoryInfo);
            }
            else
            {
                cdc.UpdateCategory(objCategoryInfo);
            }
        }
        public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(ModuleInfo ModInfo)
        {
            var            SearchItemCollection = new SearchItemInfoCollection();
            SearchItemInfo SearchItem           = null;
            string         summary = null;
            string         title   = null;
            var            cdc     = new ContentDejourController();

            var objContents = cdc.GetContents(ModInfo.ModuleID, MonthArray.Null, DayArray.Null, DayofWeekArray.Null, DateInteger.Null, Null.NullInteger, Null.NullInteger, Null.NullInteger, "", false);

            foreach (ContentDejourInfo objContent in objContents)
            {
                title      = HttpUtility.HtmlDecode(objContent.Title);
                summary    = Utilities.GetSummary(objContent.DesktopSummary, objContent.DesktopHTML);
                SearchItem = new SearchItemInfo(ModInfo.ModuleTitle + " - " + title, summary, objContent.CreatedByUserID, objContent.CreatedOnDate, ModInfo.ModuleID, objContent.KeyID.ToString(), HttpUtility.HtmlDecode(objContent.DesktopHTML), "KeyID=" + objContent.KeyID.ToString());
                SearchItemCollection.Add(SearchItem);
            }
            return(SearchItemCollection);
        }
Beispiel #10
0
        private void cmdUpdate_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                var cdc = new ContentDejourController();
                try
                {
                    LoadData(); // load form fields into CurrentItem

                    // save the content
                    if (Mode == "Add")
                    {
                        KeyID = cdc.AddContent(CurrentItem, UserId);
                        SaveContentItem(CurrentItem, false);
                    }
                    else if (Mode == "Edit")
                    {
                        cdc.UpdateContent(CurrentItem, UserId);
                        SaveContentItem(CurrentItem, true);
                    }
                    // refresh cache
                    ModuleController.SynchronizeModule(ModuleId);

                    if (!divSelect.Visible && KeyID > 0)
                    {
                        Response.Redirect(Globals.NavigateURL("", "keyid=" + KeyID.ToString()), true);
                    }
                    else
                    {
                        KeyID = 0;
                        Mode  = "Select";
                        BindGrid(SortColumns.Count > 0);
                    }
                }
                catch (Exception exc)
                {
                    Exceptions.ProcessModuleLoadException(this, exc);
                }
            }
        }
        protected int SaveContentItem(ContentDejourInfo objContentDejour, bool update)
        {
            objContentDejour.Content       = objContentDejour.DesktopHTML;
            objContentDejour.ContentKey    = "mid=" + ModuleId.ToString() + "&KeyID=" + objContentDejour.KeyID.ToString();
            objContentDejour.ContentTypeId = GetContentTypeID();
            objContentDejour.ModuleID      = ModuleId;
            objContentDejour.TabID         = TabId;
            objContentDejour.Indexed       = false;
            var cc  = new ContentController();
            var cdc = new ContentDejourController();

            if (objContentDejour.ContentItemId == Null.NullInteger)
            {
                objContentDejour.ContentItemId = cc.AddContentItem(objContentDejour);
                cdc.LinkContentItem(objContentDejour.KeyID, objContentDejour.ContentItemId);
            }
            else if (update)
            {
                cc.UpdateContentItem(objContentDejour);
            }
            return(objContentDejour.ContentItemId);
        }
        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);
            }
        }
        /// ImportModule implements the IPortable ImportModule Interface
        /// -----------------------------------------------------------------------------
        public void ImportModule(int ModuleID, string Content, string Version, int UserId)
        {
            try
            {
                System.Collections.Specialized.NameValueCollection ForeignKeyTranslator = new System.Collections.Specialized.NameValueCollection();
                XmlNode Node         = null;
                XmlNode xmlDocuments = Globals.GetContent(Content, "contentdejour");

                var MyConfiguration = new Configuration(ModuleID);
                Node = xmlDocuments.SelectSingleNode("configuration");
                string category            = string.Empty;
                string profilePropertyName = string.Empty;
                MyConfiguration.SelectBy          = (Enums.SelectBy)Enum.Parse(typeof(Enums.SelectBy), Node["SelectBy"].InnerText);
                MyConfiguration.MultipleHandling  = (Enums.MultipleHandling)Enum.Parse(typeof(Enums.MultipleHandling), Node["MultipleHandling"].InnerText);
                MyConfiguration.Interval          = Convert.ToInt32(Node["Interval"].InnerText);
                MyConfiguration.IncludeDisabled   = Convert.ToBoolean(Node["IncludeDisabled"].InnerText);
                MyConfiguration.HideWhenNoContent = Convert.ToBoolean(Node["HideWhenNoContent"].InnerText);
                MyConfiguration.ReplaceTitle      = Convert.ToBoolean(Node["ReplaceTitle"].InnerText);
                MyConfiguration.ReplaceTokens     = Convert.ToBoolean(Node["ReplaceTokens"].InnerText);
                if (Version == "04.00.00")
                {
                    MyConfiguration.ProfilePropertyName      = Defaults.ProfilePropertyName;
                    MyConfiguration.EnableUserTimeConversion = Defaults.EnableUserTimeConversion;
                }
                else
                {
                    MyConfiguration.ProfilePropertyName      = Node["ProfilePropertyName"].InnerText;
                    MyConfiguration.EnableUserTimeConversion = Convert.ToBoolean(Node["EnableUserTimeConversion"].InnerText);
                }

                category = Node["Category"].InnerText;
                var cdc = new ContentDejourController();

                CategoryInfo objCategory = null;
                foreach (XmlNode NodeWithinLoop in xmlDocuments.SelectNodes("categories/category"))
                {
                    Node                  = NodeWithinLoop;
                    objCategory           = new CategoryInfo();
                    objCategory.ModuleID  = ModuleID;
                    objCategory.Category  = NodeWithinLoop["Category"].InnerText;
                    objCategory.ViewOrder = int.Parse(NodeWithinLoop["ViewOrder"].InnerText);
                    try
                    {
                        cdc.AddCategory(objCategory);
                    }
                    catch
                    {
                    }
                }
                ForeignKeyTranslator.Add("CAT-", "-1");
                foreach (CategoryInfo objCategoryWithinLoop in cdc.GetCategories(ModuleID))
                {
                    objCategory = objCategoryWithinLoop;
                    ForeignKeyTranslator.Add("CAT-" + objCategoryWithinLoop.Category, objCategoryWithinLoop.CategoryID.ToString());
                    if (objCategoryWithinLoop.Category == category)
                    {
                        MyConfiguration.CategoryID = objCategoryWithinLoop.CategoryID;
                    }
                }

                MyConfiguration.SaveSettings();

                var rc       = new RoleController();
                var portalID = MyConfiguration.PortalSettings.PortalId;

                foreach (XmlNode NodeWithinLoop in xmlDocuments.SelectNodes("contents/content"))
                {
                    Node = NodeWithinLoop;
                    var objContent = new ContentDejourInfo();
                    objContent.ModuleID = ModuleID;
                    if (Version == "04.00.00")
                    {
                        objContent.Months               = (new MonthArray()).AddMonth(Convert.ToInt16(NodeWithinLoop["Month"].InnerText));
                        objContent.Days                 = (new DayArray()).AddDay(Convert.ToInt32(NodeWithinLoop["Day"].InnerText));
                        objContent.DaysofWeek           = (new DayofWeekArray()).AddDay(Convert.ToInt32(NodeWithinLoop["DayofWeek"].InnerText));
                        objContent.ProfilePropertyValue = string.Empty;
                    }
                    else
                    {
                        objContent.Months               = new MonthArray(Convert.ToInt16(NodeWithinLoop["Months"].InnerText));
                        objContent.Days                 = new DayArray(Convert.ToInt32(NodeWithinLoop["Days"].InnerText));
                        objContent.DaysofWeek           = new DayofWeekArray(Convert.ToByte(NodeWithinLoop["DaysofWeek"].InnerText));
                        objContent.ProfilePropertyValue = NodeWithinLoop["ProfilePropertyValue"].InnerText;
                    }
                    objContent.StartDate  = new DateInteger(Convert.ToInt32(NodeWithinLoop["StartDate"].InnerText));
                    objContent.EndDate    = new DateInteger(Convert.ToInt32(NodeWithinLoop["EndDate"].InnerText));
                    objContent.StartTime  = Convert.ToInt32(NodeWithinLoop["StartTime"].InnerText);
                    objContent.EndTime    = Convert.ToInt32(NodeWithinLoop["EndTime"].InnerText);
                    objContent.CategoryID = Convert.ToInt32(ForeignKeyTranslator["CAT-" + NodeWithinLoop["Category"].InnerText]);

                    var groupName = NodeWithinLoop["GroupName"] == null ? "": NodeWithinLoop["GroupName"].InnerText;
                    if (groupName != "")
                    {
                        var role = rc.GetRoleByName(portalID, groupName);
                        if (role != null && role.SecurityMode != SecurityMode.SecurityRole && role.Status == RoleStatus.Approved)
                        {
                            objContent.GroupID = role.RoleID;
                        }
                    }

                    objContent.Title          = HttpUtility.HtmlEncode(NodeWithinLoop["Title"].InnerText);
                    objContent.DesktopHTML    = NodeWithinLoop["DesktopHTML"].InnerText;
                    objContent.DesktopSummary = NodeWithinLoop["DesktopSummary"].InnerText;
                    cdc.AddContent(objContent, UserId); //Note all content will be have CreatedByUserID set to UserID of current user
                }
            }
            catch (Exception exc)
            {
                string Msg = exc.Message;
            }
        }