コード例 #1
0
 public static void getQuota(ICswResources Resources, CswNbtQuotaResponse Response, QuotaRequest Request)
 {
     if (null != Resources)
     {
         CswNbtResources NbtResources  = (CswNbtResources)Resources;
         CswNbtActQuotas ActQuotas     = new CswNbtActQuotas(NbtResources);
         int             NodeTypeId    = Request.NodeTypeId;
         int             ObjectClassId = Request.ObjectClassId;
         if (NodeTypeId <= 0)
         {
             CswNbtNodeKey Key = wsNBT.getNodeKey(Request.NodeKey);
             if (null != Key)
             {
                 NodeTypeId    = Key.NodeTypeId;
                 ObjectClassId = Key.ObjectClassId;
             }
         }
         if (NodeTypeId <= 0)
         {
             CswNbtNode Node = NbtResources.Nodes[Request.NodeId];
             if (null != Node)
             {
                 NodeTypeId    = Node.NodeTypeId;
                 ObjectClassId = Node.getObjectClassId();
             }
         }
         Response.Data = ActQuotas.CheckQuota(NodeTypeId, ObjectClassId);
     }
 }
コード例 #2
0
        } // _getSearchNodes

        private void _runTreeNodesRecursive(ICswNbtTree Tree, JObject ParentJsonO)
        {
            for (Int32 c = 0; c < Tree.getChildNodeCount(); c++)
            {
                Tree.goToNthChild(c);

                CswNbtNode    ThisNode    = Tree.getNodeForCurrentPosition();
                CswNbtNodeKey ThisNodeKey = Tree.getNodeKeyForCurrentPosition();

                if (Tree.getNodeShowInTreeForCurrentPosition())
                {
                    bool      RunProps  = (_ForMobile && Tree.getChildNodeCount() == 0 && NodeSpecies.More != ThisNodeKey.NodeSpecies); // is a leaf
                    JProperty ThisJProp = _getNode(ThisNode, RunProps, ThisNodeKey.NodeSpecies);
                    ParentJsonO.Add(ThisJProp);
                    if (Tree.getChildNodeCount() > 0)
                    {
                        JObject ThisNodeObj = (JObject)ThisJProp.Value;
                        JObject NodesObj    = new JObject();
                        ThisNodeObj["nodes"] = NodesObj;
                        _runTreeNodesRecursive(Tree, NodesObj);
                    }
                } // if( Tree.getNodeShowInTreeForCurrentPosition() )
                else
                {
                    _runTreeNodesRecursive(Tree, ParentJsonO);
                }
                Tree.goToParentNode();
            }
        } // _runTreeNodesRecursive()
コード例 #3
0
        public JObject DeleteNodes(string[] NodePks, string[] NodeKeys)
        {
            JObject ret = new JObject();
            Collection <CswPrimaryKey> NodePrimaryKeys = new Collection <CswPrimaryKey>();

            if (NodeKeys.Length > 0)
            {
                foreach (string NodeKey in NodeKeys)
                {
                    CswNbtNodeKey NbtNodeKey = new CswNbtNodeKey(NodeKey);
                    if (null != NbtNodeKey &&
                        null != NbtNodeKey.NodeId &&
                        CswTools.IsPrimaryKey(NbtNodeKey.NodeId) &&
                        false == NodePrimaryKeys.Contains(NbtNodeKey.NodeId))
                    {
                        NodePrimaryKeys.Add(NbtNodeKey.NodeId);
                    }
                }
            }
            if (NodePks.Length > 0)
            {
                foreach (string NodePk in NodePks)
                {
                    CswPrimaryKey PrimaryKey = CswConvert.ToPrimaryKey(NodePk);
                    if (CswTools.IsPrimaryKey(PrimaryKey) &&
                        false == NodePrimaryKeys.Contains(PrimaryKey))
                    {
                        NodePrimaryKeys.Add(PrimaryKey);
                    }
                }
            }
            if (NodePrimaryKeys.Count > 0)
            {
                if (NodePrimaryKeys.Count < CswNbtBatchManager.getBatchThreshold(_CswNbtResources))
                {
                    bool   success      = true;
                    string DeletedNodes = "";
                    foreach (CswPrimaryKey Npk in NodePrimaryKeys)
                    {
                        string DeletedNode = "";
                        success = DeleteNode(Npk, out DeletedNode) && success;
                        if (success)
                        {
                            DeletedNodes += DeletedNode;
                        }
                    }
                    ret["Succeeded"] = success.ToString();
                }
                else
                {
                    CswNbtBatchOpMultiDelete op        = new CswNbtBatchOpMultiDelete(_CswNbtResources);
                    CswNbtObjClassBatchOp    BatchNode = op.makeBatchOp(NodePrimaryKeys);
                    ret["batch"] = BatchNode.NodeId.ToString();
                }
            }

            return(ret);
        }
コード例 #4
0
        public Collection <Location> getLocationListMobile()
        {
            Collection <Location> Locations = new Collection <Location>();

            CswNbtActSystemViews LocationSystemView = new CswNbtActSystemViews(_CswNbtResources, CswEnumNbtSystemViewName.SILocationsList, null);
            CswNbtView           LocationsListView  = LocationSystemView.SystemView;
            ICswNbtTree          Tree = _CswNbtResources.Trees.getTreeFromView(LocationsListView, true, false, false);
            Int32 LocationCount       = Tree.getChildNodeCount();

            if (LocationCount > 0)
            {
                CswNbtMetaDataObjectClass LocationsOc = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.LocationClass);

                for (Int32 N = 0; N < LocationCount; N += 1)
                {
                    Tree.goToNthChild(N);
                    CswNbtNodeKey NodeKey = Tree.getNodeKeyForCurrentPosition();

                    if (NodeKey.ObjectClassId == LocationsOc.ObjectClassId)
                    {
                        Location LocationNode = new Location();
                        Collection <CswNbtTreeNodeProp> Props = Tree.getChildNodePropsOfNode();

                        // LocationNode.Name = Tree.getNodeNameForCurrentPosition();
                        LocationNode.LocationId = Tree.getNodeIdForCurrentPosition().ToString();
                        foreach (CswNbtTreeNodeProp Prop in Props)
                        {
                            if (Prop.FieldType == CswEnumNbtFieldType.Location)
                            {
                                // CIS-52811: If Location != Site
                                if (Int32.MinValue != Prop.Field1_Fk)
                                {
                                    LocationNode.Name = Prop.Gestalt + CswNbtNodePropLocation.PathDelimiter;
                                }
                                LocationNode.Name += Tree.getNodeNameForCurrentPosition();
                            }
                        }
                        Locations.Add(LocationNode);
                    }
                    Tree.goToParentNode();
                }
                foreach (var Location in from Location _Location
                         in Locations
                         orderby _Location.Name
                         select _Location)
                {
                    Locations.Add(Location);
                }

                //IEnumerable < Location > OrderedLocations = Locations.OrderBy( location => location.Name );
                //Locations = OrderedLocations.ToList();
            }
            return(Locations);
        }//getLocationListMobile()
コード例 #5
0
        } // SearchOrder

        public Int32 getPropOrder(Int32 NodeTypePropId, CswNbtNodeKey NodeKey, CswNbtView View = null)
        {
            Int32 ret = 0;
            SortedSet <SearchOrder> dict = getPropOrderDict(NodeKey, View);

            if (null != dict)
            {
                foreach (SearchOrder ThisOrder in dict.Where(ThisOrder => ThisOrder.NodeTypePropId == NodeTypePropId))
                {
                    ret = ThisOrder.Order;
                }
            }
            return(ret);
        } // getPropOrder()
