Exemplo n.º 1
0
        }//restoreView()

        public CswNbtView restoreView(string ViewName, CswEnumNbtViewVisibility Visibility)
        {
            CswNbtView ReturnVal = null;

            if (null == Visibility)
            {
                Visibility = CswEnumNbtViewVisibility.Unknown;
            }

            List <CswNbtView> AllViews = restoreViews(ViewName, Visibility);

            if (1 == AllViews.Count)
            {
                ReturnVal = AllViews[0];
            }
            else if (AllViews.Count > 1)
            {
                List <CswNbtView> VisibilityViews = AllViews.Where(View => View.Visibility == Visibility).ToList();
                if (1 == VisibilityViews.Count)
                {
                    ReturnVal = VisibilityViews[0];
                }
            }

            return(ReturnVal);
        }//restoreView()
Exemplo n.º 2
0
        /// <summary>
        /// Convenience function for hiding all views in a category
        /// </summary>
        /// <param name="hidden">true if the views should be hidden</param>
        /// <param name="category">the category to get all views in</param>
        /// <param name="visibility">the original visibility of the view when not hidden</param>
        public void ToggleViewsInCategory(bool hidden, string category, CswEnumNbtViewVisibility visibility)
        {
            CswTableSelect tu        = _CswNbtResources.makeCswTableSelect("toggleViewsInCategory_26717", "node_views");
            DataTable      nodeviews = tu.getTable("where category = '" + category + "'");

            foreach (DataRow row in nodeviews.Rows)
            {
                ToggleView(hidden, row["viewname"].ToString(), visibility);
            }
        }
Exemplo n.º 3
0
        public List <CswNbtView> restoreViews(string ViewName, CswEnumNbtViewVisibility Visibility, Int32 VisibilityId = Int32.MinValue, bool allowPartialMatches = false)
        {
            List <CswNbtView> ReturnVal = new List <CswNbtView>();

            CswTableSelect          ViewSelect = _CswNbtResources.makeCswTableSelect("CswNbtViewSelect_restoreViews_select", "node_views");
            CswCommaDelimitedString SelectCols = new CswCommaDelimitedString()
            {
                "nodeviewid",
                "viewname"
            };

            ViewName = ViewName.ToLower().Trim();
            if (ViewName.Length > 200)
            {
                ViewName = ViewName.Substring(0, 200);
            }

            string WhereClause = string.Empty;

            if (Visibility != CswEnumNbtViewVisibility.Unknown)
            {
                WhereClause = "where visibility='" + Visibility.ToString() + "'";
            }
            else if (Visibility == CswEnumNbtViewVisibility.Role)
            {
                if (Int32.MinValue != VisibilityId)
                {
                    WhereClause += " and roleid='" + VisibilityId.ToString() + "'";
                }
            }
            else if (Visibility == CswEnumNbtViewVisibility.User)
            {
                if (Int32.MinValue != VisibilityId)
                {
                    WhereClause += " and userid='" + VisibilityId.ToString() + "'";
                }
            }

            DataTable ViewTable = ViewSelect.getTable(SelectCols, string.Empty, Int32.MinValue, WhereClause, false);

            foreach (DataRow CurrentRow in ViewTable.Rows)
            {
                string CurrentViewName = CswConvert.ToString(CurrentRow["viewname"]).ToLower().Trim();
                if (ViewName == CurrentViewName || (allowPartialMatches && CurrentViewName.Contains(ViewName)))
                {
                    ReturnVal.Add(_CswNbtResources.ViewSelect.restoreView(new CswNbtViewId(CswConvert.ToInt32(CurrentRow["nodeviewid"]))));
                }
            }

            return(ReturnVal);
        }//restoreViews()
Exemplo n.º 4
0
        } // getViews()

        public CswNbtViewId getViewIdByName(string ViewName, CswEnumNbtViewVisibility Visibility, CswPrimaryKey VisibilityRoleId, CswPrimaryKey VisibilityUserId)
        {
            CswTableSelect ViewsTable  = _CswNbtResources.makeCswTableSelect("CswNbtViewSelect_viewExists_select", "node_views");
            string         WhereClause = "where viewname = '" + CswTools.SafeSqlParam(ViewName) + "'";

            if (Visibility == CswEnumNbtViewVisibility.Role)
            {
                WhereClause += " and visibility = 'Role' and roleid = " + VisibilityRoleId.PrimaryKey.ToString();
            }
            else if (Visibility == CswEnumNbtViewVisibility.User)
            {
                WhereClause += " and visibility = 'User' and userid = " + VisibilityUserId.PrimaryKey.ToString();
            }
            else
            {
                WhereClause += " and visibility = '" + Visibility.ToString() + "'";
            }
            return(new CswNbtViewId(Convert.ToInt32(ViewsTable.getTable(new CswCommaDelimitedString("nodeviewid"), WhereClause).Rows[0]["nodeviewid"])));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get a DataTable with a single view, by name and visibility
        /// </summary>
        public DataTable getView(string ViewName, CswEnumNbtViewVisibility Visibility, CswPrimaryKey VisibilityRoleId, CswPrimaryKey VisibilityUserId)
        {
            CswTableSelect ViewsTable  = _CswNbtResources.makeCswTableSelect("CswNbtViewSelect_viewExists_select", "node_views");
            string         WhereClause = "where viewname = '" + CswTools.SafeSqlParam(ViewName) + "'";

            if (Visibility == CswEnumNbtViewVisibility.Role)
            {
                WhereClause += " and visibility = 'Role' and roleid = " + VisibilityRoleId.PrimaryKey.ToString();
            }
            else if (Visibility == CswEnumNbtViewVisibility.User)
            {
                WhereClause += " and visibility = 'User' and userid = " + VisibilityUserId.PrimaryKey.ToString();
            }
            else
            {
                WhereClause += " and visibility = '" + Visibility.ToString() + "'";
            }
            return(ViewsTable.getTable(WhereClause));
        } // getViews()
Exemplo n.º 6
0
        /// <summary>
        /// Convenience function for hiding views (null safe)
        /// </summary>
        /// <param name="hidden">True if the view should be hidden</param>
        /// <param name="viewName">The name of the view to hide/unhide</param>
        /// /// <param name="visibility">the original visibility of the view when not hidden</param>
        public void ToggleView(bool hidden, string viewName, CswEnumNbtViewVisibility Visibility)
        {
            CswEnumNbtViewVisibility FindVisibility = hidden ? Visibility : CswEnumNbtViewVisibility.Hidden;
            CswEnumNbtViewVisibility SetVisibility  = hidden ? CswEnumNbtViewVisibility.Hidden : Visibility;

            DataTable viewDT = _CswNbtResources.ViewSelect.getView(viewName, FindVisibility, null, null);

            if (viewDT.Rows.Count == 1)
            {
                CswNbtView view = _CswNbtResources.ViewSelect.restoreView(viewDT.Rows[0]["viewxml"].ToString());
                if (null != view)
                {
                    // case 30162 - check for redundant existing views of all visibility types (other than itself)
                    List <CswNbtView> MatchingViews = _CswNbtResources.ViewSelect.restoreViews(viewName);
                    if (MatchingViews.Count <= 1)
                    {
                        view.SetVisibility(SetVisibility, null, null);
                        view.save();
                    }
                }
            }
        }