} // _populateDictionary()

        /// <summary>
        /// FOR DISPLAYING CHEMCAT RESULTS
        /// </summary>
        /// <param name="C3SearchResultsObj"></param>
        /// <param name="PropsToHide"></param>
        /// <returns></returns>
        private Int32 _populateDictionary( CswRetObjSearchResults C3SearchResultsObj, Collection<string> PropsToHide, string DataService )
        {
            Int32 results = 0;

            for( int i = 0; i < C3SearchResultsObj.CswC3SearchResults.Count(); i++ )//todo: if results are null
            {
                TableNode thisNode = new TableNode();

                //Note: For now, we are hardcoding the nodetype as "Chemical" for each results from ChemCatCentral.
                thisNode.NodeType = _CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.ChemicalClass ).FirstNodeType;
                if( null != thisNode.NodeType )
                {
                    // default image, overridden below
                    if( thisNode.NodeType.IconFileName != string.Empty )
                    {
                        thisNode.ThumbnailUrl = CswNbtMetaDataObjectClass.IconPrefix100 + thisNode.NodeType.IconFileName;
                    }
                    else
                    {
                        thisNode.ThumbnailUrl = "Images/icons/300/_placeholder.gif";
                    }

                    thisNode.AllowView = _CswNbtResources.Permit.canAnyTab( Security.CswEnumNbtNodeTypePermission.View, thisNode.NodeType );
                    thisNode.AllowEdit = _CswNbtResources.Permit.canAnyTab( Security.CswEnumNbtNodeTypePermission.Edit, thisNode.NodeType );

                    //C3 results are not nodes and hence they can't be deleted.
                    thisNode.AllowDelete = false;
                    //C3 results CAN however be imported into Nbt IF the user has Create Material Permissions
                    thisNode.AllowImport = _CswNbtResources.Permit.can( CswEnumNbtActionName.Create_Material, _CswNbtResources.CurrentNbtUser );
                    thisNode.AllowRequest = _CswNbtResources.Permit.can( CswEnumNbtActionName.Submit_Request, _CswNbtResources.CurrentNbtUser );

                    // Properties
                    int propIndex = 0;
                    CswC3Product[] products = C3SearchResultsObj.CswC3SearchResults;

                    CswC3Product product = products[i];
                    JObject productObject = JObject.FromObject( product );
                    IEnumerable properties = productObject.Properties();
                    foreach( JProperty prop in properties )
                    {
                        string name = prop.Name;
                        string value = prop.Value.ToString();

                        if( prop.Name == "TradeName" )
                        {
                            thisNode.NodeName = prop.Value.ToString();
                        }

                        if( prop.Name == "ProductId" )
                        {
                            thisNode.C3ProductId = CswConvert.ToInt32( prop.Value );
                        }

                        if( prop.Name == "Cdbregno" )
                        {
                            thisNode.ACDCdbregno = CswConvert.ToInt32( prop.Value );
                        }

                        TableProp thisProp = new TableProp();
                        if( PropsToHide == null || false == PropsToHide.Contains( name ) )
                        {
                            thisProp.PropName = name;
                            thisProp.Gestalt = value;
                            thisNode.Props.Add( propIndex, thisProp );
                        }

                        propIndex++;

                    }

                    // Thumbnail image -- set to molimage if we have one
                    if( DataService.Equals( "C3" ) && false == String.IsNullOrEmpty( product.MolImage ) )
                    {
                        thisNode.ThumbnailBase64Str = "data:image/jpeg;base64," + product.MolImage;
                    }
                    else if( DataService.Equals( "ACD" ) )
                    {
                        thisNode.ThumbnailUrl = "Services/BlobData/getExternalImage?cdbregno=" + thisNode.ACDCdbregno + "&productid=" + product.ProductId + "&uid=" + CswRandom.RandomString();
                    }

                    if( false == _TableDict.ContainsKey( thisNode.NodeType ) )
                    {
                        _TableDict.Add( thisNode.NodeType, new Collection<TableNode>() );
                    }
                    _TableDict[thisNode.NodeType].Add( thisNode );

                    results++;

                }//if (null != thisNode.NodeType)

            }//for( int i = 0; i < C3SearchResultsObj.CswC3SearchResults.Count(); i++ )

            return results;
        } // _populateDictionary()
Beispiel #2
0
 public void Reassign(DataRow NewRow)
 {
     _FieldTypeRow = NewRow;
     _UniqueId     = CswConvert.ToInt32(NewRow[UniqueIdFieldName]);
 }
