コード例 #1
0
            public JObject ToJson()
            {
                JObject NodeObj = new JObject();
                NodeObj["nodename"] = NodeName;
                if( null == NodeId )
                {
                    NodeObj["nodeid"] = "";
                }
                else
                {
                    NodeObj["nodeid"] = NodeId.ToString();
                }
                if( null == NodeKey )
                {
                    NodeObj["nodekey"] = "";
                }
                else
                {
                    NodeObj["nodekey"] = NodeKey.ToString();
                }
                NodeObj["nodelink"] = CswNbtNode.getNodeLink( NodeId, NodeName );
                NodeObj["c3productid"] = C3ProductId.ToString();
                NodeObj["acdcdbregno"] = ACDCdbregno.ToString();
                NodeObj["locked"] = Locked.ToString().ToLower();
                NodeObj["disabled"] = Disabled.ToString().ToLower();
                NodeObj["isFavorite"] = IsFavorite.ToString().ToLower();
                NodeObj["nodetypeid"] = NodeType.NodeTypeId;
                NodeObj["nodetypename"] = NodeType.NodeTypeName;
                NodeObj["thumbnailurl"] = ThumbnailUrl;
                NodeObj["thumbnailbase64str"] = ThumbnailBase64Str;
                NodeObj["allowview"] = AllowView;
                NodeObj["allowedit"] = AllowEdit;
                NodeObj["allowdelete"] = AllowDelete;

                NodeObj["allowimport"] = AllowImport;
                NodeObj["allowrequest"] = AllowRequest;

                // Props in the View
                JArray PropsArray = new JArray();
                NodeObj["props"] = PropsArray;
                foreach( TableProp thisProp in Props.Values )
                {
                    PropsArray.Add( thisProp.ToJson() );
                }
                return NodeObj;
            } // ToJson()
