Ejemplo n.º 1
0
        }//Update()

        /// <summary>
        /// Helper method to determine if a view property exists with a given filter. Returns the view property if it exists.
        /// </summary>
        /// <param name="filterExists">If the filter exists</param>
        /// <param name="viewPropExists">If the given prop is in the view</param>
        /// <param name="view">The view to check</param>
        /// <param name="prop">The property to check</param>
        /// <returns>The view property (null if the prop doesn't exist)</returns>
        private CswNbtViewProperty _viewPropAndFilterExists( out bool filterExists,
            out bool viewPropExists,
            CswNbtView view,
            CswNbtMetaDataObjectClassProp prop,
            CswNbtPropFilterSql.PropertyFilterMode
            filterMode,
            string value )
        {
            CswNbtViewProperty ret = null;
            filterExists = false;
            viewPropExists = false;
            foreach( CswNbtViewProperty viewProp in view.getOrderedViewProps( false ) )
            {
                foreach( CswNbtViewPropertyFilter existingFilter in viewProp.Filters )
                {
                    if( viewProp.ObjectClassPropId.Equals( prop.ObjectClassPropId ) )
                    {
                        viewPropExists = true;
                        if( existingFilter.FilterMode.Equals( filterMode ) &&
                            existingFilter.Value.Equals( value ) )
                        {
                            filterExists = true;
                            ret = viewProp;
                        }
                    }
                }
            }
            return ret;
        }
        public override void update()
        {

            CswNbtMetaDataObjectClass materialOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.MaterialClass );
            foreach( CswNbtMetaDataNodeType materialNT in materialOC.getNodeTypes() )
            {
                CswNbtMetaDataNodeTypeProp documentNTP = materialNT.getNodeTypeProp( "Documents" );
                if( null != documentNTP )
                {
                    CswNbtView documentsPropView = _CswNbtSchemaModTrnsctn.restoreView( documentNTP.ViewId );
                    foreach( CswNbtViewProperty viewProp in documentsPropView.getOrderedViewProps( true ) )
                    {
                        if( viewProp.Name.Equals( CswNbtObjClassDocument.PropertyName.Archived ) )
                        {
                            documentsPropView.AddViewPropertyFilter( viewProp,
                                Conjunction: CswNbtPropFilterSql.PropertyFilterConjunction.Or,
                                SubFieldName: CswNbtSubField.SubFieldName.Checked,
                                FilterMode: CswNbtPropFilterSql.PropertyFilterMode.Equals,
                                Value: CswConvert.ToDbVal( true ).ToString()
                            );
                        }
                    }
                    documentsPropView.save();

                } // if( null != documentNTP )
            } //foreach( CswNbtMetaDataNodeType materialNT in materialOC.getNodeTypes() )

        } //Update()
Ejemplo n.º 3
0
        public override void update()
        {

            //get all views and find the dispense requests view
            DataTable Views = _CswNbtSchemaModTrnsctn.ViewSelect.getAllViews();
            CswNbtViewId dispenseRequestsViewId = new CswNbtViewId();
            foreach( DataRow row in Views.Rows )
            {
                if( row["viewname"].Equals( "Dispense Requests: Open" ) )
                {
                    dispenseRequestsViewId.set( CswConvert.ToInt32( row["nodeviewid"] ) );
                }
            }

            /*
             * The dispense requests view is broken. It has THREE 'Status' properties, each with different filters
             */

            if( dispenseRequestsViewId.isSet() )
            {
                CswNbtView DispenseRequestsView = _CswNbtSchemaModTrnsctn.ViewSelect.restoreView( dispenseRequestsViewId );
                LinkedList<CswNbtViewProperty> viewProps = DispenseRequestsView.getOrderedViewProps( false );
                CswNbtViewRelationship parent = null;
                foreach( CswNbtViewProperty viewProp in viewProps ) //delete the 3 duplicate 'Status' view props from this view
                {
                    if( viewProp.Name.Equals( "Status" ) )
                    {
                        DispenseRequestsView.removeViewProperty( viewProp.MetaDataProp );
                    }
                    else
                    {
                        parent = (CswNbtViewRelationship) viewProp.Parent; //get the view parent to add the Status prop later (in this specific case this get the root)
                    }
                }

                //add the property to the view ONCE
                CswNbtMetaDataObjectClass requestItemOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.RequestItemClass );
                CswNbtViewProperty statusVP = DispenseRequestsView.AddViewProperty( parent, requestItemOC.getObjectClassProp( CswNbtObjClassRequestItem.PropertyName.Status ) );

                //now add the filters
                DispenseRequestsView.AddViewPropertyFilter( statusVP, FilterMode: CswNbtPropFilterSql.PropertyFilterMode.NotEquals, Value: "Completed" );
                DispenseRequestsView.AddViewPropertyFilter( statusVP, FilterMode: CswNbtPropFilterSql.PropertyFilterMode.NotEquals, Value: "Cancelled" );

                DispenseRequestsView.save();
            }

        }//Update()
