示例#1
0
        public void fill(bool IsNew)
        {
            New = IsNew;

            CswNbtMetaDataNodeType MetaDataNodeType = _CswNbtNode.getNodeType();

            foreach (CswNbtMetaDataNodeTypeProp MetaDataProp in MetaDataNodeType.getNodeTypeProps())
            {
                DataRow PropRow = PropsTable.Rows.Cast <DataRow>().FirstOrDefault(CurrentRow => CurrentRow["nodetypepropid"].ToString() == MetaDataProp.PropId.ToString());

                CswNbtNodePropWrapper AddedProp = CswNbtNodePropFactory.makeNodeProp(_CswNbtResources, PropRow, PropsTable, _CswNbtNode, MetaDataProp, _CswNbtNode._Date);

                _Props.Add(AddedProp);
                Int32 PropsIdx = _Props.Count - 1;
                _PropsIndexByFirstVersionPropId.Add(MetaDataProp.FirstPropVersionId, PropsIdx);
                _PropsIndexByNodeTypePropId.Add(MetaDataProp.PropId, PropsIdx);
                string ObjectClassPropName = MetaDataProp.getObjectClassPropName();
                if (false == string.IsNullOrEmpty(ObjectClassPropName))
                {
                    _PropsIndexByObjectClassPropName.Add(ObjectClassPropName, PropsIdx);
                }
                AddedProp.onNodePropRowFilled();
            }

            if (_CswNbtNode != null)
            {
                _CswNbtNode.ObjClass.triggerAfterPopulateProps();
            }

            _Filled = true;
        }//fill()
示例#2
0
        }//clear()

        //public void makeNewNodeEntry( CswNbtNode Node, bool IsCopy, bool OverrideUniqueValidation )
        public void makeNewNodeEntry(CswNbtNode Node)
        {
            // case 20970
            CswNbtActQuotas Quotas = new CswNbtActQuotas(_CswNbtResources);

            CswNbtActQuotas.Quota Quota = Quotas.CheckQuotaNT(Node.NodeTypeId);
            if (!Quota.HasSpace)
            {
                Node.Locked = true;
            }

            DataTable NewNodeTable = CswTableUpdateNodes.getEmptyTable();
            DataRow   NewNodeRow   = NewNodeTable.NewRow();

            NewNodeRow["nodename"]      = Node.NodeName;
            NewNodeRow["nodetypeid"]    = CswConvert.ToDbVal(Node.NodeTypeId);
            NewNodeRow["pendingupdate"] = CswConvert.ToDbVal(false);
            NewNodeRow["readonly"]      = CswConvert.ToDbVal(false);
            NewNodeRow["isdemo"]        = CswConvert.ToDbVal(false);
            NewNodeRow["issystem"]      = CswConvert.ToDbVal(false);
            NewNodeRow["hidden"]        = CswConvert.ToDbVal(false);
            NewNodeRow["searchable"]    = CswConvert.ToDbVal(true);
            NewNodeRow["iconfilename"]  = Node.IconFileNameOverride;
            NewNodeRow["created"]       = DateTime.Now;

            //case 27709: nodes must have an explicit audit level
            CswNbtMetaDataNodeType CswNbtMetaDataNodeType = Node.getNodeType();

            if (null != CswNbtMetaDataNodeType)
            {
                NewNodeRow[_CswAuditMetaData.AuditLevelColName] = CswNbtMetaDataNodeType.AuditLevel;
                Node.AuditLevel = CswNbtMetaDataNodeType.AuditLevel; //Otherwise the Node's deafult NoAudit setting gets written to db; trust me on this one
            }

            NewNodeTable.Rows.Add(NewNodeRow);

            Node.NodeId = new CswPrimaryKey("nodes", CswConvert.ToInt32(NewNodeTable.Rows[0]["nodeid"]));

            // case 29311 - Sync with relational data
            if (Node.getNodeType().DoRelationalSync)
            {
                _CswNbtNodeWriterRelationalDb.makeNewNodeEntry(Node, false);
            }
            if (CswTools.IsPrimaryKey(Node.RelationalId))
            {
                NewNodeRow["relationalid"]    = Node.RelationalId.PrimaryKey;
                NewNodeRow["relationaltable"] = Node.RelationalId.TableName;
            }
            CswTableUpdateNodes.update(NewNodeTable, (false == Node.IsTemp));
        }//makeNewNodeEntry()
        public static void getMolImg(ICswResources CswResources, MolDataReturn Return, MolData ImgData)
        {
            string molData      = ImgData.molString;
            string nodeId       = ImgData.nodeId;
            string base64String = "";

            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            if (String.IsNullOrEmpty(molData) && false == String.IsNullOrEmpty(nodeId))      //if we only have a nodeid, get the mol text from the mol property if there is one
            {
                CswPrimaryKey pk   = CswConvert.ToPrimaryKey(nodeId);
                CswNbtNode    node = NbtResources.Nodes[pk];
                CswNbtMetaDataNodeTypeProp molNTP = node.getNodeType().getMolProperty();
                if (null != molNTP)
                {
                    molData = node.Properties[molNTP].AsMol.getMol();
                }
            }

            if (false == String.IsNullOrEmpty(molData))
            {
                //If the Direct Structure Search module is enabled, use the AcclDirect methods to generate an image. Otherwise, use the legacy code.
                byte[] bytes =
                    (NbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.DirectStructureSearch) ?
                     NbtResources.AcclDirect.GetImage(molData) :
                     CswStructureSearch.GetImage(molData));

                base64String = Convert.ToBase64String(bytes);
            }

            ImgData.molImgAsBase64String = base64String;
            ImgData.molString            = molData;
            Return.Data = ImgData;
        }