コード例 #2
0
        public static void wAddAuthenticationStatus(CswNbtResources CswNbtResources, CswSessionResourcesNbt CswSessionResources, CswWebSvcReturn SvcReturn, CswEnumAuthenticationStatus AuthenticationStatusIn, HttpContext HttpContext)
        {
            // ******************************************
            // IT IS VERY IMPORTANT for this function not to require the use of database resources,
            // since it occurs AFTER the call to _deInitResources(), and thus will leak Oracle connections
            // (see case 26273)
            // ******************************************
            if (null != SvcReturn)
            {
                SvcReturn.Authentication = SvcReturn.Authentication ?? new CswWebSvcSessionAuthenticateData.Authentication.Response();
                SvcReturn.Authentication.AuthenticationStatus = AuthenticationStatusIn;
                if (null != CswNbtResources)
                {
                    if (null != CswNbtResources.CswSessionManager)
                    {
                        SvcReturn.Authentication.TimeOut = CswDateTime.ToClientAsJavascriptString(CswNbtResources.CswSessionManager.TimeoutDate);
                    }
                    if (SvcReturn.Authentication.AuthenticationStatus == CswEnumAuthenticationStatus.ExpiredPassword)
                    {
                        SvcReturn.Authentication.ExpirationReset = new CswWebSvcSessionAuthenticateData.Authentication.Response.Expired();

                        ICswNbtUser CurrentUser = CswNbtResources.CurrentNbtUser;
                        SvcReturn.Authentication.ExpirationReset.UserId = CurrentUser.UserId.ToString();
                        CswNbtNodeKey FakeKey = new CswNbtNodeKey()
                        {
                            NodeId        = CurrentUser.UserId,
                            NodeSpecies   = CswEnumNbtNodeSpecies.Plain,
                            NodeTypeId    = CurrentUser.UserNodeTypeId,
                            ObjectClassId = CurrentUser.UserObjectClassId
                        };
                        SvcReturn.Authentication.ExpirationReset.UserKey = FakeKey.ToString();
                        CswPropIdAttr PasswordPropIdAttr = new CswPropIdAttr(CurrentUser.UserId, CurrentUser.PasswordPropertyId);
                        SvcReturn.Authentication.ExpirationReset.PasswordId = PasswordPropIdAttr.ToString();
                    }

                    SvcReturn.Performance               = SvcReturn.Performance ?? new CswWebSvcReturnBase.Performance();
                    SvcReturn.Performance.ServerInit    = Math.Round(CswNbtResources.ServerInitTime, 3);
                    SvcReturn.Performance.DbDeinit      = Math.Round(CswNbtResources.CswLogger.DbInitTime, 3);
                    SvcReturn.Performance.DbQuery       = Math.Round(CswNbtResources.CswLogger.DbQueryTime, 3);
                    SvcReturn.Performance.DbCommit      = Math.Round(CswNbtResources.CswLogger.DbCommitTime, 3);
                    SvcReturn.Performance.DbDeinit      = Math.Round(CswNbtResources.CswLogger.DbDeInitTime, 3);
                    SvcReturn.Performance.TreeLoaderSql = Math.Round(CswNbtResources.CswLogger.TreeLoaderSQLTime, 3);
                    SvcReturn.Performance.ServerTotal   = Math.Round(CswNbtResources.TotalServerTime, 3);

                    SvcReturn.Logging            = SvcReturn.Logging ?? new CswWebSvcReturnBase.Logging();
                    SvcReturn.Logging.CustomerId = CswNbtResources.AccessId;
                    SvcReturn.Logging.Server     = Environment.MachineName;
                    CswEnumLogLevels LogLevel = CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.Logging_Level);

                    if (LogLevel == CswNbtResources.UnknownEnum)
                    {
                        LogLevel = CswEnumLogLevels.Error;
                    }
                    SvcReturn.Logging.LogLevel = LogLevel;

                    // Return any messages acquired along the way
                    if (null != CswNbtResources.Messages && CswNbtResources.Messages.Count > 0)
                    {
                        SvcReturn.Status.Messages = CswNbtResources.Messages;
                    }
                }
            }
            HttpCookie AuthStatusCookie = HttpContext.Request.Cookies["CswAuthStatus"];

            if (null == AuthStatusCookie)
            {
                AuthStatusCookie = new HttpCookie("CswAuthStatus")
                {
                    HttpOnly = true
                };
            }
            if (AuthStatusCookie.Value != AuthenticationStatusIn.ToString())
            {
                AuthStatusCookie.Value = AuthenticationStatusIn;
                HttpContext.Response.Cookies.Add(AuthStatusCookie);
            }
        } // wAddAuthenticationStatus()
