Example #1
0
        public override void update()
        {

            CswNbtMetaDataObjectClass MailReportOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.MailReportClass );
            foreach( CswNbtMetaDataNodeType MailReportNT in MailReportOC.getNodeTypes() )
            {
                // remove 'Nodes to Report' from all layouts
                CswNbtMetaDataNodeTypeProp NodesToReportNTP = MailReportNT.getNodeTypePropByObjectClassProp( CswNbtObjClassMailReport.PropertyName.NodesToReport );
                _CswNbtSchemaModTrnsctn.MetaData.NodeTypeLayout.removePropFromAllLayouts( NodesToReportNTP );

                // remove Run Status from Add layout
                CswNbtMetaDataNodeTypeProp RunStatusNTP = MailReportNT.getNodeTypePropByObjectClassProp( CswNbtObjClassMailReport.PropertyName.RunStatus );
                RunStatusNTP.removeFromLayout( CswNbtMetaDataNodeTypeLayoutMgr.LayoutType.Add );

                // set Target Type and Event to be conditional on Type = View
                CswNbtMetaDataNodeTypeProp TypeNTP = MailReportNT.getNodeTypePropByObjectClassProp( CswNbtObjClassMailReport.PropertyName.Type );
                CswNbtMetaDataNodeTypeProp TargetTypeNTP = MailReportNT.getNodeTypePropByObjectClassProp( CswNbtObjClassMailReport.PropertyName.TargetType );
                CswNbtMetaDataNodeTypeProp EventNTP = MailReportNT.getNodeTypePropByObjectClassProp( CswNbtObjClassMailReport.PropertyName.Event );
                TargetTypeNTP.setFilter( TypeNTP, TypeNTP.getFieldTypeRule().SubFields.Default, CswNbtPropFilterSql.PropertyFilterMode.Equals, CswNbtObjClassMailReport.TypeOptionView );
                EventNTP.setFilter( TypeNTP, TypeNTP.getFieldTypeRule().SubFields.Default, CswNbtPropFilterSql.PropertyFilterMode.Equals, CswNbtObjClassMailReport.TypeOptionView );

                // add help text to Report View
                CswNbtMetaDataNodeTypeProp ReportViewNTP = MailReportNT.getNodeTypePropByObjectClassProp( CswNbtObjClassMailReport.PropertyName.ReportView );
                ReportViewNTP.HelpText = "For 'Exists' events, a report is generated if the view returns any results that match the Target Type.  For 'Edit' events, a report is only generated if one of the properties in the view was modified.";

                // set target type and event for existing mail reports
                foreach( CswNbtObjClassMailReport MailReportNode in MailReportNT.getNodes( false, true ) )
                {
                    if( CswNbtObjClassMailReport.TypeOptionView == MailReportNode.Type.Value &&
                        0 == MailReportNode.TargetType.SelectedNodeTypeIds.Count )
                    {
                        CswNbtView View = _CswNbtSchemaModTrnsctn.restoreView( MailReportNode.ReportView.ViewId );
                        if( View.Root.ChildRelationships.Count > 0 )
                        {
                            CswNbtViewRelationship RootRel = View.Root.ChildRelationships[0];
                            if( RootRel.SecondType == NbtViewRelatedIdType.NodeTypeId )
                            {
                                MailReportNode.TargetType.SelectedNodeTypeIds.Add( RootRel.SecondId.ToString() );
                            }
                            else
                            {
                                CswNbtMetaDataObjectClass RootOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( RootRel.SecondId.ToString() );
                                if( null != RootOC.FirstNodeType )
                                {
                                    MailReportNode.TargetType.SelectedNodeTypeIds.Add( RootOC.FirstNodeType.NodeTypeId.ToString() );
                                }
                            }
                        }
                    }

                    if( MailReportNode.Event.Empty )
                    {
                        MailReportNode.Event.Value = CswNbtObjClassMailReport.EventOption.Exists.ToString();
                    }
                    MailReportNode.postChanges( false );

                } // foreach( CswNbtObjClassMailReport MailReportNode in MailReportNT.getNodes( false, true ) )
            } // foreach( CswNbtMetaDataNodeType MailReportNT in MailReportOC.getNodeTypes() )

        }//Update()
Example #2
0
        internal void SetPPENodeTypeProp(string ListOptions, string Delimiter = ",", int HideThreshold = 5)
        {
            CswNbtMetaDataNodeType ChemicalNT = _CswNbtResources.MetaData.getNodeType("Chemical");

            if (ChemicalNT != null)
            {
                CswNbtMetaDataNodeTypeProp PPENTP = _CswNbtResources.MetaData.getNodeTypeProp(ChemicalNT.NodeTypeId, "PPE");
                if (PPENTP != null)
                {
                    _ChangedNodeTypePropListOptions.Add(PPENTP.PropId, ListOptions);
                    _ChangedNodeTypePropExtended.Add(PPENTP.PropId, Delimiter);
                    _ChangedNodeTypePropMaxValue.Add(PPENTP.PropId, HideThreshold);
                    //PPENTP.ListOptions = ListOptions;
                    //PPENTP.Extended = Delimiter;
                    //PPENTP.MaxValue = HideThreshold;
                    CswNbtFieldTypeAttribute ListOptionsAttr = PPENTP.getFieldTypeRule().getAttributes().FirstOrDefault(a => a.Column == CswEnumNbtPropertyAttributeColumn.Listoptions);
                    CswNbtFieldTypeAttribute ExtendedAttr    = PPENTP.getFieldTypeRule().getAttributes().FirstOrDefault(a => a.Column == CswEnumNbtPropertyAttributeColumn.Extended);
                    CswNbtFieldTypeAttribute MaxValueAttr    = PPENTP.getFieldTypeRule().getAttributes().FirstOrDefault(a => a.Column == CswEnumNbtPropertyAttributeColumn.Numbermaxvalue);
                    PPENTP.DesignNode.AttributeProperty[ListOptionsAttr.Name].SetSubFieldValue(ListOptionsAttr.SubFieldName, ListOptions);
                    PPENTP.DesignNode.AttributeProperty[ExtendedAttr.Name].SetSubFieldValue(ExtendedAttr.SubFieldName, Delimiter);
                    PPENTP.DesignNode.AttributeProperty[MaxValueAttr.Name].SetSubFieldValue(MaxValueAttr.SubFieldName, HideThreshold);
                    PPENTP.DesignNode.postChanges(false);
                }
            }
        }
 public override void update()
 {
     //New Document NT
     CswNbtMetaDataObjectClass ReceiptLotOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.ReceiptLotClass );
     CswNbtMetaDataObjectClass CofADocOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.CofADocumentClass );
     CswNbtMetaDataNodeType CofANT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "C of A Document" ) ??
          _CswNbtSchemaModTrnsctn.MetaData.makeNewNodeTypeDeprecated( CofADocOC.ObjectClassId, "C of A Document", "Materials" );
     _CswNbtSchemaModTrnsctn.createModuleNodeTypeJunction( CswEnumNbtModuleName.CofA, CofANT.NodeTypeId );
     //Default Title
     CswNbtMetaDataNodeTypeProp TitleNTP = CofANT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.Title );
     TitleNTP.DefaultValue.AsText.Text = "Certificate of Analysis";
     TitleNTP.removeFromLayout( CswEnumNbtLayoutType.Add );
     //Set Owner FK to ReceiptLot OC (This needs to be done explicitly for the NTP - see Case 26605)
     CswNbtMetaDataNodeTypeProp OwnerNTP = CofANT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.Owner );
     OwnerNTP.PropName = "Receipt Lot";
     OwnerNTP.SetFK( CswEnumNbtViewRelatedIdType.ObjectClassId.ToString(), ReceiptLotOC.ObjectClassId );
     //Set Prop Filters (This needs to be done explicitly for the NTP - see Case 26605)
     CswNbtMetaDataNodeTypeProp FileTypeNTP = CofANT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.FileType );
     CswNbtMetaDataNodeTypeProp FileNTP = CofANT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.File );
     FileNTP.setFilter( FileTypeNTP, FileTypeNTP.getFieldTypeRule().SubFields.Default, CswEnumNbtFilterMode.Equals, CswNbtPropertySetDocument.CswEnumDocumentFileTypes.File );
     CswNbtMetaDataNodeTypeProp LinkNTP = CofANT.getNodeTypePropByObjectClassProp( CswNbtObjClassDocument.PropertyName.Link );
     LinkNTP.setFilter( FileTypeNTP, FileTypeNTP.getFieldTypeRule().SubFields.Default, CswEnumNbtFilterMode.Equals, CswNbtPropertySetDocument.CswEnumDocumentFileTypes.Link );
     //NT Permission
     CswNbtObjClassRole RoleNode = _CswNbtSchemaModTrnsctn.Nodes.makeRoleNodeFromRoleName( "CISPro_Admin" );
     if( null != RoleNode )
     {
         _CswNbtSchemaModTrnsctn.Permit.set( NTPermissions, CofANT, RoleNode, true );
     }
 } // update()