コード例 #6
0
        public JObject futureScheduling(CswCommaDelimitedString SelectedGeneratorNodeKeys, DateTime EndDate)
        {
            JObject ret = new JObject();

            CswNbtActGenerateFutureNodes CswNbtActGenerateFutureNodes = new CswNbtActGenerateFutureNodes(_CswNbtResources);

            Collection <CswNbtObjClassBatchOp> BatchNodes = new Collection <CswNbtObjClassBatchOp>();

            foreach (string NodeKeyStr in SelectedGeneratorNodeKeys)
            {
                CswNbtNodeKey CurrentNodeKey       = new CswNbtNodeKey(NodeKeyStr);
                CswNbtNode    CurrentGeneratorNode = _CswNbtResources.Nodes[CurrentNodeKey.NodeId];
                BatchNodes.Add(CswNbtActGenerateFutureNodes.makeNodesBatch(CurrentGeneratorNode, EndDate));
            }//iterate selected Generator notes

            if (BatchNodes.Count > 0)
            {
                ret["result"] = BatchNodes.Count.ToString();

                CswNbtView BatchOpsView = new CswNbtView(_CswNbtResources);
                BatchOpsView.ViewName = "New Batch Operations";
                BatchOpsView.ViewMode = CswEnumNbtViewRenderingMode.Tree;
                CswNbtViewRelationship BatchRel = BatchOpsView.AddViewRelationship(BatchNodes[0].NodeType, false);
                foreach (CswNbtObjClassBatchOp BatchNode in BatchNodes)
                {
                    if (BatchNode != null)
                    {
                        BatchRel.NodeIdsToFilterIn.Add(BatchNode.NodeId);
                    }
                }

                CswNbtWebServiceTree ws = new CswNbtWebServiceTree(_CswNbtResources, BatchOpsView);
                ret["treedata"] = ws.runTree(null, null, false, true, string.Empty);

                BatchOpsView.SaveToCache(true);
                ret["sessionviewid"] = BatchOpsView.SessionViewId.ToString();
                ret["viewmode"]      = BatchOpsView.ViewMode.ToString();
            }

            return(ret);
        } // futureScheduling()
コード例 #7
0
        private void _recurseTree(ICswNbtTree results, CswNbtAPITree.CswNbtTreeResource Parent)
        {
            for (int i = 0; i < results.getChildNodeCount(); i++)
            {
                results.goToNthChild(i);
                CswNbtNodeKey             NodeKey     = results.getNodeKeyForCurrentPosition();
                string                    Name        = results.getNodeNameForCurrentPosition();
                CswNbtMetaDataNodeType    nt          = _CswNbtResources.MetaData.getNodeType(NodeKey.NodeTypeId);
                CswNbtMetaDataObjectClass oc          = nt.getObjectClass();
                CswNbtMetaDataPropertySet propSet     = oc.getPropertySet();
                string                    PropSetName = string.Empty;
                if (null != propSet)
                {
                    PropSetName = propSet.Name;
                }

                CswNbtAPITree.CswNbtTreeResource SubParent = Parent.Add(Name, NodeKey.NodeId, nt.NodeTypeName, oc.ObjectClassName, PropSetName, string.Empty);
                _recurseTree(results, SubParent);
                results.goToParentNode();
            }
        }
コード例 #8
0
        public void RunTree(CswNbtAPITree Return, int ViewIdInt)
        {
            try
            {
                CswNbtViewId ViewId = new CswNbtViewId(ViewIdInt);
                CswNbtView   View   = _CswNbtResources.ViewSelect.restoreView(ViewId);
                if (null != View)
                {
                    ICswNbtTree results = _CswNbtResources.Trees.getTreeFromView(View, true, false, false);
                    for (int i = 0; i < results.getChildNodeCount(); i++)
                    {
                        results.goToNthChild(i);
                        CswNbtNodeKey             NodeKey     = results.getNodeKeyForCurrentPosition();
                        string                    Name        = results.getNodeNameForCurrentPosition();
                        CswNbtMetaDataNodeType    nt          = _CswNbtResources.MetaData.getNodeType(NodeKey.NodeTypeId);
                        CswNbtMetaDataObjectClass oc          = nt.getObjectClass();
                        CswNbtMetaDataPropertySet propSet     = oc.getPropertySet();
                        string                    PropSetName = string.Empty;
                        if (null != propSet)
                        {
                            PropSetName = propSet.Name;
                        }

                        CswNbtAPITree.CswNbtTreeResource Parent = Return.Add(Name, NodeKey.NodeId, nt.NodeTypeName, oc.ObjectClassName, PropSetName, BuildURI(nt.NodeTypeName, NodeKey.NodeId.PrimaryKey));
                        _recurseTree(results, Parent);
                        results.goToParentNode();
                    }

                    Return.Status = HttpStatusCode.OK;
                }
                else
                {
                    Return.Status = HttpStatusCode.NotFound;
                }
            }
            catch (Exception)
            {
                Return.Status = HttpStatusCode.InternalServerError;
            }
        }
コード例 #9
0
 public void GetCollection(CswNbtResourceCollection Return, CswNbtAPIGenericRequest GenericRequest)
 {
     if (hasPermission(GenericRequest, Return))
     {
         try
         {
             CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(GenericRequest.MetaDataName);
             if (null != NodeType)
             {
                 CswNbtView GetNodeTypeView = new CswNbtView(_CswNbtResources);
                 GetNodeTypeView.AddViewRelationship(NodeType, false);
                 ICswNbtTree tree = _CswNbtResources.Trees.getTreeFromView(GetNodeTypeView, true, false, false);
                 for (int i = 0; i < tree.getChildNodeCount(); i++)
                 {
                     tree.goToNthChild(i);
                     CswNbtNodeKey             nodeKey     = tree.getNodeKeyForCurrentPosition();
                     CswPrimaryKey             nodeId      = tree.getNodeIdForCurrentPosition();
                     CswNbtMetaDataObjectClass objectClass = _CswNbtResources.MetaData.getObjectClass(nodeKey.ObjectClassId);
                     CswNbtMetaDataPropertySet propSet     = objectClass.getPropertySet();
                     string propSetStr = string.Empty;
                     if (null != propSet)
                     {
                         propSetStr = propSet.Name;
                     }
                     string nodeName = tree.getNodeNameForCurrentPosition();
                     Return.Add(nodeName, nodeId, NodeType.NodeTypeName, objectClass.ObjectClassName, propSetStr, BuildURI(NodeType.NodeTypeName, nodeKey.NodeId.PrimaryKey));
                     tree.goToParentNode();
                 }
             }
             else
             {
                 Return.Status = HttpStatusCode.NotFound;
             }
         }
         catch (Exception)
         {
             Return.Status = HttpStatusCode.InternalServerError;
         }
     }
 }
コード例 #10
0
        public static void GetRelating(ICswResources CswResources, CswNbtExplorerRelatingReturn RelatingNodes, CswNbtExplorerRequest Req)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            CswNbtView view = new CswNbtView(NbtResources);

            if (Req.RelatingId.StartsWith("OC_"))
            {
                int ObjClassId = CswConvert.ToInt32(Req.RelatingId.Substring(Req.RelatingId.LastIndexOf('_') + 1));
                CswNbtMetaDataObjectClass     ObjClass        = NbtResources.MetaData.getObjectClass(ObjClassId);
                CswNbtMetaDataObjectClassProp objectClassProp = ObjClass.getObjectClassProp(Req.RelatingPropId);

                CswNbtViewRelationship parent = view.AddViewRelationship(ObjClass, true);
                CswPrimaryKey          pk     = CswConvert.ToPrimaryKey(Req.NodeId);
                view.AddViewPropertyAndFilter(parent, objectClassProp, Value: pk.PrimaryKey.ToString(), SubFieldName: CswEnumNbtSubFieldName.NodeID);
            }
            else
            {
                int NtId = CswConvert.ToInt32(Req.RelatingId.Substring(Req.RelatingId.LastIndexOf('_') + 1));
                CswNbtMetaDataNodeType     NodeType = NbtResources.MetaData.getNodeType(NtId);
                CswNbtMetaDataNodeTypeProp ntp      = NodeType.getNodeTypeProp(Req.RelatingPropId);

                CswNbtViewRelationship parent = view.AddViewRelationship(NodeType, true);
                CswPrimaryKey          pk     = CswConvert.ToPrimaryKey(Req.NodeId);
                view.AddViewPropertyAndFilter(parent, ntp, Value: pk.PrimaryKey.ToString(), SubFieldName: CswEnumNbtSubFieldName.NodeID);
            }

            ICswNbtTree tree = NbtResources.Trees.getTreeFromView(view, false, false, false);

            for (int i = 0; i < tree.getChildNodeCount(); i++)
            {
                tree.goToNthChild(i);
                CswNbtNodeKey          nodeKey  = tree.getNodeKeyForCurrentPosition();
                string                 nodeName = tree.getNodeNameForCurrentPosition();
                CswNbtMetaDataNodeType nodetype = NbtResources.MetaData.getNodeType(nodeKey.NodeTypeId);
                RelatingNodes.Data.Add(nodeName, nodeKey.NodeId, nodetype.NodeTypeName, string.Empty, string.Empty, string.Empty);
                tree.goToParentNode();
            }
        }
