Пример #1
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"));
        }
        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());
        }
Пример #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"));
        }
Пример #4
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;
            }
        }
        /// 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;
            }
        }