Example #4
0
        } // getBulkEditProperties()

        public static void DownloadBulkEditData(ICswResources CswResources, BulkEditDownload ret, BulkEditParams Params)
        {
            CswNbtResources        NbtResources = (CswNbtResources)CswResources;
            CswNbtMetaDataNodeType NodeType     = NbtResources.MetaData.getNodeType(Params.NodeTypeId);

            if (null != NodeType)
            {
                ret.CsvData = new DataTable();
                ret.CsvData.Columns.Add("nodeid");
                foreach (Int32 PropId in Params.PropIds)
                {
                    CswNbtMetaDataNodeTypeProp Prop = NodeType.getNodeTypeProp(PropId);
                    if (Prop.getFieldTypeRule().SubFields.Count > 1)
                    {
                        foreach (CswNbtSubField SubField in Prop.getFieldTypeRule().SubFields)
                        {
                            ret.CsvData.Columns.Add(Prop.PropName + " " + SubField.Name);
                        }
                    }
                    else
                    {
                        ret.CsvData.Columns.Add(Prop.PropName);
                    }
                }

                CswNbtView  View = NbtResources.ViewSelect.restoreView(new CswNbtViewId(Params.ViewId));
                ICswNbtTree Tree = NbtResources.Trees.getTreeFromView(View, RequireViewPermissions: true, IncludeSystemNodes: false, IncludeHiddenNodes: false);
                _recurseBulkEditData(NodeType, Tree, ret, Params);
            }
        } // DownloadBulkEditData()
Example #5
0
        /// <summary>
        /// Add new Binding entries to a definition (for use by CswNbtImporter)
        /// </summary>
        public static void addBindingEntries(CswNbtResources CswNbtResources, DataTable BindingsDataTable)
        {
            CswTableUpdate importBindingsUpdate = CswNbtResources.makeCswTableUpdate("storeDefinition_Bindings_update", CswNbtImportTables.ImportDefBindings.TableName);

            foreach (DataRow BindingRow in BindingsDataTable.Select())
            {
                //set blank instances to min value
                if (BindingRow["instance"] == DBNull.Value || String.IsNullOrEmpty(BindingRow["instance"].ToString()))
                {
                    BindingRow["instance"] = Int32.MinValue;
                }

                CswNbtMetaDataNodeType     DestNodeType = null;
                CswNbtMetaDataNodeTypeProp DestProp     = null;

                string DestNTName  = BindingRow["destnodetypename"].ToString();
                string DestNTPName = BindingRow["destpropname"].ToString();
                DestNodeType = CswNbtResources.MetaData.getNodeType(DestNTName);

                if (DestNTPName == "Legacy Id")
                {
                    BindingRow["destsubfield"] = "";
                }
                else
                {
                    DestProp = DestNodeType.getNodeTypeProp(DestNTPName);
                    if (null == DestNodeType)
                    {
                        throw new CswDniException(CswEnumErrorType.Error, "Error reading bindings", "Invalid destnodetype defined in 'Bindings' sheet: " + DestNTName);
                    }
                    else if (null == DestProp)
                    {
                        throw new CswDniException(CswEnumErrorType.Error, "Error reading bindings", "Invalid destproperty defined in 'Bindings' sheet: " + BindingRow["destpropname"].ToString() + " (nodetype: " + DestNTName + ")");
                    }
                    else
                    {
                        string DestSubFieldStr = BindingRow["destsubfield"].ToString();
                        if (DestSubFieldStr != CswEnumNbtSubFieldName.Blob.ToString())
                        {
                            CswNbtSubField DestSubfield = DestProp.getFieldTypeRule().SubFields[(CswEnumNbtSubFieldName)BindingRow["destsubfield"].ToString()];
                            if (DestSubfield == null)
                            {
                                DestSubfield    = DestProp.getFieldTypeRule().SubFields.Default;
                                DestSubFieldStr = DestSubfield.Name.ToString();
                            }
                        }
                        BindingRow["destsubfield"] = DestSubFieldStr;
                    } // else -- (when DestNodeType and DestProp are defined)
                }
            }         // foreach( DataRow BindingRow in BindingsDataTable.Rows )

            //this is a hack, and the fact that we can even do this makes me sad
            importBindingsUpdate._DoledOutTables.Add(BindingsDataTable);
            importBindingsUpdate.update(BindingsDataTable);
        } // addBindingEntries()
Example #6
0
        /// <summary>
        /// Returns the original value of the default subfield for this property
        /// </summary>
        public string GetOriginalPropRowValue()
        {
            string ret = string.Empty;
            ICswNbtFieldTypeRule FieldTypeRule = _CswNbtMetaDataNodeTypeProp.getFieldTypeRule();

            if (FieldTypeRule != null)
            {
                ret = GetOriginalPropRowValue(FieldTypeRule.SubFields.Default.Column);
            }
            return(ret);
        }
        /// <summary>
        /// Update logic
        /// </summary>
        public override void update()
        {

            CswNbtMetaDataNodeType materialDocumentNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Material Document" );
            CswNbtMetaDataNodeTypeProp documentClassNTP = materialDocumentNT.getNodeTypeProp( "Document Class" );
            if( null != materialDocumentNT && null != documentClassNTP )
            {
                CswNbtMetaDataNodeTypeTab materialDocumentNTT = materialDocumentNT.getFirstNodeTypeTab();
                if( null != materialDocumentNTT )
                {
                    CswNbtMetaDataNodeTypeProp issueDateNTP = _CswNbtSchemaModTrnsctn.MetaData.makeNewProp( materialDocumentNT, CswNbtMetaDataFieldType.NbtFieldType.DateTime, "Issue Date", materialDocumentNTT.TabId );

                    issueDateNTP.setFilter( documentClassNTP, documentClassNTP.getFieldTypeRule().SubFields.Default, CswNbtPropFilterSql.PropertyFilterMode.Equals, CswNbtObjClassDocument.DocumentClasses.MSDS );

                    _CswNbtSchemaModTrnsctn.MetaData.NodeTypeLayout.updatePropLayout(
                        CswNbtMetaDataNodeTypeLayoutMgr.LayoutType.Add,
                        materialDocumentNT.NodeTypeId,
                        issueDateNTP.PropId,
                        true,
                        materialDocumentNTT.TabId );

                    _CswNbtSchemaModTrnsctn.MetaData.NodeTypeLayout.updatePropLayout(
                        CswNbtMetaDataNodeTypeLayoutMgr.LayoutType.Edit,
                        materialDocumentNT.NodeTypeId,
                        issueDateNTP.PropId,
                        true,
                        materialDocumentNTT.TabId );
                }
            }

        }
        } // update()


        private void _addJctRow( DataTable JctTable, CswNbtMetaDataNodeTypeProp Prop, string TableName, string ColumnName, CswEnumNbtSubFieldName SubFieldName = null )
        {
            _CswNbtSchemaModTrnsctn.CswDataDictionary.setCurrentColumn( TableName, ColumnName );
            DataRow NodeTypeNameRow = JctTable.NewRow();
            NodeTypeNameRow["nodetypepropid"] = Prop.PropId;
            NodeTypeNameRow["datadictionaryid"] = _CswNbtSchemaModTrnsctn.CswDataDictionary.TableColId;
            if( null != SubFieldName )
            {
                NodeTypeNameRow["subfieldname"] = SubFieldName.ToString();
            }
            else if( null != Prop.getFieldTypeRule().SubFields.Default )
            {
                NodeTypeNameRow["subfieldname"] = Prop.getFieldTypeRule().SubFields.Default.Name;
            }
            JctTable.Rows.Add( NodeTypeNameRow );
        }