示例#4
0
        }//makeNewNodeEntry()

        public void write(CswNbtNode Node, bool ForceSave, bool IsCopy, bool OverrideUniqueValidation, bool Creating, bool AllowAuditing, bool SkipEvents)
        {
            if (CswEnumNbtNodeSpecies.Plain == Node.NodeSpecies &&
                (ForceSave || CswEnumNbtNodeModificationState.Modified == Node.ModificationState))
            {
                //When CswNbtNode.NodeId is Int32.MinValue, we know that the node data was not
                //filled from an existing node and therefore needs to be written to
                //the db, after which it will have a node id
                if (null == Node.NodeId)
                {
                    makeNewNodeEntry(Node);
                    //makeNewNodeEntry( Node, IsCopy, OverrideUniqueValidation );
                }

                //bz # 5878
                //propcoll knows whether or not he's got new values to update (presumably)
                Node.Properties.update(Node, IsCopy, OverrideUniqueValidation, Creating, AllowAuditing, SkipEvents);

                //set nodename with updated prop values
                _synchNodeName(Node);

                // save nodename and pendingupdate
                if (Node.NodeId.TableName != "nodes")
                {
                    throw new CswDniException(CswEnumErrorType.Error, "Internal data error", "CswNbtNodeWriterNative attempted to write a node in table: " + Node.NodeId.TableName);
                }

                DataTable NodesTable = CswTableUpdateNodes.getTable("nodeid", Node.NodeId.PrimaryKey);
                if (1 != NodesTable.Rows.Count)
                {
                    throw (new CswDniException(CswEnumErrorType.Error, "Internal data errors", "There are " + NodesTable.Rows.Count.ToString() + " node table records for node id (" + Node.NodeId.ToString() + ")"));
                }

                NodesTable.Rows[0]["nodename"]      = Node.NodeName;
                NodesTable.Rows[0]["pendingupdate"] = CswConvert.ToDbVal(Node.PendingUpdate);
                NodesTable.Rows[0]["readonly"]      = CswConvert.ToDbVal(Node.ReadOnlyPermanent);
                NodesTable.Rows[0]["locked"]        = CswConvert.ToDbVal(Node.Locked);
                NodesTable.Rows[0]["isdemo"]        = CswConvert.ToDbVal(Node.IsDemo);
                NodesTable.Rows[0]["istemp"]        = CswConvert.ToDbVal(Node.IsTemp);
                NodesTable.Rows[0]["sessionid"]     = CswConvert.ToDbVal(Node.SessionId);
                NodesTable.Rows[0][_CswAuditMetaData.AuditLevelColName] = Node.AuditLevel;
                NodesTable.Rows[0]["hidden"]       = CswConvert.ToDbVal(Node.Hidden);
                NodesTable.Rows[0]["iconfilename"] = Node.IconFileNameOverride;
                NodesTable.Rows[0]["searchable"]   = CswConvert.ToDbVal(Node.Searchable);
                NodesTable.Rows[0]["legacyid"]     = CswConvert.ToDbVal(Node.LegacyId);

                // case 29311 - Sync with relational data
                if (Node.getNodeType().DoRelationalSync)
                {
                    _CswNbtNodeWriterRelationalDb.write(Node, ForceSave, IsCopy, AllowAuditing);
                }

                if (null != Node.RelationalId)
                {
                    NodesTable.Rows[0]["relationalid"]    = Node.RelationalId.PrimaryKey;
                    NodesTable.Rows[0]["relationaltable"] = Node.RelationalId.TableName;
                }
                CswTableUpdateNodes.update(NodesTable);
            } //if node was modified
        }     //write()
        private static void _recurseForRelatingNodes(CswNbtResources NbtResources, CswNbtExplorerReturn Return, CswNbtNode Node, int Level, string OwnerIdStr)
        {
            CswNbtMetaDataNodeType TargetNodeType = Node.getNodeType();

            foreach (CswNbtMetaDataNodeTypeProp RelNTP in TargetNodeType.getNodeTypeProps(CswEnumNbtFieldType.Relationship))    //TODO: Locations are just like relationships, we should be able to handle them
            {
                CswNbtNodePropRelationship RelProp = Node.Properties[RelNTP];
                string Icon = _getIconFromRelationshipProp(NbtResources, RelNTP);
                if (CswTools.IsPrimaryKey(RelProp.RelatedNodeId))
                {
                    CswNbtNode             TargetNode = NbtResources.Nodes[RelProp.RelatedNodeId];
                    CswNbtMetaDataNodeType TargetNT   = TargetNode.getNodeType();

                    if (FilterVal.Contains("NT_" + TargetNode.NodeTypeId) || FilterVal.Contains("OC_" + TargetNode.getObjectClassId()))
                    {
                        string targetIdStr = OwnerIdStr + "_" + RelProp.RelatedNodeId.ToString();
                        _addToGraph(Return, RelProp.PropName + ": " + RelProp.CachedNodeName, Node.NodeId.ToString(), RelProp.RelatedNodeId.ToString(), Icon, Level, "Instance", RelProp.RelatedNodeId.ToString(), TargetNT.NodeTypeName, RelNTP.PropId);

                        if (Level + 1 <= MAX_DEPTH)
                        {
                            _recurseForRelatedNTs(NbtResources, Return, TargetNode.NodeTypeId, 1, RelProp.RelatedNodeId.ToString());
                        }

                        if (Level + 1 <= MAX_DEPTH)
                        {
                            _recurseForRelatingNodes(NbtResources, Return, TargetNode, Level + 1, targetIdStr);
                        }
                    }
                }
            }
        }
示例#6
0
        public override void setItemDataForUI(DataRow LandingPageRow, LandingPageData.Request Request)
        {
            Int32 ObjectClassPropId = CswConvert.ToInt32(LandingPageRow["to_objectclasspropid"]);

            if (ObjectClassPropId != Int32.MinValue)
            {
                CswNbtNode RequestNode = _CswNbtResources.Nodes.GetNode(CswConvert.ToPrimaryKey(Request.NodeId));
                if (null != RequestNode)
                {
                    CswNbtMetaDataNodeType NodeType = RequestNode.getNodeType();
                    if (null != NodeType)
                    {
                        String OCPName = _CswNbtResources.MetaData.getObjectClassPropName(ObjectClassPropId);
                        CswNbtMetaDataNodeTypeProp NodeTypeProp = NodeType.getNodeTypePropByObjectClassProp(OCPName);
                        if (null != NodeTypeProp && false == RequestNode.Properties[NodeTypeProp].AsButton.Hidden)
                        {
                            String DisplayText = LandingPageRow["displaytext"].ToString();
                            _ItemData.Text           = false == String.IsNullOrEmpty(DisplayText) ? DisplayText : "Add New " + NodeTypeProp.PropName;
                            _ItemData.NodeTypePropId = RequestNode.NodeId.ToString() + "_" + NodeTypeProp.PropId.ToString();
                            _ItemData.ActionName     = NodeTypeProp.PropName;
                            _ItemData.ButtonIcon     = CswNbtMetaDataObjectClass.IconPrefix100 + NodeType.IconFileName;
                            _setCommonItemDataForUI(LandingPageRow);
                        }
                    }
                }
            }
        }
 public void Delete(CswNbtResource Return, CswNbtAPIGenericRequest GenericRequest)
 {
     if (hasPermission(GenericRequest, Return))
     {
         try
         {
             CswNbtNode DoomedNode = _CswNbtResources.Nodes.GetNode(GenericRequest.NodeId);
             if (null != DoomedNode && GenericRequest.MetaDataName == DoomedNode.getNodeType().NodeTypeName)
             {
                 DoomedNode.delete();
                 Return.Status = HttpStatusCode.OK;
             }
             else
             {
                 Return.Status = HttpStatusCode.NotFound;
             }
         }
         catch (Exception)
         {
             Return.Status = HttpStatusCode.InternalServerError;
         }
     }
     else
     {
         Return.Status = HttpStatusCode.Forbidden;
     }
 }
        public override void CommitOperation(ref OperationData OpData)
        {
            CswNbtNode item         = _CswNbtResources.Nodes[OpData.Field2.NodeId];
            string     itemTypeName = item.getNodeType().NodeTypeName;
            ICswNbtKioskModeStatusable AsStatusable = (ICswNbtKioskModeStatusable)item.ObjClass;
            string statusMsg = string.Empty;

            if (_CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Edit, item.getNodeType()) && false == AsStatusable.Status.ReadOnly)
            {
                if (AsStatusable.CanChangeStatus(out statusMsg))
                {
                    AsStatusable.ChangeStatus(OpData.Field1.Value);
                    item.postChanges(false);

                    OpData.Log.Add(DateTime.Now + " - Status of " + itemTypeName + " " + OpData.Field2.Value + " changed to \"" + OpData.Field1.Value + "\"");
                    base.CommitOperation(ref OpData);
                }
                else
                {
                    OpData.Field2.FoundObjClass   = string.Empty;
                    OpData.Field2.StatusMsg       = statusMsg;
                    OpData.Field2.ServerValidated = false;
                    OpData.Log.Add(DateTime.Now + " - ERROR: " + statusMsg);
                }
            }
            else
            {
                statusMsg = "You do not have permission to edit " + itemTypeName + " (" + OpData.Field2.Value + ")";
                OpData.Field2.FoundObjClass   = string.Empty;
                OpData.Field2.StatusMsg       = statusMsg;
                OpData.Field2.ServerValidated = false;
                OpData.Log.Add(DateTime.Now + " - ERROR: " + statusMsg);
            }
        }