コード例 #11
0
        public void Search(CswNbtResourceCollection Return, CswNbtApiSearchRequest SearchRequest)
        {
            try
            {
                int filter_nt_id = Int32.MinValue;
                if (false == String.IsNullOrEmpty(SearchRequest.NodeType))
                {
                    filter_nt_id = _CswNbtResources.MetaData.getNodeType(SearchRequest.NodeType).NodeTypeId;
                }

                CswNbtWebServiceSearch searchService = new CswNbtWebServiceSearch(_CswNbtResources, null);
                CswNbtSearch           search        = searchService.getSearch(SearchRequest.Query, SearchRequest.SearchType, filter_nt_id, Int32.MinValue, Int32.MinValue);
                ICswNbtTree            results       = search.Results();
                for (int i = 0; i < results.getChildNodeCount(); i++)
                {
                    results.goToNthChild(i);
                    CswNbtNodeKey             NodeKey     = results.getNodeKeyForCurrentPosition();
                    string                    Name        = results.getNodeNameForCurrentPosition();
                    CswNbtMetaDataNodeType    nt          = _CswNbtResources.MetaData.getNodeType(NodeKey.NodeTypeId);
                    CswNbtMetaDataObjectClass oc          = nt.getObjectClass();
                    CswNbtMetaDataPropertySet propSet     = oc.getPropertySet();
                    string                    PropSetName = string.Empty;
                    if (null != propSet)
                    {
                        PropSetName = propSet.Name;
                    }

                    Return.Add(Name, NodeKey.NodeId, nt.NodeTypeName, oc.ObjectClassName, PropSetName, BuildURI(nt.NodeTypeName, NodeKey.NodeId.PrimaryKey));
                    results.goToParentNode();
                }

                Return.Status = HttpStatusCode.OK;
            }
            catch (Exception)
            {
                Return.Status = HttpStatusCode.InternalServerError;
            }
        }
コード例 #12
0
ファイル: CswNbtSdTrees.cs プロジェクト: crfroehlich/legacy
        } // _treeNodeJObject()

        public void runTree(Contract.Response.ResponseData ResponseData, Contract.Request Request, Int32 PerLevelNodeLimit = Int32.MinValue, Int32 TotalNodeLimit = Int32.MinValue)
        {
            ResponseData.Tree = ResponseData.Tree ?? new Collection <CswExtTree.TreeNode>();
            ICswNbtTree Tree     = null;
            string      RootName = string.Empty;

            if (null != _View)
            {
                Tree = _CswNbtResources.Trees.getTreeFromView(_View, Request.RequireViewPermissions, false, false, PerLevelNodeLimit: PerLevelNodeLimit);
                _View.SaveToCache(Request.IncludeInQuickLaunch);
                RootName = _View.ViewName;
            }

            CswPrimaryKey IncludeNodeId     = null;
            CswNbtNodeKey SelectKey         = null;
            Int32         IncludeNodeTypeId = Int32.MinValue;

            if (null != Request.IncludeNodeKey)
            {
                IncludeNodeId     = Request.IncludeNodeKey.NodeId;
                IncludeNodeTypeId = Request.IncludeNodeKey.NodeTypeId;
                if (null != Tree)
                {
                    Tree.makeNodeCurrent(Request.IncludeNodeKey);
                    if (Tree.isCurrentNodeDefined())
                    {
                        SelectKey = Request.IncludeNodeKey;
                    }
                }
            }
            else if (CswTools.IsPrimaryKey(Request.IncludeNodeId))
            {
                IncludeNodeId = Request.IncludeNodeId;
                CswNbtNode IncludeNode = _CswNbtResources.Nodes[IncludeNodeId];
                if (null != IncludeNode)
                {
                    IncludeNodeTypeId = IncludeNode.NodeTypeId;
                }
                if (null != Tree)
                {
                    SelectKey = Tree.getNodeKeyByNodeId(IncludeNodeId);
                }
            }

            if ((CswTools.IsPrimaryKey(IncludeNodeId) && IncludeNodeTypeId != Int32.MinValue) &&
                (Tree == null ||
                 (Request.IncludeNodeRequired && SelectKey == null)))
            {
                CswNbtMetaDataNodeType IncludeNodeType = _CswNbtResources.MetaData.getNodeType(IncludeNodeTypeId);
                if (null != IncludeNodeType)
                {
                    _View          = IncludeNodeType.CreateDefaultView(false);
                    _View.ViewName = IncludeNodeType.NodeTypeName;
                    _View.Root.ChildRelationships[0].NodeIdsToFilterIn.Add(IncludeNodeId);
                    _View.SaveToCache(Request.IncludeInQuickLaunch);   // case 22713
                    RootName = _View.ViewName;

                    Tree = _CswNbtResources.Trees.getTreeFromView(_View, false, false, false);
                }
            }

            bool HasResults = false;

            if (null != Tree)
            {
                Tree.goToRoot();
                HasResults = (Tree.getChildNodeCount() > 0);
                //ReturnObj["result"] = HasResults.ToString().ToLower();
                //ReturnObj["types"] = getTypes();
                ResponseData.PageSize = _CswNbtResources.CurrentNbtUser.PageSize;

                ResponseData.SelectedNodeKey = null;
                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 (SelectKey != null)
                    {
                        Tree.makeNodeCurrent(SelectKey);
                        if (Tree.isCurrentNodeDefined())
                        {
                            ResponseData.SelectedNodeKey = SelectKey;
                        }
                    }
                    if (ResponseData.SelectedNodeKey == null)
                    {
                        switch (Request.DefaultSelect)
                        {
                        case "none":
                            break;

                        case "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)
                            {
                                ResponseData.SelectedNodeKey = CurrentKey;
                            }
                            break;
                        } // switch( DefaultSelect )
                    }     // if( ReturnObj["selectid"] == null )
                }         // if( HasResults )
                else
                {
                    Request.DefaultSelect = "root";
                }

                Tree.goToRoot();
            }
            //Build the Response:

            ResponseData.Name = RootName;

            //#1: the Root node
            CswExtTree.TreeNode RootNode = new CswExtTree.TreeNode();
            ResponseData.Tree.Add(RootNode);

            RootNode.Name     = RootName;
            RootNode.IsRoot   = true;
            RootNode.Expanded = true;
            RootNode.Path     = "|root";
            RootNode.Id       = "root";
            RootNode.Icon     = "Images/view/viewtree.gif";

            //#2: the columns for the Tree Grid
            ResponseData.Columns.Add(new CswExtJsGridColumn
            {
                dataIndex    = new CswExtJsGridDataIndex(_View.ViewName, "text"),
                xtype        = CswEnumExtJsXType.treecolumn,
                MenuDisabled = true,
                width        = 269,
                header       = "Tree",
                resizable    = false,
            });
            ResponseData.Columns.Add(new CswExtJsGridColumn
            {
                dataIndex    = new CswExtJsGridDataIndex(_View.ViewName, "nodetypeid"),
                header       = "NodeTypeId",
                hidden       = true,
                resizable    = false,
                width        = 0,
                xtype        = CswEnumExtJsXType.gridcolumn,
                MenuDisabled = false
            });
            ResponseData.Columns.Add(new CswExtJsGridColumn
            {
                dataIndex    = new CswExtJsGridDataIndex(_View.ViewName, "objectclassid"),
                header       = "ObjectClassId",
                hidden       = true,
                resizable    = false,
                width        = 0,
                xtype        = CswEnumExtJsXType.gridcolumn,
                MenuDisabled = false
            });
            ResponseData.Columns.Add(new CswExtJsGridColumn
            {
                dataIndex    = new CswExtJsGridDataIndex(_View.ViewName, "nodeid"),
                header       = "NodeId",
                hidden       = true,
                resizable    = false,
                width        = 0,
                xtype        = CswEnumExtJsXType.gridcolumn,
                MenuDisabled = false
            });
            ResponseData.Columns.Add(new CswExtJsGridColumn
            {
                dataIndex    = new CswExtJsGridDataIndex(_View.ViewName, "disabled"),
                header       = "Disabled",
                hidden       = true,
                resizable    = false,
                width        = 0,
                xtype        = CswEnumExtJsXType.booleancolumn,
                MenuDisabled = false
            });


            //#3: The fields to map the columns to the data store
            ResponseData.Fields.Add(new CswExtJsGridField {
                name = "text", type = "string"
            });
            ResponseData.Fields.Add(new CswExtJsGridField {
                name = "nodetypeid", type = "string"
            });
            ResponseData.Fields.Add(new CswExtJsGridField {
                name = "objectclassid", type = "string"
            });
            ResponseData.Fields.Add(new CswExtJsGridField {
                name = "nodeid", type = "string"
            });
            ResponseData.Fields.Add(new CswExtJsGridField {
                name = "disabled", type = "bool"
            });

            //#4: View Properties are columns now too
            Collection <string> UniqueColumnNames = new Collection <string>()
            {
                "text", "nodetypeid", "objectclassid", "nodeid", "disabled"
            };

            CswNbtViewRoot.forEachProperty AddProp = (ViewProperty) =>
            {
                string PropName = ViewProperty.Name.ToLower().Trim();
                bool   HideProp = (null != Request.PropsToShow && false == Request.PropsToShow.Contains(PropName));
                if (false == UniqueColumnNames.Contains(PropName))
                {
                    UniqueColumnNames.Add(PropName);

                    CswExtJsGridColumn Col = new CswExtJsGridColumn
                    {
                        dataIndex    = new CswExtJsGridDataIndex(_View.ViewName, PropName),
                        header       = ViewProperty.Name,
                        hidden       = HideProp,
                        resizable    = false,
                        width        = ViewProperty.Width * 7,
                        xtype        = CswEnumExtJsXType.gridcolumn,
                        MenuDisabled = false
                    };
                    CswExtJsGridField Fld = new CswExtJsGridField {
                        name = PropName, type = "string"
                    };
                    Fld.dataIndex = Col.dataIndex;

                    ResponseData.Columns.Add(Col);
                    ResponseData.Fields.Add(Fld);
                }
            };
            _View.Root.eachRelationship(relationshipCallBack: null, propertyCallBack: AddProp);


            //#5: the tree
            RootNode.Children = new Collection <CswExtTree.TreeNode>();
            if (HasResults)
            {
                Tree.goToRoot();
                int count = 0;
                _runTreeNodesRecursive(Tree, RootNode.Children, RootNode, Request, TotalNodeLimit, ref count);

                if (Int32.MinValue != TotalNodeLimit && count >= TotalNodeLimit && RootNode.Children[0].Name != "Results Truncated")
                {
                    CswExtTree.TreeNode TruncatedTreeNode = _getTreeNode(Tree, RootNode, null);
                    TruncatedTreeNode.Name   = "Results Truncated";
                    TruncatedTreeNode.IsLeaf = true;
                    TruncatedTreeNode.Icon   = "Images/icons/truncated.gif";
                    TruncatedTreeNode.Id     = TruncatedTreeNode.Id + "_truncated";
                    TruncatedTreeNode.NodeId = "";
                    RootNode.Children.Insert(0, TruncatedTreeNode);
                }
            }
            else
            {
                CswExtTree.TreeNode EmptyNode = new CswExtTree.TreeNode();
                EmptyNode.Name     = "No Results";
                EmptyNode.IsLeaf   = true;
                EmptyNode.Selected = true;
                EmptyNode.Id       = "empty";
                EmptyNode.ParentId = RootNode.Id;
                EmptyNode.Path     = RootNode.Path + "|empty";
                RootNode.Children.Add(EmptyNode);
            }
            //}
        } // runTree()