コード例 #3
0
        public static void jAddAuthenticationStatus(CswNbtResources CswNbtResources, CswSessionResourcesNbt CswSessionResources, JObject SvcReturn, CswEnumAuthenticationStatus AuthenticationStatusIn, bool IsMobile = false)
        {
            if (SvcReturn != null)
            {
                SvcReturn["AuthenticationStatus"]     = AuthenticationStatusIn.ToString();
                SvcReturn["AuthenticationStatusText"] = CswEnumAuthenticationStatus.EuphamizedText[AuthenticationStatusIn];
                if (false == IsMobile)
                {
                    SvcReturn["server"] = Environment.MachineName;
                    if (null != CswNbtResources)
                    {
                        if (null != CswNbtResources.CswSessionManager)
                        {
                            SvcReturn["timeout"] = CswDateTime.ToClientAsJavascriptString(CswNbtResources.CswSessionManager.TimeoutDate);
                        }
                        if (AuthenticationStatusIn == CswEnumAuthenticationStatus.ExpiredPassword)
                        {
                            ICswNbtUser CurrentUser = CswNbtResources.CurrentNbtUser;
                            SvcReturn.Add(new JProperty("nodeid", CurrentUser.UserId.ToString()));
                            CswNbtNodeKey FakeKey = new CswNbtNodeKey()
                            {
                                NodeId        = CurrentUser.UserId,
                                NodeSpecies   = CswEnumNbtNodeSpecies.Plain,
                                NodeTypeId    = CurrentUser.UserNodeTypeId,
                                ObjectClassId = CurrentUser.UserObjectClassId
                            };
                            SvcReturn.Add(new JProperty("nodekey", FakeKey.ToString()));
                            CswPropIdAttr PasswordPropIdAttr = new CswPropIdAttr(CurrentUser.UserId, CurrentUser.PasswordPropertyId);
                            SvcReturn.Add(new JProperty("passwordpropid", PasswordPropIdAttr.ToString()));
                        }

                        SvcReturn["timer"] = new JObject();

                        SvcReturn["timer"]["serverinit"] = Math.Round(CswNbtResources.ServerInitTime, 3);
                        CswEnumLogLevels LogLevel = CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.Logging_Level);
                        if (LogLevel == CswNbtResources.UnknownEnum)
                        {
                            LogLevel = CswEnumLogLevels.Error;
                        }
                        SvcReturn["LogLevel"] = LogLevel.ToString().ToLower();

                        SvcReturn["timer"]["customerid"]    = CswNbtResources.AccessId;
                        SvcReturn["timer"]["dbinit"]        = Math.Round(CswNbtResources.CswLogger.DbInitTime, 3);
                        SvcReturn["timer"]["dbquery"]       = Math.Round(CswNbtResources.CswLogger.DbQueryTime, 3);
                        SvcReturn["timer"]["dbcommit"]      = Math.Round(CswNbtResources.CswLogger.DbCommitTime, 3);
                        SvcReturn["timer"]["dbdeinit"]      = Math.Round(CswNbtResources.CswLogger.DbDeInitTime, 3);
                        SvcReturn["timer"]["treeloadersql"] = Math.Round(CswNbtResources.CswLogger.TreeLoaderSQLTime, 3);
                        SvcReturn["timer"]["servertotal"]   = Math.Round(CswNbtResources.TotalServerTime, 3);

                        // Return any messages acquired along the way
                        if (null != CswNbtResources.Messages && CswNbtResources.Messages.Count > 0)
                        {
                            JArray Messages = new JArray();
                            SvcReturn["messages"] = Messages;
                            foreach (CswWebSvcReturnBase.ErrorMessage Message in CswNbtResources.Messages)
                            {
                                Messages.Add(Message.ToJObject());
                            }
                        }
                    }//if( null != CswNbtResources )
                }
            }
        }
