Ejemplo n.º 1
0
 private ListInfo FillListInfo(IDataReader dr, bool CheckForOpenDataReader)
 {
     ListInfo objListInfo = null;
     // read datareader
     bool canContinue = true;
     if (CheckForOpenDataReader)
     {
         canContinue = false;
         if (dr.Read())
         {
             canContinue = true;
         }
     }
     if (canContinue)
     {
         objListInfo = new ListInfo(Convert.ToString(dr["ListName"]));
         {
             objListInfo.Level = Convert.ToInt32(dr["Level"]);
             objListInfo.PortalID = Convert.ToInt32(dr["PortalID"]);
             objListInfo.DefinitionID = Convert.ToInt32(dr["DefinitionID"]);
             objListInfo.EntryCount = Convert.ToInt32(dr["EntryCount"]);
             objListInfo.ParentID = Convert.ToInt32(dr["ParentID"]);
             objListInfo.ParentKey = Convert.ToString(dr["ParentKey"]);
             objListInfo.Parent = Convert.ToString(dr["Parent"]);
             objListInfo.ParentList = Convert.ToString(dr["ParentList"]);
             objListInfo.EnableSortOrder = (Convert.ToInt32(dr["MaxSortOrder"]) > 0);
             objListInfo.SystemList = Convert.ToInt32(dr["SystemList"]) > 0;
         }
     }
     return objListInfo;
 }