コード例 #13
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()
コード例 #14
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()
コード例 #15
0
        public JObject getMenu(CswNbtView View, string SafeNodeKey, Int32 NodeTypeId, string PropIdAttr, bool ReadOnly, string NodeId)
        {
            CswTimer MainMenuTimer = new CswTimer();

            JObject Ret = new JObject();

            CswPrimaryKey RelatedNodeId   = new CswPrimaryKey();
            string        RelatedNodeName = string.Empty;
            CswNbtNode    Node            = null;

            if (false == String.IsNullOrEmpty(SafeNodeKey))
            {
                CswNbtNodeKey NbtNodeKey = new CswNbtNodeKey(SafeNodeKey);
                Node = _CswNbtResources.Nodes[NbtNodeKey];
            }
            else if (false == String.IsNullOrEmpty(NodeId))
            {
                CswPrimaryKey NodePk = CswConvert.ToPrimaryKey(NodeId);
                Node = _CswNbtResources.Nodes[NodePk];
            }
            if (null != Node)
            {
                RelatedNodeId   = Node.NodeId;
                RelatedNodeName = Node.NodeName;
            }

            // MORE
            if (_MenuItems.Contains("More"))
            {
                JObject MoreObj = new JObject();

                if (null == View && Int32.MinValue != NodeTypeId)
                {
                    // ADD for Searches
                    if (_MenuItems.Contains("Add") && false == ReadOnly)
                    {
                        JObject AddObj = new JObject();

                        CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(NodeTypeId);
                        if (null != NodeType && _CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Create, NodeType) && NodeType.getObjectClass().CanAdd)
                        {
                            AddObj[NodeType.NodeTypeName] = makeAddMenuItem(NodeType, RelatedNodeId, RelatedNodeName);
                            AddObj["haschildren"]         = true;
                            Ret["Add"] = AddObj;
                        }
                    } // if( _MenuItems.Contains( "Add" ) && false == ReadOnly )
                }     // if( null == View && Int32.MinValue != NodeTypeId )
                if (null != View)
                {
                    // ADD for Views
                    if (_MenuItems.Contains("Add") && false == ReadOnly)
                    {
                        JObject AddObj = new JObject();

                        // case 21672
                        CswNbtViewNode ParentNode = View.Root;
                        bool           LimitToFirstLevelRelationships = (View.ViewMode == CswEnumNbtViewRenderingMode.Grid);
                        if (LimitToFirstLevelRelationships && View.Visibility == CswEnumNbtViewVisibility.Property)
                        {
                            if (null == Node)
                            {
                                ICswNbtTree Tree = _CswNbtResources.Trees.getTreeFromView(View, false, false, false);
                                if (Tree.getChildNodeCount() > 0)
                                {
                                    Tree.goToNthChild(0);
                                    CswNbtNodeKey NodeKey = Tree.getNodeKeyForCurrentPosition();
                                    Node = _CswNbtResources.Nodes[NodeKey];
                                    if (null != Node)
                                    {
                                        RelatedNodeId   = Node.NodeId;
                                        RelatedNodeName = Node.NodeName;
                                    }
                                }
                            }
                            if (View.Root.ChildRelationships.Count > 0)
                            {
                                ParentNode = View.Root.ChildRelationships[0];
                            }
                        }
                        foreach (JProperty AddNodeType in ParentNode.AllowedChildNodeTypes(LimitToFirstLevelRelationships)
                                 .Select(Entry => new JProperty(Entry.NodeType.NodeTypeName,
                                                                makeAddMenuItem(Entry.NodeType, RelatedNodeId, RelatedNodeName))))
                        {
                            AddObj.Add(AddNodeType);
                        }

                        if (AddObj.HasValues)
                        {
                            AddObj["haschildren"] = true;
                            Ret["Add"]            = AddObj;
                        }
                    }

                    // COPY
                    if (
                        _MenuItems.Contains("Copy") &&
                        false == ReadOnly &&
                        null != Node && Node.NodeSpecies == CswEnumNbtNodeSpecies.Plain &&
                        View.ViewMode != CswEnumNbtViewRenderingMode.Grid &&
                        _CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Create, Node.getNodeType()) &&
                        Node.getObjectClass().CanAdd //If you can't Add the node, you can't Copy it either
                        )
                    {
                        MoreObj["Copy"]               = new JObject();
                        MoreObj["Copy"]["copytype"]   = _getActionType(Node.getNodeType());
                        MoreObj["Copy"]["action"]     = CswEnumNbtMainMenuActions.CopyNode.ToString();
                        MoreObj["Copy"]["nodeid"]     = Node.NodeId.ToString();
                        MoreObj["Copy"]["nodename"]   = Node.NodeName;
                        MoreObj["Copy"]["nodetypeid"] = Node.NodeTypeId.ToString();
                    }

                    // DELETE
                    if (_MenuItems.Contains("Delete") &&
                        false == ReadOnly &&
                        false == string.IsNullOrEmpty(SafeNodeKey) &&
                        null != Node &&
                        View.ViewMode != CswEnumNbtViewRenderingMode.Grid &&
                        Node.NodeSpecies == CswEnumNbtNodeSpecies.Plain &&
                        _CswNbtResources.Permit.isNodeWritable(CswEnumNbtNodeTypePermission.Delete, Node.getNodeType(), Node.NodeId))
                    {
                        MoreObj["Delete"]             = new JObject();
                        MoreObj["Delete"]["action"]   = CswEnumNbtMainMenuActions.DeleteNode.ToString();
                        MoreObj["Delete"]["nodeid"]   = Node.NodeId.ToString();
                        MoreObj["Delete"]["nodename"] = Node.NodeName;
                    }

                    // SAVE VIEW AS
                    if (_MenuItems.Contains("Save View As") &&
                        false == View.ViewId.isSet() &&
                        _CswNbtResources.Permit.can(_CswNbtResources.Actions[CswEnumNbtActionName.Edit_View]))
                    {
                        View.SaveToCache(false);
                        MoreObj["Save View As"]             = new JObject();
                        MoreObj["Save View As"]["action"]   = CswEnumNbtMainMenuActions.SaveViewAs.ToString();
                        MoreObj["Save View As"]["viewid"]   = View.SessionViewId.ToString();
                        MoreObj["Save View As"]["viewmode"] = View.ViewMode.ToString();
                    }

                    JObject PrintObj = null;

                    // PRINT LABEL

                    bool ValidForTreePrint = (false == string.IsNullOrEmpty(SafeNodeKey) &&
                                              View.ViewMode != CswEnumNbtViewRenderingMode.Grid &&
                                              null != Node &&
                                              null != Node.getNodeType() &&
                                              Node.getNodeType().HasLabel);

                    bool  ValidForGridPrint    = false;
                    bool  TryValidForGridPrint = (View.ViewMode == CswEnumNbtViewRenderingMode.Grid);
                    Int32 MultiPrintNodeTypeId = Int32.MinValue;
                    if (TryValidForGridPrint)
                    {
                        CswNbtViewRelationship TryRel = null;
                        if (View.Visibility != CswEnumNbtViewVisibility.Property && View.Root.ChildRelationships.Count == 1)
                        {
                            TryRel = View.Root.ChildRelationships[0];
                        }
                        else if (View.Visibility == CswEnumNbtViewVisibility.Property &&
                                 View.Root.ChildRelationships.Count == 1 &&
                                 View.Root.ChildRelationships[0].ChildRelationships.Count == 1)
                        {
                            TryRel = View.Root.ChildRelationships[0].ChildRelationships[0];
                        }

                        if (null != TryRel)
                        {
                            ICswNbtMetaDataDefinitionObject MdDef = TryRel.SecondMetaDataDefinitionObject();
                            if (null != MdDef)
                            {
                                if (MdDef.HasLabel)
                                {
                                    //This assumes that only NodeTypes will implement this property
                                    MultiPrintNodeTypeId = MdDef.UniqueId;
                                    ValidForGridPrint    = true;
                                }
                            }
                        }
                    }

                    if (_MenuItems.Contains("Print") &&
                        (ValidForTreePrint || ValidForGridPrint))
                    {
                        PrintObj = PrintObj ?? new JObject(new JProperty("haschildren", true));
                        PrintObj["Print Label"]           = new JObject();
                        PrintObj["Print Label"]["action"] = CswEnumNbtMainMenuActions.PrintLabel.ToString();

                        if (ValidForTreePrint)
                        {
                            PrintObj["Print Label"]["nodeid"]     = Node.NodeId.ToString();
                            PrintObj["Print Label"]["nodetypeid"] = Node.NodeTypeId;
                            PrintObj["Print Label"]["nodename"]   = Node.NodeName;
                        }
                        else if (ValidForGridPrint)
                        {
                            PrintObj["Print Label"]["nodetypeid"] = MultiPrintNodeTypeId;
                        }
                    }
                    // PRINT
                    if (_MenuItems.Contains("Print") &&
                        View.ViewMode == CswEnumNbtViewRenderingMode.Grid)
                    {
                        View.SaveToCache(false);
                        PrintObj = PrintObj ?? new JObject(new JProperty("haschildren", true));
                        PrintObj["Print View"]           = new JObject();
                        PrintObj["Print View"]["action"] = CswEnumNbtMainMenuActions.PrintView.ToString();
                    }

                    if (null != PrintObj)
                    {
                        MoreObj["Print"] = PrintObj;
                    }

                    // EXPORT
                    if (_MenuItems.Contains("Export"))
                    {
                        if (CswEnumNbtViewRenderingMode.Grid == View.ViewMode)
                        {
                            JObject ExportObj = new JObject();
                            MoreObj["Export"] = ExportObj;

                            View.SaveToCache(false);
                            ExportObj["CSV"] = new JObject();
                            string ExportLink = "wsNBT.asmx/gridExportCSV?ViewId=" + View.SessionViewId + "&SafeNodeKey='";
                            if (CswEnumNbtViewVisibility.Property == View.Visibility)
                            {
                                ExportLink += SafeNodeKey;
                            }
                            ExportLink += "'";

                            ExportObj["CSV"]["popup"] = ExportLink;

                            ExportObj["haschildren"] = true;
                        }
                    }
                } // if( null != View )

                // EDIT VIEW
                if (_MenuItems.Contains("Edit View") &&
                    _CswNbtResources.Permit.can(CswEnumNbtActionName.Edit_View) &&
                    (null == View || (false == View.IsSystem || CswNbtObjClassUser.ChemSWAdminUsername == _CswNbtResources.CurrentNbtUser.Username)))
                {
                    MoreObj["Edit View"]           = new JObject();
                    MoreObj["Edit View"]["action"] = CswEnumNbtMainMenuActions.editview.ToString();
                }

                if (_MenuItems.Contains("Multi-Edit") &&
                    false == ReadOnly &&
                    null != View &&
                    _CswNbtResources.Permit.can(CswEnumNbtActionName.Multi_Edit) &&
                    // Per discussion with David, for the short term eliminate the need to validate the selection of nodes across different nodetypes in Grid views.
                    // Case 21701: for Grid Properties, we need to look one level deeper
                    // Case 29032: furthermore (for Grids), we need to exclude ObjectClass relationships (which can also produce the multi-nodetype no-no
                    (View.ViewMode != CswEnumNbtViewRenderingMode.Grid ||
                     ((View.Root.ChildRelationships.Count == 1 && View.Root.ChildRelationships[0].SecondType == CswEnumNbtViewRelatedIdType.NodeTypeId) &&
                      (View.Visibility != CswEnumNbtViewVisibility.Property || (View.Root.ChildRelationships[0].ChildRelationships.Count == 1 && View.Root.ChildRelationships[0].ChildRelationships[0].SecondType == CswEnumNbtViewRelatedIdType.NodeTypeId))))
                    )
                {
                    MoreObj["Multi-Edit"]           = new JObject();
                    MoreObj["Multi-Edit"]["action"] = CswEnumNbtMainMenuActions.multiedit.ToString();
                }
                if (_MenuItems.Contains("Bulk Edit") &&
                    false == ReadOnly &&
                    null != View &&
                    _CswNbtResources.Permit.can(CswEnumNbtActionName.Bulk_Edit))
                {
                    MoreObj["Bulk Edit"]           = new JObject();
                    MoreObj["Bulk Edit"]["action"] = CswEnumNbtMainMenuActions.bulkedit.ToString();
                }

                if (MoreObj.Count > 0)
                {
                    MoreObj["haschildren"] = true;
                    Ret["More"]            = MoreObj;
                }
            } // if( _MenuItems.Contains( "More" ) )

            _CswNbtResources.logTimerResult("CswNbtWebServiceMainMenu.getMenu()", MainMenuTimer.ElapsedDurationInSecondsAsString);


            return(Ret);
        } // getMenu()