示例#9
0
        public override void CommitOperation(ref OperationData OpData)
        {
            bool   succeeded = false;
            string statusMsg = null;

            CswNbtObjClassUser newTransferOwner = _getNodeByBarcode(CswEnumNbtObjectClass.UserClass, OpData.Field1.Value, true);

            CswNbtNode             node     = _CswNbtResources.Nodes[OpData.Field2.NodeId];
            CswNbtMetaDataNodeType NodeType = node.getNodeType();
            string itemName = NodeType.NodeTypeName;

            ICswNbtKioskModeTransferable AsTransferable = (ICswNbtKioskModeTransferable)node.ObjClass;

            if (AsTransferable.CanTransfer(out statusMsg))
            {
                AsTransferable.Transfer(newTransferOwner);
                succeeded = true;
            }

            if (null != node && succeeded)
            {
                node.postChanges(false);
                CswNbtObjClassLocation newLocationNode = _CswNbtResources.Nodes[newTransferOwner.DefaultLocationId];
                OpData.Log.Add(DateTime.Now + " - Transferred " + itemName + " " + OpData.Field2.Value + " ownership to " + newTransferOwner.Username + " (" + OpData.Field1.Value + ") at " + newLocationNode.Name.Text);
                base.CommitOperation(ref OpData);
            }
            else
            {
                statusMsg = statusMsg ?? "You do not have permission to edit " + itemName + " (" + OpData.Field2.Value + ")";
                OpData.Field2.StatusMsg       = statusMsg;
                OpData.Field2.ServerValidated = false;
                OpData.Log.Add(DateTime.Now + " - ERROR: " + statusMsg);
            }
        }
        }//if we got any result

        public static void getImageProp(ICswResources CswResources, NodePropImageReturn Return, BlobDataParams Request)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            CswPropIdAttr PropIdAttr = new CswPropIdAttr(Request.propid);
            CswNbtNode    node       = NbtResources.Nodes[PropIdAttr.NodeId];

            if (null != node)
            {
                CswNbtMetaDataNodeType NodeType = node.getNodeType();
                CswNbtNodePropWrapper  prop     = node.Properties[PropIdAttr.NodeTypePropId];

                if (NbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.View, NodeType, NbtResources.CurrentNbtUser))
                {
                    if (Int32.MinValue == prop.JctNodePropId)
                    {
                        prop.makePropRow(); //if we don't have a jct_node_prop row for this prop, we do now
                        node.postChanges(true);
                    }
                    prop.AsImage.SetImages(Request.date);
                    if (null != prop)
                    {
                        Return.Data = prop;
                    }
                }
                else
                {
                    throw new CswDniException(CswEnumErrorType.Warning, "You do not have sufficient priviledges to get this image property", "User " + NbtResources.CurrentNbtUser.UserId + " attempted to call getImageProp on prop " + prop.JctNodePropId);
                }
            }
        }
        public override void CommitOperation(ref OperationData OpData)
        {
            CswNbtNode             itemToMove = _CswNbtResources.Nodes[OpData.Field2.NodeId];
            CswNbtMetaDataNodeType thisNT     = itemToMove.getNodeType();
            string itemType = thisNT.NodeTypeName;

            if (_CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Edit, itemToMove.getNodeType()) && false == thisNT.getLocationProperty().ReadOnly)
            {
                ICswNbtKioskModeMoveable AsMoveable = (ICswNbtKioskModeMoveable)itemToMove.ObjClass;
                string specificStatusError          = string.Empty;
                if (AsMoveable.CanMove(out specificStatusError))
                {
                    CswNbtObjClassLocation locationToMoveTo = _CswNbtResources.Nodes[OpData.Field1.NodeId];
                    AsMoveable.Move(locationToMoveTo);
                    itemToMove.postChanges(false);
                    OpData.Log.Add(DateTime.Now + " - Moved " + itemType + " " + OpData.Field2.Value + " to " + locationToMoveTo.Location.Gestalt + " > " + locationToMoveTo.Name.Text + " (" + OpData.Field1.Value + ")");
                    base.CommitOperation(ref OpData);
                }
                else
                {
                    OpData.Field2.FoundObjClass   = string.Empty;
                    OpData.Field2.StatusMsg       = specificStatusError;
                    OpData.Field2.ServerValidated = false;
                    OpData.Log.Add(DateTime.Now + " - ERROR: " + specificStatusError);
                }
            }
            else
            {
                string statusMsg = "You do not have permission to edit " + itemType + " (" + OpData.Field2.Value + ")";
                OpData.Field2.FoundObjClass   = string.Empty;
                OpData.Field2.StatusMsg       = statusMsg;
                OpData.Field2.ServerValidated = false;
                OpData.Log.Add(DateTime.Now + " - ERROR: " + statusMsg);
            }
        }
