public override void ReadDataRow(DataRow PropRow, Dictionary <string, Int32> NodeMap, Dictionary <Int32, Int32> NodeTypeMap)
        {
            string StringVal = CswTools.XmlRealAttributeName(PropRow[_QuantitySubField.ToXmlNodeName()].ToString());

            if (CswTools.IsFloat(StringVal))
            {
                Quantity = Convert.ToDouble(StringVal);
            }
            CachedUnitName = CswTools.XmlRealAttributeName(PropRow[_UnitNameSubField.ToXmlNodeName()].ToString());

            string NodeId = CswTools.XmlRealAttributeName(PropRow[_UnitIdSubField.ToXmlNodeName()].ToString());

            if (NodeMap != null && NodeMap.ContainsKey(NodeId.ToLower()))
            {
                UnitId = new CswPrimaryKey("nodes", NodeMap[NodeId.ToLower()]);
            }
            else if (CswTools.IsInteger(NodeId))
            {
                UnitId = new CswPrimaryKey("nodes", CswConvert.ToInt32(NodeId));
            }
            else
            {
                UnitId = null;
            }

            if (null != UnitId)
            {
                PendingUpdate = true;
            }
        }
Beispiel #2
0
        public CswNbtNodePropViewReference(CswNbtResources CswNbtResources, CswNbtNodePropData CswNbtNodePropData, CswNbtMetaDataNodeTypeProp CswNbtMetaDataNodeTypeProp, CswNbtNode Node)
            : base(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node)
        {
            _ViewIdSubField         = ((CswNbtFieldTypeRuleViewReference)_FieldTypeRule).ViewIdSubField;
            _CachedViewNameSubField = ((CswNbtFieldTypeRuleViewReference)_FieldTypeRule).CachedViewNameSubField;


            // Associate subfields with methods on this object, for SetSubFieldValue()
            _SubFieldMethods.Add(_ViewIdSubField.Name, new Tuple <Func <dynamic>, Action <dynamic> >(() => ViewId,
                                                                                                     x =>
            {
                if (CswTools.IsInteger(x))
                {
                    ViewId = new CswNbtViewId(CswConvert.ToInt32(x));
                }
                else if (x is CswNbtViewId)
                {
                    ViewId = x;
                }
                else if (string.IsNullOrEmpty(x))
                {
                    ViewId = null;
                }
                else
                {
                    throw new CswDniException(CswEnumErrorType.Error, "Invalid parameter", "CswNbtNodePropViewReference got an invalid parameter for setting ViewId: " + x.ToString());
                }
            }));
            _SubFieldMethods.Add(_CachedViewNameSubField.Name, new Tuple <Func <dynamic>, Action <dynamic> >(() => CachedViewName, x => CachedViewName = CswConvert.ToString(x)));
        }
        public CswNbtNode GetNode(string NodeId, string NodeKey, CswDateTime Date = null)
        {
            CswNbtNode Node = null;

            if (!string.IsNullOrEmpty(NodeKey))
            {
                //CswNbtNodeKey RealNodeKey = new CswNbtNodeKey( CswNbtResources, FromSafeJavaScriptParam( NodeKey ) );
                CswNbtNodeKey RealNodeKey = new CswNbtNodeKey(NodeKey);
                Node = _CswNbtResources.getNode(RealNodeKey, Date);
            }
            else if (!string.IsNullOrEmpty(NodeId))
            {
                CswPrimaryKey RealNodeId = new CswPrimaryKey();
                if (CswTools.IsInteger(NodeId))
                {
                    RealNodeId.TableName  = "nodes";
                    RealNodeId.PrimaryKey = CswConvert.ToInt32(NodeId);
                }
                else
                {
                    RealNodeId.FromString(NodeId);
                }
                Node = _CswNbtResources.getNode(RealNodeId, Date);
            }
            return(Node);
        } // getNode()
Beispiel #4
0
        public static bool isSessionDataIdString(string TestString)
        {
            CswDelimitedString delimstr = new CswDelimitedString(_delimiter);

            delimstr.FromString(TestString);

            return(delimstr.Count == 2 &&
                   delimstr[0] == _StringPrefix &&
                   CswTools.IsInteger(delimstr[1]));
        }
Beispiel #5
0
        public static bool isViewIdString(string TestString)
        {
            CswDelimitedString delimstr = new CswDelimitedString(_delimiter);

            delimstr.FromString(TestString);

            return(delimstr.Count == 2 &&
                   delimstr[0].ToLower() == _StringPrefix.ToLower() &&
                   CswTools.IsInteger(delimstr[1]));
        }