コード例 #16
0
        public void assignPropsToLocations( string LocationNodeKeys, bool UpdateInventoryGroup, string SelectedInventoryGroupNodeId, bool UpdateAllowInventory, string AllowInventory, bool UpdateControlZone, string SelectedControlZoneNodeId, bool UpdateStorageCompatability, string SelectedImages )
        {

            if( false == string.IsNullOrEmpty( LocationNodeKeys ) )
            {


                ///we don't pre-load he allowinventory value because there's no extra expense
                ///to doing so repeatedly in the loop

                CswNbtNode InventoryGroupNode = null;
                if( ( true == UpdateInventoryGroup ) && ( false == string.IsNullOrEmpty( SelectedInventoryGroupNodeId ) ) )
                {
                    CswPrimaryKey IGKey = new CswPrimaryKey();
                    IGKey.FromString( SelectedInventoryGroupNodeId );
                    InventoryGroupNode = _CswNbtResources.Nodes[IGKey];
                }

                CswNbtNode ControlZoneNode = null;
                if( ( true == UpdateControlZone ) && ( false == string.IsNullOrEmpty( SelectedControlZoneNodeId ) ) )
                {
                    CswPrimaryKey IGKey = new CswPrimaryKey();
                    IGKey.FromString( SelectedControlZoneNodeId );
                    ControlZoneNode = _CswNbtResources.Nodes[IGKey];
                }



                CswDelimitedString Images = new CswDelimitedString( ',' );
                if( true == UpdateStorageCompatability )
                {
                    if( false == string.IsNullOrEmpty( SelectedImages ) )
                    {
                        Images.FromString( SelectedImages );
                    }
                }



                foreach( string CurrentLocationKey in LocationNodeKeys.Split( ',' ) )
                {
                    if( false == string.IsNullOrEmpty( CurrentLocationKey ) )
                    {
                        CswNbtNodeKey LKey = new CswNbtNodeKey( CurrentLocationKey );
                        CswNbtObjClassLocation CurrentLocationNode = _CswNbtResources.Nodes[LKey];
                        if( null != CurrentLocationNode )
                        {

                            if( true == UpdateInventoryGroup )
                            {
                                if( null != InventoryGroupNode )
                                {
                                    CurrentLocationNode.InventoryGroup.RelatedNodeId = InventoryGroupNode.NodeId;
                                }
                                else
                                {
                                    CurrentLocationNode.InventoryGroup.RelatedNodeId = null;
                                }
                            }

                            if( true == UpdateControlZone )
                            {
                                if( null != ControlZoneNode )
                                {
                                    CurrentLocationNode.ControlZone.RelatedNodeId = ControlZoneNode.NodeId;
                                }
                                else
                                {
                                    CurrentLocationNode.ControlZone.RelatedNodeId = null;
                                }
                            }
                            

                            if( UpdateAllowInventory )
                            {
                                CurrentLocationNode.AllowInventory.Checked = CswConvert.ToTristate( AllowInventory );
                            }

                            if( UpdateStorageCompatability )
                            {
                                CurrentLocationNode.StorageCompatibility.Value = Images;
                            }

                            CurrentLocationNode.postChanges( true );

                        }//if current key yielded a node

                    } //if there is a location keye

                } //iterate locations


            }//if we have location keys

        }//assignInventoryGroupToLocations() 