Beispiel #3
0
 public override void update()
 {
     CswNbtMetaDataFieldType BarcodeFT = _CswNbtSchemaModTrnsctn.MetaData.getFieldType( CswEnumNbtFieldType.Barcode );
     string SelectText = "select nodetypepropid from nodetype_props where fieldtypeid = " + BarcodeFT.FieldTypeId;
     CswArbitrarySelect GetBarcodePropsSelect = _CswNbtSchemaModTrnsctn.makeCswArbitrarySelect( "Get Barcode Props Select", SelectText );
     DataTable BarcodePropsTable = GetBarcodePropsSelect.getTable();
     foreach( DataRow BarcodePropsRow in BarcodePropsTable.Rows )
     {
         CswNbtMetaDataNodeTypeProp BarcodeProp = _CswNbtSchemaModTrnsctn.MetaData.getNodeTypeProp( CswConvert.ToInt32( BarcodePropsRow["nodetypepropid"] ) );
         BarcodeProp.ReadOnly = true;
     }
 } // update()
        /// <summary>
        ///     returns a collection of config vars, to be displayed on the config var page. Only config vars the currently logged in user can see are included
        /// </summary>
        /// <param name="NbtResources">Instance of NbtResources</param>
        /// <returns>dictionary of config vars, arranged by module</returns>
        private static CswNbtDataContractConfigurationVariablesPage _getConfigVars(CswNbtResources NbtResources)
        {
            CswAjaxDictionary <Collection <CswNbtDataContractConfigurationVariable> > configVarsByModule =
                new CswAjaxDictionary <Collection <CswNbtDataContractConfigurationVariable> >();
            //system vars are grouped manually in order to add them
            //to the end of the collection
            Collection <CswNbtDataContractConfigurationVariable> systemConfigVars =
                new Collection <CswNbtDataContractConfigurationVariable>();
            Collection <CswNbtDataContractConfigurationVariable> commonConfigVars =
                new Collection <CswNbtDataContractConfigurationVariable>();

            CswTableSelect CVTableSelect = NbtResources.makeCswTableSelect("config_var_nu", "configuration_variables");
            DataTable      CVDataTable   = CVTableSelect.getTable();

            //go through each config var
            //if it is associated with a module, select only those
            //which are attached to modules in use
            foreach (DataRow currentRow in CVDataTable.Rows)
            {
                //check if the config var should be added based on module
                bool includeConfigVar     = true;
                int  moduleIDForConfigVar = CswConvert.ToInt32(currentRow[COL_MODULEID]);

                //if this config var is associated with a module
                //and that module is currently disabled
                //hide it
                if (moduleIDForConfigVar != Int32.MinValue)
                {
                    if (false == (NbtResources.Modules.IsModuleEnabled(moduleIDForConfigVar)))
                    {
                        includeConfigVar = false;
                    }
                }

                if (includeConfigVar)
                {
                    CswNbtDataContractConfigurationVariable thisConfigVarDataContract =
                        new CswNbtDataContractConfigurationVariable
                    {
                        VariableName  = currentRow[COL_VARIABLENAME].ToString(),
                        VariableValue = currentRow[COL_VARIABLEVALUE].ToString(),
                        IsSystem      = CswConvert.ToBoolean(currentRow[COL_ISSYSTEM]),
                        DataType      = currentRow[COL_DATATYPE].ToString(),
                        Description   = currentRow[COL_DESCRIPTION].ToString()
                    };

                    //set the constraints according to datatype
                    if (DATATYPE_INT == thisConfigVarDataContract.DataType)
                    {
                        thisConfigVarDataContract.Minvalue = currentRow[COL_CONSTRAINT].ToString();
                    }

                    else if (DATATYPE_LIST == thisConfigVarDataContract.DataType)
                    {
                        string listOptionsAsString = currentRow[COL_CONSTRAINT].ToString();
                        //string[] listOptionsAsArray = listOptionsAsString.Split( ',' );
                        thisConfigVarDataContract.ListOptions = new CswCommaDelimitedString(listOptionsAsString);
                    }

                    //if this configVar is a system id, group as system settings
                    //if this configVar has a moduleID, find the module name.
                    //if this configVar is a common module, add it under a blank module name
                    if (CswConvert.ToBoolean(currentRow[COL_ISSYSTEM]))
                    {
                        systemConfigVars.Add(thisConfigVarDataContract);
                    }
                    else if (currentRow[COL_MODULEID] == DBNull.Value)
                    {
                        commonConfigVars.Add(thisConfigVarDataContract);
                    }
                    else
                    {
                        string thisConfigVarModuleName =
                            NbtResources.Modules.GetModuleName(CswConvert.ToInt32(currentRow[COL_MODULEID]));

                        //add the config var module to the collection
                        //if the module doesn't exist in the collection, create it
                        if (false == configVarsByModule.ContainsKey(thisConfigVarModuleName))
                        {
                            configVarsByModule[thisConfigVarModuleName] =
                                new Collection <CswNbtDataContractConfigurationVariable>();
                        }

                        configVarsByModule[thisConfigVarModuleName].Add(thisConfigVarDataContract);
                    }
                } //if configVar is to be included according to _includeConfigVar()
            }     //foreach dataRow

            configVarsByModule.Add("Common", commonConfigVars);

            //only add the system config vars if the current
            //user is chemsw_admin
            if (NbtResources.CurrentUser.Username == CswAuthenticator.ChemSWAdminUsername)
            {
                configVarsByModule.Add("System", systemConfigVars);
            }

            CswNbtDataContractConfigurationVariablesPage ret = new CswNbtDataContractConfigurationVariablesPage();

            ret.ConfigVarsByModule = configVarsByModule;

            return(ret);
        }
        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);
        }
        public override void update()
        {
            Int32 AdminRolePk = Int32.MinValue;
            CswCommaDelimitedString AdminRoles = new CswCommaDelimitedString();

            // Change the visibilily of the 'Roles and Users' view to global
            CswNbtView RolesAndUsersView = _CswNbtSchemaModTrnsctn.restoreView( "Roles and Users" );
            if( null != RolesAndUsersView )
            {
                RolesAndUsersView.SetVisibility( CswEnumNbtViewVisibility.Global, null, null );
                RolesAndUsersView.save();

                // For any roles that aren't Administrator roles, remove any role permissions
                CswNbtMetaDataObjectClass RoleOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.RoleClass );
                foreach( CswNbtObjClassRole RoleNode in RoleOC.getNodes( false, true, false ) )
                {
                    if( CswEnumTristate.True != RoleNode.Administrator.Checked )
                    {
                        foreach( CswEnumNbtNodeTypePermission Permission in CswEnumNbtNodeTypePermission.Members )
                        {
                            RoleNode.NodeTypePermissions.RemoveValue( CswNbtObjClassRole.MakeNodeTypePermissionValue( RoleOC.FirstNodeType.NodeTypeId, Permission ) );
                        }
                        RoleNode.NodeTypePermissions.SyncGestalt();
                        RoleNode.postChanges( false );
                    }
                    else
                    {
                        AdminRoles.Add( CswConvert.ToString( RoleNode.NodeId.PrimaryKey ) );
                    }

                    // We need this because setting the landing page for this Role is a special case
                    if( RoleNode.Name.Text == "Administrator" )
                    {
                        AdminRolePk = RoleNode.NodeId.PrimaryKey;
                    }
                }

                // Redirect Welcome Landingpage items
                CswTableUpdate TableUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "updateLandingPageItems_Case28518", "landingpage" );
                DataTable LandingPageDt = TableUpdate.getTable( "where for_roleid in (" + AdminRoles.ToString() + ")" );
                foreach( DataRow CurrentRow in LandingPageDt.Rows )
                {
                    if( CswConvert.ToInt32( CurrentRow["for_roleid"] ) == AdminRolePk )
                    {
                        if( CswConvert.ToString( CurrentRow["to_nodeviewid"] ) == "19" )
                        {
                            CurrentRow["displaytext"] = RolesAndUsersView.ViewName;
                        }
                    }

                    if( CswConvert.ToString( CurrentRow["displaytext"] ) == "Roles and Users" )
                    {
                        CurrentRow["to_nodeviewid"] = RolesAndUsersView.ViewId.get();
                    }

                }

                TableUpdate.update( LandingPageDt );
            }//if( null != RolesAndUsersView )

        }// update()
        /// <summary>
        /// Stores data in temporary Oracle tables
        /// </summary>
        public static Int32 storeData(CswNbtResources CswNbtResources, string FileName, string FullFilePath, string ImportDefinitionName, bool Overwrite)
        {
            CswNbtSchemaModTrnsctn _CswNbtSchemaModTrnsctn = new CswNbtSchemaModTrnsctn(CswNbtResources);

            //StringCollection ret = new StringCollection();
            DataSet ExcelDataSet = ReadExcel(FullFilePath);

            // Store the job reference in import_data_job
            CswTableUpdate ImportDataJobUpdate = CswNbtResources.makeCswTableUpdate("Importer_DataJob_Insert", CswNbtImportTables.ImportDataJob.TableName);
            DataTable      ImportDataJobTable  = ImportDataJobUpdate.getEmptyTable();
            DataRow        DataJobRow          = ImportDataJobTable.NewRow();

            DataJobRow[CswNbtImportTables.ImportDataJob.filename]    = FileName;
            DataJobRow[CswNbtImportTables.ImportDataJob.userid]      = CswNbtResources.CurrentNbtUser.UserId.PrimaryKey;
            DataJobRow[CswNbtImportTables.ImportDataJob.datestarted] = CswConvert.ToDbVal(DateTime.Now);
            ImportDataJobTable.Rows.Add(DataJobRow);
            Int32 JobId = CswConvert.ToInt32(DataJobRow[CswNbtImportTables.ImportDataJob.importdatajobid]);

            ImportDataJobUpdate.update(ImportDataJobTable);

            foreach (DataTable ExcelDataTable in ExcelDataSet.Tables)
            {
                string          SheetName  = ExcelDataTable.TableName;
                CswNbtImportDef Definition = null;
                //try
                //{
                Definition = new CswNbtImportDef(CswNbtResources, ImportDefinitionName, SheetName);
                //}
                //catch( Exception ex )
                //{
                //    //OnMessage( "Sheet '" + SheetName + "' is invalid: " + ex.Message );
                //}

                // ignore bad sheetnames
                if (null != Definition)
                {
                    // Determine Oracle table name
                    Int32  i = 1;
                    string ImportDataTableName = CswNbtImportTables.ImportDataN.TableNamePrefix + i.ToString();
                    while (_CswNbtSchemaModTrnsctn.isTableDefinedInDataBase(ImportDataTableName))
                    {
                        i++;
                        ImportDataTableName = CswNbtImportTables.ImportDataN.TableNamePrefix + i.ToString();
                    }

                    // Generate an Oracle table for storing and manipulating data
                    _CswNbtSchemaModTrnsctn.addTable(ImportDataTableName, CswNbtImportTables.ImportDataN.PkColumnName);
                    _CswNbtSchemaModTrnsctn.addBooleanColumn(ImportDataTableName, CswNbtImportTables.ImportDataN.error, "", false);
                    _CswNbtSchemaModTrnsctn.addClobColumn(ImportDataTableName, CswNbtImportTables.ImportDataN.errorlog, "", false);
                    foreach (DataColumn ExcelColumn in ExcelDataTable.Columns)
                    {
                        _CswNbtSchemaModTrnsctn.addStringColumn(ImportDataTableName, CswNbtImportDefBinding.SafeColName(ExcelColumn.ColumnName), "", false, 4000);
                    }
                    foreach (CswNbtImportDefOrder Order in Definition.ImportOrder.Values)
                    {
                        _CswNbtSchemaModTrnsctn.addLongColumn(ImportDataTableName, Order.PkColName, "", false);
                    }
                    CswNbtResources.commitTransaction();
                    CswNbtResources.beginTransaction();
                    CswNbtResources.DataDictionary.refresh();

                    // Store the sheet reference in import_data_map
                    CswTableUpdate ImportDataMapUpdate = CswNbtResources.makeCswTableUpdate("Importer_DataMap_Insert", CswNbtImportTables.ImportDataMap.TableName);
                    DataTable      ImportDataMapTable  = ImportDataMapUpdate.getEmptyTable();
                    DataRow        DataMapRow          = ImportDataMapTable.NewRow();
                    DataMapRow[CswNbtImportTables.ImportDataMap.datatablename]   = ImportDataTableName;
                    DataMapRow[CswNbtImportTables.ImportDataMap.importdefid]     = Definition.ImportDefinitionId;
                    DataMapRow[CswNbtImportTables.ImportDataMap.importdatajobid] = JobId;
                    DataMapRow[CswNbtImportTables.ImportDataMap.overwrite]       = CswConvert.ToDbVal(Overwrite);
                    DataMapRow[CswNbtImportTables.ImportDataMap.completed]       = CswConvert.ToDbVal(false);
                    ImportDataMapTable.Rows.Add(DataMapRow);
                    ImportDataMapUpdate.update(ImportDataMapTable);

                    // Copy the Excel data into the Oracle table
                    CswTableUpdate ImportDataUpdate = CswNbtResources.makeCswTableUpdate("Importer_Update", ImportDataTableName);
                    DataTable      ImportDataTable  = ImportDataUpdate.getEmptyTable();
                    foreach (DataRow ExcelRow in ExcelDataTable.Rows)
                    {
                        bool    hasData   = false;
                        DataRow ImportRow = ImportDataTable.NewRow();
                        ImportRow[CswNbtImportTables.ImportDataN.error] = CswConvert.ToDbVal(false);
                        foreach (DataColumn ExcelColumn in ExcelDataTable.Columns)
                        {
                            if (ExcelRow[ExcelColumn] != DBNull.Value)
                            {
                                hasData = true;
                            }
                            ImportRow[CswNbtImportDefBinding.SafeColName(ExcelColumn.ColumnName)] = ExcelRow[ExcelColumn];
                        }
                        if (hasData == true)
                        {
                            ImportDataTable.Rows.Add(ImportRow);
                        }
                    }
                    ImportDataUpdate.update(ImportDataTable);
                    //OnMessage( "Sheet '" + SheetName + "' is stored in Table '" + ImportDataTableName + "'" );
                } // if( null != Definition )
            }     // foreach( DataTable ExcelDataTable in ExcelDataSet.Tables )

            CswNbtResources.commitTransaction();
            CswNbtResources.beginTransaction();

            //return ret;
            return(JobId);
        }
 /// <summary>
 /// For loading from XML
 /// </summary>
 public CswNbtViewProperty(CswNbtResources CswNbtResources, CswNbtView View, XmlNode PropNode)
     : base(CswNbtResources, View)
 {
     try
     {
         if (PropNode.Attributes["type"] != null)
         {
             Type = PropNode.Attributes["type"].Value;
         }
         if (PropNode.Attributes["value"] != null)    //backwards compatibility
         {
             if (Type == CswEnumNbtViewPropType.NodeTypePropId)
             {
                 NodeTypePropId = CswConvert.ToInt32(PropNode.Attributes["value"].Value);
             }
             else
             {
                 ObjectClassPropId = CswConvert.ToInt32(PropNode.Attributes["value"].Value);
             }
         }
         if (PropNode.Attributes["nodetypepropid"] != null)
         {
             NodeTypePropId = CswConvert.ToInt32(PropNode.Attributes["nodetypepropid"].Value);
         }
         if (PropNode.Attributes["objectclasspropid"] != null)
         {
             ObjectClassPropId = CswConvert.ToInt32(PropNode.Attributes["objectclasspropid"].Value);
         }
         if (PropNode.Attributes["name"] != null)
         {
             Name = PropNode.Attributes["name"].Value;
         }
         //if( PropNode.Attributes["arbitraryid"] != null )
         //    ArbitraryId = PropNode.Attributes["arbitraryid"].Value;
         if (PropNode.Attributes["sortby"] != null)
         {
             SortBy = Convert.ToBoolean(PropNode.Attributes["sortby"].Value);
         }
         if (PropNode.Attributes["sortmethod"] != null)
         {
             SortMethod = PropNode.Attributes["sortmethod"].Value;
         }
         if (PropNode.Attributes["fieldtype"] != null && PropNode.Attributes["fieldtype"].Value != string.Empty)
         {
             FieldType = CswNbtMetaDataFieldType.getFieldTypeFromString(PropNode.Attributes["fieldtype"].Value);
         }
         if (PropNode.Attributes["order"] != null && PropNode.Attributes["order"].Value != string.Empty)
         {
             Order = CswConvert.ToInt32(PropNode.Attributes["order"].Value);
         }
         if (PropNode.Attributes["width"] != null && PropNode.Attributes["width"].Value != string.Empty)
         {
             Width = CswConvert.ToInt32(PropNode.Attributes["width"].Value);
         }
         if (PropNode.Attributes["showingrid"] != null && PropNode.Attributes["showingrid"].Value != string.Empty)
         {
             ShowInGrid = CswConvert.ToBoolean(PropNode.Attributes["showingrid"].Value);
         }
     }
     catch (Exception ex)
     {
         throw new CswDniException(CswEnumErrorType.Error, "Misconfigured CswViewProperty",
                                   "CswViewProperty.constructor(xmlnode) encountered an invalid attribute value",
                                   ex);
     }
     try
     {
         foreach (XmlNode ChildNode in PropNode.ChildNodes)
         {
             if (ChildNode.Name.ToLower() == CswEnumNbtViewXmlNodeName.Filter.ToString().ToLower())
             {
                 CswNbtViewPropertyFilter Filter = new CswNbtViewPropertyFilter(CswNbtResources, _View, ChildNode);
                 this.addFilter(Filter);
             }
         }
     }
     catch (Exception ex)
     {
         throw new CswDniException(CswEnumErrorType.Error, "Misconfigured CswViewProperty",
                                   "CswViewProperty.constructor(xmlnode) encountered an invalid filter definition",
                                   ex);
     }
 }