Example #9
0
        public CswViewBuilderProp(CswNbtMetaDataNodeTypeProp NodeTypeProp)
        {
            CswNbtMetaDataNodeType nt = NodeTypeProp.getNodeType();

            if (null != nt)
            {
                OwnerName = nt.NodeTypeName;
            }
            FieldType = NodeTypeProp.getFieldTypeValue();
            //ListOptions.FromString( NodeTypeProp.ListOptions );
            ListOptions.FromString(NodeTypeProp.DesignNode.AttributeProperty[CswEnumNbtPropertyAttributeName.Options].AsText.Text);
            RelatedIdType = CswEnumNbtViewRelatedIdType.NodeTypeId;
            MetaDataPropNameWithQuestionNo = NodeTypeProp.PropNameWithQuestionNo;
            MetaDataPropId   = NodeTypeProp.FirstPropVersionId;
            MetaDataPropName = NodeTypeProp.PropName;
            MetaDataTypeName = NodeTypeProp.getNodeType().NodeTypeName;
            FieldTypeRule    = NodeTypeProp.getFieldTypeRule();
            Type             = CswEnumNbtViewPropType.NodeTypePropId;
            PropName         = MetaDataPropName;
            AssociatedPropIds.Add(MetaDataPropId.ToString());
            if (NodeTypeProp.ObjectClassPropId != Int32.MinValue)
            {
                AssociatedPropIds.Add(NodeTypeProp.ObjectClassPropId.ToString());
            }
        } //ctor Ntp
Example #10
0
        public override void update()
        {
            CswNbtMetaDataObjectClass DesignNtpOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.DesignNodeTypePropClass );

            foreach( CswNbtMetaDataNodeType DesignNtpNT in DesignNtpOC.getNodeTypes() )
            {
                // Set existing values of hidden
                foreach( CswNbtObjClassDesignNodeTypeProp DesignNtpNode in DesignNtpNT.getNodes( false, true ) )
                {
                    DesignNtpNode.Hidden.Checked = CswConvert.ToTristate( DesignNtpNode.RelationalNodeTypeProp.Hidden );
                    DesignNtpNode.postChanges( false );
                }

                // Fix layout
                CswNbtMetaDataNodeTypeProp HiddenNTP = DesignNtpNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignNodeTypeProp.PropertyName.Hidden );
                CswNbtMetaDataNodeTypeProp ReadOnlyNTP = DesignNtpNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignNodeTypeProp.PropertyName.ReadOnly );
                _CswNbtSchemaModTrnsctn.MetaData.NodeTypeLayout.updatePropLayout( CswEnumNbtLayoutType.Edit, HiddenNTP, ReadOnlyNTP, true );
            }

            // Synchronize property with nodetype_props.hidden
            CswTableUpdate jctUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "51775_jctddntp_update", "jct_dd_ntp" );
            DataTable jctTable = jctUpdate.getEmptyTable();
            foreach( CswNbtMetaDataNodeType DesignNtpNT in DesignNtpOC.getNodeTypes() )
            {
                _CswNbtSchemaModTrnsctn.CswDataDictionary.setCurrentColumn( "nodetype_props", "hidden" );
                CswNbtMetaDataNodeTypeProp HiddenNTP = DesignNtpNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignNodeTypeProp.PropertyName.Hidden );

                DataRow NodeTypeNameRow = jctTable.NewRow();
                NodeTypeNameRow["nodetypepropid"] = HiddenNTP.PropId;
                NodeTypeNameRow["datadictionaryid"] = _CswNbtSchemaModTrnsctn.CswDataDictionary.TableColId;
                if( null != HiddenNTP.getFieldTypeRule().SubFields.Default )
                {
                    NodeTypeNameRow["subfieldname"] = HiddenNTP.getFieldTypeRule().SubFields.Default.Name;
                }
                jctTable.Rows.Add( NodeTypeNameRow );
            }
            jctUpdate.update( jctTable );


            // make Request module require the Multi-Inventory-Group module
            _CswNbtSchemaModTrnsctn.execArbitraryPlatformNeutralSql( @"update modules 
                                                                          set prereq = (select moduleid from modules 
                                                                                         where name = '" + CswEnumNbtModuleName.MultiInventoryGroup + @"')
                                                                        where name = '" + CswEnumNbtModuleName.Requesting + @"'" );

        } // update()
 private void _filterToSDS( CswNbtMetaDataNodeType DocumentNT, String NodeTypePropName )
 {
     CswNbtMetaDataNodeTypeProp DocumentNTP = DocumentNT.getNodeTypeProp( NodeTypePropName );
     if( null != DocumentNTP )
     {
         DocumentNTP.setFilter( DocumentClassNTP, DocumentClassNTP.getFieldTypeRule().SubFields.Default, CswNbtPropFilterSql.PropertyFilterMode.Equals, CswNbtObjClassDocument.DocumentClasses.SDS );
         DocumentNTP.updateLayout( CswNbtMetaDataNodeTypeLayoutMgr.LayoutType.Add, true, DocumentNT.getFirstNodeTypeTab().TabId );
     }
 }
Example #12
0
 private void _setPermissionPropFilters( CswNbtMetaDataNodeType PermissionNT )
 {
     CswNbtMetaDataNodeTypeProp ApplyToAllWorkUnitsNTP = PermissionNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetPermission.PropertyName.ApplyToAllWorkUnits );
     CswNbtMetaDataNodeTypeProp WorkUnitNTP = PermissionNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetPermission.PropertyName.WorkUnit );
     WorkUnitNTP.setFilter( ApplyToAllWorkUnitsNTP, ApplyToAllWorkUnitsNTP.getFieldTypeRule().SubFields.Default, CswEnumNbtFilterMode.Equals, CswEnumTristate.False );
     CswNbtMetaDataNodeTypeProp ApplyToAllRolesNTP = PermissionNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetPermission.PropertyName.ApplyToAllRoles );
     CswNbtMetaDataNodeTypeProp RoleNTP = PermissionNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetPermission.PropertyName.Role );
     RoleNTP.setFilter( ApplyToAllRolesNTP, ApplyToAllRolesNTP.getFieldTypeRule().SubFields.Default, CswEnumNbtFilterMode.Equals, CswEnumTristate.False );
 }