コード例 #17
0
        public CswNbtWebServiceGrid(CswNbtResources CswNbtResources, CswNbtView View, bool ForReport, CswNbtNodeKey ParentNodeKey = null)
        {
            _CswNbtResources = CswNbtResources;
            _View            = View;
            _ForReport       = ForReport;

            if (_View.ViewMode != CswEnumNbtViewRenderingMode.Grid)
            {
                throw new CswDniException(CswEnumErrorType.Error, "Cannot create a grid using a view type of " + _View.ViewMode, "Cannot create a grid view if the view is not a grid.");
            }

            _ParentNodeKey = ParentNodeKey;

            Collection <CswNbtViewRelationship> FirstLevelRelationships = new Collection <CswNbtViewRelationship>();

            if (null != _ParentNodeKey && _View.Visibility == CswEnumNbtViewVisibility.Property)
            {
                foreach (CswNbtViewRelationship Relationship in _View.Root.ChildRelationships.SelectMany(NodeRelationship => NodeRelationship.ChildRelationships))
                {
                    FirstLevelRelationships.Add(Relationship);
                }
            }
            else
            {
                FirstLevelRelationships = _View.Root.ChildRelationships;
            }
            // Case 21778
            // Maybe do this in Permit someday; however, the meaning of Edit and Delete is very specific in this context:
            // only evaluating visibility of the option to edit or delete root nodetypes of a view
            foreach (CswNbtViewRelationship Relationship in FirstLevelRelationships)
            {
                Collection <CswNbtMetaDataNodeType> FirstLevelNodeTypes = new Collection <CswNbtMetaDataNodeType>();

                if (Relationship.SecondId != Int32.MinValue)
                {
                    if (Relationship.SecondType == CswEnumNbtViewRelatedIdType.PropertySetId)
                    {
                        foreach (CswNbtMetaDataObjectClass SecondOc in _CswNbtResources.MetaData.getObjectClassesByPropertySetId(Relationship.SecondId))
                        {
                            if (null != SecondOc)
                            {
                                foreach (CswNbtMetaDataNodeType NT in SecondOc.getNodeTypes())
                                {
                                    FirstLevelNodeTypes.Add(NT);
                                }
                            }
                        }
                    }
                    else if (Relationship.SecondType == CswEnumNbtViewRelatedIdType.ObjectClassId)
                    {
                        CswNbtMetaDataObjectClass SecondOc = _CswNbtResources.MetaData.getObjectClass(Relationship.SecondId);
                        if (null != SecondOc)
                        {
                            foreach (CswNbtMetaDataNodeType NT in SecondOc.getNodeTypes())
                            {
                                FirstLevelNodeTypes.Add(NT);
                            }
                        }
                    }
                    else if (Relationship.SecondType == CswEnumNbtViewRelatedIdType.NodeTypeId)
                    {
                        CswNbtMetaDataNodeType SecondNt = _CswNbtResources.MetaData.getNodeType(Relationship.SecondId);
                        if (null != SecondNt)
                        {
                            FirstLevelNodeTypes.Add(SecondNt);
                        }
                    }
                } // if( Relationship.SecondId != Int32.MinValue )

                foreach (CswNbtMetaDataNodeType NodeType in FirstLevelNodeTypes)
                {
                    _NodeTypePermission Permission = new _NodeTypePermission(NodeType, _CswNbtResources);
                    _ActionEnabled = false == _ForReport &&
                                     (_ActionEnabled || Permission.CanView || Permission.CanDelete || Permission.CanDelete);
                    if (false == _Permissions.ContainsKey(NodeType.FirstVersionNodeTypeId))
                    {
                        _Permissions.Add(NodeType.FirstVersionNodeTypeId, Permission);
                    }
                }
            }

            _CswNbtGrid  = new CswNbtGrid(_CswNbtResources);
            _PropsInGrid = new Collection <CswViewBuilderProp>();
            _getGridProperties(_View.Root.ChildRelationships, _PropsInGrid);
        } //ctor
コード例 #18
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()
コード例 #19
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 )
                }
            }
        }