Beispiel #9
0
        public override void update()
        {
            CswTableUpdate LandingPageUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "28523_LandingPageUpdate", "landingpage" );
            DataTable LandingPageTable = LandingPageUpdate.getTable();

            // Clear bogus existing landing page icons
            foreach( DataRow LandingPageRow in LandingPageTable.Rows )
            {
                LandingPageRow["buttonicon"] = "";
            }

            // Set default icons for actions
            CswTableUpdate ActionsUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "28523_ActionsUpdate", "actions" );
            DataTable ActionsTable = ActionsUpdate.getTable();

            foreach( DataRow ActionRow in ActionsTable.Rows )
            {
                // Set action icon
                string IconFileName = string.Empty;
                CswNbtActionName ActionName = CswNbtAction.ActionNameStringToEnum( ActionRow["actionname"].ToString() );
                Int32 ActionId = CswConvert.ToInt32( ActionRow["actionid"] );
                
                switch( ActionName)
                {
                    case CswNbtActionName.Create_Inspection         : IconFileName = "clipboardcheck.png"; break;
                    case CswNbtActionName.Create_Material           : IconFileName = "atomplus.png";       break;
                    case CswNbtActionName.Design                    : IconFileName = "wrench.png";         break;
                    case CswNbtActionName.DispenseContainer         : IconFileName = "flask.png";          break;
                    case CswNbtActionName.DisposeContainer          : IconFileName = "trash.png";          break;
                    case CswNbtActionName.Edit_View                 : IconFileName = "options.png";        break;
                    case CswNbtActionName.Future_Scheduling         : IconFileName = "calendarstack.png";  break;
                    case CswNbtActionName.HMIS_Reporting            : IconFileName = "doc.png";            break;
                    case CswNbtActionName.Kiosk_Mode                 : IconFileName = "barcode.png";        break;
                    case CswNbtActionName.Modules                   : IconFileName = "options.png";        break;
                    case CswNbtActionName.Multi_Edit                : IconFileName = "largeicons.png";     break;
                    case CswNbtActionName.Quotas                    : IconFileName = "plus.png";           break;
                    case CswNbtActionName.Receiving                 : IconFileName = "bottlebox.png";      break;
                    case CswNbtActionName.Reconciliation            : IconFileName = "bottlecalendar.png"; break;
                    case CswNbtActionName.Sessions                  : IconFileName = "personclock.png";    break;
                    case CswNbtActionName.Submit_Request            : IconFileName = "cartplus.png";       break;
                    case CswNbtActionName.Subscriptions             : IconFileName = "envelopes.png";      break;
                    case CswNbtActionName.Tier_II_Reporting         : IconFileName = "doc.png";            break;
                    case CswNbtActionName.UndisposeContainer        : IconFileName = "flask.png";          break;
                    case CswNbtActionName.Upload_Legacy_Mobile_Data : IconFileName = "up.png";             break;
                    case CswNbtActionName.View_Scheduled_Rules      : IconFileName = "clock.png";          break;
                    default: break;
                }
                ActionRow["iconfilename"] = IconFileName;

                //// Fix existing landing page icons
                //foreach( DataRow LandingPageRow in from DataRow LandingPageRow in LandingPageTable.Rows 
                //                                    let LandingPageActionId = CswConvert.ToInt32( LandingPageRow["to_actionid"] ) 
                //                                  where ActionId == LandingPageActionId 
                //                                 select LandingPageRow )
                //{
                //    LandingPageRow["buttonicon"] = IconFileName;
                //}
            } // foreach( DataRow ActionRow in ActionsTable.Rows )

            ActionsUpdate.update( ActionsTable );
            LandingPageUpdate.update( LandingPageTable );

            // update getActiveActions s4
            _CswNbtSchemaModTrnsctn.UpdateS4( "getActiveActions", @"select a.actionid, a.actionname, a.showinlist, a.url, a.category, a.iconfilename, lower(a.actionname) mssqlorder
  from actions a
 where exists (select m.moduleid
          from modules m, jct_modules_actions jma
         where jma.actionid = a.actionid
           and jma.moduleid = m.moduleid
           and m.enabled = '1')
       or not exists (select m.moduleid
          from modules m, jct_modules_actions jma
         where jma.actionid = a.actionid
           and jma.moduleid = m.moduleid)
 order by lower(a.actionname)" );

        } // update()