Ejemplo n.º 4
0
        public override void update()
        {

            CswNbtMetaDataNodeType containerNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Container" );
            if( null != containerNT )
            {
                CswNbtMetaDataNodeTypeProp docsNTP = containerNT.getNodeTypeProp( "Documents" );
                if( null != docsNTP )
                {
                    CswNbtView docsView = _CswNbtSchemaModTrnsctn.ViewSelect.restoreView( docsNTP.ViewId );
                    foreach( CswNbtViewProperty viewProp in docsView.getOrderedViewProps( false ) )
                    {
                        if( viewProp.Name.Equals( "Disposed" ) && viewProp.Filters.Count > 0 )
                        {
                            viewProp.removeFilter( (CswNbtViewPropertyFilter) viewProp.Filters[0] );
                            docsView.save();
                        }
                    }
                }
            }

        }//Update()
Ejemplo n.º 5
0
        } // _getUniquePrefix()

        public JObject TreeToJson(string Title, CswNbtView View, ICswNbtTree Tree, bool IsPropertyGrid = false, string GroupByCol = "")
        {
            JObject Ret = new JObject();

            if (null != View)
            {
                string gridUniquePrefix = _getUniquePrefix(View);

                CswExtJsGrid grid = new CswExtJsGrid(gridUniquePrefix);
                if (string.IsNullOrEmpty(GroupByCol))
                {
                    GroupByCol = View.GridGroupByCol;
                }
                grid.groupfield = GroupByCol;
                grid.title      = Title;
                if (_CswNbtResources.CurrentNbtUser != null && _CswNbtResources.CurrentNbtUser.PageSize > 0)
                {
                    grid.PageSize = _CswNbtResources.CurrentNbtUser.PageSize;
                }

                if (IsPropertyGrid && Tree.getChildNodeCount() > 0)
                {
                    Tree.goToNthChild(0);
                }

                grid.Truncated = Tree.getCurrentNodeChildrenTruncated();

                CswExtJsGridDataIndex nodeIdDataIndex = new CswExtJsGridDataIndex(gridUniquePrefix, "nodeId");
                {
                    CswExtJsGridField nodeIdFld = new CswExtJsGridField {
                        dataIndex = nodeIdDataIndex
                    };
                    grid.fields.Add(nodeIdFld);
                    CswExtJsGridColumn nodeIdCol = new CswExtJsGridColumn {
                        header = "Internal ID", dataIndex = nodeIdDataIndex, hidden = true
                    };
                    grid.columns.Add(nodeIdCol);
                }
                CswExtJsGridDataIndex nodekeyDataIndex = new CswExtJsGridDataIndex(gridUniquePrefix, "nodekey");
                {
                    CswExtJsGridField nodekeyFld = new CswExtJsGridField {
                        dataIndex = nodekeyDataIndex
                    };
                    grid.fields.Add(nodekeyFld);
                    CswExtJsGridColumn nodekeyCol = new CswExtJsGridColumn {
                        header = "Internal Key", dataIndex = nodekeyDataIndex, hidden = true
                    };
                    grid.columns.Add(nodekeyCol);
                }
                CswExtJsGridDataIndex nodenameDataIndex = new CswExtJsGridDataIndex(gridUniquePrefix, "nodename");
                {
                    CswExtJsGridField nodenameFld = new CswExtJsGridField {
                        dataIndex = nodenameDataIndex
                    };
                    grid.fields.Add(nodenameFld);
                    CswExtJsGridColumn nodenameCol = new CswExtJsGridColumn {
                        header = "Internal Name", dataIndex = nodenameDataIndex, hidden = true
                    };
                    grid.columns.Add(nodenameCol);
                }
                CswExtJsGridDataIndex NodeTypeDataIndex = new CswExtJsGridDataIndex(gridUniquePrefix, "nodetypeid");
                {
                    CswExtJsGridField NodeTypeField = new CswExtJsGridField {
                        dataIndex = NodeTypeDataIndex
                    };
                    grid.fields.Add(NodeTypeField);
                    CswExtJsGridColumn NodeTypeColumn = new CswExtJsGridColumn {
                        header = "Internal Type ID", dataIndex = NodeTypeDataIndex, hidden = true
                    };
                    grid.columns.Add(NodeTypeColumn);
                }
                CswExtJsGridDataIndex ObjectClassDataIndex = new CswExtJsGridDataIndex(gridUniquePrefix, "objectclassid");
                {
                    CswExtJsGridField ObjectClassField = new CswExtJsGridField {
                        dataIndex = ObjectClassDataIndex
                    };
                    grid.fields.Add(ObjectClassField);
                    CswExtJsGridColumn ObjectClassColumn = new CswExtJsGridColumn {
                        header = "Internal Parent Type ID", dataIndex = ObjectClassDataIndex, hidden = true
                    };
                    grid.columns.Add(ObjectClassColumn);
                }
                // View Properties determine Columns and Fields
                foreach (CswNbtViewProperty ViewProp in View.getOrderedViewProps(true))
                {
                    if (null != ViewProp)
                    {
                        ICswNbtMetaDataProp MetaDataProp = null;
                        if (ViewProp.Type == CswEnumNbtViewPropType.NodeTypePropId)
                        {
                            MetaDataProp = ViewProp.NodeTypeProp;
                        }
                        else if (ViewProp.Type == CswEnumNbtViewPropType.ObjectClassPropId)
                        {
                            MetaDataProp = ViewProp.ObjectClassProp;
                        }

                        // Because properties in the view might be by object class, but properties on the tree will always be by nodetype,
                        // we have to use name, not id, as the dataIndex
                        if (null != MetaDataProp)
                        {
                            string header = MetaDataProp.PropNameWithQuestionNo;
                            CswExtJsGridDataIndex dataIndex = new CswExtJsGridDataIndex(gridUniquePrefix, MetaDataProp.PropName);   // don't use PropNameWithQuestionNo here, because it won't match the propname from the tree

                            // Potential bug here!
                            // If the same property is added to the view more than once, we'll only use the grid definition for the first instance
                            if (false == grid.columnsContains(header))
                            {
                                CswExtJsGridField fld = new CswExtJsGridField {
                                    dataIndex = dataIndex
                                };
                                CswExtJsGridColumn col = new CswExtJsGridColumn {
                                    header = header, dataIndex = dataIndex, hidden = (false == ViewProp.ShowInGrid)
                                };
                                switch (ViewProp.FieldType)
                                {
                                case CswEnumNbtFieldType.Button:
                                    col.MenuDisabled = true;
                                    col.IsSortable   = false;
                                    break;

                                case CswEnumNbtFieldType.Number:
                                    fld.type  = "number";
                                    col.xtype = CswEnumExtJsXType.numbercolumn;
                                    break;

                                case CswEnumNbtFieldType.DateTime:
                                    fld.type  = "date";
                                    col.xtype = CswEnumExtJsXType.datecolumn;

                                    // case 26782 - Set dateformat as client date format
                                    string dateformat      = string.Empty;
                                    string DateDisplayMode = CswEnumNbtDateDisplayMode.Date.ToString();
                                    if (ViewProp.Type == CswEnumNbtViewPropType.NodeTypePropId && ViewProp.NodeTypeProp != null)
                                    {
                                        DateDisplayMode = ViewProp.NodeTypeProp.DesignNode.getAttributeValueByName(CswNbtFieldTypeRuleDateTime.AttributeName.DateType);
                                    }
                                    else if (ViewProp.Type == CswEnumNbtViewPropType.ObjectClassPropId && ViewProp.ObjectClassProp != null)
                                    {
                                        DateDisplayMode = ViewProp.ObjectClassProp.Extended;
                                    }
                                    if (DateDisplayMode == string.Empty ||
                                        DateDisplayMode == CswEnumNbtDateDisplayMode.Date.ToString() ||
                                        DateDisplayMode == CswEnumNbtDateDisplayMode.DateTime.ToString())
                                    {
                                        dateformat += CswTools.ConvertNetToPHP(_CswNbtResources.CurrentNbtUser.DateFormat);
                                        if (DateDisplayMode == CswEnumNbtDateDisplayMode.DateTime.ToString())
                                        {
                                            dateformat += " ";
                                        }
                                    }
                                    if (DateDisplayMode == CswEnumNbtDateDisplayMode.Time.ToString() ||
                                        DateDisplayMode == CswEnumNbtDateDisplayMode.DateTime.ToString())
                                    {
                                        dateformat += CswTools.ConvertNetToPHP(_CswNbtResources.CurrentNbtUser.TimeFormat);
                                    }
                                    col.dateformat = dateformat;
                                    break;
                                }
                                if (ViewProp.Width > 0)
                                {
                                    col.width = ViewProp.Width * 7; // approx. characters to pixels
                                }
                                grid.columns.Add(col);
                                grid.fields.Add(fld);
                            } // if( false == grid.columnsContains( header ) )
                        }     // if(null != MetaDataProp )
                    }         // if( ViewProp != null )
                }             // foreach( CswNbtViewProperty ViewProp in View.getOrderedViewProps() )

                // Nodes in the Tree determine Rows
                for (Int32 c = 0; c < Tree.getChildNodeCount(); c++)
                {
                    CswExtJsGridRow gridrow = new CswExtJsGridRow(c, gridUniquePrefix);
                    Tree.goToNthChild(c);

                    CswNbtTreeNode TreeNode = Tree.getCurrentTreeNode();

                    gridrow.data.Add(nodeIdDataIndex, Tree.getNodeIdForCurrentPosition().ToString());
                    gridrow.data.Add(nodekeyDataIndex, Tree.getNodeKeyForCurrentPosition().ToString());
                    gridrow.data.Add(nodenameDataIndex, Tree.getNodeNameForCurrentPosition().ToString());
                    gridrow.data.Add(NodeTypeDataIndex, TreeNode.NodeTypeId.ToString());
                    gridrow.data.Add(ObjectClassDataIndex, TreeNode.ObjectClassId.ToString());

                    CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(Tree.getNodeKeyForCurrentPosition().NodeTypeId);

                    gridrow.canView = _CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.View, NodeType) &&
                                      _CswNbtResources.Permit.isNodeWritable(CswEnumNbtNodeTypePermission.View, NodeType, Tree.getNodeIdForCurrentPosition());
                    gridrow.canEdit = (_CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Edit, NodeType) &&
                                       (_CswNbtResources.CurrentNbtUser.IsAdministrator() ||
                                        _CswNbtResources.Permit.isNodeWritable(CswEnumNbtNodeTypePermission.Edit,
                                                                               NodeType,
                                                                               NodeId: Tree.getNodeIdForCurrentPosition())) &&
                                       false == Tree.getNodeLockedForCurrentPosition());

                    gridrow.canDelete = (_CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Delete,
                                                                             NodeType) &&
                                         _CswNbtResources.Permit.isNodeWritable(CswEnumNbtNodeTypePermission.Delete,
                                                                                NodeType,
                                                                                NodeId: Tree.getNodeIdForCurrentPosition())
                                         );
                    gridrow.isLocked   = Tree.getNodeLockedForCurrentPosition();
                    gridrow.isDisabled = (false == Tree.getNodeIncludedForCurrentPosition());
                    if (null != _CswNbtResources.CurrentNbtUser)
                    {
                        gridrow.isFavorite = Tree.getNodeFavoritedForCurrentPosition();
                    }

                    _TreeNodeToGrid(View, Tree, grid, gridrow);

                    Tree.goToParentNode();
                    grid.rowData.rows.Add(gridrow);
                }
                Ret = grid.ToJson();
            }
            return(Ret);
        } // TreeToJson()