コード例 #20
0
ファイル: CswNbtSearch.cs プロジェクト: crfroehlich/legacy
        /// <summary>
        /// New Filters to offer, based on Results
        /// </summary>
        public JArray FilterOptions(ICswNbtTree Tree)
        {
            JArray FiltersArr = new JArray();

            Tree.goToRoot();
            bool SingleNodeType = IsSingleNodeType();

            if (false == SingleNodeType)
            {
                // Filter on NodeTypes only
                SortedList <string, NodeTypeEntry> NodeTypeOptions = new SortedList <string, NodeTypeEntry>();
                Int32 ChildCnt = Tree.getChildNodeCount();
                for (Int32 n = 0; n < ChildCnt; n++)
                {
                    Tree.goToNthChild(n);
                    CswNbtNodeKey NodeKey = Tree.getNodeKeyForCurrentPosition();
                    if (NodeKey != null)
                    {
                        CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(NodeKey.NodeTypeId);
                        string LatestName = NodeType.getNodeTypeLatestVersion().NodeTypeName;
                        if (false == NodeTypeOptions.ContainsKey(LatestName))
                        {
                            NodeTypeOptions.Add(LatestName, new NodeTypeEntry
                            {
                                NodeType   = NodeType,
                                NodeTypeId = NodeType.NodeTypeId,
                                LatestName = LatestName,
                                Count      = 0
                            });
                        }
                        NodeTypeOptions[LatestName].Count += 1;
                    }
                    Tree.goToParentNode();
                } // for( Int32 n = 0; n < ChildCnt; n++ )

                if (NodeTypeOptions.Keys.Count == 1)
                {
                    if (false == IsSingleNodeType())
                    {
                        // If we have uniform results but no nodetype filter applied
                        // add the filter to the filters list for display
                        NodeTypeEntry      entry          = NodeTypeOptions.Values[0];
                        CswNbtSearchFilter NodeTypeFilter = makeFilter(entry.NodeType, entry.Count, false, CswEnumNbtSearchPropOrderSourceType.Unknown);
                        addFilter(NodeTypeFilter);
                    }
                    SingleNodeType = true;
                }
                else
                {
                    JArray FilterSet = new JArray();
                    FiltersArr.Add(FilterSet);

                    foreach (NodeTypeEntry entry in NodeTypeOptions.Values)
                    {
                        CswNbtSearchFilter NodeTypeFilter = makeFilter(entry.NodeType, entry.Count, true, CswEnumNbtSearchPropOrderSourceType.Unknown);
                        FilterSet.Add(NodeTypeFilter.ToJObject());
                    }
                }
            } // if( false == SingleNodeType )

            if (SingleNodeType)
            {
                // Filter on property values in the results
                Collection <Int32> FilteredPropIds = getFilteredPropIds();
                Dictionary <Int32, Dictionary <string, Int32> > PropCounts = new Dictionary <Int32, Dictionary <string, Int32> >();
                SortedSet <CswNbtSearchPropOrder.SearchOrder>   PropOrder  = new SortedSet <CswNbtSearchPropOrder.SearchOrder>();
                Int32 ChildCnt = Tree.getChildNodeCount();
                for (Int32 n = 0; n < ChildCnt; n++)
                {
                    Tree.goToNthChild(n);

                    if (0 == PropOrder.Count)
                    {
                        PropOrder = _CswNbtSearchPropOrder.getPropOrderDict(Tree.getNodeKeyForCurrentPosition());
                    }
                    Collection <CswNbtTreeNodeProp> Props = Tree.getChildNodePropsOfNode();
                    foreach (CswNbtTreeNodeProp Prop in Props)
                    {
                        CswNbtMetaDataFieldType FieldType = _CswNbtResources.MetaData.getFieldType(Prop.FieldType);
                        if (false == FilteredPropIds.Contains(Prop.NodeTypePropId) && FieldType.Searchable)
                        {
                            string Gestalt = Prop.Gestalt;
                            if (Gestalt.Length > 50)
                            {
                                Gestalt = Gestalt.Substring(0, 50);
                            }

                            if (false == PropCounts.ContainsKey(Prop.NodeTypePropId))
                            {
                                PropCounts[Prop.NodeTypePropId] = new Dictionary <string, Int32>();
                            }
                            if (false == PropCounts[Prop.NodeTypePropId].ContainsKey(Gestalt))
                            {
                                PropCounts[Prop.NodeTypePropId][Gestalt] = 0;
                            }
                            PropCounts[Prop.NodeTypePropId][Gestalt] += 1;
                        }
                    }

                    Tree.goToParentNode();
                } // for( Int32 n = 0; n < ChildCnt; n++ )

                foreach (Int32 NodeTypePropId in PropCounts.Keys.OrderBy(NodeTypePropId => PropOrder.First(Order => Order.NodeTypePropId == NodeTypePropId).Order))
                {
                    CswNbtMetaDataNodeTypeProp NodeTypeProp = _CswNbtResources.MetaData.getNodeTypePropLatestVersion(NodeTypePropId);
                    if (false == NodeTypeProp.IsUnique())    // case 27649
                    {
                        CswNbtSearchPropOrder.SearchOrder order = PropOrder.First(Order => Order.NodeTypePropId == NodeTypePropId);

                        JArray FilterSet = new JArray();
                        FiltersArr.Add(FilterSet);

                        // Sort by count descending, then alphabetically by gestalt
                        Dictionary <string, Int32> sortedDict = (from entry
                                                                 in PropCounts[NodeTypePropId]
                                                                 orderby entry.Value descending, entry.Key ascending
                                                                 select entry
                                                                 ).ToDictionary(pair => pair.Key, pair => pair.Value);
                        foreach (string Value in sortedDict.Keys)
                        {
                            Int32 Count = sortedDict[Value];
                            CswNbtSearchFilter Filter = makeFilter(NodeTypeProp, Value, Count, true, order.Source);
                            FilterSet.Add(Filter.ToJObject());
                        }
                    } // if( false == NodeTypeProp.IsUnique() )
                }     // foreach( Int32 NodeTypePropId in PropCounts.Keys.OrderBy( NodeTypePropId => PropOrder.First( Order => Order.NodeTypePropId == NodeTypePropId ).Order ) )
            }         // if( SingleNodeType )

            return(FiltersArr);
        } // FilterOptions()