Beispiel #10
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()
Beispiel #11
0
        public List <CswNbtView> restoreViews(string ViewName, CswEnumNbtViewVisibility Visibility, Int32 VisibilityId = Int32.MinValue, bool allowPartialMatches = false)
        {
            List <CswNbtView> ReturnVal = new List <CswNbtView>();

            CswTableSelect          ViewSelect = _CswNbtResources.makeCswTableSelect("CswNbtViewSelect_restoreViews_select", "node_views");
            CswCommaDelimitedString SelectCols = new CswCommaDelimitedString()
            {
                "nodeviewid",
                "viewname"
            };

            ViewName = ViewName.ToLower().Trim();
            if (ViewName.Length > 200)
            {
                ViewName = ViewName.Substring(0, 200);
            }

            string WhereClause = string.Empty;

            if (Visibility != CswEnumNbtViewVisibility.Unknown)
            {
                WhereClause = "where visibility='" + Visibility.ToString() + "'";
            }
            else if (Visibility == CswEnumNbtViewVisibility.Role)
            {
                if (Int32.MinValue != VisibilityId)
                {
                    WhereClause += " and roleid='" + VisibilityId.ToString() + "'";
                }
            }
            else if (Visibility == CswEnumNbtViewVisibility.User)
            {
                if (Int32.MinValue != VisibilityId)
                {
                    WhereClause += " and userid='" + VisibilityId.ToString() + "'";
                }
            }

            DataTable ViewTable = ViewSelect.getTable(SelectCols, string.Empty, Int32.MinValue, WhereClause, false);

            foreach (DataRow CurrentRow in ViewTable.Rows)
            {
                string CurrentViewName = CswConvert.ToString(CurrentRow["viewname"]).ToLower().Trim();
                if (ViewName == CurrentViewName || (allowPartialMatches && CurrentViewName.Contains(ViewName)))
                {
                    ReturnVal.Add(_CswNbtResources.ViewSelect.restoreView(new CswNbtViewId(CswConvert.ToInt32(CurrentRow["nodeviewid"]))));
                }
            }

            return(ReturnVal);
        }//restoreViews()
        public CswNbtNodePropScientific(CswNbtResources CswNbtResources, CswNbtNodePropData CswNbtNodePropData, CswNbtMetaDataNodeTypeProp CswNbtMetaDataNodeTypeProp, CswNbtNode Node)
            : base(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node)
        {
            _BaseSubField     = ((CswNbtFieldTypeRuleScientific)_FieldTypeRule).BaseSubField;
            _ExponentSubField = ((CswNbtFieldTypeRuleScientific)_FieldTypeRule).ExponentSubField;

            // Associate subfields with methods on this object, for SetSubFieldValue()
            _SubFieldMethods.Add(_BaseSubField.Name, new Tuple <Func <dynamic>, Action <dynamic> >(() => Base, x => Base             = CswConvert.ToDouble(x)));
            _SubFieldMethods.Add(_ExponentSubField.Name, new Tuple <Func <dynamic>, Action <dynamic> >(() => Exponent, x => Exponent = CswConvert.ToInt32(x)));
        }
 public override void ReadJSON(JObject JObject, Dictionary <Int32, Int32> NodeMap, Dictionary <Int32, Int32> NodeTypeMap)
 {
     Base     = CswConvert.ToDouble(JObject[_BaseSubField.ToXmlNodeName(true)]);
     Exponent = CswConvert.ToInt32(JObject[_ExponentSubField.ToXmlNodeName(true)]);
 }
        private Collection <CswNbtViewRelationship> getPropertySetRelated(Int32 PropertySetId, CswNbtView View, Int32 Level)
        {
            Collection <CswNbtViewRelationship> Relationships = new Collection <CswNbtViewRelationship>();

            // If we're doing a grid, we can only pick things in which the provided nodetype has a relationship to,
            // rather than things that are related to the provided nodetype.
            // If this is a property grid, then the above rule does not apply to the first level.
            bool Restrict = (View.ViewMode == CswEnumNbtViewRenderingMode.Grid || View.ViewMode == CswEnumNbtViewRenderingMode.Table) &&
                            (View.Visibility != CswEnumNbtViewVisibility.Property || Level >= 2);

            CswNbtMetaDataPropertySet PropertySet = _CswNbtResources.MetaData.getPropertySet(PropertySetId);

            CswStaticSelect RelationshipPropsSelect = _CswNbtResources.makeCswStaticSelect("getRelationsForPropertySetId_select", "getRelationsForPropertySetId");

            RelationshipPropsSelect.S4Parameters.Add("getpropertysetid", new CswStaticParam("getpropertysetid", PropertySetId));
            DataTable RelationshipPropsTable = RelationshipPropsSelect.getTable();

            foreach (DataRow PropRow in RelationshipPropsTable.Rows)
            {
                // Ignore relationships that don't have a target
                if (PropRow["fktype"].ToString() != String.Empty &&
                    PropRow["fkvalue"].ToString() != String.Empty)
                {
                    ICswNbtMetaDataProp ThisProp = null;
                    if (PropRow["proptype"].ToString() == CswEnumNbtViewPropIdType.ObjectClassPropId.ToString())
                    {
                        ThisProp = _CswNbtResources.MetaData.getObjectClassProp(CswConvert.ToInt32(PropRow["propid"]));
                    }
                    else if (PropRow["proptype"].ToString() == CswEnumNbtViewPropIdType.NodeTypePropId.ToString())
                    {
                        ThisProp = _CswNbtResources.MetaData.getNodeTypeProp(CswConvert.ToInt32(PropRow["propid"]));
                    }

                    if (PropRow["propertysetid"].ToString() == CswEnumNbtViewRelatedIdType.PropertySetId.ToString() &&
                        PropRow["fktype"].ToString() == CswEnumNbtViewRelatedIdType.PropertySetId.ToString() &&
                        PropRow["fkvalue"].ToString() == PropertySetId.ToString())
                    {
                        // Special case -- relationship to my own set
                        // We need to create two relationships from this
                        CswNbtViewRelationship R1 = View.AddViewRelationship(null, CswEnumNbtViewPropOwnerType.First, ThisProp, false);
                        R1.overrideFirst(PropertySet);
                        R1.overrideSecond(PropertySet);
                        _InsertRelationship(Relationships, R1);

                        if (!Restrict)
                        {
                            CswNbtViewRelationship R2 = View.AddViewRelationship(null, CswEnumNbtViewPropOwnerType.Second, ThisProp, false);
                            R2.overrideFirst(PropertySet);
                            R2.overrideSecond(PropertySet);
                            _InsertRelationship(Relationships, R2);
                        }
                    }
                    else
                    {
                        CswNbtViewRelationship R = null;
                        if (PropRow["propertysetid"].ToString() == PropertySetId.ToString())
                        {
                            // my relation to something else
                            R = View.AddViewRelationship(null, CswEnumNbtViewPropOwnerType.First, ThisProp, false);
                            R.overrideSecond(PropRow["fktype"].ToString(), CswConvert.ToInt32(PropRow["fkvalue"]));
                            R.overrideFirst(PropertySet);
                            _InsertRelationship(Relationships, R);
                        }
                        else if (PropRow["fktype"].ToString() == CswEnumNbtViewRelatedIdType.PropertySetId.ToString() &&
                                 PropRow["fkvalue"].ToString() == PropertySetId.ToString())
                        {
                            if (!Restrict)
                            {
                                // something else's relation to me
                                R = View.AddViewRelationship(null, CswEnumNbtViewPropOwnerType.Second, ThisProp, false);
                                if (PropRow["proptype"].ToString() == CswEnumNbtViewPropIdType.ObjectClassPropId.ToString())
                                {
                                    R.overrideSecond(_CswNbtResources.MetaData.getObjectClass(CswConvert.ToInt32(PropRow["typeid"])));
                                }
                                else
                                {
                                    R.overrideSecond(_CswNbtResources.MetaData.getNodeType(CswConvert.ToInt32(PropRow["typeid"])));
                                }
                                R.overrideFirst(PropertySet);
                                _InsertRelationship(Relationships, R);
                            }
                        }
                        else
                        {
                            throw new CswDniException(CswEnumErrorType.Error, "An unexpected data condition has occurred", "getPropertySetRelated() found a relationship which did not match the original propertysetid");
                        }
                    }
                }
            }

            return(Relationships);
        }
 public CswNbtAPIGenericRequest(string MetaDataNameIn, string Id)
 {
     NodeId       = new CswPrimaryKey("nodes", CswConvert.ToInt32(Id));
     MetaDataName = MetaDataNameIn;
 }
        public override void update()
        {
            CswTableUpdate jctUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "29311_jctddntp_update", "jct_dd_ntp" );
            DataTable jctTable = jctUpdate.getEmptyTable();

            // Set up Sequence Nodetype
            CswNbtMetaDataObjectClass SequenceOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.DesignSequenceClass );
            CswNbtMetaDataNodeType SequenceNT = _CswNbtSchemaModTrnsctn.MetaData.makeNewNodeTypeNew( new CswNbtWcfMetaDataModel.NodeType( SequenceOC )
                {
                    NodeTypeName = "Design Sequence",
                    Category = "Design",
                    IconFileName = "wrench.png"
                } );
            //SequenceNT.addNameTemplateText( CswNbtObjClassDesignSequence.PropertyName.Name );
            SequenceNT._DataRow["nametemplate"] = CswNbtMetaData.TemplateTextToTemplateValue( SequenceNT.getNodeTypeProps(), CswNbtMetaData.MakeTemplateEntry( CswNbtObjClassDesignSequence.PropertyName.Name ) );

            Int32 TabId = SequenceNT.getFirstNodeTypeTab().TabId;

            CswNbtMetaDataNodeTypeProp SeqNameNTP = SequenceNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignSequence.PropertyName.Name );
            CswNbtMetaDataNodeTypeProp SeqNextValueNTP = SequenceNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignSequence.PropertyName.NextValue );
            CswNbtMetaDataNodeTypeProp SeqPadNTP = SequenceNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignSequence.PropertyName.Pad );
            CswNbtMetaDataNodeTypeProp SeqPostNTP = SequenceNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignSequence.PropertyName.Post );
            CswNbtMetaDataNodeTypeProp SeqPreNTP = SequenceNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignSequence.PropertyName.Pre );

            // Edit Layout
            SeqNameNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 1, DisplayColumn: 1 );
            SeqPreNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 2, DisplayColumn: 1 );
            SeqPostNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 3, DisplayColumn: 1 );
            SeqPadNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 4, DisplayColumn: 1 );
            SeqNextValueNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 5, DisplayColumn: 1 );

            // Add Layout
            SeqNameNTP.updateLayout( CswEnumNbtLayoutType.Add, false, Int32.MinValue, DisplayRow: 1, DisplayColumn: 1 );
            SeqPreNTP.updateLayout( CswEnumNbtLayoutType.Add, false, Int32.MinValue, DisplayRow: 2, DisplayColumn: 1 );
            SeqPostNTP.updateLayout( CswEnumNbtLayoutType.Add, false, Int32.MinValue, DisplayRow: 3, DisplayColumn: 1 );
            SeqPadNTP.updateLayout( CswEnumNbtLayoutType.Add, false, Int32.MinValue, DisplayRow: 4, DisplayColumn: 1 );
            SeqNextValueNTP.removeFromLayout( CswEnumNbtLayoutType.Add );

            // Populate nodes
            // Very important that this happens BEFORE we map to the nodetypes table, or else we'll end up duplicating rows!
            Dictionary<Int32, CswNbtObjClassDesignSequence> SequenceNodeMap = new Dictionary<int, CswNbtObjClassDesignSequence>();
            CswTableSelect SequencesTableSelect = _CswNbtSchemaModTrnsctn.makeCswTableSelect( "29311_sequencetable_select", "sequences" );
            DataTable SequencesTable = SequencesTableSelect.getTable();
            foreach( DataRow SeqRow in SequencesTable.Rows )
            {
                CswNbtObjClassDesignSequence node = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( SequenceNT.NodeTypeId, OverrideUniqueValidation: true, OnAfterMakeNode: delegate( CswNbtNode NewNode )
                    {
                        CswNbtObjClassDesignSequence NewSeqNode = NewNode;
                        NewSeqNode.Name.Text = SeqRow["sequencename"].ToString();
                        NewSeqNode.Pad.Value = CswConvert.ToInt32( SeqRow["pad"] );
                        NewSeqNode.Post.Text = SeqRow["post"].ToString();
                        NewSeqNode.Pre.Text = SeqRow["prep"].ToString();
                    } );
                node.RelationalId = new CswPrimaryKey( "sequences", CswConvert.ToInt32( SeqRow["sequenceid"] ) );
                node.postChanges( false );
                SequenceNodeMap.Add( node.RelationalId.PrimaryKey, node );
            }

            // Here's where the extra special super-secret magic comes in

            //SequenceNT.TableName = "sequences";
            SequenceNT._DataRow["tablename"] = "sequences";

            _addJctRow( jctTable, SeqNameNTP, SequenceNT.TableName, "sequencename" );
            _addJctRow( jctTable, SeqPadNTP, SequenceNT.TableName, "pad" );
            _addJctRow( jctTable, SeqPostNTP, SequenceNT.TableName, "post" );
            _addJctRow( jctTable, SeqPreNTP, SequenceNT.TableName, "prep" );
            jctUpdate.update( jctTable );

            // Set up existing relationships to sequences
            Dictionary<Int32, CswNbtObjClassDesignSequence> SequenceValueMap = new Dictionary<Int32, CswNbtObjClassDesignSequence>();
            string Sql = @"select n.nodeid, r.sequenceid
                             from nodetype_props p
                             join nodetypes t on p.nodetypeid = t.nodetypeid
                             join nodes n on t.nodetypeid = n.nodetypeid
                             join nodetype_props r on n.relationalid = r.nodetypepropid
                            where p.propname = 'Sequence' and t.nodetypename like 'Design%'";
            CswArbitrarySelect ExistingSequenceIdSelect = _CswNbtSchemaModTrnsctn.makeCswArbitrarySelect( "getExistingSequenceIds", Sql );
            DataTable ExistingSequenceIdTable = ExistingSequenceIdSelect.getTable();
            foreach( DataRow row in ExistingSequenceIdTable.Rows )
            {
                Int32 thisSeqId = CswConvert.ToInt32( row["sequenceid"] );
                if( Int32.MinValue != thisSeqId && SequenceNodeMap.ContainsKey( thisSeqId ) )
                {
                    SequenceValueMap.Add( CswConvert.ToInt32( row["nodeid"] ), SequenceNodeMap[thisSeqId] );
                }
            }

            foreach( CswEnumNbtFieldType ft in new CswEnumNbtFieldType[] { CswEnumNbtFieldType.Barcode, CswEnumNbtFieldType.Sequence } )
            {
                CswNbtMetaDataNodeType PropNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( CswNbtObjClassDesignNodeTypeProp.getNodeTypeName( ft ) );
                //CswNbtFieldTypeRuleSequence Rule = (CswNbtFieldTypeRuleSequence) _CswNbtSchemaModTrnsctn.MetaData.getFieldTypeRule( ft );
                //CswNbtFieldTypeAttribute SequenceAttribute = Rule.getAttributes().FirstOrDefault( a => a.Name == CswEnumNbtPropertyAttributeName.Sequence );
                CswNbtMetaDataNodeTypeProp SequenceNTP = PropNT.getNodeTypeProp( CswEnumNbtPropertyAttributeName.Sequence );
                SequenceNTP.SetFKDeprecated( CswEnumNbtViewRelatedIdType.ObjectClassId.ToString(), SequenceOC.ObjectClassId );

                CswNbtViewId ViewId = SequenceNTP.DesignNode.AttributeProperty[CswNbtFieldTypeRuleRelationship.AttributeName.View].AsViewReference.ViewId;
                CswNbtView View = _CswNbtSchemaModTrnsctn.ViewSelect.restoreView( ViewId );
                CswNbtFieldTypeRuleDefaultImpl.setDefaultView( _CswNbtSchemaModTrnsctn.MetaData, SequenceNTP.DesignNode, View, CswEnumNbtViewRelatedIdType.ObjectClassId.ToString(), SequenceOC.ObjectClassId, false );

                foreach( CswNbtObjClassDesignNodeTypeProp PropNode in PropNT.getNodes( false, true ) )
                {
                    if( SequenceValueMap.ContainsKey( PropNode.NodeId.PrimaryKey ) )
                    {
                        CswNbtObjClassDesignSequence SeqNode = SequenceValueMap[PropNode.NodeId.PrimaryKey];
                        if( null != SeqNode )
                        {
                            PropNode.Node.Properties[SequenceNTP].AsRelationship.RelatedNodeId = SeqNode.NodeId;
                            PropNode.postChanges( false );
                        }
                    }
                }
            } // foreach( CswEnumNbtFieldType ft in new CswEnumNbtFieldType[] {CswEnumNbtFieldType.Barcode, CswEnumNbtFieldType.Sequence} )

        } // update()
        private CswNbtObjClassContainer _createChildContainer(string ContainerNodeTypeId, CswPrimaryKey UnitId, string Barcode)
        {
            CswNbtObjClassContainer ChildContainer = null;
            CswNbtMetaDataNodeType  ContainerNT    = _CswNbtResources.MetaData.getNodeType(CswConvert.ToInt32(ContainerNodeTypeId));

            if (ContainerNT != null)
            {
                _CswNbtResources.Nodes.makeNodeFromNodeTypeId(ContainerNT.NodeTypeId, delegate(CswNbtNode CopyNode)
                {
                    CopyNode.copyPropertyValues(_SourceContainer.Node);
                    ChildContainer = CopyNode;
                    if (false == String.IsNullOrEmpty(Barcode))
                    {
                        ChildContainer.Barcode.setBarcodeValueOverride(Barcode, false);
                    }
                    else
                    {
                        ChildContainer.Barcode.setBarcodeValue();
                    }
                    ChildContainer.ReceiptLot.RelatedNodeId      = null;
                    ChildContainer.ExpirationDate.DateTimeValue  = _SourceContainer.ExpirationDate.DateTimeValue;
                    ChildContainer.SourceContainer.RelatedNodeId = _SourceContainer.NodeId;
                    ChildContainer.Quantity.Quantity             = 0;
                    ChildContainer.Quantity.UnitId  = UnitId;
                    ChildContainer.Disposed.Checked = CswEnumTristate.False;
                    _ContainersToView.Add(ChildContainer.NodeId);
                });
            }
            return(ChildContainer);
        }
        /// <summary>
        /// For loading from JSON
        /// </summary>
        public CswNbtViewProperty(CswNbtResources CswNbtResources, CswNbtView View, JObject PropObj)
            : base(CswNbtResources, View)
        {
            try
            {
                string _Type = CswConvert.ToString(PropObj["type"]);
                if (!string.IsNullOrEmpty(_Type))
                {
                    Type = _Type;
                }

                Int32 _Value = CswConvert.ToInt32(PropObj["value"]);
                if (Int32.MinValue != _Value)  //backwards compatibility
                {
                    if (Type == CswEnumNbtViewPropType.NodeTypePropId)
                    {
                        NodeTypePropId = _Value;
                    }
                    else
                    {
                        ObjectClassPropId = _Value;
                    }
                }

                Int32 _NtPropId = CswConvert.ToInt32(PropObj["nodetypepropid"]);
                if (Int32.MinValue != _NtPropId)
                {
                    NodeTypePropId = _NtPropId;
                }

                Int32 _OcPropId = CswConvert.ToInt32(PropObj["objectclasspropid"]);
                if (Int32.MinValue != _OcPropId)
                {
                    ObjectClassPropId = _OcPropId;
                }

                string _Name = CswConvert.ToString(PropObj["name"]);
                if (!string.IsNullOrEmpty(_Name))
                {
                    Name = _Name;
                }

                if (PropObj["sortby"] != null)
                {
                    bool _Sort = CswConvert.ToBoolean(PropObj["sortby"]);
                    SortBy = _Sort;
                }

                string _SortedMethod = CswConvert.ToString(PropObj["sortmethod"]);
                if (!string.IsNullOrEmpty(_SortedMethod))
                {
                    SortMethod = _SortedMethod;
                }


                string _FieldType = CswConvert.ToString(PropObj["fieldtype"]);
                if (!string.IsNullOrEmpty(_FieldType))
                {
                    FieldType = CswNbtMetaDataFieldType.getFieldTypeFromString(_FieldType);
                }

                Int32 _Order = CswConvert.ToInt32(PropObj["order"]);
                if (Int32.MinValue != _Order)
                {
                    Order = _Order;
                }

                Int32 _Width = CswConvert.ToInt32(PropObj["width"]);
                if (Int32.MinValue != _Width)
                {
                    Width = _Width;
                }

                ShowInGrid = CswConvert.ToBoolean(PropObj["showingrid"]);
            }
            catch (Exception ex)
            {
                throw new CswDniException(CswEnumErrorType.Error, "Misconfigured CswViewProperty",
                                          "CswViewProperty.constructor(xmlnode) encountered an invalid attribute value",
                                          ex);
            }
            try
            {
                JProperty FiltersProp = PropObj.Property(_FiltersName);
                if (null != FiltersProp)
                {
                    JObject FiltersObj = (JObject)FiltersProp.Value;
                    foreach (CswNbtViewPropertyFilter Filter in
                             from FilterProp
                             in FiltersObj.Properties()
                             select(JObject) FilterProp.Value
                             into FilterObj
                             let NodeName = CswConvert.ToString(FilterObj["nodename"])
                                            where NodeName == CswEnumNbtViewXmlNodeName.Filter.ToString().ToLower()
                                            select new CswNbtViewPropertyFilter(CswNbtResources, _View, FilterObj))
                    {
                        this.addFilter(Filter);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new CswDniException(CswEnumErrorType.Error, "Misconfigured CswViewProperty",
                                          "CswViewProperty.constructor(xmlnode) encountered an invalid filter definition",
                                          ex);
            }
        }
Beispiel #19
0
        }//delete()

        public void fill()
        {
            if (NodeSpecies == CswEnumNbtNodeSpecies.Plain)
            {
                //bool NodeInfoFetched = false;
                if (CswTools.IsPrimaryKey(NodeId) && (NodeTypeId <= 0 || NodeName == String.Empty))
                {
                    DataTable NodesTable = null;
                    if (CswTools.IsDate(_Date))
                    {
                        string             NodesSql         = "select * from " + CswNbtAuditTableAbbreviation.getAuditTableSql(_CswNbtResources, "nodes", _Date, NodeId.PrimaryKey);
                        CswArbitrarySelect NodesTableSelect = _CswNbtResources.makeCswArbitrarySelect("fetchNodeInfo_Select", NodesSql);
                        NodesTable = NodesTableSelect.getTable();
                    }
                    else
                    {
                        CswTableSelect NodesTableSelect = _CswNbtResources.makeCswTableSelect("CswNbtNode.fill_nodes", "nodes");
                        NodesTable = NodesTableSelect.getTable("nodeid", NodeId.PrimaryKey);
                    }
                    if (NodesTable.Rows.Count > 0)
                    {
                        read(NodesTable.Rows[0]);
                        RelationalId = new CswPrimaryKey(NodesTable.Rows[0]["relationaltable"].ToString(), CswConvert.ToInt32(NodesTable.Rows[0]["relationalid"]));
                    }

                    CswTimer Timer = new CswTimer();
                    if (getNodeType() != null)
                    {
                        Properties.fill(false);
                    }
                    _CswNbtResources.logTimerResult("Filled in node property data for node (" + NodeId.ToString() + "): " + NodeName, Timer.ElapsedDurationInSecondsAsString);

                    if (CswTools.IsDate(_Date))
                    {
                        setReadOnly(value: true, SaveToDb: false);
                    }
                }
            }

            _NodeModificationState = CswEnumNbtNodeModificationState.Unchanged;
        }//fill()
Beispiel #20
0
 public CswNbtSdLocations(CswNbtResources Resources)
 {
     _CswNbtResources = Resources;
     _SearchThreshold = CswConvert.ToInt32(_CswNbtResources.ConfigVbls.getConfigVariableValue(CswEnumNbtConfigurationVariables.relationshipoptionlimit.ToString()));
 }
Beispiel #21
0
        } // ToJObject()

        /// <summary>
        /// Restore search from row in 'sessiondata' table
        /// </summary>
        public void FromSessionData(DataRow SessionDataRow)
        {
            FromJObject(JObject.Parse(SessionDataRow["viewxml"].ToString()));
            SessionDataId = new CswNbtSessionDataId(CswConvert.ToInt32(SessionDataRow["sessiondataid"]));
        }
