예제 #1
0
        }//ctor

        public override void update()
        {
            _CswTstCaseRsrc = new CswTestCaseRsrc(_CswNbtSchemaModTrnsctn);
            _CswTstCaseRsrc_010.CswNbtSchemaModTrnsctn = _CswNbtSchemaModTrnsctn;
            //Int32 MaterialsPk = Int32.MinValue;


            //SETUP: BEGIN *****************************************
            //Step 1: Make the nodetype ****************************
            Int32                     TestByteArraySize    = 256;
            string                    BlobNodeTypeName     = "TestForBlobNodeType";
            string                    BlobPropName         = "The Blob";
            CswNbtMetaData            CswNbtMetaData       = _CswNbtSchemaModTrnsctn.MetaData;
            CswNbtMetaDataObjectClass GenericObjectClass   = CswNbtMetaData.getObjectClass(CswEnumNbtObjectClass.GenericClass);
            CswNbtMetaDataNodeType    BlobNodeTypeNodeType = CswNbtMetaData.makeNewNodeTypeNew(new CswNbtWcfMetaDataModel.NodeType(GenericObjectClass)
            {
                NodeTypeName = BlobNodeTypeName,
                Category     = string.Empty
            });
            CswNbtMetaDataNodeTypeProp BlobNodeTypeNodeTypeProp = CswNbtMetaData.makeNewPropNew(
                new CswNbtWcfMetaDataModel.NodeTypeProp(BlobNodeTypeNodeType, _CswNbtSchemaModTrnsctn.MetaData.getFieldType(CswEnumNbtFieldType.Image), BlobPropName));


            _CswNbtSchemaModTrnsctn.MetaData.refreshAll();

            if (null == _CswNbtSchemaModTrnsctn.MetaData.getNodeType(BlobNodeTypeName))
            {
                throw (new CswDniException("Nodetype " + BlobNodeTypeName + " was not created; test cannot proceed"));
            }

            //Step 1: Make a node ****************************
            CswNbtNode     BlobNode          = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId(BlobNodeTypeNodeType.NodeTypeId);
            Int32          BlobJctNodePropId = BlobNode.Properties[BlobNodeTypeNodeTypeProp].JctNodePropId;
            CswTableUpdate JctUpdate         = _CswNbtSchemaModTrnsctn.makeCswTableUpdate("CswScmUpdt_TstCse_DataTable_PreserveBlobColumns_1", "jct_nodes_props");

            JctUpdate.AllowBlobColumns = true;
            DataTable JctTable = JctUpdate.getTable("jctnodepropid", BlobJctNodePropId);

            JctTable.Rows[0]["blobdata"] = new Byte[TestByteArraySize];
            JctTable.Rows[0]["field1"]   = "Dummy File Name";
            JctTable.Rows[0]["field2"]   = "Dummy File Type";
            JctUpdate.update(JctTable);


            //SETUP: END *****************************************



            //*** TEST PART 1: That we don't nuke the blob column when select columns are unspecified
            JctUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate("01G02_JctNodesProps_update", "jct_nodes_props");

            JctTable = JctUpdate.getTable();
            foreach (DataRow JctRow in JctTable.Rows)
            {
                JctRow["nodeidtablename"] = "nodes";
            }
            JctUpdate.update(JctTable);


            CswTableSelect CswTableSelect = _CswNbtSchemaModTrnsctn.makeCswTableSelect("CswScmUpdt_TstCse_DataTable_PreserveBlobColumns_2", "jct_nodes_props");
            DataTable      DataTable      = CswTableSelect.getTable(" where blobdata is not null  ");

            if (0 == DataTable.Rows.Count)
            {
                throw (new CswDniException("A generic update of jct_nodes_props nuked the blob columns"));
            }


            //*** TEST PART 2: That we can retrieve and update the blob column when we use the AllowBlob flag
            //***              Note that in the setup sections we implciitly tested that we can retrieve and
            //***              update the blob column when set the AllowBlobFlag.
            JctUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate("01G02_JctNodesProps_update", "jct_nodes_props");

            CswCommaDelimitedString SelectColumns = new CswCommaDelimitedString();

            SelectColumns.Add("field1");
            SelectColumns.Add("field2");
            SelectColumns.Add("blobdata");
            JctTable = JctUpdate.getTable(SelectColumns);

            if (false == JctTable.Columns.Contains("blobdata"))
            {
                throw (new CswDniException("Blob column was not retrieved when it was specified as a select column"));
            }


            Byte[] TestByteArray = new Byte[TestByteArraySize]; // update an arbitrary row

            for (int idx = 0; idx < TestByteArraySize; idx++)
            {
                TestByteArray[idx] = 1;
            }

            JctTable.Rows[0]["blobdata"] = TestByteArray;
            Int32 Arbitraryjctnodepropid = Convert.ToInt32(JctTable.Rows[0]["jctnodepropid"]);

            JctUpdate.update(JctTable);


            CswTableSelect = _CswNbtSchemaModTrnsctn.makeCswTableSelect("CswScmUpdt_TstCse_DataTable_PreserveBlobColumns_2", "jct_nodes_props");
            DataTable      = CswTableSelect.getTable(" where jctnodepropid=  " + Arbitraryjctnodepropid.ToString() + "and blobdata is not null ");

            if (0 == DataTable.Rows.Count)
            {
                throw (new CswDniException("An update of a blob column with specified select columns failed"));
            }


            throw (new CswDniExceptionIgnoreDeliberately());
        }