コード例 #4
0
ファイル: CswNbtSdTrees.cs プロジェクト: crfroehlich/legacy
        } // _runTreeNodesRecursive()

        /// <summary>
        /// Generate a JObject for the tree's current node
        /// </summary>
        private CswExtTree.TreeNode _getTreeNode(ICswNbtTree Tree, CswExtTree.TreeNode Parent, CswNbtSdTrees.Contract.Request Request)
        {
            CswExtTree.TreeNode Ret;
            if (null != Request && Request.UseCheckboxes)
            {
                Ret = new CswExtTree.TreeNodeWithCheckbox();
            }
            else
            {
                Ret = new CswExtTree.TreeNode();
            }

            CswNbtNodeKey ThisNodeKey       = Tree.getNodeKeyForCurrentPosition();
            string        ThisNodeName      = Tree.getNodeNameForCurrentPosition();
            string        ThisNodeIcon      = "";
            string        ThisNodeKeyString = ThisNodeKey.ToString();
            string        ThisNodeId        = "";
            int           ThisNodeTypeId    = int.MinValue;
            int           ThisObjectClassId = int.MinValue;

            bool ThisNodeLocked   = false;
            bool ThisNodeDisabled = false;
            bool ThisNodeFavorite = false;
            CswNbtMetaDataNodeType ThisNodeType = _CswNbtResources.MetaData.getNodeType(ThisNodeKey.NodeTypeId);

            switch (ThisNodeKey.NodeSpecies)
            {
            case CswEnumNbtNodeSpecies.Plain:
                ThisNodeId        = ThisNodeKey.NodeId.ToString();
                ThisNodeName      = Tree.getNodeNameForCurrentPosition();
                ThisNodeTypeId    = ThisNodeType.FirstVersionNodeTypeId;
                ThisObjectClassId = ThisNodeType.ObjectClassId;
                ThisNodeLocked    = Tree.getNodeLockedForCurrentPosition();
                ThisNodeDisabled  = (false == Tree.getNodeIncludedForCurrentPosition());
                ThisNodeFavorite  = Tree.getNodeFavoritedForCurrentPosition();
                if (ThisNodeFavorite)
                {
                    ThisNodeIcon = CswNbtMetaDataObjectClass.IconPrefix16 + "starsolid.png";
                }
                else
                {
                    ThisNodeIcon = CswNbtMetaDataObjectClass.IconPrefix16 + Tree.getNodeIconForCurrentPosition();
                }
                break;

            case CswEnumNbtNodeSpecies.Group:
                Ret.CssClass = "folder";
                break;
            }

            CswNbtViewNode ThisNodeViewNode = _View.FindViewNodeByUniqueId(ThisNodeKey.ViewNodeUniqueId);

            string ThisNodeState = "closed";

            if (ThisNodeKey.NodeSpecies == CswEnumNbtNodeSpecies.More ||
                _View.ViewMode == CswEnumNbtViewRenderingMode.List ||
                (Tree.IsFullyPopulated && Tree.getChildNodeCount() == 0) ||
                (ThisNodeViewNode != null && ThisNodeViewNode.GetChildrenOfType(CswEnumNbtViewNodeType.CswNbtViewRelationship).Count == 0))
            {
                ThisNodeState = "leaf";
            }

            Ret.Name = ThisNodeName;
            Ret.Icon = ThisNodeIcon;
            Ret.Id   = ThisNodeKeyString;
            switch (ThisNodeState)
            {
            case "closed":
                Ret.Expanded = false;
                break;

            case "leaf":
                Ret.IsLeaf = true;
                break;
            }

            if (null != Request)
            {
                Ret.Expanded = Request.ExpandAll;
            }

            if (int.MinValue != ThisNodeTypeId)
            {
                Ret.NodeTypeId = ThisNodeTypeId.ToString();
            }
            if (int.MinValue != ThisObjectClassId)
            {
                Ret.ObjectClassId = ThisObjectClassId.ToString();
            }

            Ret.NodeSpecies = ThisNodeKey.NodeSpecies.ToString();
            Ret.NodeId      = ThisNodeId;
            Ret.IsLocked    = ThisNodeLocked;
            if (ThisNodeDisabled)
            {
                Ret.IsDisabled = true;
                Ret.CssClass   = "disabled";
            }
            Ret.IsFavorite = ThisNodeFavorite;

            if (null != Parent && false == string.IsNullOrEmpty(Parent.Path))
            {
                Ret.Path = Parent.Path;
            }
            else
            {
                Ret.ParentId = "root";
                Ret.Path     = "|root";
            }
            if (false == Tree.isCurrentPositionRoot())
            {
                CswNbtNodeKey ParentKey = Tree.getNodeKeyForParentOfCurrentPosition();
                if (ParentKey.NodeSpecies != CswEnumNbtNodeSpecies.Root)
                {
                    Ret.ParentId = ParentKey.ToString();
                }
            }

            Ret.Path += "|" + Ret.Id;

            if (Tree.getChildNodeCount() > 0)
            {
                Ret.Children = new Collection <CswExtTree.TreeNode>();
            }
            else
            {
                Ret.Children = null;
            }

            Collection <CswNbtTreeNodeProp> ThisNodeProps = Tree.getChildNodePropsOfNode();

            CswNbtViewRoot.forEachProperty EachNodeProp = (ViewProp) =>
            {
                foreach (CswNbtTreeNodeProp NodeProp in ThisNodeProps)
                {
                    if (NodeProp.PropName.ToLower().Trim() == ViewProp.Name.ToLower().Trim())
                    {
                        Ret.data[new CswExtJsGridDataIndex(_View.ViewName, ViewProp.Name.ToLower().Trim())] = NodeProp.Gestalt;
                    }
                }
            };

            _View.Root.eachRelationship(relationshipCallBack: null, propertyCallBack: EachNodeProp);

            //ThisNodeObj["childcnt"] = Tree.getChildNodeCount().ToString();


            return(Ret);
        } // _treeNodeJObject()