Beispiel #6
0
        public CswNbtWebServiceMobile(CswNbtResources CswNbtResources, bool ForMobile)
        {
            _CswNbtResources = CswNbtResources;
            _ForMobile       = ForMobile;
            string PageSize = _CswNbtResources.ConfigVbls.getConfigVariableValue(CswNbtResources.ConfigurationVariables.mobileview_resultlim.ToString());

            if (CswTools.IsInteger(PageSize))
            {
                _MobilePageSize = CswConvert.ToInt32(PageSize);
            }
        }
        } // ToJSON()

        public override void ReadDataRow( DataRow PropRow, Dictionary<string, Int32> NodeMap, Dictionary<Int32, Int32> NodeTypeMap )
        {
            string NodeId = CswTools.XmlRealAttributeName( PropRow[_NodeIDSubField.ToXmlNodeName()].ToString() );
            if( NodeMap != null && NodeMap.ContainsKey( NodeId.ToLower() ) )
                RelatedNodeId = new CswPrimaryKey( "nodes", NodeMap[NodeId.ToLower()] );
            else if( CswTools.IsInteger( NodeId ) )
                RelatedNodeId = new CswPrimaryKey( "nodes", CswConvert.ToInt32( NodeId ) );
            else
                RelatedNodeId = null;

            if( null != RelatedNodeId )
            {
                PendingUpdate = true;
            }
        }
Beispiel #8
0
        } // formatSequence()

        public Int32 deformatSequence(string FormattedSequenceVal)
        {
            Int32  ret     = Int32.MinValue;
            string PrepVal = Pre.Text;
            string PostVal = Post.Text;

            if (FormattedSequenceVal.Length > (PrepVal.Length + PostVal.Length))
            {
                if (FormattedSequenceVal.Substring(0, PrepVal.Length) == PrepVal &&
                    FormattedSequenceVal.Substring(FormattedSequenceVal.Length - PostVal.Length, PostVal.Length) == PostVal)
                {
                    string RawSequenceVal = FormattedSequenceVal.Substring(PrepVal.Length, (FormattedSequenceVal.Length - PrepVal.Length - PostVal.Length));
                    if (CswTools.IsInteger(RawSequenceVal))
                    {
                        ret = CswConvert.ToInt32(RawSequenceVal);
                    }
                }
            }
            return(ret);
        } // deformatSequence()