Example #13
0
        } // _recurseBulkEditData()

        private static void _addNodeToData(CswNbtMetaDataNodeType NodeType, CswNbtNode Node, BulkEditDownload ret, BulkEditParams Params)
        {
            DataRow row = ret.CsvData.NewRow();

            row["nodeid"] = Node.NodeId.ToString();

            foreach (Int32 PropId in Params.PropIds)
            {
                CswNbtMetaDataNodeTypeProp Prop = NodeType.getNodeTypeProp(PropId);
                if (Prop.getFieldTypeRule().SubFields.Count > 1)
                {
                    foreach (CswNbtSubField SubField in Prop.getFieldTypeRule().SubFields)
                    {
                        row[Prop.PropName + " " + SubField.Name] = Node.Properties[Prop].GetSubFieldValue(SubField);
                    }
                }
                else
                {
                    row[Prop.PropName] = Node.Properties[Prop].GetSubFieldValue(Prop.getFieldTypeRule().SubFields.Default);
                }
            }
            ret.CsvData.Rows.Add(row);
        } // _addNodeToData()
        } //_makeNodeSql()

        private CswNbtSubField _getDefaultSubFieldForProperty(CswEnumNbtViewPropIdType Type, Int32 Id)
        {
            CswNbtSubField ret = null;

            if (Type == CswEnumNbtViewPropIdType.NodeTypePropId)
            {
                CswNbtMetaDataNodeTypeProp NodeTypeProp = _CswNbtResources.MetaData.getNodeTypeProp(Id);
                ret = NodeTypeProp.getFieldTypeRule().SubFields.Default;
            }
            else if (Type == CswEnumNbtViewPropIdType.ObjectClassPropId)
            {
                CswNbtMetaDataObjectClassProp ObjectClassProp = _CswNbtResources.MetaData.getObjectClassProp(Id);
                ret = ObjectClassProp.getFieldTypeRule().SubFields.Default;
            }
            return(ret);
        }
Example #15
0
        public override void update()
        {
            // Set MailReport.OutputFormat to be conditional on Type = Report

            CswNbtMetaDataObjectClass MailReportOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.MailReportClass );
            CswNbtMetaDataObjectClassProp TypeOCP = MailReportOC.getObjectClassProp( CswNbtObjClassMailReport.PropertyName.Type );
            CswNbtMetaDataObjectClassProp OutputFormatOCP = MailReportOC.getObjectClassProp( CswNbtObjClassMailReport.PropertyName.OutputFormat );

            _CswNbtSchemaModTrnsctn.MetaData.UpdateObjectClassProp( OutputFormatOCP,
                                                                    CswNbtMetaDataObjectClassProp.ObjectClassPropAttributes.filterpropid,
                                                                    TypeOCP.PropId.ToString() );

            _CswNbtSchemaModTrnsctn.MetaData.UpdateObjectClassProp( OutputFormatOCP,
                                                                    CswNbtMetaDataObjectClassProp.ObjectClassPropAttributes.filter,
                                                                    CswNbtMetaDataObjectClassProp.makeFilter( TypeOCP.getFieldTypeRule().SubFields.Default,
                                                                                                              CswNbtPropFilterSql.PropertyFilterMode.Equals,
                                                                                                              CswNbtObjClassMailReport.TypeOptionReport ) );

            // because of case 27922, need to apply this to nodetypes manually
            foreach( CswNbtMetaDataNodeType MailReportNT in MailReportOC.getNodeTypes() )
            {
                CswNbtMetaDataNodeTypeProp TypeNTP = MailReportNT.getNodeTypePropByObjectClassProp( CswNbtObjClassMailReport.PropertyName.Type );
                CswNbtMetaDataNodeTypeProp OutputFormatNTP = MailReportNT.getNodeTypePropByObjectClassProp( CswNbtObjClassMailReport.PropertyName.OutputFormat );

                OutputFormatNTP.setFilter( TypeNTP,
                                           TypeNTP.getFieldTypeRule().SubFields.Default,
                                           CswNbtPropFilterSql.PropertyFilterMode.Equals,
                                           CswNbtObjClassMailReport.TypeOptionReport );

                // revert readonly
                foreach( CswNbtObjClassMailReport MailReportNode in MailReportNT.getNodes( false, true ) )
                {
                    MailReportNode.OutputFormat.setReadOnly( value: false, SaveToDb: true );
                    MailReportNode.postChanges( false );
                }

            } // foreach( CswNbtMetaDataNodeType MailReportNT in MailReportOC.getNodeTypes() )

        }//Update()
        public override void update()
        {
            CswNbtMetaDataObjectClass RegulatoryListOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.RegulatoryListClass );
            if( null != RegulatoryListOC )
            {
                foreach( CswNbtMetaDataNodeType CurrentRegulatoryListNT in RegulatoryListOC.getNodeTypes() )
                {
                    Int32 TabId = CurrentRegulatoryListNT.getFirstNodeTypeTab().TabId;

                    CswNbtMetaDataNodeTypeProp ListModeNTP = CurrentRegulatoryListNT.getNodeTypePropByObjectClassProp( CswNbtObjClassRegulatoryList.PropertyName.ListMode );
                    CswNbtMetaDataNodeTypeProp RegionsNTP = CurrentRegulatoryListNT.getNodeTypePropByObjectClassProp( CswNbtObjClassRegulatoryList.PropertyName.Regions );
                    RegionsNTP.updateLayout( CswEnumNbtLayoutType.Add, true, DisplayRow: 3, DisplayColumn: 1 );
                    RegionsNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 3, DisplayColumn: 1 );
                    RegionsNTP.setFilterDeprecated( FilterProp: ListModeNTP,
                                                    SubField: ListModeNTP.getFieldTypeRule().SubFields.Default,
                                                    FilterMode: CswEnumNbtFilterMode.Equals,
                                                    FilterValue: CswNbtObjClassRegulatoryList.CswEnumRegulatoryListListModes.ArielManaged );

                }//foreach( CswNbtMetaDataNodeType CurrentRegulatoryListNT in RegulatoryListOC.getNodeTypes() )

            }//if( null != RegulatoryListOC )
        } // update()
        } // getNodeIdByRelationalId()

        /// <summary>
        /// Find a node by a unique property value
        /// </summary>
        /// <param name="MetaDataProp">Property to search with</param>
        /// <param name="PropWrapper">Value to find</param>
        /// <returns></returns>
        public CswNbtNode FindNodeByUniqueProperty(CswNbtMetaDataNodeTypeProp MetaDataProp, CswNbtNodePropWrapper PropWrapper)
        {
            CswNbtNode ret      = null;
            string     SQLQuery = string.Empty;

            foreach (CswNbtSubField SubField in MetaDataProp.getFieldTypeRule().SubFields)
            {
                if (SQLQuery != string.Empty)
                {
                    SQLQuery += " INTERSECT ";
                }
                //if( SubField.RelationalTable == string.Empty )
                //{
                SQLQuery += " (select nodeid, 'nodes' tablename ";
                SQLQuery += "    from jct_nodes_props ";
                SQLQuery += "   where nodetypepropid = " + MetaDataProp.PropId.ToString() + " ";
                SQLQuery += "     and " + SubField.Column.ToString() + " = '" + PropWrapper.GetSubFieldValue(SubField) + "') ";
                //}
                //else
                //{
                //    string PrimeKeyCol = _CswNbtResources.DataDictionary.getPrimeKeyColumn( SubField.RelationalTable );
                //    SQLQuery += " (select " + PrimeKeyCol + " nodeid, '" + SubField.RelationalTable + "' tablename ";
                //    SQLQuery += "    from " + SubField.RelationalTable + " ";
                //    SQLQuery += "   where " + SubField.RelationalColumn + " = '" + PropWrapper.GetSubFieldValue( SubField ) + "') ";
                //}
            }
            SQLQuery = "select nodeid, tablename from " + SQLQuery;

            CswArbitrarySelect UniquePropSelect = _CswNbtResources.makeCswArbitrarySelect("FindNodeByUniqueProperty_select", SQLQuery);
            DataTable          UniquePropTable  = UniquePropSelect.getTable();

            if (UniquePropTable.Rows.Count > 0)
            {
                ret = this[new CswPrimaryKey(UniquePropTable.Rows[0]["tablename"].ToString(), CswConvert.ToInt32(UniquePropTable.Rows[0]["nodeid"]))];
            }

            return(ret);
        } // FindNodeByUniqueProperty()
        public override void update()
        {
            CswNbtMetaDataObjectClass RegulatoryListOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.RegulatoryListClass );
            if( null != RegulatoryListOC )
            {
                foreach( CswNbtMetaDataNodeType CurrentRegulatoryListNT in RegulatoryListOC.getNodeTypes() )
                {
                    Int32 TabId = CurrentRegulatoryListNT.getFirstNodeTypeTab().TabId;

                    // Name
                    CswNbtMetaDataNodeTypeProp NameNTP = CurrentRegulatoryListNT.getNodeTypePropByObjectClassProp( CswNbtObjClassRegulatoryList.PropertyName.Name );
                    NameNTP.updateLayout( CswEnumNbtLayoutType.Add, true, DisplayRow: 1, DisplayColumn: 1 );
                    NameNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 1, DisplayColumn: 1 );

                    // List Mode
                    CswNbtMetaDataNodeTypeProp ListModeNTP = CurrentRegulatoryListNT.getNodeTypePropByObjectClassProp( CswNbtObjClassRegulatoryList.PropertyName.ListMode );
                    ListModeNTP.updateLayout( CswEnumNbtLayoutType.Add, true, DisplayRow: 2, DisplayColumn: 1 );
                    ListModeNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 2, DisplayColumn: 1 );

                    // Add CAS Numbers
                    CswNbtMetaDataNodeTypeProp AddCASNumbersNTP = CurrentRegulatoryListNT.getNodeTypePropByObjectClassProp( CswNbtObjClassRegulatoryList.PropertyName.AddCASNumbers );
                    AddCASNumbersNTP.updateLayout( CswEnumNbtLayoutType.Add, true, DisplayRow: 3, DisplayColumn: 1 );
                    AddCASNumbersNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 3, DisplayColumn: 1 );
                    AddCASNumbersNTP.setFilter( FilterProp: ListModeNTP,
                                                SubField: ListModeNTP.getFieldTypeRule().SubFields.Default,
                                                FilterMode: CswEnumNbtFilterMode.Equals,
                                                FilterValue: CswNbtObjClassRegulatoryList.CswEnumRegulatoryListListModes.ManuallyManaged );

                    // Exclusive
                    CswNbtMetaDataNodeTypeProp ExclusiveNTP = CurrentRegulatoryListNT.getNodeTypePropByObjectClassProp( CswNbtObjClassRegulatoryList.PropertyName.Exclusive );
                    ExclusiveNTP.removeFromAllLayouts();

                }//foreach( CswNbtMetaDataNodeType CurrentRegulatoryListNT in RegulatoryListOC.getNodeTypes() )

            }//if( null != RegulatoryListOC )

        } // update()