コード例 #5
0
        } //getDemoDataGrid()

        public static void getDemoDataNodesAsGrid(ICswResources CswResources, CswNbtDemoDataReturn Return, CswNbtDemoDataRequests.CswDemoNodesGridRequest Request)
        {
            CswNbtResources CswNbtResources = (CswNbtResources)CswResources;

            //Build table infrastructure
            DataTable GridTable = new DataTable("depdendentnodestable");

            GridTable.Columns.Add(CswNbtDemoDataReturn.ColumnNames.NodeId, typeof(Int32));
            GridTable.Columns.Add(CswNbtDemoDataReturn.ColumnNames.Name, typeof(string));
            GridTable.Columns.Add(CswNbtDemoDataReturn.ColumnNames.Type, typeof(string));
            GridTable.Columns.Add(CswNbtDemoDataReturn.ColumnNames.IsDemo, typeof(string));
            //            GridTable.Columns.Add( CswNbtDemoDataReturn.ColumnNames.Action, typeof( sbyte ) );
            GridTable.Columns.Add(CswNbtDemoDataReturn.ColumnNames.MenuOptions, typeof(string));


            string DependentNodesQuery = "select n.nodeid, t.nodetypeid, n.nodename as \"name\" ,n.isdemo \"Is Demo\", t.nodetypename as \"type\" ";

            DependentNodesQuery += "from nodes n ";
            DependentNodesQuery += "join nodetypes t on (n.nodetypeid=t.nodetypeid) ";



            //We have to cope with oracle's limit of 1000 on lists
            //as per case 29811
            DependentNodesQuery += " where ";
            List <string> AllNodeIds        = Request.NodeIds;
            int           NumberoFInClauses = (AllNodeIds.Count / 1000) + 1; //we _only_ want the whole-number result here

            for (int idx = 0; idx < NumberoFInClauses; idx++)
            {
                if (idx > 0)
                {
                    DependentNodesQuery += " or ";
                }

                List <string> CurrentList = null;
                if (AllNodeIds.Count > 1000)
                {
                    CurrentList = AllNodeIds.GetRange(0, 1000);
                    AllNodeIds.RemoveRange(0, 1000);
                }
                else
                {
                    CurrentList = AllNodeIds;
                }

                CswDelimitedString DepdendentNodeIds = new CswDelimitedString(',');
                DepdendentNodeIds.FromArray(CurrentList.ToArray());
                DependentNodesQuery += " n.nodeid in (" + DepdendentNodeIds.ToString() + ") ";
            }



            DependentNodesQuery += "order by lower(n.nodename), lower(t.nodetypename)";

            CswArbitrarySelect DependentNodesSelect      = CswNbtResources.makeCswArbitrarySelect("select_depdendent_nodes", DependentNodesQuery);
            DataTable          DepdendentNodesTableTable = DependentNodesSelect.getTable();

            foreach (DataRow CurrentDependentNodeRow in DepdendentNodesTableTable.Rows)
            {
                DataRow NewGridRowOfDependentNodes = GridTable.NewRow();
                GridTable.Rows.Add(NewGridRowOfDependentNodes);

                NewGridRowOfDependentNodes[CswNbtDemoDataReturn.ColumnNames.NodeId] = CurrentDependentNodeRow[CswNbtDemoDataReturn.ColumnNames.NodeId];
                NewGridRowOfDependentNodes[CswNbtDemoDataReturn.ColumnNames.Name]   = CurrentDependentNodeRow[CswNbtDemoDataReturn.ColumnNames.Name];
                NewGridRowOfDependentNodes[CswNbtDemoDataReturn.ColumnNames.Type]   = CurrentDependentNodeRow[CswNbtDemoDataReturn.ColumnNames.Type];
                NewGridRowOfDependentNodes[CswNbtDemoDataReturn.ColumnNames.IsDemo] = ("1" == CurrentDependentNodeRow[CswNbtDemoDataReturn.ColumnNames.IsDemo].ToString()) ? "yes" : "no";

                CswPrimaryKey cswPrimaryKey = new CswPrimaryKey();
                cswPrimaryKey.FromString("nodes_" + CurrentDependentNodeRow[CswNbtDemoDataReturn.ColumnNames.NodeId].ToString());
                CswNbtNodeKey CswNbtNodeKey = new CswNbtNodeKey();
                CswNbtNodeKey.NodeId     = cswPrimaryKey;
                CswNbtNodeKey.NodeTypeId = CswConvert.ToInt32(CurrentDependentNodeRow["nodetypeid"]);


                string menu_options = "{ ";
                menu_options += "\"nodeid\" : \"nodes_" + CurrentDependentNodeRow[CswNbtDemoDataReturn.ColumnNames.NodeId].ToString() + "\",";
                menu_options += "\"nodename\" : \" " + CurrentDependentNodeRow[CswNbtDemoDataReturn.ColumnNames.Name].ToString() + "\",";
                menu_options += "\"nodekey\" : \" " + CswNbtNodeKey.ToString() + "\"";
                menu_options += " }";


                NewGridRowOfDependentNodes[CswNbtDemoDataReturn.ColumnNames.MenuOptions] = menu_options;
            }//iterate result rows

            CswNbtGrid Grid = new CswNbtGrid(CswNbtResources);

            Return.Data.Grid = Grid.DataTableToGrid(GridTable, IncludeEditFields: false);
        }//getDemoDataNodesAsGrid()