示例#12
0
        public void Create(CswNbtResource Return, CswNbtAPIGenericRequest GenericRequest)
        {
            if (hasPermission(GenericRequest, Return))
            {
                try
                {
                    CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(GenericRequest.MetaDataName);
                    CswNbtNode             NewNode  = _CswNbtResources.Nodes.makeNodeFromNodeTypeId(NodeType.NodeTypeId, IsTemp : GenericRequest.Properties.Count > 0, OnAfterMakeNode : delegate(CswNbtNode node)
                    {
                        foreach (CswNbtWcfProperty WcfProp in GenericRequest.Properties)
                        {
                            ReadPropertyData(node, WcfProp);
                        }
                    });


                    Return.NodeId       = NewNode.NodeId;
                    Return.NodeName     = NewNode.NodeName;
                    Return.NodeType     = NewNode.getNodeType().NodeTypeName;
                    Return.ObjectClass  = NewNode.ObjClass.ObjectClass.ObjectClassName;
                    Return.URI          = BuildURI(NodeType.NodeTypeName, NewNode.NodeId.PrimaryKey);
                    Return.PropertyData = GetPropertyData(NewNode);

                    Return.Status = HttpStatusCode.Created;
                }
                catch (Exception)
                {
                    Return.Status = HttpStatusCode.InternalServerError;
                }
            }
            else
            {
                Return.Status = HttpStatusCode.Forbidden;
            }
        }
        public override void CommitOperation(ref OperationData OpData)
        {
            bool succeeded = false;
            CswNbtObjClassUser newOwner = _CswNbtResources.Nodes[OpData.Field1.NodeId];

            CswNbtNode             node     = _CswNbtResources.Nodes[OpData.Field2.NodeId];
            CswNbtMetaDataNodeType NodeType = node.getNodeType();
            string itemName  = NodeType.NodeTypeName;
            string statusMsg = null;

            ICswNbtKioskModeOwnerable AsOwnerable = (ICswNbtKioskModeOwnerable)node.ObjClass;

            if (AsOwnerable.CanUpdateOwner(out statusMsg))
            {
                AsOwnerable.UpdateOwner(newOwner);
                succeeded = true;
            }

            if (null != node && succeeded)
            {
                node.postChanges(false);
                OpData.Log.Add(DateTime.Now + " - Changed owner of " + itemName + " " + OpData.Field2.Value + " to " + newOwner.Username + " (" + OpData.Field1.Value + ")");
                base.CommitOperation(ref OpData);
            }
            else
            {
                statusMsg = statusMsg ?? "You do not have permission to edit " + itemName + " (" + OpData.Field2.Value + ")";
                OpData.Field2.StatusMsg       = statusMsg;
                OpData.Field2.ServerValidated = false;
                OpData.Log.Add(DateTime.Now + " - ERROR: " + statusMsg);
            }
        }
        public static void Initialize(ICswResources CswResources, CswNbtExplorerReturn Return, CswNbtExplorerRequest Request)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;
            CswPrimaryKey   NodeId       = CswConvert.ToPrimaryKey(Request.NodeId);

            if (Request.Depth <= 4 || Request.Depth > 0)  //We never want a request higher than 4 and 0 doesn't make sense
            {
                MAX_DEPTH = Request.Depth;
            }

            FilterVal = new CswCommaDelimitedString();
            if (String.IsNullOrEmpty(Request.FilterVal))
            {
                FilterVal.FromString(CswNbtArborGraph._setDefaultFilterVal(NbtResources));
            }
            else
            {
                FilterVal.FromString(Request.FilterVal);
            }


            StartingNode = NbtResources.Nodes[NodeId];
            CswNbtMetaDataNodeType startingNT = StartingNode.getNodeType();

            //Add the initial node to the graph
            _addToGraph(Return, StartingNode.NodeName, string.Empty, NodeId.ToString(), startingNT.IconFileName, 0, "Instance", NodeId.ToString(), startingNT.NodeTypeName, Int32.MinValue);

            _recurseForRelatingNodes(NbtResources, Return, StartingNode, 1, NodeId.ToString());

            _recurseForRelatedNTs(NbtResources, Return, StartingNode.NodeTypeId, 1, NodeId.ToString());
        }
        //public void clear()
        //{
        //}//clear()

        public void makeNewNodeEntry(CswNbtNode Node, bool SyncProps)
        {
            // Don't sync for temp nodes
            if (false == Node.IsTemp)
            {
                string         TableName      = Node.getNodeType().TableName;
                string         PkColumnName   = _CswNbtResources.getPrimeKeyColName(TableName);
                CswTableUpdate CswTableUpdate = _CswNbtResources.makeCswTableUpdate("CswNbtNodeWriterRelationalDb.makeNewNodeEntry_update", TableName);

                DataTable NewNodeTable = CswTableUpdate.getEmptyTable();
                DataRow   NewNodeRow   = NewNodeTable.NewRow();
                NewNodeTable.Rows.Add(NewNodeRow);

                Node.RelationalId = new CswPrimaryKey(TableName, CswConvert.ToInt32(NewNodeTable.Rows[0][PkColumnName]));

                CswTableUpdate.update(NewNodeTable);

                if (SyncProps)
                {
                    // It is possible for the node to have existed as a temp node, and therefore already have property values.
                    // Now that the node has a relationalid, this will sync the current property values to the new relational row
                    Node.Properties.update(Node,
                                           IsCopy: false,
                                           OverrideUniqueValidation: false,
                                           Creating: false,
                                           AllowAuditing: true,
                                           SkipEvents: false);
                }
            }
        }
示例#16
0
        }     //write()

        private string _makeDefaultNodeName(CswNbtNode Node)
        {
            string ReturnVal = "";

            ReturnVal = Node.getNodeType().NodeTypeName + " " + Node.NodeId.PrimaryKey.ToString();

            return(ReturnVal);
        }//_makeDefaultNodeName
示例#17
0
        } // getPercentDone()

        /// <summary>
        /// Run the next iteration of this batch operation
        /// </summary>
        public void runBatchOp(CswNbtObjClassBatchOp BatchNode)
        {
            try
            {
                if (BatchNode != null && BatchNode.OpNameValue == CswEnumNbtBatchOpName.SyncLocation)
                {
                    BatchNode.start();

                    SyncLocationBatchData BatchData = new SyncLocationBatchData(BatchNode.BatchData.Text);

                    if (BatchData.NodePks.Count > 0)
                    {
                        int NodesProcessedPerIteration = CswConvert.ToInt32(_CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.NodesProcessedPerCycle));
                        for (int i = 0; i < NodesProcessedPerIteration && BatchData.NodePks.Count > 0; i++)
                        {
                            CswNbtNode Node = _CswNbtResources.Nodes[CswConvert.ToString(BatchData.NodePks[0])];
                            BatchData.NodePks.RemoveAt(0);
                            bool LocationUpdated = false;
                            if (null != Node)
                            {
                                CswNbtMetaDataNodeType NodeType = Node.getNodeType();
                                if (null != NodeType)
                                {
                                    CswNbtMetaDataNodeTypeProp LocationNTP = NodeType.getLocationProperty();
                                    if (null != LocationNTP)
                                    {
                                        CswNbtNodePropLocation LocationProp = Node.Properties[LocationNTP];
                                        if (null != LocationProp)
                                        {
                                            LocationProp.SelectedNodeId = BatchData.LocationId;
                                            Node.postChanges(false);
                                            LocationUpdated = true;
                                        }
                                    }
                                }
                            }//if( null != Node )

                            if (false == LocationUpdated)
                            {
                                BatchNode.appendToLog("Unable to update the location of: " + Node.NodeName + " (" + Node.NodeId.ToString() + ")");
                            }
                        }//for( int i = 0; i < NodesProcessedPerIteration && BatchData.NodePks.Count > 0; i++ )
                    }
                    else
                    {
                        BatchNode.finish();
                    }

                    BatchNode.PercentDone.Value = getPercentDone(BatchNode);
                    BatchNode.BatchData.Text    = BatchData.ToString();
                    BatchNode.postChanges(false);
                }
            }
            catch (Exception ex)
            {
                BatchNode.error(ex);
            }
        } // runBatchOp()
        private bool _validateItem(ref OperationData OpData)
        {
            bool ret = false;

            CswNbtSearch search = new CswNbtSearch(_CswNbtResources)
            {
                SearchTerm = OpData.Field2.Value,
                SearchType = CswEnumSqlLikeMode.Exact
            };
            ICswNbtTree tree = search.Results();

            int childCount = tree.getChildNodeCount();

            for (int i = 0; i < childCount; i++)
            {
                tree.goToNthChild(i);
                CswNbtNode                 node        = tree.getNodeForCurrentPosition();
                CswNbtMetaDataNodeType     nodeType    = node.getNodeType();
                CswNbtMetaDataNodeTypeProp barcodeProp = (CswNbtMetaDataNodeTypeProp)nodeType.getBarcodeProperty();

                if (null != barcodeProp)
                {
                    string barcodeValue = node.Properties[barcodeProp].AsBarcode.Barcode;
                    string ObjClass     = node.ObjClass.ObjectClass.ObjectClass;

                    if (string.Equals(barcodeValue, OpData.Field2.Value, StringComparison.CurrentCultureIgnoreCase))
                    {
                        if (ObjClass == CswEnumNbtObjectClass.EquipmentAssemblyClass)
                        {
                            OpData.Field2.FoundObjClass = CswEnumNbtObjectClass.EquipmentAssemblyClass;
                            OpData.Field2.NodeIdStr     = tree.getNodeIdForCurrentPosition().ToString();
                            ret = true;
                        }

                        if (ObjClass == CswEnumNbtObjectClass.EquipmentClass)
                        {
                            OpData.Field2.FoundObjClass = CswEnumNbtObjectClass.EquipmentClass;
                            OpData.Field2.NodeIdStr     = tree.getNodeIdForCurrentPosition().ToString();
                            ret = true;
                        }
                    }
                }
                tree.goToParentNode();
            }

            if (string.IsNullOrEmpty(OpData.Field2.FoundObjClass))
            {
                string StatusMsg = "Could not find " + CswEnumNbtObjectClass.EquipmentClass.Replace("Class", "");
                StatusMsg += " or " + CswEnumNbtObjectClass.EquipmentAssemblyClass.Replace("Class", "") + " with barcode " + OpData.Field2.Value;

                OpData.Field2.StatusMsg       = StatusMsg;
                OpData.Field2.ServerValidated = false;
                OpData.Log.Add(DateTime.Now + " - ERROR: " + StatusMsg);
                ret = false;
            }

            return(ret);
        }