Example #19
0
 internal void RevertNodeTypePropAttributes()
 {
     foreach (KeyValuePair <int, string> OriginalNodeTypePropId in _ChangedNodeTypePropListOptions)
     {
         CswNbtMetaDataNodeTypeProp OriginalNodeTypeProp = _CswNbtResources.MetaData.getNodeTypeProp(OriginalNodeTypePropId.Key);
         if (null != OriginalNodeTypeProp)
         {
             //OriginalNodeTypeProp.ListOptions = OriginalNodeTypePropId.Value;
             CswNbtFieldTypeAttribute attr = OriginalNodeTypeProp.getFieldTypeRule().getAttributes().FirstOrDefault(a => a.Column == CswEnumNbtPropertyAttributeColumn.Listoptions);
             OriginalNodeTypeProp.DesignNode.AttributeProperty[attr.Name].SetSubFieldValue(attr.SubFieldName, OriginalNodeTypePropId.Value);
             OriginalNodeTypeProp.DesignNode.postChanges(false);
         }
     }
     foreach (KeyValuePair <int, string> OriginalNodeTypePropId in _ChangedNodeTypePropExtended)
     {
         CswNbtMetaDataNodeTypeProp OriginalNodeTypeProp = _CswNbtResources.MetaData.getNodeTypeProp(OriginalNodeTypePropId.Key);
         if (null != OriginalNodeTypeProp)
         {
             //OriginalNodeTypeProp.Extended = OriginalNodeTypePropId.Value;
             CswNbtFieldTypeAttribute attr = OriginalNodeTypeProp.getFieldTypeRule().getAttributes().FirstOrDefault(a => a.Column == CswEnumNbtPropertyAttributeColumn.Extended);
             OriginalNodeTypeProp.DesignNode.AttributeProperty[attr.Name].SetSubFieldValue(attr.SubFieldName, OriginalNodeTypePropId.Value);
             OriginalNodeTypeProp.DesignNode.postChanges(false);
         }
     }
     foreach (KeyValuePair <int, int> OriginalNodeTypePropId in _ChangedNodeTypePropMaxValue)
     {
         CswNbtMetaDataNodeTypeProp OriginalNodeTypeProp = _CswNbtResources.MetaData.getNodeTypeProp(OriginalNodeTypePropId.Key);
         if (null != OriginalNodeTypeProp)
         {
             //OriginalNodeTypeProp.MaxValue = OriginalNodeTypePropId.Value;
             CswNbtFieldTypeAttribute attr = OriginalNodeTypeProp.getFieldTypeRule().getAttributes().FirstOrDefault(a => a.Column == CswEnumNbtPropertyAttributeColumn.Numbermaxvalue);
             OriginalNodeTypeProp.DesignNode.AttributeProperty[attr.Name].SetSubFieldValue(attr.SubFieldName, OriginalNodeTypePropId.Value);
             OriginalNodeTypeProp.DesignNode.postChanges(false);
         }
     }
 }