コード例 #6
0
        } // _runTreeNodesRecursive()

        /// <summary>
        /// Generate a JObject for the tree's current node
        /// </summary>
        private JObject _treeNodeJObject(ICswNbtTree Tree)
        {
            JObject ThisNodeObj = new JObject();

            CswNbtNodeKey ThisNodeKey       = Tree.getNodeKeyForCurrentPosition();
            string        ThisNodeName      = Tree.getNodeNameForCurrentPosition();
            string        ThisNodeIcon      = "";
            string        ThisNodeKeyString = ThisNodeKey.ToString();
            string        ThisNodeId        = "";

            string ThisNodeRel                  = "";
            bool   ThisNodeLocked               = false;
            bool   ThisNodeDisabled             = false;
            CswNbtMetaDataNodeType ThisNodeType = _CswNbtResources.MetaData.getNodeType(ThisNodeKey.NodeTypeId);

            switch (ThisNodeKey.NodeSpecies)
            {
            //case NodeSpecies.More:
            //    ThisNodeId = ThisNodeKey.NodeId.ToString();
            //    ThisNodeName = NodeSpecies.More.ToString() + "...";
            //    ThisNodeIcon = "Images/icons/triangle_blueS.gif";
            //    ThisNodeRel = "nt_" + ThisNodeType.FirstVersionNodeTypeId;
            //    break;
            case CswEnumNbtNodeSpecies.Plain:
                ThisNodeId       = ThisNodeKey.NodeId.ToString();
                ThisNodeName     = Tree.getNodeNameForCurrentPosition();
                ThisNodeRel      = "nt_" + ThisNodeType.FirstVersionNodeTypeId;
                ThisNodeLocked   = Tree.getNodeLockedForCurrentPosition();
                ThisNodeDisabled = (false == Tree.getNodeIncludedForCurrentPosition());
                if (false == string.IsNullOrEmpty(ThisNodeType.IconFileName))
                {
                    ThisNodeIcon = CswNbtMetaDataObjectClass.IconPrefix16 + ThisNodeType.IconFileName;
                }
                break;

            case CswEnumNbtNodeSpecies.Group:
                ThisNodeRel = "group";
                break;
            }

            CswNbtViewNode ThisNodeViewNode = _View.FindViewNodeByUniqueId(ThisNodeKey.ViewNodeUniqueId);

            string ThisNodeState = "closed";

            if (ThisNodeKey.NodeSpecies == CswEnumNbtNodeSpecies.More ||
                _View.ViewMode == CswEnumNbtViewRenderingMode.List ||
                (Tree.IsFullyPopulated && Tree.getChildNodeCount() == 0) ||
                (ThisNodeViewNode != null && ThisNodeViewNode.GetChildrenOfType(CswEnumNbtViewNodeType.CswNbtViewRelationship).Count == 0))
            {
                ThisNodeState = "leaf";
            }

            ThisNodeObj["data"]       = ThisNodeName;
            ThisNodeObj["icon"]       = ThisNodeIcon;
            ThisNodeObj["attr"]       = new JObject();
            ThisNodeObj["attr"]["id"] = _IdPrefix + ThisNodeKeyString;   // This is the only unique string for this node in this tree
            //ThisNodeObj["attr"]["id"] = _IdPrefix + ThisNodeId;
            ThisNodeObj["attr"]["rel"]     = ThisNodeRel;
            ThisNodeObj["attr"]["state"]   = ThisNodeState;
            ThisNodeObj["attr"]["species"] = ThisNodeKey.NodeSpecies.ToString();
            ThisNodeObj["attr"]["nodeid"]  = ThisNodeId;
            ThisNodeObj["attr"]["nodekey"] = ThisNodeKeyString;
            ThisNodeObj["attr"]["locked"]  = ThisNodeLocked.ToString().ToLower();
            if (ThisNodeDisabled)
            {
                ThisNodeObj["attr"]["disabled"] = ThisNodeDisabled.ToString().ToLower();
            }
            CswNbtNodeKey ParentKey = Tree.getNodeKeyForParentOfCurrentPosition();

            if (ParentKey.NodeSpecies != CswEnumNbtNodeSpecies.Root)
            {
                ThisNodeObj["attr"]["parentkey"] = ParentKey.ToString();
            }

            //if( "leaf" != ThisNodeState && Tree.getChildNodeCount() > 0 )
            //{
            ThisNodeObj["state"]    = ThisNodeState;
            ThisNodeObj["children"] = new JArray();
            ThisNodeObj["childcnt"] = Tree.getChildNodeCount().ToString();
            //}
            return(ThisNodeObj);
        } // _treeNodeJObject()
