Пример #1
0
        public static OtherSettings ParseOtherSettings(string otherSettingsString)
        {
            OtherSettings others = new OtherSettings();

            if (otherSettingsString != string.Empty)
            {
                try
                {
                    dynamic otherSettingsObject = Json.Decode(otherSettingsString);
                    if (otherSettingsObject.Content == null)
                    {
                        return(null);
                    }
                    others.Content        = otherSettingsObject.Content;
                    others.CssClass       = otherSettingsObject.CssClass != null ? otherSettingsObject.CssClass : string.Empty;
                    others.MobileCssClass = otherSettingsObject.MobileCssClass != null ? otherSettingsObject.MobileCssClass : string.Empty;
                    others.FeaturedImage  = otherSettingsObject.FeaturedImage != null ? otherSettingsObject.FeaturedImage : string.Empty;
                }
                catch (System.ArgumentException ex)
                {
                    others.Content = otherSettingsString;
                }
            }

            return(others);
        }
Пример #2
0
        public static List <SuperFlexiItem> GetModuleItems(Int32 moduleId)
        {
            string content = string.Empty;
            List <SuperFlexiItem> items = new List <SuperFlexiItem>();

            using (IDataReader reader = DBLinks.GetLinks(moduleId))
            {
                while (reader.Read())
                {
                    SuperFlexiItem item = new SuperFlexiItem();

                    item.itemID        = Convert.ToInt32(reader["ItemID"], CultureInfo.InvariantCulture);
                    item.moduleID      = Convert.ToInt32(reader["ModuleID"], CultureInfo.InvariantCulture);
                    item.createdByUser = Convert.ToInt32(reader["CreatedBy"], CultureInfo.InvariantCulture);
                    item.createdDate   = Convert.ToDateTime(reader["CreatedDate"], CultureInfo.CurrentCulture);
                    item.title         = reader["Title"].ToString();
                    item.url           = reader["Url"].ToString();
                    item.viewOrder     = Convert.ToInt32(reader["ViewOrder"]);
                    content            = reader["Description"].ToString();
                    OtherSettings others = ParseOtherSettings(content);
                    if (others != null)
                    {
                        item.content        = others.Content;
                        item.cssClass       = others.CssClass;
                        item.mobileCssClass = others.MobileCssClass;
                        item.featuredImage  = others.FeaturedImage;
                    }
                    else
                    {
                        try
                        {
                            item.contentItems = JsonConvert.DeserializeObject <List <ContentItem> >(content);
                        }
                        catch (JsonSerializationException ex)
                        {
                            item.content = content;
                        }
                    }
                    item.target = reader["Target"].ToString();

                    //string test = reader["ItemGuid"].ToString();

                    item.itemGuid   = new Guid(reader["ItemGuid"].ToString());
                    item.moduleGuid = new Guid(reader["ModuleGuid"].ToString());
                    string user = reader["UserGuid"].ToString();
                    if (user.Length == 36)
                    {
                        item.userGuid = new Guid(user);
                    }
                    items.Add(item);
                }
            }
            return(items);
        }
Пример #3
0
        private void GetItem(Int32 itemId)
        {
            string content = string.Empty;

            using (IDataReader reader = DBLinks.GetLink(itemId))
            {
                if (reader.Read())
                {
                    this.itemID        = Convert.ToInt32(reader["ItemID"], CultureInfo.InvariantCulture);
                    this.moduleID      = Convert.ToInt32(reader["ModuleID"], CultureInfo.InvariantCulture);
                    this.createdByUser = Convert.ToInt32(reader["CreatedBy"], CultureInfo.InvariantCulture);
                    this.createdDate   = Convert.ToDateTime(reader["CreatedDate"], CultureInfo.CurrentCulture);
                    this.title         = reader["Title"].ToString();
                    this.url           = reader["Url"].ToString();
                    this.viewOrder     = Convert.ToInt32(reader["ViewOrder"]);

                    content     = reader["Description"].ToString();
                    this.target = reader["Target"].ToString();

                    string test = reader["ItemGuid"].ToString();

                    this.itemGuid   = new Guid(reader["ItemGuid"].ToString());
                    this.moduleGuid = new Guid(reader["ModuleGuid"].ToString());
                    string user = reader["UserGuid"].ToString();
                    if (user.Length == 36)
                    {
                        this.userGuid = new Guid(user);
                    }
                }
            }
            OtherSettings others = ParseOtherSettings(content);

            if (others != null)
            {
                this.content        = others.Content;
                this.cssClass       = others.CssClass;
                this.mobileCssClass = others.MobileCssClass;
                this.featuredImage  = others.FeaturedImage;
            }
            else
            {
                try
                {
                    this.contentItems = JsonConvert.DeserializeObject <List <ContentItem> >(content);
                }
                catch (JsonSerializationException ex)
                {
                    this.content = content;
                }
            }
        }