Example #20
0
        }//ctor

        public void update(Int32 NodeTypeId, CswPrimaryKey RelationalId, DataTable PropsTable)
        {
            if (CswTools.IsPrimaryKey(RelationalId))
            {
                CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(NodeTypeId);
                string TableName = NodeType.TableName;
                if (TableName != "nodes")
                {
                    string         PkColumnName   = _CswNbtResources.getPrimeKeyColName(TableName);
                    CswTableUpdate CswTableUpdate = null;
                    DataTable      DataTable      = null;
                    DataRow        DataRow        = null;

                    // horrible special case for Design
                    // We need to use CswNbtMetaDataResources objects, or else we have dirty-write problems
                    if (NodeType.TableName.StartsWith("nodetype"))
                    {
                        switch (NodeType.TableName)
                        {
                        case "nodetypes":
                            CswTableUpdate = _CswNbtResources.MetaData._CswNbtMetaDataResources.NodeTypeTableUpdate;
                            CswNbtMetaDataNodeType relatedNT = _CswNbtResources.MetaData.getNodeType(RelationalId.PrimaryKey, null, true);
                            DataTable = relatedNT._DataRow.Table;
                            DataRow   = relatedNT._DataRow;
                            break;

                        case "nodetype_tabset":
                            CswTableUpdate = _CswNbtResources.MetaData._CswNbtMetaDataResources.NodeTypeTabTableUpdate;
                            CswNbtMetaDataNodeTypeTab relatedNTT = _CswNbtResources.MetaData.getNodeTypeTab(RelationalId.PrimaryKey, true);
                            DataTable = relatedNTT._DataRow.Table;
                            DataRow   = relatedNTT._DataRow;
                            break;

                        case "nodetype_props":
                            CswTableUpdate = _CswNbtResources.MetaData._CswNbtMetaDataResources.NodeTypePropTableUpdate;
                            CswNbtMetaDataNodeTypeProp relatedNTP = _CswNbtResources.MetaData.getNodeTypeProp(RelationalId.PrimaryKey, null, true);
                            DataTable = relatedNTP._DataRow.Table;
                            DataRow   = relatedNTP._DataRow;
                            break;
                        }
                    } // if( NodeType.TableName.StartsWith( "nodetype" ) )

                    if (null == DataTable || null == CswTableUpdate)
                    {
                        CswTableUpdate = _CswNbtResources.makeCswTableUpdate("CswNbtNodePropCollDataRelational_update", TableName);
                        DataTable      = CswTableUpdate.getTable(null, PkColumnName, RelationalId.PrimaryKey, string.Empty, false);
                        DataRow        = DataTable.Rows[0];
                    }

                    if (null != DataRow)
                    {
                        CswTableSelect MappingSelect = _CswNbtResources.makeCswTableSelect("PropCollDataRelational_mapping", "jct_dd_ntp");
                        DataTable      MappingTable  = MappingSelect.getTable("where nodetypepropid in (select nodetypepropid from nodetype_props where nodetypeid =" + NodeTypeId.ToString() + ")");

                        foreach (DataRow CurrentRow in PropsTable.Rows)
                        {
                            CswNbtMetaDataNodeTypeProp thisNTP = NodeType.getNodeTypeProp(CswConvert.ToInt32(CurrentRow["nodetypepropid"]));
                            if (null != thisNTP)
                            {
                                foreach (CswNbtSubField CurrentSubField in thisNTP.getFieldTypeRule().SubFields)
                                {
                                    DataRow MappingRow = MappingTable.Rows.Cast <DataRow>()
                                                         .FirstOrDefault(r => CswConvert.ToInt32(r["nodetypepropid"]) == thisNTP.PropId &&
                                                                         r["subfieldname"].ToString() == CurrentSubField.Name.ToString());
                                    if (null != MappingRow)
                                    {
                                        _CswNbtResources.DataDictionary.setCurrentColumn(CswConvert.ToInt32(MappingRow["datadictionaryid"]));
                                        if (_CswNbtResources.DataDictionary.ColumnName != string.Empty)
                                        {
                                            if (CurrentRow[CurrentSubField.Column.ToString()].ToString() == string.Empty)
                                            {
                                                DataRow[_CswNbtResources.DataDictionary.ColumnName] = DBNull.Value;
                                            }
                                            else if (_CswNbtResources.DataDictionary.ColumnName == CswEnumNbtPropertyAttributeColumn.Defaultvalueid)
                                            {
                                                // Special case for Default Value: we need to sync the jctnodepropid row, not the value
                                                DataRow[_CswNbtResources.DataDictionary.ColumnName] = CurrentRow["jctnodepropid"];
                                            }
                                            else
                                            {
                                                object value = CurrentRow[CurrentSubField.Column.ToString()];

                                                // Special case for Multi: translate "Single" and "Multiple" to 0 and 1 resp.
                                                if (_CswNbtResources.DataDictionary.ColumnName == CswEnumNbtPropertyAttributeColumn.Multi)
                                                {
                                                    if (value.ToString() == CswEnumNbtPropertySelectMode.Single.ToString())
                                                    {
                                                        value = 1;
                                                    }
                                                    else
                                                    {
                                                        value = 0;
                                                    }
                                                }
                                                // Special case for booleans and tristates
                                                else if (thisNTP.getFieldTypeValue() == CswEnumNbtFieldType.Logical)
                                                {
                                                    value = CswConvert.TristateToDbVal(CswConvert.ToTristate(CurrentRow[CurrentSubField.Column.ToString()]));
                                                }
                                                // Special case for relationships and locations, if the related entity is also relational
                                                else if (CurrentSubField.Name == CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID &&
                                                         (thisNTP.getFieldTypeValue() == CswEnumNbtFieldType.Relationship ||
                                                          thisNTP.getFieldTypeValue() == CswEnumNbtFieldType.Location))
                                                {
                                                    CswNbtNode RelatedNode = _CswNbtResources.Nodes[new CswPrimaryKey("nodes", CswConvert.ToInt32(value))];
                                                    if (null != RelatedNode && RelatedNode.getNodeType().DoRelationalSync)
                                                    {
                                                        // Remap the foreign key reference to the relational primary key
                                                        value = RelatedNode.RelationalId.PrimaryKey;
                                                    }
                                                }

                                                DataRow[_CswNbtResources.DataDictionary.ColumnName] = value; //CurrentRow[CurrentSubField.Column.ToString()];
                                            }
                                        } // if( _CswNbtResources.DataDictionary.ColumnName != string.Empty )
                                    } // if( null != MappingRow )
                                }     // foreach( CswNbtSubField CurrentSubField in thisNTP.getFieldTypeRule().SubFields )
                            }         // if( null != thisNTP )
                        }             // foreach( DataRow CurrentRow in PropsTable.Rows )

                        CswTableUpdate.update(DataTable);
                    } // if( null != DataRow )
                }     // if( TableName != "nodes" )
            }         // if( CswTools.IsPrimaryKey( RelationalId ) )
        }             //update()
        /// <summary>
        /// Do the update
        /// </summary>
        public override void update()
        {
            CswNbtMetaDataObjectClass DocumentOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswNbtMetaDataObjectClass.NbtObjectClass.DocumentClass );

            CswNbtMetaDataObjectClassProp ArchivedDateOcp = _CswNbtSchemaModTrnsctn.createObjectClassProp( new CswNbtWcfMetaDataModel.ObjectClassProp( DocumentOc )
                {
                    PropName = CswNbtObjClassDocument.PropertyName.ArchiveDate,
                    FieldType = CswNbtMetaDataFieldType.NbtFieldType.DateTime
                } );

            CswNbtMetaDataObjectClassProp DocumentClassOcp = DocumentOc.getObjectClassProp( CswNbtObjClassDocument.PropertyName.DocumentClass );

            CswNbtMetaDataObjectClassProp LanguageOcp = _CswNbtSchemaModTrnsctn.createObjectClassProp( new CswNbtWcfMetaDataModel.ObjectClassProp( DocumentOc )
            {
                PropName = CswNbtObjClassDocument.PropertyName.Language,
                FieldType = CswNbtMetaDataFieldType.NbtFieldType.List,
                ListOptions = "en,fr,es,de",
                SetValOnAdd = false
                //This worked for Size on Request Item but does not seem to work when making the prop conditional on another prop of the same Object Class
                //IsFk = true,
                //FkType = NbtViewPropIdType.ObjectClassPropId.ToString(),
                //FkValue = DocumentClassOcp.PropId,
                //FilterPropId = DocumentClassOcp.PropId,
                //Filter = CswNbtMetaDataObjectClassProp.makeFilter( DocumentClassOcp.getFieldTypeRule().SubFields.Default, CswNbtPropFilterSql.PropertyFilterMode.Equals, CswNbtObjClassDocument.DocumentClasses.MSDS )
            } );

            CswNbtMetaDataObjectClassProp FormatOcp = _CswNbtSchemaModTrnsctn.createObjectClassProp( new CswNbtWcfMetaDataModel.ObjectClassProp( DocumentOc )
            {
                PropName = CswNbtObjClassDocument.PropertyName.Format,
                FieldType = CswNbtMetaDataFieldType.NbtFieldType.List,
                ListOptions = CswNbtObjClassDocument.Formats.Options.ToString(),
                SetValOnAdd = false
                //IsFk = true,
                //FkType = NbtViewPropIdType.ObjectClassPropId.ToString(),
                //FkValue = DocumentClassOcp.PropId,
                //FilterPropId = DocumentClassOcp.PropId,
                //Filter = CswNbtMetaDataObjectClassProp.makeFilter( DocumentClassOcp.getFieldTypeRule().SubFields.Default, CswNbtPropFilterSql.PropertyFilterMode.Equals, CswNbtObjClassDocument.DocumentClasses.MSDS )
            } );

            foreach( CswNbtMetaDataNodeType DocumentNt in DocumentOc.getLatestVersionNodeTypes() )
            {
                CswNbtMetaDataNodeTypeProp FormatNtp = DocumentNt.getNodeTypePropByObjectClassProp( FormatOcp.PropId );
                CswNbtMetaDataNodeTypeProp LanguageNtp = DocumentNt.getNodeTypePropByObjectClassProp( LanguageOcp.PropId );
                if( false == DocumentNt.NodeTypeName.Contains( "material" ) && false == DocumentNt.NodeTypeName.Contains( "Material" ) )
                {
                    FormatNtp.removeFromAllLayouts();
                    LanguageNtp.removeFromAllLayouts();
                }
                CswNbtMetaDataNodeTypeProp DocumentClassNtp = DocumentNt.getNodeTypePropByObjectClassProp( DocumentClassOcp.PropId );
                FormatNtp.setFilter( DocumentClassNtp, DocumentClassNtp.getFieldTypeRule().SubFields.Default, CswNbtPropFilterSql.PropertyFilterMode.Equals, CswNbtObjClassDocument.DocumentClasses.MSDS );
                LanguageNtp.setFilter( DocumentClassNtp, DocumentClassNtp.getFieldTypeRule().SubFields.Default, CswNbtPropFilterSql.PropertyFilterMode.Equals, CswNbtObjClassDocument.DocumentClasses.MSDS );
            }

            CswNbtMetaDataObjectClassProp LinkOcp = DocumentOc.getObjectClassProp( CswNbtObjClassDocument.PropertyName.Link );
            CswNbtMetaDataObjectClassProp FileOcp = DocumentOc.getObjectClassProp( CswNbtObjClassDocument.PropertyName.File );
            CswNbtMetaDataObjectClassProp FileTypeOcp = DocumentOc.getObjectClassProp( CswNbtObjClassDocument.PropertyName.FileType );
            CswNbtMetaDataObjectClassProp ArchivedOcp = DocumentOc.getObjectClassProp( CswNbtObjClassDocument.PropertyName.Archived );
            CswNbtMetaDataObjectClassProp AcquiredDateOcp = DocumentOc.getObjectClassProp( CswNbtObjClassDocument.PropertyName.AcquiredDate );

            _CswNbtSchemaModTrnsctn.MetaData.UpdateObjectClassProp( LinkOcp, CswNbtMetaDataObjectClassProp.ObjectClassPropAttributes.setvalonadd, true );
            _CswNbtSchemaModTrnsctn.MetaData.UpdateObjectClassProp( FileOcp, CswNbtMetaDataObjectClassProp.ObjectClassPropAttributes.setvalonadd, true );
            _CswNbtSchemaModTrnsctn.MetaData.UpdateObjectClassProp( FileTypeOcp, CswNbtMetaDataObjectClassProp.ObjectClassPropAttributes.isrequired, true );
            _CswNbtSchemaModTrnsctn.MetaData.UpdateObjectClassProp( AcquiredDateOcp, CswNbtMetaDataObjectClassProp.ObjectClassPropAttributes.servermanaged, true );
            _CswNbtSchemaModTrnsctn.MetaData.SetObjectClassPropDefaultValue( FileTypeOcp, FileTypeOcp.getFieldTypeRule().SubFields.Default.Name, CswNbtObjClassDocument.FileTypes.File );

            _CswNbtSchemaModTrnsctn.MetaData.UpdateObjectClassProp( ArchivedOcp, CswNbtMetaDataObjectClassProp.ObjectClassPropAttributes.isrequired, true );
            _CswNbtSchemaModTrnsctn.MetaData.SetObjectClassPropDefaultValue( ArchivedOcp, ArchivedOcp.getFieldTypeRule().SubFields.Default.Name, Tristate.False );

        }//Update()