Beispiel #9
0
        /// <summary>
        /// Constructor for string version of Schema Version tag.  Detects single integers for backwards compatibility.
        /// </summary>
        public CswSchemaVersion(string SchemaVersionAsString)
        {
            if (SchemaVersionAsString.Length < 6 && CswTools.IsInteger(SchemaVersionAsString))
            {
                // Example: 74   (backwards compatibility)
                _init(0, 'X', CswConvert.ToInt32(SchemaVersionAsString));
            }
            else
            {
                // Example: 01F-02

                Int32 CycleIteration    = CswConvert.ToInt32(SchemaVersionAsString.Substring(0, 2));
                char  ReleaseIdentifier = SchemaVersionAsString.Substring(2, 1)[0];

                //case 27448: variable length iteration segment (retro-handle 2-character segments and forward-handle 3-character segments)
                Int32 ReleaseIteration = CswConvert.ToInt32(SchemaVersionAsString.Substring(4, SchemaVersionAsString.Length - 4));

                _init(CycleIteration, ReleaseIdentifier, ReleaseIteration);
            }
        }
        private void _initDefaultValue(bool CreateMissingRow)
        {
            if (_DefaultValue == null)
            {
                if (_DefaultValueRow == null)
                {
                    if (_ObjectClassPropRow.Table.Columns.Contains("defaultvalueid"))
                    {
                        if (_ObjectClassPropRow["defaultvalueid"] != null && CswTools.IsInteger(_ObjectClassPropRow["defaultvalueid"]))
                        {
                            DataTable DefaultValueTable = _CswNbtMetaDataResources.JctNodesPropsTableUpdate.getTable("jctnodepropid", CswConvert.ToInt32(_ObjectClassPropRow["defaultvalueid"]));
                            //WARNING: there is a possibility that DefaultValueTable will be empty, upon which DefaultValue will not be set.
                            //This can cause _CswNbtSchemaModTrnsctn.MetaData.SetObjectClassPropDefaultValue() to throw an ORNY exception.
                            //This needs to be fixed at some point - see Reviews K4156 and K4157 for details.
                            if (DefaultValueTable.Rows.Count > 0)
                            {
                                _DefaultValueRow = DefaultValueTable.Rows[0];
                            }
                        }
                        else if (CreateMissingRow)
                        {
                            DataTable NewDefaultValueTable = _CswNbtMetaDataResources.JctNodesPropsTableUpdate.getEmptyTable();
                            _DefaultValueRow = NewDefaultValueTable.NewRow();
                            _DefaultValueRow["objectclasspropid"] = CswConvert.ToDbVal(this.PropId);
                            NewDefaultValueTable.Rows.Add(_DefaultValueRow);

                            _ObjectClassPropRow["defaultvalueid"] = _DefaultValueRow["jctnodepropid"];
                            _CswNbtMetaDataResources.ObjectClassPropTableUpdate.update(_ObjectClassPropRow.Table);
                        }
                    } // if( _NodeTypePropRow.Table.Columns.Contains( "defaultvalueid" ) )
                }     // if( _DefaultValueRow == null )

                if (_DefaultValueRow != null)
                {
                    _DefaultValue = new CswNbtNodePropData(_CswNbtMetaDataResources.CswNbtResources, _DefaultValueRow, _DefaultValueRow.Table, ObjectClassPropId, null);
                }
            } // if( _DefaultValue == null )
        }
        public CswNbtNodePropMetaDataList(CswNbtResources CswNbtResources, CswNbtNodePropData CswNbtNodePropData, CswNbtMetaDataNodeTypeProp CswNbtMetaDataNodeTypeProp, CswNbtNode Node)
            : base(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node)
        {
            _TypeSubField = ((CswNbtFieldTypeRuleMetaDataList)_FieldTypeRule).TypeSubField;
            _IdSubField   = ((CswNbtFieldTypeRuleMetaDataList)_FieldTypeRule).IdSubField;
            _TextSubField = ((CswNbtFieldTypeRuleMetaDataList)_FieldTypeRule).TextSubField;

            _ConstrainToObjectClass = CswNbtNodePropData[CswNbtFieldTypeRuleMetaDataList.AttributeName.ConstrainToObjectClass];

            // Associate subfields with methods on this object, for SetSubFieldValue()
            _SubFieldMethods.Add(_TypeSubField.Name, new Tuple <Func <dynamic>, Action <dynamic> >(() => Type, x => Type = CswConvert.ToString(x)));
            _SubFieldMethods.Add(_TextSubField.Name, new Tuple <Func <dynamic>, Action <dynamic> >(() => Text, x => Text = CswConvert.ToString(x)));
            _SubFieldMethods.Add(_IdSubField.Name, new Tuple <Func <dynamic>, Action <dynamic> >(() => Id,
                                                                                                 delegate(dynamic x)
            {
                if (CswTools.IsInteger(x))
                {
                    if (Type == CswEnumNbtViewRelatedIdType.NodeTypeId)
                    {
                        setValue(NodeTypePrefix + CswConvert.ToString(x));
                    }
                    else if (Type == CswEnumNbtViewRelatedIdType.ObjectClassId)
                    {
                        setValue(ObjectClassPrefix + CswConvert.ToString(x));
                    }
                    else if (Type == CswEnumNbtViewRelatedIdType.PropertySetId)
                    {
                        setValue(PropertySetPrefix + CswConvert.ToString(x));
                    }
                }
                else
                {
                    setValue(CswConvert.ToString(x));
                }
            }));
        }
        public override void ReadDataRow(DataRow PropRow, Dictionary <string, Int32> NodeMap, Dictionary <Int32, Int32> NodeTypeMap)
        {
            string UserIds = CswTools.XmlRealAttributeName(PropRow[_SelectedUserIdsSubField.ToXmlNodeName()].ToString());

            SelectedUserIds.FromString(UserIds);

            foreach (string UserIdString in SelectedUserIds)
            {
                Int32 UserId = Int32.MinValue;
                if (NodeMap != null && NodeMap.ContainsKey(UserIdString.ToLower()))
                {
                    UserId = NodeMap[UserIdString.ToLower()];
                }
                else if (CswTools.IsInteger(UserIdString))
                {
                    UserId = CswConvert.ToInt32(UserIdString);
                }
                if (UserId != Int32.MinValue)
                {
                    SelectedUserIds.Replace(UserIdString, UserId.ToString());
                }
            }
            PendingUpdate = true;
        }
        public HMISData getHMISData(HMISData.HMISDataRequest Request)
        {
            HMISData      Data          = new HMISData();
            CswPrimaryKey ControlZoneId = null;

            if (false == string.IsNullOrEmpty(Request.ControlZoneId))
            {
                ControlZoneId = CswConvert.ToPrimaryKey(Request.ControlZoneId);
            }
            else if (false == string.IsNullOrEmpty(Request.ControlZone))
            {
                if (CswTools.IsInteger(Request.ControlZone))
                {
                    ControlZoneId = new CswPrimaryKey("nodes", CswConvert.ToInt32(Request.ControlZone));
                }
                else
                {
                    CswNbtView  ControlZoneView = getControlZonesView(Request.ControlZone);
                    ICswNbtTree ControlZoneTree = _CswNbtResources.Trees.getTreeFromView(ControlZoneView, RequireViewPermissions: false, IncludeSystemNodes: true, IncludeHiddenNodes: true);
                    if (ControlZoneTree.getChildNodeCount() > 0)
                    {
                        ControlZoneTree.goToNthChild(0);
                        ControlZoneId = ControlZoneTree.getNodeIdForCurrentPosition();
                    }
                }
            }

            if (CswTools.IsPrimaryKey(ControlZoneId))
            {
                Data.ControlZone = _CswNbtResources.Nodes.getNodeName(ControlZoneId);

                string HMISSql = @"with loc as (select n.nodeid
                                                  from nodes n
                                                  join nodetypes t on t.nodetypeid = n.nodetypeid
                                                  join object_class oc on t.objectclassid = oc.objectclassid
                                                  join (select j.nodeid, j.field1_fk 
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Control Zone'
                                                       ) cz on (cz.nodeid = n.nodeid)
                                                 where oc.objectclass = 'LocationClass'
                                                   and cz.field1_fk = " + ControlZoneId.PrimaryKey + @"
                                               ),
                                        mat as (select n.nodeid, n.nodename materialname, hc.clobdata hazardclasses, sf.gestaltsearch specialflags, ps.field1 physstate
                                                  from nodes n
                                                  join nodetypes t on t.nodetypeid = n.nodetypeid
                                                  join object_class oc on t.objectclassid = oc.objectclassid
                                                  join (select j.nodeid, j.clobdata
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Hazard Classes'
                                                       ) hc on (hc.nodeid = n.nodeid)
                                                  join (select j.nodeid, j.gestaltsearch 
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Special Flags'
                                                       ) sf on (sf.nodeid = n.nodeid)
                                                  join (select j.nodeid, j.field1
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Physical State'
                                                       ) ps on (ps.nodeid = n.nodeid)
                                                 where oc.objectclass = 'ChemicalClass'
                                                   and (sf.gestaltsearch is null or sf.gestaltsearch not like '%not reportable%')";
                if (string.IsNullOrEmpty(Request.Class))
                {
                    HMISSql += "   and hc.clobdata is not null";
                }
                else
                {
                    HMISSql += "   and hc.clobdata like '%" + Request.Class + @"%'";
                }
                HMISSql += @"                ),
                                       cont as (select SUM(q.field2_numeric) total_qty_kg, 
                                                       SUM(q.field3_numeric) total_qty_lt, 
                                                       ut.field1 usetype, 
                                                       m.field1_fk materialid
                                                  from nodes n
                                                  join nodetypes t on t.nodetypeid = n.nodetypeid
                                                  join object_class oc on t.objectclassid = oc.objectclassid
                                                  join (select j.nodeid, j.field1_fk 
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Location'
                                                       ) l on (l.nodeid = n.nodeid)
                                                  join (select j.nodeid, j.field2_numeric, j.field3_numeric 
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Quantity'
                                                       ) q on (q.nodeid = n.nodeid)
                                                  join (select j.nodeid, j.field1 
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Use Type'
                                                       ) ut on (ut.nodeid = n.nodeid)
                                                  join (select j.nodeid, j.field1_fk 
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Material'
                                                       ) m on (m.nodeid = n.nodeid)
                                                 where oc.objectclass = 'ContainerClass'
                                                   and ut.field1 is not null
                                                   and l.field1_fk in (select nodeid from loc) 
                                                   and (q.field2_numeric > 0 
                                                     or q.field3_numeric > 0)
                                                 group by ut.field1, m.field1_fk
                                               )
                                   select c.*, mat.hazardclasses, mat.specialflags, mat.materialname, mat.physstate
                                     from cont c
                                     join mat on (c.materialid = mat.nodeid)";
                CswArbitrarySelect HMISSelect = _CswNbtResources.makeCswArbitrarySelect("HMIS_Select", HMISSql);
                DataTable          HMISTable  = HMISSelect.getTable();

                if (string.IsNullOrEmpty(Request.Class))
                {
                    // Get totals for all classes
                    _setFireClasses(ControlZoneId, Data);

                    foreach (DataRow row in HMISTable.Rows)
                    {
                        CswCommaDelimitedString HazardClasses = new CswCommaDelimitedString();
                        HazardClasses.FromString(CswConvert.ToString(row["hazardclasses"]));
                        if (HazardClasses.Contains("FL-1A") || HazardClasses.Contains("FL-1B") || HazardClasses.Contains("FL-1C"))
                        {
                            HazardClasses.Add("FL-Comb");
                        }
                        foreach (String HazardClass in HazardClasses)
                        {
                            HMISData.HMISMaterial HMISMaterial = Data.Materials.FirstOrDefault(EmptyHazardClass => EmptyHazardClass.HazardClass == HazardClass);
                            if (null != HMISMaterial)  //This would only be null if the Material's HazardClass options don't match the Default FireClass nodes
                            {
                                _addQuantityDataToHMISMaterial(HMISMaterial,
                                                               CswConvert.ToString(row["usetype"]),
                                                               CswConvert.ToDouble(row["total_qty_kg"]),
                                                               CswConvert.ToDouble(row["total_qty_lt"]),
                                                               CswConvert.ToString(row["physstate"]),
                                                               new CswPrimaryKey("nodes", CswConvert.ToInt32(row["materialid"])));
                            }
                        }
                    } // foreach( DataRow row in HMISTable )
                }     // if( string.IsNullOrEmpty( Request.Class ) )
                else
                {
                    // Get material information for one class
                    foreach (DataRow row in HMISTable.Rows)
                    {
                        HMISData.HMISMaterial NewMaterial = new HMISData.HMISMaterial
                        {
                            Material    = CswConvert.ToString(row["materialname"]),
                            NodeId      = CswConvert.ToInt32(row["materialid"]),
                            HazardClass = Request.Class
                        };
                        _addQuantityDataToHMISMaterial(NewMaterial,
                                                       CswConvert.ToString(row["usetype"]),
                                                       CswConvert.ToDouble(row["total_qty_kg"]),
                                                       CswConvert.ToDouble(row["total_qty_lt"]),
                                                       CswConvert.ToString(row["physstate"]),
                                                       new CswPrimaryKey("nodes", CswConvert.ToInt32(row["materialid"])));
                        Data.Materials.Add(NewMaterial);
                    }
                } // if-else( string.IsNullOrEmpty( Request.Class ) )
            }     // if( CswTools.IsPrimaryKey( ControlZoneId ) )
            return(Data);
        }
        private string _makeNodeSql()
        {
            string CurrentUserIdClause = string.Empty;

            if (null != _CswNbtResources.CurrentNbtUser && null != _CswNbtResources.CurrentNbtUser.UserId)
            {
                CurrentUserIdClause = " and f.userid = " + _CswNbtResources.CurrentNbtUser.UserId.PrimaryKey;
            }
            IEnumerable <string> SafeLikeClauses = _makeSafeLikeClauses();
            string Query = string.Empty;

            if (SafeLikeClauses.Any())
            {
                Query += @" with props as ( select p.nodetypeid, p.objectclasspropid, p.nodetypepropid, p.propname, f.fieldtype, nl.nodetypelayoutid, nl.display_row, op.propname as objectclasspropname
                                              from nodetype_props p
                                              join field_types f on p.fieldtypeid = f.fieldtypeid
                                              left outer join nodetype_layout nl on (nl.nodetypepropid = p.nodetypepropid and nl.layouttype = 'Table')
                                              left outer join object_class_props op on p.objectclasspropid = op.objectclasspropid
                                             where ( nl.nodetypelayoutid is not null 
                                                     or f.fieldtype in ('Image', 'MOL') 
                                                     or ( f.searchable = '1'
                                                          and p.nodetypepropid in (select nodetypepropid 
                                                                                     from jct_nodes_props j ";
                Query += "                                                          where ( ";
                bool first = true;
                foreach (string SafeLikeClause in SafeLikeClauses)
                {
                    if (false == first)
                    {
                        Query += "                                                     or ";
                    }
                    Query += "                                                             j.gestaltsearch " + SafeLikeClause + " ";
                    first  = false;
                }
                Query += @"                                                               )
                                                                                  )
                                                       )
                                                  )
                                          ),

                                 jctnd as ( select jnp.nodeid, jnp.gestaltsearch
                                              from jct_nodes_props jnp
                                              join nodetype_props p on (jnp.nodetypepropid = p.nodetypepropid)
                                              join nodetypes t on (p.nodetypeid = t.nodetypeid)
                                              join field_types f on (p.fieldtypeid = f.fieldtypeid)
                                              where f.searchable = '1'";
                if (false == _SingleNodetype)
                {
                    Query += @"                   and t.searchdeferpropid is null";
                    Query += @"                   and t.searchable = '1'";
                }
                Query += @"                UNION
                                            select rn.nodeid, jnp.gestaltsearch
                                              from nodes n
                                              join jct_nodes_props jnp on jnp.nodeid = n.nodeid
                                              join nodetype_props p on (jnp.nodetypepropid = p.nodetypepropid)
                                              join field_types f on (p.fieldtypeid = f.fieldtypeid)
                                              join nodetypes t on t.nodetypeid = p.nodetypeid
                                              join nodetype_props r on t.searchdeferpropid = r.nodetypepropid
                                              join jct_nodes_props rj on (r.nodetypepropid = rj.nodetypepropid and rj.nodeid = n.nodeid)
                                              join nodes rn on rj.field1_fk = rn.nodeid
                                             where f.searchable = '1'
                                          ),

                                pval as (select j.nodeid, op.propname, j.field1_fk
                                           from object_class_props op
                                           join nodetype_props p on op.objectclasspropid = p.objectclasspropid
                                           join jct_nodes_props j on j.nodetypepropid = p.nodetypepropid
                                          where op.propname in ('Location', 'Inventory Group', 'Report Group', 'Mail Report Group')
                                        ),
                                permgrp as ( " + _makePermissionGroupSQL() + @" ),
                                obsoleteprops as ( " + _makeMaterialObsoleteFilterSQL() + @" ),
                                  srch as ( select n.nodeid,
                                                   n.relationalid, n.relationaltable,
                                                   n.nodename,
                                                   n.locked,
                                                   nvl(n.iconfilename, t.iconfilename) iconfilename,
                                                   t.nodetypename,
                                                   t.nametemplate,
                                                   t.nodetypeid,
                                                   o.objectclass,
                                                   o.objectclassid,
                                                   lower(n.nodename) mssqlorder,
                                                   props.nodetypepropid,
                                                   props.objectclasspropid,
                                                   props.propname,
                                                   props.objectclasspropname,
                                                   props.fieldtype,
                                                   props.display_row,
                                                   propval.jctnodepropid,
                                                   propval.gestaltsearch as gestalt,
                                                   propval.field1,
                                                   propval.field2,
                                                   propval.field1_fk,
                                                   propval.field1_numeric,
                                                   propval.hidden,
                                                   propval.field1_big,
                                                   i.permissiongroupid,
                                                   f.userid,
                                                   oprops.obsolete
                                              from nodes n
                                              join nodetypes t on (n.nodetypeid = t.nodetypeid)
                                              join object_class o on (t.objectclassid = o.objectclassid)
                                              left outer join favorites f on n.nodeid = f.itemid " + CurrentUserIdClause + @"
                                              left outer join permgrp i on (n.nodeid = i.nodeid)
                                              left outer join props on (props.nodetypeid = t.nodetypeid)
                                              left outer join obsoleteprops oprops on (oprops.nodeid = n.nodeid)
                                              left outer join jct_nodes_props propvaljoin on (props.nodetypepropid = propvaljoin.nodetypepropid and propvaljoin.nodeid = n.nodeid)
                                              left outer join jct_nodes_props propval on (propval.jctnodepropid = propvaljoin.jctnodepropid)
                                             where n.istemp = '0' ";
                //If we have access to disabled module MetaData, we should have access to their Nodes as well
                if (_CswNbtResources.MetaData.ExcludeDisabledModules)
                {
                    Query += "                 and t.enabled = '1' ";
                }
                // case 31056
                if (_OnlyMergeableNodeTypes)
                {
                    Query += "                 and t.mergeable = '1' ";
                }
                // BZ 6008
                if (!_IncludeSystemNodes)
                {
                    Query += "                 and n.issystem = '0' ";
                }
                //case 27862
                if (false == _IncludeHiddenNodes)
                {
                    Query += "                 and n.hidden = '0' ";
                }

                Query += "                     and ( ";
                first  = true;
                foreach (string SafeLikeClause in SafeLikeClauses)
                {
                    if (false == first)
                    {
                        Query += "                     and ";
                    }
                    Query += "                             n.nodeid in (select nodeid from jctnd where gestaltsearch " + SafeLikeClause;
                    if (CswTools.IsInteger(_SearchTerm))
                    {
                        Query += @"                                      union select " + _SearchTerm + " from dual";
                    }
                    Query += "                                         ) ";
                    first  = false;
                }
                Query += @"                        ) ";
                if (false == _SingleNodetype)
                {
                    Query += @"                    and t.searchable = '1'";
                    Query += @"                    and t.searchdeferpropid is null";
                }
                Query += @"                    and ( n.searchable = '1' or ( props.fieldtype = 'Barcode' and propval.field1 = '" + CswTools.SafeSqlParam(_SearchTerm) + @"' ) )";
                // CIS-52280
                Query += @"                    and ( oprops.obsolete is null or oprops.obsolete = '0' or oprops.obsolete = 'N')";
                Query += _ExtraWhereClause;
                // Case 31351: Exclude specific nodes
                if (_ExcludeNodeIds.Count > 0)
                {
                    Query += "                     and n.nodeid not in (" + _ExcludeNodeIds.ToString() + ") ";
                }
                Query += @"               )
                
                                   select *
                                     from srch";

                // Handle result limits by looking at unique nodeids in the results
                Query += @"         where srch.nodeid in ( select nodeid 
                                                             from ( select nodeid, rownum as rnum
                                                                      from (select distinct nodeid from srch))
                                                            where rnum <= " + _CswNbtResources.TreeViewResultLimit + @")
                                    order by srch.userid, lower(srch.nodename), srch.nodeid, lower(srch.propname), srch.display_row ";
            }
            return(Query);
        } //_makeNodeSql()