예제 #2
0
        private static void _makeLocationsTreeView(ref CswNbtView LocationsView, CswNbtMetaData MetaData, CswConfigurationVariables ConfigVbls, Int32 loc_max_depth, CswPrimaryKey NodeIdToFilterOut, bool RequireAllowInventory, IEnumerable <CswPrimaryKey> InventoryGroupIds, bool DisableLowestLevel, CswEnumNbtFilterResultMode ResultMode, string FullPathFilter = "")
        {
            if (null != LocationsView)
            {
                CswNbtMetaDataObjectClass     LocationOC                = MetaData.getObjectClass(CswEnumNbtObjectClass.LocationClass);
                CswNbtMetaDataObjectClassProp LocationLocationOCP       = LocationOC.getObjectClassProp(PropertyName.Location);
                CswNbtMetaDataObjectClassProp LocationOrderOCP          = LocationOC.getObjectClassProp(PropertyName.Order);
                CswNbtMetaDataObjectClassProp LocationAllowInventoryOCP = LocationOC.getObjectClassProp(PropertyName.AllowInventory);
                CswNbtMetaDataObjectClassProp LocationInventoryGroupOCP = LocationOC.getObjectClassProp(PropertyName.InventoryGroup);
                CswNbtMetaDataObjectClassProp LocationNameOCP           = LocationOC.getObjectClassProp(PropertyName.Name);
                CswNbtMetaDataObjectClassProp LocationFullPathOCP       = LocationOC.getObjectClassProp(PropertyName.FullPath);

                LocationsView.Root.ChildRelationships.Clear();

                CswNbtViewRelationship LocReln = LocationsView.AddViewRelationship(LocationOC, true);
                LocationsView.AddViewProperty(LocReln, LocationLocationOCP);

                if (null != NodeIdToFilterOut)
                {
                    LocReln.NodeIdsToFilterOut.Add(NodeIdToFilterOut);
                }

                CswNbtViewProperty InGroupVp = LocationsView.AddViewProperty(LocReln, LocationInventoryGroupOCP);
                InGroupVp.Width = 100;

                if (null != InventoryGroupIds)
                {
                    CswCommaDelimitedString Pks = new CswCommaDelimitedString();
                    foreach (CswPrimaryKey InventoryGroupId in InventoryGroupIds)
                    {
                        Pks.Add(InventoryGroupId.PrimaryKey.ToString());
                    }

                    LocationsView.AddViewPropertyFilter(InGroupVp,
                                                        Conjunction: CswEnumNbtFilterConjunction.And,
                                                        ResultMode: ResultMode,
                                                        FilterMode: CswEnumNbtFilterMode.In,
                                                        SubFieldName: CswNbtFieldTypeRuleRelationship.SubFieldName.NodeID,
                                                        Value: Pks.ToString());
                }

                CswNbtViewProperty OrderVPn = LocationsView.AddViewProperty(LocReln, LocationOrderOCP);
                LocationsView.setSortProperty(OrderVPn, CswEnumNbtViewPropertySortMethod.Ascending, false);

                if (RequireAllowInventory)
                {
                    LocationsView.AddViewPropertyAndFilter(LocReln, LocationAllowInventoryOCP,
                                                           Conjunction: CswEnumNbtFilterConjunction.And,
                                                           ResultMode: ResultMode,
                                                           FilterMode: CswEnumNbtFilterMode.Equals,
                                                           Value: CswEnumTristate.True.ToString());
                }

                // Filter on Full Path property
                if (false == string.IsNullOrEmpty(FullPathFilter))
                {
                    LocationsView.AddViewPropertyAndFilter(LocReln, LocationFullPathOCP,
                                                           Conjunction: CswEnumNbtFilterConjunction.And,
                                                           SubFieldName: CswEnumNbtSubFieldName.Value,
                                                           FilterMode: CswEnumNbtFilterMode.Contains,
                                                           Value: FullPathFilter);
                }
                else
                {
                    LocationsView.AddViewProperty(LocReln, LocationFullPathOCP);
                }

                // Add the Name property to the view
                LocationsView.AddViewProperty(LocReln, LocationNameOCP);
            } // if( null != LocationsView )
        }     // makeLocationsTreeView()