示例#19
0
        private JProperty _getNode(CswNbtNode ThisNode, bool RunProps = true, NodeSpecies ThisNodeSpecies = null)
        {
            JProperty Ret = new JProperty("No Results");

            if (null != ThisNode)
            {
                string ThisNodeName = ThisNode.NodeName;

                Ret = new JProperty(NodeIdPrefix + ThisNode.NodeId);
                JObject NodeProps = new JObject();
                Ret.Value = NodeProps;

                NodeSpecies NodeSpecie = ThisNodeSpecies ?? ThisNode.NodeSpecies;
                if (NodeSpecies.More == NodeSpecie)
                {
                    ThisNodeName = "Results Truncated at " + _MobilePageSize;
                }

                NodeProps["node_name"]   = CswTools.SafeJavascriptParam(ThisNodeName);
                NodeProps["nodetype"]    = CswTools.SafeJavascriptParam(ThisNode.getNodeType().NodeTypeName);
                NodeProps["objectclass"] = CswTools.SafeJavascriptParam(ThisNode.getObjectClass().ObjectClass.ToString());
                NodeProps["nodespecies"] = CswTools.SafeJavascriptParam(NodeSpecie.ToString());
                if (RunProps)
                {
                    JObject TabsObj = new JObject();
                    NodeProps["tabs"] = TabsObj;
                    _runProperties(ThisNode, TabsObj);
                }

                if (ThisNode.Locked)
                {
                    NodeProps["iconfilename"] = "Images/quota/lock.gif";
                }
                else if (false == string.IsNullOrEmpty(ThisNode.IconFileName))
                {
                    NodeProps["iconfilename"] = CswNbtMetaDataObjectClass.IconPrefix16 + CswTools.SafeJavascriptParam(ThisNode.IconFileName);
                }

                _addObjectClassProps(ThisNode, NodeProps);

                foreach (CswNbtMetaDataNodeTypeProp MetaDataProp in _CswNbtResources.MetaData.getNodeTypeProps(ThisNode.NodeTypeId)
                         .Cast <CswNbtMetaDataNodeTypeProp>()
                         .Where(MetaDataProp => MetaDataProp.MobileSearch))
                {
                    if ((MetaDataProp.getObjectClassProp() != null))
                    {
                        NodeProps["search_ocp_" + MetaDataProp.ObjectClassPropId] = CswTools.SafeJavascriptParam(ThisNode.Properties[MetaDataProp].Gestalt);
                    }
                    else
                    {
                        NodeProps["search_ntp_" + MetaDataProp.PropId] = CswTools.SafeJavascriptParam(ThisNode.Properties[MetaDataProp].Gestalt);
                    }
                }
            }
            return(Ret);
        }
示例#20
0
        }//delete()

        private void _synchNodeName(CswNbtNode Node)
        {
            string OldNodeName  = Node.NodeName;
            string NewNodeName  = string.Empty;
            string NameTemplate = Node.getNodeType().NameTemplateValue;

            if (NameTemplate.Length > 0)
            {
                //we assume that the nodetype has nodetype_props corresponding to all "[]"
                //parameters in the nametemplate.
                if (Node.Properties.Count > 0)
                {
                    NewNodeName = NameTemplate;
                    RegexOptions RegExOpts = new RegexOptions();
                    RegExOpts |= RegexOptions.IgnoreCase;

                    foreach (CswNbtNodePropWrapper CurrentProp in Node.Properties)
                    {
                        string TemplateParamCandidate = CswNbtMetaData.MakeTemplateEntry(CurrentProp.NodeTypePropId.ToString());
                        int    TemplateParamStartIdx  = NewNodeName.ToLower().IndexOf(TemplateParamCandidate);
                        if (TemplateParamStartIdx > -1)
                        {
                            Regex RegExObj = new Regex("\\" + TemplateParamCandidate, RegExOpts);
                            NewNodeName = RegExObj.Replace(NewNodeName, CurrentProp.ValueForNameTemplate);
                        } //if current property is used in the name template
                    }     //iterate props
                }         // if( Node.Properties.Count > 0 )
            }             // if( NameTemplate.Length > 0 )

            //Case 31057 - nodename can only be 255 chars max
            if (NewNodeName.Length > 255)
            {
                NewNodeName = NewNodeName.Substring(0, 255);
            }

            NewNodeName = NewNodeName.Trim();
            if (NewNodeName != string.Empty)
            {
                Node.NodeName = NewNodeName;
            }
            else
            {
                Node.NodeName = _makeDefaultNodeName(Node);
            }

            // When a node's name changes, we need to update any relationships (and locations) referencing that node
            if (Node.NodeName != OldNodeName)
            {
                updateRelationsToThisNode(Node);
            }
        }//_synchNodeName()
示例#21
0
 public void GetResource(CswNbtResource Return, CswNbtAPIGenericRequest GenericRequest)
 {
     if (hasPermission(GenericRequest, Return))
     {
         try
         {
             CswNbtNode Node = _CswNbtResources.Nodes.GetNode(GenericRequest.NodeId);
             if (null != Node && GenericRequest.MetaDataName.ToLower() == Node.getNodeType().NodeTypeName.ToLower())
             {
                 Return.NodeId      = GenericRequest.NodeId;
                 Return.NodeName    = Node.NodeName;
                 Return.NodeType    = Node.getNodeType().NodeTypeName;
                 Return.ObjectClass = Node.ObjClass.ObjectClass.ObjectClassName;
                 CswNbtMetaDataPropertySet propSet = Node.getObjectClass().getPropertySet();
                 if (null != propSet)
                 {
                     Return.PropertySet = propSet.Name;
                 }
                 Return.URI          = BuildURI(Return.NodeType, Node.NodeId.PrimaryKey);
                 Return.PropertyData = GetPropertyData(Node);
             }
             else
             {
                 Return.Status = HttpStatusCode.NotFound;
             }
         }
         catch (Exception)
         {
             Return.Status = HttpStatusCode.InternalServerError;
         }
     }
     else
     {
         Return.Status = HttpStatusCode.Forbidden;
     }
 }