Beispiel #15
0
        /// <summary>
        /// Set property values according to the value in the DbConfig file or from the target schema
        /// </summary>
        public void syncCustomerInfo()
        {
            if( _CompanyIDDefined() )
            {
                // get data from DbConfig file
                _CswNbtResources.CswDbCfgInfo.makeConfigurationCurrent( CompanyID.Text );
                if( _CswNbtResources.CswDbCfgInfo.CurrentDeactivated )
                    Deactivated.Checked = CswEnumTristate.True;
                else
                    Deactivated.Checked = CswEnumTristate.False;
                IPFilterRegex.Text = _CswNbtResources.CswDbCfgInfo.CurrentIPFilterRegex;
                if( CswTools.IsInteger( _CswNbtResources.CswDbCfgInfo.CurrentUserCount ) )
                    UserCount.Value = CswConvert.ToInt32( _CswNbtResources.CswDbCfgInfo.CurrentUserCount );
                else
                    UserCount.Value = Double.NaN;

                // case 25960
                this.SchemaName.StaticText = _CswNbtResources.CswDbCfgInfo.CurrentUserName;

                CswCommaDelimitedString YValues = new CswCommaDelimitedString();
                foreach( CswEnumNbtModuleName ModuleName in CswEnumNbtModuleName.All )
                {
                    if( CswEnumNbtModuleName.Unknown != ModuleName )
                    {
                        YValues.Add( ModuleName.ToString() );
                    }
                }
                ModulesEnabled.YValues = YValues;
                ModulesEnabled.XValues = new CswCommaDelimitedString() { ModulesEnabledXValue };

                // get data from target schema
                //string OriginalAccessId = _CswNbtResources.AccessId;
                //_CswNbtResources.AccessId = CompanyID.Text;
                CswNbtResources OtherResources = makeOtherResources();

                Collection<CswEnumNbtModuleName> Modules = new Collection<CswEnumNbtModuleName>();
                foreach( CswEnumNbtModuleName Module in OtherResources.Modules.ModulesEnabled() )
                {
                    Modules.Add( Module );
                }

                // case 25960
                string OtherSchemaVersion = OtherResources.ConfigVbls.getConfigVariableValue( CswEnumNbtConfigurationVariables.schemaversion.ToString() );

                //case 28079 - count the number of pending feedback nodes
                int count = 0;
                //Sourced from case 29852. If this schema is out of date, it's very possible that touching MetaData will generate an exception. 
                //Per Steve, we're not doing anything about this now.
                CswNbtMetaDataObjectClass feedbackOC = OtherResources.MetaData.getObjectClass( CswEnumNbtObjectClass.FeedbackClass );
                foreach( CswNbtObjClassFeedback feedbackNode in feedbackOC.getNodes( false, false ) )
                {
                    if( feedbackNode.Status.Value.Equals( CswNbtObjClassFeedback.Statuses.PendingReview ) )
                    {
                        count++;
                    }
                }
                PendingFeedbackCount.Value = count;

                // reconnect to original schema
                //_CswNbtResources.AccessId = OriginalAccessId;
                finalizeOtherResources( OtherResources );

                foreach( CswEnumNbtModuleName ModuleName in CswEnumNbtModuleName.All )
                {
                    if( CswEnumNbtModuleName.Unknown != ModuleName )
                    {
                        ModulesEnabled.SetValue( ModulesEnabledXValue, ModuleName.ToString(), Modules.Contains( ModuleName ) );
                    }
                }

                this.SchemaVersion.StaticText = OtherSchemaVersion;

                //case 29751
                if( CompanyID.Text == _CswNbtResources.AccessId )
                {
                    Login.setHidden( true, false );
                }
            }
        } // syncCustomerInfo()
        public static string renderViewPropFilter(ICswNbtUser RunAsUser, CswNbtFieldResources CswNbtFieldResources, CswNbtViewPropertyFilter CswNbtViewPropertyFilterIn, CswEnumNbtPropColumn Column)
        {
            string ValueColumn  = "jnp." + Column.ToString();
            string ReturnVal    = string.Empty;
            bool   IncludesTime = false;

            DateTime FilterValue = DateTime.MinValue;
            string   Value       = CswNbtViewPropertyFilterIn.Value.ToLower().Trim();

            if (Value.StartsWith("today"))
            {
                Int32 PlusDays = 0;
                if (Value.Length > "today".Length)
                {
                    string Operator = Value.Substring("today".Length, 1);
                    string Operand  = Value.Substring("today".Length + 1);
                    if (CswTools.IsInteger(Operand))
                    {
                        PlusDays = CswConvert.ToInt32(Operand);
                        if (Operator == "-")
                        {
                            PlusDays = PlusDays * -1;
                        }
                    }
                }
                FilterValue = DateTime.Now.AddDays(PlusDays).Date;
            }
            else
            {
                FilterValue = CswConvert.ToDateTime(CswNbtViewPropertyFilterIn.Value);
                if (FilterValue.TimeOfDay != TimeSpan.Zero)  // midnight
                {
                    IncludesTime = true;
                }
            }

            if (CswNbtViewPropertyFilterIn.FilterMode == CswEnumNbtFilterMode.NotNull)
            {
                ReturnVal = ValueColumn + " is not null";
            }
            else if (CswNbtViewPropertyFilterIn.FilterMode == CswEnumNbtFilterMode.Null)
            {
                ReturnVal = ValueColumn + " is null";
            }
            else if (FilterValue != DateTime.MinValue)
            {
                // case 26844
                // If no time was specified in our filter value, then
                // we need to ignore the time part of values in our comparisons

                string ThisDayString = CswNbtFieldResources.CswNbtResources.getDbNativeDate(FilterValue);
                string NextDayString = CswNbtFieldResources.CswNbtResources.getDbNativeDate(FilterValue.AddDays(1));

                if (CswNbtViewPropertyFilterIn.FilterMode == CswEnumNbtFilterMode.Equals)
                {
                    if (IncludesTime)
                    {
                        ReturnVal = ValueColumn + " = " + ThisDayString;
                    }
                    else
                    {
                        ReturnVal  = ValueColumn + " >= " + ThisDayString;
                        ReturnVal += " and " + ValueColumn + " < " + NextDayString;
                    }
                }
                else if (CswNbtViewPropertyFilterIn.FilterMode == CswEnumNbtFilterMode.GreaterThan)
                {
                    if (IncludesTime)
                    {
                        ReturnVal = ValueColumn + " > " + ThisDayString;
                    }
                    else
                    {
                        ReturnVal = ValueColumn + " >= " + NextDayString;
                    }
                }
                else if (CswNbtViewPropertyFilterIn.FilterMode == CswEnumNbtFilterMode.GreaterThanOrEquals)
                {
                    ReturnVal = ValueColumn + " >= " + ThisDayString;
                }
                else if (CswNbtViewPropertyFilterIn.FilterMode == CswEnumNbtFilterMode.LessThan)
                {
                    ReturnVal = ValueColumn + " < " + ThisDayString;
                }
                else if (CswNbtViewPropertyFilterIn.FilterMode == CswEnumNbtFilterMode.LessThanOrEquals)
                {
                    if (IncludesTime)
                    {
                        ReturnVal = ValueColumn + " <= " + ThisDayString;
                    }
                    else
                    {
                        ReturnVal = ValueColumn + " < " + NextDayString;   // not <=, see case 28620
                    }
                }
                else if (CswNbtViewPropertyFilterIn.FilterMode == CswEnumNbtFilterMode.NotEquals)
                {
                    if (IncludesTime)
                    {
                        ReturnVal = ValueColumn + " <> " + ThisDayString;
                    }
                    else
                    {
                        ReturnVal  = "(" + ValueColumn + " < " + ThisDayString;
                        ReturnVal += " or " + ValueColumn + " >= " + NextDayString + ")";
                    }
                }
                else
                {
                    throw new CswDniException(CswEnumErrorType.Error, "Invalid filter", "An invalid FilterMode was encountered in CswNbtNodeProp.GetFilter()) { " + CswNbtViewPropertyFilterIn.FilterMode.ToString());
                } // switch( CswNbtViewPropertyFilterIn.FilterMode )
            }     // if( FilterValue != DateTime.MinValue )

            return(ReturnVal);
        }//renderViewPropFilter()
        public CswNbtNodePropRelationship( CswNbtResources CswNbtResources, CswNbtNodePropData CswNbtNodePropData, CswNbtMetaDataNodeTypeProp CswNbtMetaDataNodeTypeProp, CswNbtNode Node )
            : base( CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node )
        {
            _NameSubField = ( (CswNbtFieldTypeRuleRelationship) _FieldTypeRule ).NameSubField;
            _NodeIDSubField = ( (CswNbtFieldTypeRuleRelationship) _FieldTypeRule ).NodeIDSubField;

            // case 25956
            _SearchThreshold = CswConvert.ToInt32( _CswNbtResources.ConfigVbls.getConfigVariableValue( CswEnumNbtConfigurationVariables.relationshipoptionlimit.ToString() ) );
            if( _SearchThreshold <= 0 )
            {
                _SearchThreshold = 100;
            }

            // Associate subfields with methods on this object, for SetSubFieldValue()
            _SubFieldMethods.Add( _NameSubField.Name, new Tuple<Func<dynamic>, Action<dynamic>>( () => CachedNodeName, x => CachedNodeName = CswConvert.ToString( x ) ) );
            _SubFieldMethods.Add( _NodeIDSubField.Name, new Tuple<Func<dynamic>, Action<dynamic>>( () => RelatedNodeId,
                                                                                              x =>
                                                                                              {
                                                                                                  if( CswTools.IsInteger( x ) )
                                                                                                  {
                                                                                                      RelatedNodeId = new CswPrimaryKey( "nodes", x );
                                                                                                  }
                                                                                                  else
                                                                                                  {
                                                                                                      RelatedNodeId = CswConvert.ToPrimaryKey( x );
                                                                                                  }
                                                                                              } ) );
        }