コード例 #7
0
        } // _treeNodeJObject()

        public JObject runTree(CswPrimaryKey IncludeNodeId, CswNbtNodeKey IncludeNodeKey, bool IncludeNodeRequired, bool IncludeInQuickLaunch, string DefaultSelect, string AccessedByObjClassId = "")
        {
            JObject ReturnObj = new JObject();

            if (null != _View)  //&& ( _View.ViewMode == NbtViewRenderingMode.Tree || _View.ViewMode == NbtViewRenderingMode.List ) )
            {
                ICswNbtTree Tree = _CswNbtResources.Trees.getTreeFromView(_View, true, false, false);
                _View.SaveToCache(IncludeInQuickLaunch);

                if (IncludeNodeId != null && IncludeNodeId.PrimaryKey != Int32.MinValue && IncludeNodeKey == null)
                {
                    IncludeNodeKey = Tree.getNodeKeyByNodeId(IncludeNodeId);
                    if (IncludeNodeRequired && IncludeNodeKey == null)
                    {
                        CswNbtMetaDataNodeType IncludeKeyNodeType = _CswNbtResources.Nodes[IncludeNodeId].getNodeType();
                        _View          = IncludeKeyNodeType.CreateDefaultView();
                        _View.ViewName = "New " + IncludeKeyNodeType.NodeTypeName;
                        _View.Root.ChildRelationships[0].NodeIdsToFilterIn.Add(IncludeNodeId);
                        _View.SaveToCache(IncludeInQuickLaunch);   // case 22713
                        ReturnObj["newviewid"]   = _View.SessionViewId.ToString();
                        ReturnObj["newviewmode"] = _View.ViewMode.ToString();
                        Tree = _CswNbtResources.Trees.getTreeFromView(_View, true, false, false);
                    }
                }
                if (IncludeNodeRequired && IncludeNodeKey != null && Tree.getNodeKeyByNodeId(IncludeNodeKey.NodeId) == null)
                {
                    CswNbtMetaDataNodeType IncludeKeyNodeType = _CswNbtResources.MetaData.getNodeType(IncludeNodeKey.NodeTypeId);
                    _View          = IncludeKeyNodeType.CreateDefaultView();
                    _View.ViewName = "New " + IncludeKeyNodeType.NodeTypeName;
                    _View.Root.ChildRelationships[0].NodeIdsToFilterIn.Add(IncludeNodeKey.NodeId);
                    _View.SaveToCache(IncludeInQuickLaunch);   // case 22713
                    ReturnObj["newviewid"]   = _View.SessionViewId.ToString();
                    ReturnObj["newviewmode"] = _View.ViewMode.ToString();
                    Tree = _CswNbtResources.Trees.getTreeFromView(_View, true, false, false);
                }

                Tree.goToRoot();
                bool HasResults = (Tree.getChildNodeCount() > 0);
                ReturnObj["result"] = HasResults.ToString().ToLower();
                ReturnObj["types"]  = getTypes();
                //ReturnObj["pagesize"] = _CswNbtResources.CurrentNbtUser.PageSize.ToString();

                if (HasResults)
                {
                    // Determine the default selected node:
                    // If the requested node to select is on the tree, return it.
                    // If the requested node to select is not on the tree, return the first child of the root.
                    if (IncludeNodeKey != null)
                    {
                        Tree.makeNodeCurrent(IncludeNodeKey);
                        if (Tree.isCurrentNodeDefined())
                        {
                            //ReturnObj["selectid"] = _IdPrefix + IncludeNodeKey.NodeId.ToString();
                            ReturnObj["selectid"] = _IdPrefix + IncludeNodeKey.ToString();
                        }
                    }
                    if (ReturnObj["selectid"] == null)
                    {
                        switch (DefaultSelect)
                        {
                        case "none":
                            break;

                        case "root":
                            ReturnObj["selectid"] = _IdPrefix + "root";
                            break;

                        case "firstchild":
                            Tree.goToRoot();
                            CswNbtNodeKey CurrentKey = Tree.getNodeKeyForCurrentPosition();
                            while (CurrentKey != null &&
                                   CurrentKey.NodeSpecies != CswEnumNbtNodeSpecies.Plain &&
                                   Tree.getChildNodeCount() > 0)
                            {
                                Tree.goToNthChild(0);
                                CurrentKey = Tree.getNodeKeyForCurrentPosition();
                            }
                            if (CurrentKey != null && CurrentKey.NodeSpecies == CswEnumNbtNodeSpecies.Plain)
                            {
                                // ReturnObj["selectid"] = _IdPrefix + Tree.getNodeIdForCurrentPosition().ToString();
                                ReturnObj["selectid"] = _IdPrefix + CurrentKey.ToString();
                            }
                            break;
                        } // switch( DefaultSelect )
                    }     // if( ReturnObj["selectid"] == null )
                }         // if( HasResults )
                else
                {
                    ReturnObj["selectid"] = _IdPrefix + "root";
                }

                Tree.goToRoot();
                ReturnObj["root"]                     = new JObject();
                ReturnObj["root"]["data"]             = _View.ViewName;
                ReturnObj["root"]["attr"]             = new JObject();
                ReturnObj["root"]["attr"]["id"]       = _IdPrefix + "root";
                ReturnObj["root"]["attr"]["rel"]      = "root";
                ReturnObj["root"]["attr"]["disabled"] = false == Tree.getNodeIncludedForCurrentPosition();
                //Tree.goToRoot();
                //ReturnObj["attr"]["nodekey"] = Tree.getNodeKeyForCurrentPosition().ToString();
                ReturnObj["root"]["state"]    = "open";
                ReturnObj["root"]["children"] = new JArray();

                if (HasResults)
                {
                    Tree.goToRoot();
                    _runTreeNodesRecursive(Tree, (JArray)ReturnObj["root"]["children"], true);
                }
                else
                {
                    JObject NoResultsObj = new JObject();
                    NoResultsObj["state"] = "leaf";
                    NoResultsObj["data"]  = "No Results";
                    ((JArray)ReturnObj["root"]["children"]).Add(NoResultsObj);
                }
            }
            return(ReturnObj);
        } // runTree()