示例#22
0
        private bool _DeleteNode(CswPrimaryKey NodePk, CswNbtResources NbtResources, out string NodeName, bool DeleteAllRequiredRelatedNodes = false)
        {
            bool ret = false;

            NodeName = "";
            CswNbtNode NodeToDelete = NbtResources.Nodes[NodePk];

            if (null != NodeToDelete)
            {
                CswNbtMetaDataNodeType NodeType = NodeToDelete.getNodeType();
                NodeName = NodeType.NodeTypeName + ": " + NodeToDelete.NodeName;
                NodeToDelete.delete(DeleteAllRequiredRelatedNodes: DeleteAllRequiredRelatedNodes);
                ret = true;
            }
            return(ret);
        }
示例#23
0
        public void ReadPropertyData(CswNbtNode Node, CswNbtWcfProperty WcfProp)
        {
            CswNbtMetaDataNodeType NodeType    = Node.getNodeType();
            CswNbtNodePropWrapper  propWrapper = null;

            if (false == String.IsNullOrEmpty(WcfProp.OriginalPropName))
            {
                propWrapper = Node.Properties[WcfProp.OriginalPropName];
            }
            else
            {
                CswNbtMetaDataNodeTypeProp ntp = NodeType.getNodeTypeProp(WcfProp.PropName);
                propWrapper = Node.Properties[ntp];
            }

            JObject propData = ConvertWcfPropertyData(WcfProp);

            propWrapper.ReadJSON(propData, null, null);
        }
        public void Edit(CswNbtAPIReturn Return, CswNbtAPIGenericRequest GenericRequest)
        {
            if (hasPermission(GenericRequest, Return))
            {
                try
                {
                    CswNbtNode Node = _CswNbtResources.Nodes.GetNode(GenericRequest.NodeId);
                    if (null != Node && GenericRequest.MetaDataName == Node.getNodeType().NodeTypeName)
                    {
                        if (null != GenericRequest.ResourceToUpdate)
                        {
                            foreach (string propKey in GenericRequest.ResourceToUpdate.PropertyData.properties.Keys)
                            {
                                CswNbtWcfProperty wcfProp = GenericRequest.ResourceToUpdate.PropertyData.properties[propKey];
                                ReadPropertyData(Node, wcfProp);
                            }
                        }

                        if (Node.IsTemp)
                        {
                            Node.PromoteTempToReal();
                        }
                        else
                        {
                            Node.postChanges(false);
                        }
                    }
                    else
                    {
                        Return.Status = HttpStatusCode.NotFound;
                    }
                }
                catch (Exception)
                {
                    Return.Status = HttpStatusCode.InternalServerError;
                }
            }
            else
            {
                Return.Status = HttpStatusCode.Forbidden;
            }
        }