Beispiel #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()
Beispiel #23
0
 /// <summary>
 /// Restore search from row in 'search' table
 /// </summary>
 public void FromSearchRow(DataRow SearchRow)
 {
     FromJObject(JObject.Parse(SearchRow["searchdata"].ToString()));
     SearchId = new CswPrimaryKey(CswNbtSearchManager.SearchTableName, CswConvert.ToInt32(SearchRow["searchid"]));
 }
Beispiel #24
0
        public static CswNbtChemWatchRequest SDSDocumentSearch(ICswResources CswResources, CswNbtChemWatchRequest Request)
        {
            CswNbtChemWatchRequest Return       = new CswNbtChemWatchRequest();
            CswNbtResources        NbtResources = (CswNbtResources)CswResources;
            string errorMsg;

            if (_authenticate(NbtResources, out errorMsg))
            {
                DocumentServiceClient cwDocClient = new DocumentServiceClient();
                cwDocClient.Endpoint.Behaviors.Add(_cookieBehavior);   //every service client needs to share this

                DocumentRequest DocumentRequest = new DocumentRequest();

                List <int> CountryIdsList  = Request.Countries.selected.Select(ListItem => CswConvert.ToInt32(ListItem.Id)).ToList();
                int[]      CountryIdsArray = CountryIdsList.ToArray();
                DocumentRequest.CountryCode = CountryIdsArray;

                List <int> LanguageIdsList  = Request.Languages.selected.Select(ListItem => CswConvert.ToInt32(ListItem.Id)).ToList();
                int[]      LanguageIdsArray = LanguageIdsList.ToArray();
                DocumentRequest.LanguageCode = LanguageIdsArray;

                DocumentRequest.MaterialId   = CswConvert.ToString(Request.ChemWatchMaterialId);
                DocumentRequest.IsShowOwn    = false;
                DocumentRequest.IsLatest     = true;
                DocumentRequest.ShowOnlyGold = false;
                DocumentRequest.PageNumber   = 1;
                DocumentRequest.PageSize     = 50;
                DocumentRequest.HideGold     = true;
                DocumentRequest.Gid          = Request.Supplier;

                ListResultOfDocument DocumentList = cwDocClient.GetDocumentsByMaterialId(DocumentRequest);
                foreach (Document Doc in DocumentList.Rows)
                {
                    ChemWatchSDSDoc SDSDoc = new ChemWatchSDSDoc();
                    SDSDoc.Language    = Doc.LanguageCode;
                    SDSDoc.Country     = Doc.CountryCode;
                    SDSDoc.FileName    = Doc.FileName.Length > 0 ? Doc.FileName : String.Empty;
                    SDSDoc.ExternalUrl = Doc.ExternalUrl;
                    Return.SDSDocuments.Add(SDSDoc);
                }
            }
            else
            {
                throw new CswDniException(CswEnumErrorType.Error, "There was a problem authenticating with ChemWatch", errorMsg);
            }

            return(Return);
        }
        //_getConfigVars

        /// <summary>
        /// powers the webservice, which handles incoming updated config vars from server
        /// </summary>
        /// <param name="NbtResources">NbtResources object</param>
        /// <param name="varsFromServer">Encapsulates a collection of config vars form server</param>
        /// <returns></returns>
        private static CswNbtDataContractConfigurationUpdateSuccessResponse _updateConfigVars(CswNbtResources NbtResources,
                                                                                              CswNbtDataContractConfigurationVariableResponseContainer varsFromServer)
        {
            CswNbtDataContractConfigurationUpdateSuccessResponse ret = new CswNbtDataContractConfigurationUpdateSuccessResponse();
            Dictionary <string, string> updatedConfigVarsFromClient  = new Dictionary <string, string>();

            //add all the config vars into the dictionary
            //keyed by name. If the incoming array contains
            //more than one change to the same config var,
            //the last change 'wins'.
            foreach (CswNbtDataContractConfigurationVariableResponse thisResponse in varsFromServer.responseArray)
            {
                if (updatedConfigVarsFromClient.ContainsKey(thisResponse.VariableName))
                {
                    updatedConfigVarsFromClient[thisResponse.VariableName] = thisResponse.VariableValue;
                }
                else
                {
                    updatedConfigVarsFromClient.Add(thisResponse.VariableName, thisResponse.VariableValue);
                }
            }

            CswTableUpdate CVTableUpdate = NbtResources.makeCswTableUpdate("update config vars", "configuration_variables");
            DataTable      CVDataTable   = CVTableUpdate.getTable();

            foreach (DataRow thisRow in CVDataTable.Rows)
            {
                string configVarName = thisRow[COL_VARIABLENAME].ToString();

                if (updatedConfigVarsFromClient.ContainsKey(configVarName))
                {
                    string updatedConfigVarValue = updatedConfigVarsFromClient[configVarName];
                    string currentConfigVarValue = thisRow[COL_VARIABLEVALUE].ToString();

                    //make sure config var has been altered
                    if (updatedConfigVarValue != currentConfigVarValue)
                    {
                        string configVarDataType = thisRow[COL_DATATYPE].ToString();

                        //now do type specific validation
                        switch (configVarDataType)
                        {
                        case DATATYPE_INT:
                            int configValueAsInt = CswConvert.ToInt32(updatedConfigVarValue);
                            int configMinValue   = CswConvert.ToInt32(thisRow[COL_CONSTRAINT]);
                            //throw exception if the value is > minvalue
                            if (configValueAsInt <= configMinValue)
                            {
                                throw new CswDniException(CswEnumErrorType.Warning,
                                                          "The value of " + configVarName + " must be greater than "
                                                          + configMinValue,
                                                          "Config varible of INT datatype must be < " + configMinValue);
                            }
                            else
                            {
                                thisRow[COL_VARIABLEVALUE] = updatedConfigVarValue;
                            }
                            break;

                        case DATATYPE_LIST:
                            CswCommaDelimitedString listOptions = new CswCommaDelimitedString(thisRow[COL_CONSTRAINT].ToString());
                            if (false == listOptions.Contains(updatedConfigVarValue))
                            {
                                string listOptionsString = listOptions.ToString();
                                throw new CswDniException(CswEnumErrorType.Warning,
                                                          configVarName + " must be set to one of these options: "
                                                          + listOptionsString,
                                                          "Config variable " + configVarName + " cannot be set to " + currentConfigVarValue +
                                                          " since it is not one of the predefined options " + listOptionsString);
                            }
                            else
                            {
                                thisRow[COL_VARIABLEVALUE] = updatedConfigVarValue;
                            }
                            break;

                        case DATATYPE_BOOL:
                            if (false == (updatedConfigVarValue == "0" ||
                                          updatedConfigVarValue == "1"))
                            {
                                throw new CswDniException(CswEnumErrorType.Warning,
                                                          configVarName + " must be set to 0 or 1",
                                                          configVarName + " is of type BOOL, therefore it must be set to 0 or 1");
                            }
                            else
                            {
                                thisRow[COL_VARIABLEVALUE] = updatedConfigVarValue;
                            }
                            break;

                        //for string type there is no config var specific validation
                        default:
                            thisRow[COL_VARIABLEVALUE] = updatedConfigVarValue;
                            break;
                        } //switch by ConfigVarDatatype
                    }     // if config var has been updated
                }         //if this config var was returned from client
            }             //for each dataRow

            //commit changes
            CVTableUpdate.update(CVDataTable);

            //if any errors are encountered, the exception will throw an error message
            //so there is no execution path where we return false
            ret.success = true;
            return(ret);
        }