Ejemplo n.º 2
0
        public ListInfoCollection GetListInfoCollection(string listName, string parentKey, int portalId)
        {
            IList lists = new ListInfoCollection();

            foreach (KeyValuePair <string, ListInfo> listPair in this.GetListInfoDictionary(portalId).OrderBy(l => l.Value.DisplayName))
            {
                ListInfo list = listPair.Value;
                if ((list.Name == listName || string.IsNullOrEmpty(listName)) && (list.ParentKey == parentKey || string.IsNullOrEmpty(parentKey)) &&
                    (list.PortalID == portalId || portalId == Null.NullInteger))
                {
                    lists.Add(list);
                }
            }

            return((ListInfoCollection)lists);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Deletes a list.
        /// </summary>
        /// <param name="listName">The name of the list to delete.</param>
        /// <param name="parentKey">The parent key of the list to delete.</param>
        /// <param name="portalId">The id of the site (portal) on which to delete the list.</param>
        public void DeleteList(string listName, string parentKey, int portalId)
        {
            ListInfo list = this.GetListInfo(listName, parentKey, portalId);

            this.eventLogger.AddLog(
                "ListName",
                listName,
                PortalController.Instance.GetCurrentSettings(),
                UserController.Instance.GetCurrentUserInfo().UserID,
                EventLogType.LISTENTRY_DELETED);

            DataProvider.Instance().DeleteList(listName, parentKey);
            if (list != null)
            {
                this.ClearListCache(list.PortalID);
                this.ClearEntriesCache(list.Name, list.PortalID);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets a single list.
        /// </summary>
        /// <param name="key">The key to fetch the list.</param>
        /// <param name="cache">A value indicating whether to cache this list.</param>
        /// <returns>A list object.</returns>
        public object Item(string key, bool cache)
        {
            int    index;
            object obj        = null;
            bool   itemExists = false;

            // Do validation first
            try
            {
                if (this.mKeyIndexLookup[key.ToLowerInvariant()] != null)
                {
                    itemExists = true;
                }
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
            }

            // key will be in format Country.US:Region
            if (!itemExists)
            {
                var      ctlLists  = new ListController();
                string   listName  = key.Substring(key.IndexOf(":") + 1);
                string   parentKey = key.Replace(listName, string.Empty).TrimEnd(':');
                ListInfo listInfo  = ctlLists.GetListInfo(listName, parentKey);

                // the collection has been cache, so add this entry list into it if specified
                if (cache)
                {
                    this.Add(listInfo.Key, listInfo);
                    return(listInfo);
                }
            }
            else
            {
                index = Convert.ToInt32(this.mKeyIndexLookup[key.ToLowerInvariant()]);
                obj   = this.List[index];
            }

            return(obj);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Select a list in dropdownlist
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SelectListIndexChanged(object sender, EventArgs e)
        {
            var ctlLists = new ListController();

            if (!String.IsNullOrEmpty(ddlSelectList.SelectedValue))
            {
                ListInfo selList = GetList(ddlSelectList.SelectedItem.Value, false);
                {
                    ddlSelectParent.Enabled        = true;
                    ddlSelectParent.DataSource     = ctlLists.GetListEntryInfoItems(selList.Name, selList.ParentKey);
                    ddlSelectParent.DataTextField  = "DisplayName";
                    ddlSelectParent.DataValueField = "EntryID";
                    ddlSelectParent.DataBind();
                }
            }
            else
            {
                ddlSelectParent.Enabled = false;
                ddlSelectParent.Items.Clear();
            }
        }
Ejemplo n.º 6
0
        public ListInfo FillListInfo(string ListName, string ParentKey, int DefinitionID) // Get single entry list by Name
        {
            IDataReader dr = DataProvider.Instance().GetList(ListName, ParentKey, DefinitionID);
            ListInfo objListInfo = null;

            try
            {
                if (dr.Read())
                {
                    objListInfo = new ListInfo(Convert.ToString(dr["ListName"]));
                    objListInfo.DisplayName = Convert.ToString(dr["DisplayName"]);
                    objListInfo.Level = Convert.ToInt32(dr["Level"]);
                    objListInfo.DefinitionID = Convert.ToInt32(dr["DefinitionID"]);
                    objListInfo.Key = Convert.ToString(dr["Key"]);
                    objListInfo.EntryCount = Convert.ToInt32(dr["EntryCount"]);
                    objListInfo.ParentID = Convert.ToInt32(dr["ParentID"]);
                    objListInfo.ParentKey = Convert.ToString(dr["ParentKey"]);
                    objListInfo.Parent = Convert.ToString(dr["Parent"]);
                    objListInfo.ParentList = Convert.ToString(dr["ParentList"]);
                    objListInfo.EnableSortOrder = Convert.ToInt32(dr["MaxSortOrder"]) > 0;
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
            finally
            {
                // close datareader
                if (dr != null)
                {
                    dr.Close();
                }
            }

            return objListInfo;
        }
Ejemplo n.º 7
0
        public ListInfo FillListInfo(string ListName, string ParentKey, int DefinitionID) // Get single entry list by Name
        {
            IDataReader dr          = DataProvider.Instance().GetList(ListName, ParentKey, DefinitionID);
            ListInfo    objListInfo = null;

            try
            {
                if (dr.Read())
                {
                    objListInfo                 = new ListInfo(Convert.ToString(dr["ListName"]));
                    objListInfo.DisplayName     = Convert.ToString(dr["DisplayName"]);
                    objListInfo.Level           = Convert.ToInt32(dr["Level"]);
                    objListInfo.DefinitionID    = Convert.ToInt32(dr["DefinitionID"]);
                    objListInfo.Key             = Convert.ToString(dr["Key"]);
                    objListInfo.EntryCount      = Convert.ToInt32(dr["EntryCount"]);
                    objListInfo.ParentID        = Convert.ToInt32(dr["ParentID"]);
                    objListInfo.ParentKey       = Convert.ToString(dr["ParentKey"]);
                    objListInfo.Parent          = Convert.ToString(dr["Parent"]);
                    objListInfo.ParentList      = Convert.ToString(dr["ParentList"]);
                    objListInfo.EnableSortOrder = Convert.ToInt32(dr["MaxSortOrder"]) > 0;
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
            finally
            {
                // close datareader
                if (dr != null)
                {
                    dr.Close();
                }
            }

            return(objListInfo);
        }
Ejemplo n.º 8
0
        public void DeleteList(ListInfo list, bool includeChildren)
        {
            if (list == null)
            {
                return;
            }

            var lists = new SortedList<string, ListInfo>();
            lists.Add(list.Key, list);
            //add Children
            if (includeChildren)
            {
                foreach (KeyValuePair<string, ListInfo> listPair in GetListInfoDictionary(list.PortalID))
                {
                    if ((listPair.Value.ParentList.StartsWith(list.Key)))
                    {
                        lists.Add(listPair.Value.Key.Replace(":", "."), listPair.Value);
                    }
                }
            }
            //Delete items in reverse order so deeper descendants are removed before their parents
            for (int i = lists.Count - 1; i >= 0; i += -1)
            {
				DeleteList(lists.Values[i].Name, lists.Values[i].ParentKey, lists.Values[i].PortalID);
            }
        }
Ejemplo n.º 9
0
        public ListInfoCollection GetListInfoCollection(string ListName, string ParentKey, int DefinitionID)
        {
            IList objListInfoCollection = new ListInfoCollection();
            ListInfo objListInfo = new ListInfo();

            return ((ListInfoCollection)CBO.FillCollection(DataProvider.Instance().GetList(ListName, ParentKey, DefinitionID), typeof(ListInfo), ref objListInfoCollection));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Loads top level entry list
        /// </summary>       
        /// <history>
        ///     [tamttt] 20/10/2004	Created
        /// </history>
        private void InitList()
        {
            ListController ctlLists = new ListController();
            string listName = SelectedKey.Substring(SelectedKey.IndexOf(":") + 1);
            string parentKey = SelectedKey.Replace(listName, "").TrimEnd(':');

            selListInfo = ctlLists.GetListInfo(listName, parentKey);
            SelectedText = selListInfo.DisplayName;
            EnableSortOrder = selListInfo.EnableSortOrder;
            SystemList = selListInfo.SystemList;

        }