示例#25
0
        /// <summary>
        /// Gets property data for a given Node and returns it in our WCF object format
        /// <returns>All visible non-UI-specific properties on the Node's Edit layout for which the current user has view permissions</returns>
        /// </summary>
        public CswNbtWcfPropCollection GetPropertyData(CswNbtNode Node)
        {
            CswNbtWcfPropCollection PropCollection = new CswNbtWcfPropCollection();
            List <Int32>            PropIdsAdded   = new List <Int32>();
            CswNbtMetaDataNodeType  NodeType       = Node.getNodeType();

            foreach (CswNbtMetaDataNodeTypeTab Tab in NodeType.getNodeTypeTabs())
            {
                if (_CswNbtResources.Permit.canTab(CswEnumNbtNodeTypePermission.View, NodeType, Tab))
                {
                    IEnumerable <CswNbtMetaDataNodeTypeProp> Props = _CswNbtResources.MetaData.NodeTypeLayout.getPropsInLayout(Node.NodeTypeId, Tab.TabId, CswEnumNbtLayoutType.Edit);
                    foreach (CswNbtMetaDataNodeTypeProp Prop in Props)
                    {
                        if (false == PropIdsAdded.Contains(Prop.PropId) &&            //Don't grab the same prop more than once
                            Prop.getFieldTypeValue() != CswEnumNbtFieldType.Button && //Exclude these prop types
                            Prop.getFieldTypeValue() != CswEnumNbtFieldType.Password &&
                            false == Prop.Hidden)                                     //Don't grab hidden props
                        {
                            CswNbtWcfProperty WCFProp = new CswNbtWcfProperty
                            {
                                PropId           = Prop.PropId.ToString(),
                                PropName         = Prop.PropName,
                                OriginalPropName = Prop.getObjectClassPropName()
                            };
                            JObject PropVals = new JObject();
                            Node.Properties[Prop].ToJSON(PropVals);
                            foreach (JProperty OldPropValue in PropVals["values"].Children())
                            {
                                WCFProp.values[OldPropValue.Name] = OldPropValue.Value.ToString();
                            }
                            PropCollection.addProperty(WCFProp);
                            PropIdsAdded.Add(Prop.PropId);
                        }
                    }
                }
            }
            return(PropCollection);
        }
        public static void getBlob(ICswResources CswResources, BlobDataReturn Return, BlobDataParams Request)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            DataTable blobDataTbl;
            int       BlobDataId = CswConvert.ToInt32(Request.Blob.BlobDataId);
            int       PropId     = _getNodeTypePropIdFromJctNodePropId(NbtResources, CswConvert.ToInt32(Request.propid));
            CswNbtMetaDataNodeTypeProp MetaDataProp = NbtResources.MetaData.getNodeTypeProp(PropId);

            if (NbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.View, MetaDataProp.getNodeType(), NbtResources.CurrentNbtUser))
            {
                //Get the file from blob_data
                if (String.IsNullOrEmpty(Request.date))
                {
                    CswTableSelect blobDataSelect = NbtResources.makeCswTableSelect("getBlob", "blob_data");
                    string         whereClause    = "where jctnodepropid = " + Request.propid;
                    if (Int32.MinValue != BlobDataId)
                    {
                        whereClause += " and blobdataid = " + Request.Blob.BlobDataId;
                    }
                    blobDataTbl = blobDataSelect.getTable(whereClause);
                }
                else //get the audited record
                {
                    int jctnodepropid = CswConvert.ToInt32(Request.propid);
                    CswArbitrarySelect blobDataAuditSelect = CswNbtSdBlobData.GetBlobAuditSelect(NbtResources, Request.date, jctnodepropid, BlobDataId);
                    blobDataTbl = blobDataAuditSelect.getTable();
                }

                foreach (DataRow row in blobDataTbl.Rows)
                {
                    Request.data             = row["blobdata"] as byte[];
                    Request.Blob.FileName    = row["filename"].ToString();
                    Request.Blob.ContentType = row["contenttype"].ToString();
                }

                if (null == Request.data || Request.data.Length == 0)
                {
                    bool UseNTPlaceHolder = CswConvert.ToBoolean(Request.usenodetypeasplaceholder);
                    if (UseNTPlaceHolder)
                    {
                        CswPrimaryKey NodeId = CswConvert.ToPrimaryKey(Request.nodeid);
                        CswNbtNode    Node   = NbtResources.Nodes[NodeId];
                        if (null != Node)
                        {
                            CswNbtMetaDataNodeType NodeType = Node.getNodeType();
                            if (null != NodeType && NodeType.IconFileName != string.Empty)
                            {
                                Request.Blob.FileName    = NodeType.IconFileName;
                                Request.Blob.ContentType = "image/png";
                                Request.data             = File.ReadAllBytes(Request.appPath + CswNbtMetaDataObjectClass.IconPrefix100 + NodeType.IconFileName);
                            }
                        }
                    }
                    else
                    {
                        Request.data             = File.ReadAllBytes(Request.appPath + "/Images/icons/300/_placeholder.gif");
                        Request.Blob.ContentType = "image/gif";
                        Request.Blob.FileName    = "empty.gif";
                    }
                }

                Return.Data = Request;
            } // NbtResources.Permit.canNodeType()
            else
            {
                throw new CswDniException(CswEnumErrorType.Warning, "You do no have sufficient priveledges to fetch this file.", "User " + NbtResources.CurrentNbtUser.UserId + " tried to fetch a file " + PropId + " they do not have permission on.");
            }
        }
        public void displayBlobData(HttpContext Context)
        {
            bool UseNodeTypeAsPlaceHolder = true;

            if (null != Context.Request["usenodetypeasplaceholder"])
            {
                UseNodeTypeAsPlaceHolder = CswConvert.ToBoolean(Context.Request["usenodetypeasplaceholder"]);
            }
            if (null != Context.Request["jctnodepropid"])
            {
                Int32 JctNodePropId = Convert.ToInt32(Context.Request["jctnodepropid"]);
                if (Int32.MinValue != JctNodePropId)
                {
                    CswTableSelect JctSelect = _CswNbtResources.makeCswTableSelect("displayBlobData_select", "jct_nodes_props");
                    JctSelect.AllowBlobColumns = true;
                    CswCommaDelimitedString SelectColumns = new CswCommaDelimitedString();
                    SelectColumns.Add("blobdata");
                    SelectColumns.Add("field2");
                    SelectColumns.Add("field1");
                    SelectColumns.Add("nodeid");
                    DataTable JctTable = JctSelect.getTable(SelectColumns, "jctnodepropid", JctNodePropId, "", true);

                    byte[] BlobData    = null;
                    string FileName    = "empty";
                    string ContentType = "image/gif";
                    if (JctTable.Rows.Count > 0)
                    {
                        Int32 NodeId = CswConvert.ToInt32(JctTable.Rows[0]["nodeid"]);
                        if (false == JctTable.Rows[0].IsNull("blobdata"))
                        {
                            FileName    = JctTable.Rows[0]["field1"].ToString();
                            ContentType = JctTable.Rows[0]["field2"].ToString();
                            BlobData    = JctTable.Rows[0]["blobdata"] as byte[];
                        }
                        else if (UseNodeTypeAsPlaceHolder)
                        {
                            CswNbtNode Node = _CswNbtResources.Nodes[new CswPrimaryKey("nodes", NodeId)];
                            if (null != Node)
                            {
                                CswNbtMetaDataNodeType NodeType = Node.getNodeType();
                                if (null != NodeType && NodeType.IconFileName != string.Empty)
                                {
                                    FileName    = NodeType.IconFileName;
                                    ContentType = "image/png";
                                    BlobData    = File.ReadAllBytes(Context.Request.PhysicalApplicationPath + CswNbtMetaDataObjectClass.IconPrefix100 + NodeType.IconFileName);
                                }
                            }
                        }
                    } // if( JctTable.Rows.Count > 0 )

                    if (FileName == "empty")
                    {
                        BlobData = File.ReadAllBytes(Context.Request.PhysicalApplicationPath + "/Images/icons/300/_placeholder.gif");
                    }

                    MemoryStream mem     = new MemoryStream();
                    BinaryWriter BWriter = new BinaryWriter(mem, System.Text.Encoding.Default);
                    BWriter.Write(BlobData);

                    Context.Response.ClearContent();
                    Context.Response.ContentType = ContentType;
                    Context.Response.BinaryWrite(mem.ToArray());
                    Context.Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName + ";");
                    Context.Response.End();
                }
            }
        }//if we got any result
        public string RecalculateReferenceValue()
        {
            string Value = String.Empty;

            if (RelationshipId > 0 && RelatedPropId > 0)
            {
                CswNbtMetaDataNodeTypeProp RelationshipNTP = _getRelationshipProp();
                if (null != RelationshipNTP)
                {
                    CswPrimaryKey RelatedNodeId = _Node.Properties[RelationshipNTP].AsRelationship.RelatedNodeId;
                    CswNbtNode    RelatedNode   = _CswNbtResources.Nodes[RelatedNodeId];
                    if (null != RelatedNode)
                    {
                        CswNbtMetaDataNodeTypeProp ToReferenceNtp = null;

                        // CIS-52280 - This is a bit of a kludge.
                        // If the relationship is by property set (e.g. Container's Material),
                        // but the property reference is defined by object class, then the valuepropid will be wrong.
                        // We have to look it up by object class property name instead.
                        // See CIS-50822 for a more permanent fix.
                        if (RelationshipNTP.FKType == CswEnumNbtViewRelatedIdType.PropertySetId.ToString())
                        {
                            if (RelatedPropType == CswEnumNbtViewPropIdType.NodeTypePropId)
                            {
                                CswNbtMetaDataNodeTypeProp origRefProp = _CswNbtResources.MetaData.getNodeTypeProp(RelatedPropId);
                                if (null != origRefProp.getObjectClassProp())
                                {
                                    ToReferenceNtp = RelatedNode.getNodeType().getNodeTypePropByObjectClassProp(origRefProp.getObjectClassProp().PropName);
                                }
                                else
                                {
                                    ToReferenceNtp = RelatedNode.getNodeType().getNodeTypeProp(origRefProp.PropName);
                                }
                            }
                            else if (RelatedPropType == CswEnumNbtViewPropIdType.ObjectClassPropId)
                            {
                                CswNbtMetaDataObjectClassProp origRefProp = _CswNbtResources.MetaData.getObjectClassProp(RelatedPropId);
                                ToReferenceNtp = RelatedNode.getNodeType().getNodeTypePropByObjectClassProp(origRefProp.PropName);
                            }
                        }
                        else if (RelatedPropType == CswEnumNbtViewPropIdType.NodeTypePropId)
                        {
                            ToReferenceNtp = _CswNbtResources.MetaData.getNodeTypeProp(RelatedPropId);
                        }
                        else if (RelatedPropType == CswEnumNbtViewPropIdType.ObjectClassPropId)
                        {
                            ToReferenceNtp = RelatedNode.getNodeType().getNodeTypePropByObjectClassProp(RelatedPropId);
                        }

                        if (null != ToReferenceNtp)
                        {
                            Value = RelatedNode.Properties[ToReferenceNtp].Gestalt;
                        }
                    }
                }
            } // if (RelationshipId > 0 && RelatedPropId > 0)

            SetPropRowValue(_CachedValueSubField, Value);
            _setGestalt(Value, Sequence);
            PendingUpdate = false;

            return(Value);
        }