Example #22
0
        } // getPercentDone()

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

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

                    if (BatchData.CurrentRow < BatchData.TotalRows)
                    {
                        if (null != BatchData.excelData.Columns["nodeid"])
                        {
                            int   NodesProcessedPerIteration = CswConvert.ToInt32(_CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumConfigurationVariableNames.NodesProcessedPerCycle));
                            Int32 r;
                            for (r = BatchData.CurrentRow; r < BatchData.excelData.Rows.Count && (r - BatchData.CurrentRow) < NodesProcessedPerIteration && NoErrors; r++)
                            {
                                try
                                {
                                    DataRow row = BatchData.excelData.Rows[r];

                                    CswPrimaryKey NodeId = new CswPrimaryKey();
                                    NodeId.FromString(row["nodeid"].ToString());
                                    if (CswTools.IsPrimaryKey(NodeId))
                                    {
                                        CswNbtNode Node = _CswNbtResources.Nodes[NodeId];
                                        if (null != Node)
                                        {
                                            foreach (DataColumn col in BatchData.excelData.Columns)
                                            {
                                                if (NoErrors)
                                                {
                                                    try
                                                    {
                                                        if (col.ColumnName != "nodeid")
                                                        {
                                                            CswNbtMetaDataNodeTypeProp Prop = Node.getNodeType().getNodeTypeProp(col.ColumnName);
                                                            CswNbtSubField             SubField;
                                                            if (null != Prop)
                                                            {
                                                                SubField = Prop.getFieldTypeRule().SubFields.Default;
                                                            }
                                                            else
                                                            {
                                                                string propName     = col.ColumnName.Substring(0, col.ColumnName.LastIndexOf(" "));
                                                                string subFieldName = col.ColumnName.Substring(col.ColumnName.LastIndexOf(" ") + 1);
                                                                Prop     = Node.getNodeType().getNodeTypeProp(propName);
                                                                SubField = Prop.getFieldTypeRule().SubFields[(CswEnumNbtSubFieldName)subFieldName];
                                                            }
                                                            Node.Properties[Prop].SetSubFieldValue(SubField, row[col.ColumnName]);
                                                        } // if( col.ColumnName != "nodeid" )
                                                    }     // try
                                                    catch (Exception ex)
                                                    {
                                                        BatchNode.error(ex, "Error on row: " + (r + 1).ToString() + ", column: " + col.ColumnName + "; ");
                                                        NoErrors = false;
                                                    }
                                                }
                                            } // foreach( DataColumn col in BatchData.excelData.Columns )
                                        }     // if( null != Node )
                                        Node.postChanges(false);
                                    }         // if( CswTools.IsPrimaryKey( NodeId ) )
                                }             // try
                                catch (Exception ex)
                                {
                                    BatchNode.error(ex, "Error on row: " + (r + 1).ToString() + "; ");
                                    NoErrors = false;
                                }
                            } // for

                            if (NoErrors)
                            {
                                // Setup for next iteration
                                BatchData.CurrentRow        = r;
                                BatchNode.BatchData.Text    = BatchData.ToString();
                                BatchNode.PercentDone.Value = getPercentDone(BatchNode);
                            }
                        } // if( null != BatchData.excelData.Columns["nodeid"] )
                    }     // if(BatchData.CurrentRow < BatchData.TotalRows)
                    else
                    {
                        BatchNode.finish();
                    }
                    BatchNode.postChanges(false);
                }
                catch (Exception ex)
                {
                    BatchNode.error(ex);
                }
            } // if( BatchNode != null && BatchNode.OpNameValue == NbtBatchOpName.MultiEdit )
        }     // runBatchOp()