コード例 #21
0
        /// <summary>
        /// DataBind to Tree
        /// </summary>
        protected void CswNodesList_DataBinding(object sender, EventArgs e)
        {
            try
            {
                EnsureChildControls();
                _Table.clear();

                bool NoResults = false;
                if (View == null)
                {
                    NoResults = true;
                }
                else
                {
                    ICswNbtTree Tree = _CswNbtResources.Trees.getTreeFromView(_CswNbtResources.CurrentNbtUser, View, true, false, false);
                    if (Tree == null)
                    {
                        NoResults = true;
                    }
                    else
                    {
                        if (Tree.getChildNodeCount() == 0)
                        {
                            NoResults = true;
                        }
                        else
                        {
                            if (SelectedNodeKey != null)
                            {
                                Tree.makeNodeCurrent(SelectedNodeKey);
                                if (!Tree.isCurrentNodeDefined() || SelectedNodeKey.NodeSpecies == CswEnumNbtNodeSpecies.Root)
                                {
                                    SelectedNodeKey = null;
                                }
                                Tree.goToRoot();
                            }

                            for (Int32 c = 0; c < Tree.getChildNodeCount(); c++)
                            {
                                Tree.goToNthChild(c);

                                CswNbtNodeKey CurrentNodeKey = Tree.getNodeKeyForCurrentPosition();
                                Int32         ThisRow        = _Table.Rows.Count;

                                Image  IconImage  = new Image();
                                string IconSuffix = Tree.getNodeForCurrentPosition().IconFileName;
                                string IconName   = default(string);
                                if (false == string.IsNullOrEmpty(IconSuffix))
                                {
                                    IconName = "Images/icons/" + IconSuffix;
                                }

                                IconImage.ImageUrl = IconName;
                                _Table.addControl(ThisRow, 0, IconImage);

                                _Table.addControl(ThisRow, 1, new CswLiteralNbsp());

                                if (EnableLinks)
                                {
                                    LinkButton ListLink = new LinkButton();
                                    ListLink.ID            = Tree.getNodeKeyForCurrentPosition().ToString();
                                    ListLink.Text          = Tree.getNodeNameForCurrentPosition();
                                    ListLink.OnClientClick = "return " + ClientClickFunctionName + "('" + Tree.getNodeKeyForCurrentPosition().ToString() + "');";
                                    _Table.addControl(ThisRow, ListLinkCellNumber, ListLink);
                                    _Table.getCell(ThisRow, ListLinkCellNumber).Width = Unit.Parse("100%");
                                }
                                else
                                {
                                    Label ListLabel = new Label();
                                    ListLabel.ID   = Tree.getNodeKeyForCurrentPosition().ToString();
                                    ListLabel.Text = Tree.getNodeNameForCurrentPosition();
                                    _Table.addControl(ThisRow, ListLinkCellNumber, ListLabel);
                                    _Table.getCell(ThisRow, ListLinkCellNumber).Width = Unit.Parse("100%");
                                }

                                if ((SelectedNodeKey == null && c == 0) ||   // first row
                                    CurrentNodeKey == SelectedNodeKey)       // or selected row
                                {
                                    _Table.SelectedRow = ThisRow;
                                }

                                Tree.goToParentNode();
                            } // for( Int32 c = 0; c < Tree.getChildNodeCount(); c++ )
                        }     // if-else( Tree.getChildNodeCount() == 0 )
                    }         // if-else( Tree == null )
                }             // if-else( View == null )


                if (NoResults)
                {
                    NoResults = true;
                    Label NoResultsLabel = new Label();
                    NoResultsLabel.Text = "No results";
                    _Table.addControl(0, 0, NoResultsLabel);
                    _Table.SelectedRow = 0;
                }
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
コード例 #22
0
        } // removeProp()

        public CswNbtNode addNode(CswNbtMetaDataNodeType NodeType, JObject PropsObj, out CswNbtNodeKey RetNbtNodeKey, Action <CswNbtNode> After, CswNbtView View = null, CswNbtMetaDataNodeTypeTab NodeTypeTab = null)
        {
            return(_TabsPropsSd.addNode(NodeType, PropsObj, out RetNbtNodeKey, After, View, NodeTypeTab));
        }
コード例 #23
0
        } // getPropOrder()

        /// <summary>
        /// Returns the order in which properties should appear in the table
        /// </summary>
        public SortedSet <SearchOrder> getPropOrderDict(CswNbtNodeKey NodeKey, CswNbtView View = null)
        {
            SortedSet <SearchOrder> ret      = null;
            CswNbtMetaDataNodeType  NodeType = _CswNbtResources.MetaData.getNodeType(NodeKey.NodeTypeId);

            if (null != NodeType)
            {
                if (false == _PropOrderDict.ContainsKey(NodeType))
                {
                    ret = new SortedSet <SearchOrder>();

                    // View order goes first
                    if (View != null)
                    {
                        CswNbtViewRelationship ViewRel = (CswNbtViewRelationship)View.FindViewNodeByUniqueId(NodeKey.ViewNodeUniqueId);
                        if (ViewRel != null)
                        {
                            foreach (CswNbtViewProperty ViewProp in ViewRel.Properties)
                            {
                                SearchOrder ThisOrder = new SearchOrder
                                {
                                    NodeTypePropId    = ViewProp.NodeTypePropId,
                                    ObjectClassPropId = ViewProp.ObjectClassPropId,
                                    Source            = CswEnumNbtSearchPropOrderSourceType.View,
                                    Order             = 0
                                };


                                foreach (CswNbtViewProperty OtherViewProp in ViewRel.Properties)
                                {
                                    if ((OtherViewProp.Order != Int32.MinValue && OtherViewProp.Order < ViewProp.Order) ||
                                        ViewProp.Order == Int32.MinValue)
                                    {
                                        ThisOrder.Order += 1;
                                    }
                                }
                                ret.Add(ThisOrder);
                            } // foreach( CswNbtViewProperty ViewProp in ViewRel.Properties )
                        }     // if( ViewRel != null )
                    }         // if( _View != null )


                    // Table layout goes second
                    Int32 maxOrder = (ret.Count > 0) ? ret.Max().Order : 0;
                    if (false == _TableLayoutDict.Keys.Contains(NodeType))
                    {
                        _TableLayoutDict[NodeType] = _CswNbtResources.MetaData.NodeTypeLayout.getPropsInLayout(NodeType.NodeTypeId, Int32.MinValue, CswEnumNbtLayoutType.Table);
                    }
                    foreach (CswNbtMetaDataNodeTypeProp Prop in _TableLayoutDict[NodeType])
                    {
                        SearchOrder ThisOrder = new SearchOrder
                        {
                            NodeTypePropId    = Prop.PropId,
                            ObjectClassPropId = Prop.ObjectClassPropId,
                            Source            = CswEnumNbtSearchPropOrderSourceType.Table,
                        };
                        if (false == ret.Contains(ThisOrder))
                        {
                            CswNbtMetaDataNodeTypeLayoutMgr.NodeTypeLayout propTableLayout = Prop.getTableLayout();
                            if (propTableLayout.DisplayRow > 0)
                            {
                                ThisOrder.Order = maxOrder + propTableLayout.DisplayRow;
                                ret.Add(ThisOrder);
                            }
                        }
                    } // foreach( CswNbtMetaDataNodeTypeProp Prop in _TableLayoutDict[thisNode.NodeType] )


                    // Everything else in alphabetical order
                    maxOrder = (ret.Count > 0) ? ret.Max().Order : 0;
                    foreach (CswNbtMetaDataNodeTypeProp Prop in NodeType.getNodeTypeProps()
                             .OrderBy(Prop => Prop.PropName))
                    {
                        SearchOrder ThisOrder = new SearchOrder
                        {
                            NodeTypePropId    = Prop.PropId,
                            ObjectClassPropId = Prop.ObjectClassPropId,
                            Source            = CswEnumNbtSearchPropOrderSourceType.Results,
                        };
                        if (false == ret.Contains(ThisOrder))
                        {
                            maxOrder++;
                            ThisOrder.Order = maxOrder;
                            ret.Add(ThisOrder);
                        }
                    }
                    _PropOrderDict.Add(NodeType, ret);
                } // if( false == _PropOrderDict.ContainsKey( thisNode.NodeType ) )

                ret = _PropOrderDict[NodeType];
            } // if(null != NodeType)
            return(ret);
        }     //getPropOrderDict()
コード例 #24
0
ファイル: CswNodesGrid.cs プロジェクト: crfroehlich/legacy
        void CswNodesGrid_DataBinding(object sender, EventArgs e)
        {
            try
            {
                //if( ReadOnly )
                //{
                //    DisplayMenu = false;
                //    ShowActionColumn = false;
                //}

                if (View != null)
                {
                    _GridHeaderIcon.ImageUrl = _View.IconFileName;

                    // View width is in characters, not pixels
                    _Grid.Width = Unit.Parse((CswConvert.ToInt32(View.Width * 7)).ToString() + "px");        // average pixel width per character

                    CswNbtNodeKey ParentKey = null;
                    if (ParentNodeKey != null && _View.Root.ChildRelationships.Count > 0)
                    {
                        // This is a Grid Property
                        ((CswNbtViewRelationship)_View.Root.ChildRelationships[0]).NodeIdsToFilterIn.Add(ParentNodeKey.NodeId);
                        //_View.Root.FilterInNodesRecursively = false;
                        ParentKey = ParentNodeKey;
                    }

                    // Note - Second parameter true for BZ 9200
                    CswNbtTree = _CswNbtResources.Trees.getTreeFromView(
                        RunAsUser: _CswNbtResources.CurrentNbtUser,
                        View: View,
                        RequireViewPermissions: true,
                        IncludeSystemNodes: false,
                        IncludeHiddenNodes: false);
                    //_MainFilterEditor.LoadView(Master.CswNbtView);

                    // BROKEN BY case 24709
                    //if( ParentKey != null )
                    //    CswNbtTree.XmlTreeDestinationFormat = XmlTreeDestinationFormat.TelerikRadGridProperty;
                    //else
                    //    CswNbtTree.XmlTreeDestinationFormat = XmlTreeDestinationFormat.TelerikRadGrid;

                    //string XmlStrForGrid = CswNbtTree.getTreeAsXml();
                    DataSet UnsortedXmlDataSet = new DataSet();
                    //UnsortedXmlDataSet.ReadXml( new System.IO.StringReader( XmlStrForGrid ), XmlReadMode.InferTypedSchema );

                    if (UnsortedXmlDataSet.Tables.Count > 0 && UnsortedXmlDataSet.Tables[0].Rows.Count > 0)
                    {
                        _NoResultsLiteral.Visible = false;
                        setupGridColumns(UnsortedXmlDataSet, View);

                        //CswNbtViewProperty SortProp = View.getSortProperty();
                        //if( SortProp != null )
                        //{
                        //    string SortMethod = "";
                        //    if( SortProp != null && SortProp.SortMethod == PropertySortMethod.Descending )
                        //        SortMethod = " DESC";

                        //    DataView Sortedview = UnsortedXmlDataSet.Tables[0].DefaultView;
                        //    Sortedview.Sort = "Prop_" + SortProp.NodeTypePropId + "_" + CswTools.XmlSafeAttributeName( SortProp.Name ) + SortMethod;
                        //    _Grid.DataSource = Sortedview;

                        //    if( ShowAsHtmlTable )
                        //        _setupHtmlTable( Sortedview.Table );
                        //}
                        //else
                        //{
                        _Grid.DataSource = UnsortedXmlDataSet;

                        if (ShowAsHtmlTable)
                        {
                            _setupHtmlTable(UnsortedXmlDataSet.Tables[0]);
                        }
                        //}

                        if (!ShowAsHtmlTable)
                        {
                            _Grid.AutoGenerateColumns = false;
                            _Grid.DataBind();
                        }
                    }
                    else
                    {
                        _NoResultsLiteral.Visible = true;
                    }
                    _DataSet = UnsortedXmlDataSet;


                    if (DisplayMenu)
                    {
                        _MainMenu.View          = View;
                        _MainMenu.ParentNodeKey = CswNbtTree.getNodeKeyByNodeId(ParentNodeKey.NodeId);
                    }
                }
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
コード例 #25
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()
コード例 #26
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()