示例#29
0
        public override void setItemDataForUI(DataRow LandingPageRow, LandingPageData.Request Request)
        {
            bool   finishLoading = false; //this will be set to true if and only if there's a valid link to be made
            String DisplayText   = LandingPageRow["displaytext"].ToString();
            Int32  ViewId        = CswConvert.ToInt32(LandingPageRow["to_nodeviewid"]);

            if (ViewId != Int32.MinValue)
            {
                CswNbtViewId NodeViewId = new CswNbtViewId(ViewId);
                CswNbtView   ThisView   = _CswNbtResources.ViewSelect.restoreView(NodeViewId);
                if (null != ThisView && ThisView.IsFullyEnabled() && ThisView.IsVisible())
                {
                    finishLoading  = true;
                    _ItemData.Text = LandingPageRow["displaytext"].ToString() != string.Empty ? LandingPageRow["displaytext"].ToString() : ThisView.ViewName;

                    _ItemData.ViewId   = NodeViewId.ToString();
                    _ItemData.ViewMode = ThisView.ViewMode.ToString().ToLower();
                    if (ThisView.Root.ChildRelationships.Count > 0 && ThisView.Root.ChildRelationships[0] != null)
                    {
                        _ItemData.ButtonIcon = CswNbtMetaDataObjectClass.IconPrefix100 + ThisView.Root.ChildRelationships[0].SecondIconFileName;
                    }
                    _ItemData.Type = "view";
                }
            }
            Int32 ActionId = CswConvert.ToInt32(LandingPageRow["to_actionid"]);

            if (ActionId != Int32.MinValue)
            {
                CswNbtAction ThisAction = _CswNbtResources.Actions[ActionId];
                if (null != ThisAction)
                {
                    if (_CswNbtResources.Permit.can(ThisAction.Name))
                    {
                        finishLoading        = true;
                        _ItemData.Text       = false == String.IsNullOrEmpty(DisplayText) ? DisplayText : CswNbtAction.ActionNameEnumToString(ThisAction.Name);
                        _ItemData.ActionId   = ActionId.ToString();
                        _ItemData.ActionName = ThisAction.Name.ToString();
                        _ItemData.ActionUrl  = ThisAction.Url;
                        _ItemData.ButtonIcon = CswNbtMetaDataObjectClass.IconPrefix100 + ThisAction.IconFileName;
                        _ItemData.Type       = "action";
                    }
                }
            }
            Int32 ReportId = CswConvert.ToInt32(LandingPageRow["to_reportid"]);

            if (ReportId != Int32.MinValue)
            {
                CswPrimaryKey ReportPk       = new CswPrimaryKey("nodes", ReportId);
                CswNbtNode    ThisReportNode = _CswNbtResources.Nodes[ReportPk];
                if (null != ThisReportNode)
                {
                    finishLoading        = true;
                    _ItemData.Text       = false == String.IsNullOrEmpty(DisplayText) ? DisplayText : ThisReportNode.NodeName;
                    _ItemData.ReportId   = ReportPk.ToString();
                    _ItemData.Type       = "report";
                    _ItemData.ButtonIcon = CswNbtMetaDataObjectClass.IconPrefix100 + ThisReportNode.getNodeType().IconFileName;
                }
            }
            Int32 SearchId = CswConvert.ToInt32(LandingPageRow["to_searchid"]);

            if (SearchId != Int32.MinValue)
            {
                CswPrimaryKey SearchPk = new CswPrimaryKey("search", SearchId);
                CswNbtSearch  Search   = _CswNbtResources.SearchManager.restoreSearch(SearchPk);
                if (null != Search)
                {
                    finishLoading        = true;
                    _ItemData.Text       = Search.Name;
                    _ItemData.ReportId   = SearchPk.ToString();
                    _ItemData.Type       = "search";
                    _ItemData.ButtonIcon = CswNbtMetaDataObjectClass.IconPrefix100 + "magglass.png";
                }
            }

            //we only want to send the item back with a landingpageid if it contains a valid link
            if (finishLoading)
            {
                _setCommonItemDataForUI(LandingPageRow);
            }
        }
示例#30
0
        public void delete(CswNbtNode Node)
        {
            //Case 31416 - Delete any blob_data associated with this nodes properties
            CswCommaDelimitedString DoomedBlobData = new CswCommaDelimitedString();

            foreach (CswNbtNodePropWrapper BlobProp in Node.Properties.Where(P => P.IsBlobProp()))
            {
                DoomedBlobData.Add(BlobProp.JctNodePropId.ToString());
            }
            CswTableUpdate CswTableUpdateBlobData = _CswNbtResources.makeCswTableUpdate("deletenode_blobdata", "blob_data");

            if (DoomedBlobData.Count > 0)
            {
                DataTable BlobData = CswTableUpdateBlobData.getTable("where jctnodepropid in (" + DoomedBlobData + ")");
                foreach (DataRow BlobRow in BlobData.Rows)
                {
                    BlobRow.Delete();
                }
                CswTableUpdateBlobData.update(BlobData);
            }

            // Delete this node's property values
            CswTableUpdate CswTableUpdateJct = _CswNbtResources.makeCswTableUpdate("deletenode_update", "jct_nodes_props");
            DataTable      JctTable          = CswTableUpdateJct.getTable(" where nodeid=" + Node.NodeId.PrimaryKey.ToString());

            foreach (DataRow Row in JctTable.Rows)
            {
                Row.Delete();
            }
            CswTableUpdateJct.update(JctTable);

            // Delete property values of relationships to this node
            if (Node.NodeId.TableName != "nodes")
            {
                throw new CswDniException(CswEnumErrorType.Error, "Internal System Error", "CswNbtNodeWriterNative.delete() called on a non-native node");
            }

            // From getRelationshipsToNode.  see case 27711
            string InClause = @"select j.jctnodepropid
                                      from jct_nodes_props j
                                      join nodes n on j.nodeid = n.nodeid
                                      join nodetype_props p on j.nodetypepropid = p.nodetypepropid
                                      join field_types f on p.fieldtypeid = f.fieldtypeid
                                     where (f.fieldtype = 'Relationship' or f.fieldtype = 'Location')
                                       and j.field1_fk = " + Node.NodeId.PrimaryKey.ToString();

            DataTable RelatedJctTable = CswTableUpdateJct.getTable(" where jctnodepropid in (" + InClause + ")");

            foreach (DataRow Row in RelatedJctTable.Rows)
            {
                Row.Delete();
            }
            CswTableUpdateJct.update(RelatedJctTable);

            // Delete the node

            DataTable NodesTable = CswTableUpdateNodes.getTable("nodeid", Node.NodeId.PrimaryKey, true);

            NodesTable.Rows[0].Delete();
            CswTableUpdateNodes.update(NodesTable);


            // case 29311 - Sync with relational data
            if (Node.getNodeType().DoRelationalSync)
            {
                _CswNbtNodeWriterRelationalDb.delete(Node);
            }
        }//delete()