Example #23
0
        } // TreeToJson()

        private void _TreeNodeToGrid(CswNbtView View, ICswNbtTree Tree, CswExtJsGrid grid, CswExtJsGridRow gridrow)
        {
            string gridUniquePrefix = _getUniquePrefix(View);
            Collection <CswNbtTreeNodeProp> ChildProps = Tree.getChildNodePropsOfNode();

            foreach (CswNbtTreeNodeProp Prop in ChildProps)
            {
                // Potential bug here!
                // If the view defines the property by objectclass propname, but the nodetype propname differs, this might break
                CswExtJsGridDataIndex dataIndex = new CswExtJsGridDataIndex(gridUniquePrefix, Prop.PropName);

                bool   IsHidden = Prop.Hidden;
                bool   IsLocked = Tree.getNodeLockedForCurrentPosition();
                string newValue = string.Empty;
                if (false == IsHidden)
                {
                    CswPrimaryKey NodeId = Tree.getNodeIdForCurrentPosition();
                    CswNbtMetaDataNodeTypeProp MetaDataProp = _CswNbtResources.MetaData.getNodeTypeProp(Prop.NodeTypePropId);

                    string oldValue = Prop.Gestalt;
                    if (string.IsNullOrEmpty(oldValue))
                    {
                        oldValue = null;
                    }

                    switch (Prop.FieldType)
                    {
                    case CswEnumNbtFieldType.Button:
                        if (false == IsLocked)
                        {
                            CswNbtFieldTypeRuleButton buttonFTR = (CswNbtFieldTypeRuleButton)MetaDataProp.getFieldTypeRule();
                            grid.rowData.btns.Add(new CswExtJsGridButton
                            {
                                DataIndex    = dataIndex.ToString(),
                                RowNo        = gridrow.RowNo,
                                MenuOptions  = Prop[buttonFTR.MenuOptionsSubField.Column],
                                SelectedText = oldValue ?? Prop.PropName,
                                PropAttr     = new CswPropIdAttr(NodeId, Prop.NodeTypePropId).ToString(),
                                Mode         = String.IsNullOrEmpty(MetaDataProp.DesignNode.getAttributeValueByColumn(CswEnumNbtPropertyAttributeColumn.Extended)) ? "button" : MetaDataProp.DesignNode.getAttributeValueByColumn(CswEnumNbtPropertyAttributeColumn.Extended)
                            });
                        }
                        break;

                    case CswEnumNbtFieldType.File:
                        string LinkUrl = CswNbtNodePropBlob.getLink(Prop.JctNodePropId, NodeId);
                        if (false == string.IsNullOrEmpty(LinkUrl) && false == string.IsNullOrEmpty(oldValue))
                        {
                            newValue = "<a target=\"blank\" href=\"" + LinkUrl + "\">" + (oldValue) + "</a>";
                        }
                        break;

                    case CswEnumNbtFieldType.Image:
                        string ImageUrl = CswNbtNodePropImage.getLink(Prop.JctNodePropId, NodeId);
                        if (false == string.IsNullOrEmpty(ImageUrl))
                        {
                            newValue = "<a target=\"blank\" href=\"" + ImageUrl + "\">" + (oldValue ?? "Image") + "</a>";
                        }
                        break;

                    case CswEnumNbtFieldType.Link:

                        //string Href = CswNbtNodePropLink.GetFullURL( MetaDataProp.Attribute1, Prop.Field1_Big, MetaDataProp.Attribute2 );
                        string Href = CswNbtNodePropLink.GetFullURL(MetaDataProp.DesignNode.getAttributeValueByColumn(CswEnumNbtPropertyAttributeColumn.Attribute1),
                                                                    Prop.Field1_Big,
                                                                    MetaDataProp.DesignNode.getAttributeValueByColumn(CswEnumNbtPropertyAttributeColumn.Attribute2));
                        if (false == string.IsNullOrEmpty(Href))
                        {
                            newValue = "<a target=\"blank\" href=\"" + Href + "\">" + (oldValue ?? "Link") + "</a>";
                        }
                        break;

                    case CswEnumNbtFieldType.Logical:
                        newValue = CswConvert.ToDisplayString(CswConvert.ToTristate(oldValue));
                        break;

                    case CswEnumNbtFieldType.MOL:
                        string molUrl = CswNbtNodePropMol.getLink(Prop.JctNodePropId, NodeId);
                        if (false == string.IsNullOrEmpty(molUrl))
                        {
                            newValue = "<a target=\"blank\" href=\"" + molUrl + "\">" + "Structure.jpg" + "</a>";
                        }
                        break;

                    default:
                        newValue = oldValue;
                        break;
                    }
                }
                gridrow.data[dataIndex] = newValue;
            } // foreach( JObject Prop in ChildProps )

            // Recurse, but add properties of child nodes to the same gridrow
            for (Int32 c = 0; c < Tree.getChildNodeCount(); c++)
            {
                Tree.goToNthChild(c);
                _TreeNodeToGrid(View, Tree, grid, gridrow);
                Tree.goToParentNode();
            }
        } // _TreeNodeToGrid()
 /// <summary>
 /// Get the Current state of the Property's value using the fieldtype rule's default subfield
 /// </summary>
 public string GetSubFieldValue()
 {
     return(GetSubFieldValue(NodeTypeProp.getFieldTypeRule().SubFields.Default));
 }
        } // GeneratedNodeCount

        public CswNbtView GetGeneratedTargetsView( DateTime TargetDay )
        {
            CswNbtView View = new CswNbtView( _CswNbtResources );
            View.ViewName = "Generated Node Count";

            CswNbtMetaDataNodeType TargetNT = _CswNbtResources.MetaData.getNodeType( CswConvert.ToInt32( TargetType.SelectedNodeTypeIds[0] ) );
            CswNbtMetaDataNodeTypeProp GeneratorNTP = TargetNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetGeneratorTarget.PropertyName.Generator );
            CswNbtMetaDataNodeTypeProp CreatedDateNTP = TargetNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetGeneratorTarget.PropertyName.CreatedDate );

            CswNbtViewRelationship TargetRel = View.AddViewRelationship( TargetNT, false );
            View.AddViewPropertyAndFilter( TargetRel,
                                           GeneratorNTP,
                                           Conjunction: CswEnumNbtFilterConjunction.And,
                                           ResultMode: CswEnumNbtFilterResultMode.Hide,
                                           Value: this.NodeId.PrimaryKey.ToString(),
                                           SubFieldName: ( (CswNbtFieldTypeRuleRelationship) GeneratorNTP.getFieldTypeRule() ).NodeIDSubField.Name,
                                           FilterMode: CswEnumNbtFilterMode.Equals );

            if( DateTime.MinValue != TargetDay )
            {
                View.AddViewPropertyAndFilter( TargetRel,
                                               CreatedDateNTP,
                                               Conjunction: CswEnumNbtFilterConjunction.And,
                                               ResultMode: CswEnumNbtFilterResultMode.Hide,
                                               Value: TargetDay.Date.ToString(),
                                               FilterMode: CswEnumNbtFilterMode.Equals );
            }
            return View;
        }