public DataTable getUserOptions() { DataTable Data = new CswDataTable("Userselectdatatable", ""); Data.Columns.Add(NameColumn, typeof(string)); Data.Columns.Add(KeyColumn, typeof(int)); Data.Columns.Add(StringKeyColumn, typeof(string)); Data.Columns.Add(ValueColumn, typeof(bool)); bool first = true; //ICswNbtTree UsersTree = _CswNbtResources.Trees.getTreeFromObjectClass( CswNbtMetaDataObjectClassName.NbtObjectClass.UserClass ); //for( int c = 0; c < UsersTree.getChildNodeCount(); c++ ) //{ // UsersTree.goToNthChild( c ); CswNbtMetaDataObjectClass UserOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.UserClass); foreach (CswNbtNode UserNode in UserOC.getNodes(false, false)) { if (CswEnumTristate.True != UserNode.Properties[CswNbtObjClassUser.PropertyName.Archived].AsLogical.Checked) { DataRow NTRow = Data.NewRow(); NTRow[NameColumn] = UserNode.NodeName; // UsersTree.getNodeNameForCurrentPosition(); NTRow[KeyColumn] = UserNode.NodeId.PrimaryKey; // UsersTree.getNodeIdForCurrentPosition().PrimaryKey; NTRow[StringKeyColumn] = UserNode.NodeId.ToString(); // UsersTree.getNodeIdForCurrentPosition().PrimaryKey; NTRow[ValueColumn] = (SelectedUserIds.Contains(UserNode.NodeId.PrimaryKey.ToString()) || //UsersTree.getNodeIdForCurrentPosition().PrimaryKey.ToString() ) ) || (first && Required && SelectedUserIds.Count == 0)); Data.Rows.Add(NTRow); first = false; //UsersTree.goToParentNode(); } } return(Data); } // UserOptions()
public DataTable GetDataAsTable(string NameColumn, string KeyColumn) { DataTable Data = new CswDataTable("GetDataAsTable_DataTable", ""); Data.Columns.Add(NameColumn); Data.Columns.Add(KeyColumn); foreach (string XValue in XValues) { Data.Columns.Add(XValue, typeof(bool)); } //if( _CswNbtMetaDataNodeTypeProp.IsFK && _CswNbtMetaDataNodeTypeProp.FKType == "fkeydefid" ) if (CswConvert.ToBoolean(_CswNbtNodePropData[CswNbtFieldTypeRuleLogicalSet.AttributeName.IsFK]) && _CswNbtNodePropData[CswNbtFieldTypeRuleLogicalSet.AttributeName.FKType] == "fkeydefid") { CswTableSelect FkeyDefsSelect = _CswNbtResources.makeCswTableSelect("YValues_fkeydef_select", "fkey_definitions"); //DataTable FkeyDefsTable = FkeyDefsSelect.getTable( "fkeydefid", _CswNbtMetaDataNodeTypeProp.FKValue ); DataTable FkeyDefsTable = FkeyDefsSelect.getTable("fkeydefid", CswConvert.ToInt32(_CswNbtNodePropData[CswNbtFieldTypeRuleLogicalSet.AttributeName.FKValue])); string Sql = FkeyDefsTable.Rows[0]["sql"].ToString(); CswArbitrarySelect YValuesSelect = _CswNbtResources.makeCswArbitrarySelect("YValues_select", Sql); DataTable YValuesTable = YValuesSelect.getTable(); foreach (DataRow CurrentYValueRow in YValuesTable.Rows) { DataRow Row = Data.NewRow(); Row[NameColumn] = CurrentYValueRow[FkeyDefsTable.Rows[0]["ref_column"].ToString()].ToString(); Row[KeyColumn] = CurrentYValueRow[FkeyDefsTable.Rows[0]["pk_column"].ToString()].ToString(); foreach (string XValue in XValues) { Row[XValue] = CheckValue(XValue, Row[KeyColumn].ToString()); } Data.Rows.Add(Row); } } else { foreach (string YValue in YValues) { DataRow Row = Data.NewRow(); Row[NameColumn] = YValue; Row[KeyColumn] = YValue; foreach (string XValue in XValues) { Row[XValue] = CheckValue(XValue, YValue); } Data.Rows.Add(Row); } } return(Data); }
public DataTable ViewsForCBA() { DataTable _ViewsForCBA = new CswDataTable( "viewpicklistdatatable", "" ); _ViewsForCBA.Columns.Add( KeyColumn, typeof( Int32 ) ); _ViewsForCBA.Columns.Add( NameColumn, typeof( string ) ); _ViewsForCBA.Columns.Add( ValueColumn, typeof( bool ) ); foreach( CswNbtView ThisView in Views.Values ) { DataRow NewViewRow = _ViewsForCBA.NewRow(); NewViewRow[NameColumn] = ThisView.ViewName; NewViewRow[KeyColumn] = ThisView.ViewId.get(); NewViewRow[ValueColumn] = ( ( SelectedViewIds.Contains( ThisView.ViewId.get() ) ) || ( ( Views.Values.First() == ThisView ) && Required && SelectedViewIds.Count == 0 ) ); _ViewsForCBA.Rows.Add( NewViewRow ); } return _ViewsForCBA; } // ViewsForCBA
public void FetchSchemata() { try { SetStatus("Fetching Available Schemata"); FetchSchemataEventArgs e = new FetchSchemataEventArgs(); CswNbtResources CswNbtResources = null; _InitSessionResources(string.Empty, ref CswNbtResources); if (CswNbtResources.CswDbCfgInfo.TotalDbInstances > 0) { CswDataTable DbInstances = new CswDataTable("SchemaUpdaterForm1DataTable", ""); DbInstances.Columns.Add(_ColName_AccessId, typeof(string)); DbInstances.Columns.Add(_ColName_ServerType, typeof(string)); DbInstances.Columns.Add(_ColName_ServerName, typeof(string)); DbInstances.Columns.Add(_ColName_UserName, typeof(string)); DbInstances.Columns.Add(_ColName_UserCount, typeof(string)); DbInstances.Columns.Add(_ColName_Deactivated, typeof(bool)); DbInstances.Columns.Add(_ColName_Display, typeof(string)); DbInstances.Rows.Clear(); foreach (string CurrentAccessId in CswNbtResources.CswDbCfgInfo.ActiveAccessIds) { CswNbtResources.CswDbCfgInfo.makeConfigurationCurrent(CurrentAccessId); DataRow CurrentRow = DbInstances.NewRow(); CurrentRow[_ColName_AccessId] = CurrentAccessId.ToString(); CurrentRow[_ColName_ServerType] = CswNbtResources.CswDbCfgInfo.CurrentServerType; CurrentRow[_ColName_ServerName] = CswNbtResources.CswDbCfgInfo.CurrentServerName; CurrentRow[_ColName_UserName] = CswNbtResources.CswDbCfgInfo.CurrentUserName; CurrentRow[_ColName_UserCount] = CswNbtResources.CswDbCfgInfo.CurrentUserCount; CurrentRow[_ColName_Deactivated] = CswNbtResources.CswDbCfgInfo.CurrentDeactivated; CurrentRow[_ColName_Display] = CurrentAccessId + " (" + CswNbtResources.CswDbCfgInfo.CurrentUserName + "@" + CswNbtResources.CswDbCfgInfo.CurrentServerName + ")"; DbInstances.Rows.Add(CurrentRow); } if (DbInstances.Rows.Count > 0) { e.Succeeded = true; e.DbInstances = DbInstances; } else { e.Succeeded = false; e.Message = "Database configuration file does not contain any instances."; } } // if( CswNbtResources.CswDbCfgInfo.TotalDbInstances > 0 ) else { e.Succeeded = false; e.Message = "There is no database configuration data."; } if (OnFetchSchemata != null) { OnFetchSchemata(e); } _CloseSessionResources(CswNbtResources); SetStatus("Fetching Available Schemata: Done"); } catch (Exception ex) { SetStatus("ERROR: " + ex.Message); } } // FetchSchemata
public void saveRapidLoaderData(RapidLoaderData.RapidLoaderDataRequest Request) { String TempFileName = "RL_" + _CswNbtResources.AccessId + "_" + _CswNbtResources.CurrentUser.Username + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".csv"; String FullPathName = _getFileNameAndPath(TempFileName); FileStream fs = new FileStream(FullPathName, FileMode.CreateNew); StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Default); sw.Write(Request.CSVData); sw.Flush(); sw.Close(); // CIS-53216 // We need to hack the data coming from the client into the default 'CISPro' import format DataTable CsvData = CswTools.CsvToDataTable(FullPathName, true); // Add missing columns: CsvData.Columns.Add("Department"); CsvData.Columns.Add("Physical Description"); CsvData.Columns.Add("expirationdate"); CsvData.Columns.Add("manufacturerlotno"); CsvData.Columns.Add("inventorygroupname"); CsvData.Columns.Add("Unit_Weight"); CsvData.Columns.Add("Unit_Volume"); CsvData.Columns.Add("Unit_Each"); CsvData.Columns.Add("ConvFactBase"); CsvData.Columns.Add("ConvFactExp"); CsvData.Columns.Add("Rolename"); // Rename existing columns: CsvData.Columns["Chemical"].ColumnName = "MaterialName"; CsvData.Columns["Supplier"].ColumnName = "vendorname"; CsvData.Columns["CAS No"].ColumnName = "CasNo"; CsvData.Columns["Quantity"].ColumnName = "netquantity"; CsvData.Columns["Units"].ColumnName = "UnitOfMeasureName"; CsvData.Columns["Owner"].ColumnName = "responsible"; CsvData.Columns["Barcode"].ColumnName = "barcodeid"; CsvData.Columns["CatalogNo"].ColumnName = "catalogno"; // Massage data: foreach (DataRow csvRow in CsvData.Rows) { csvRow["inventorygroupname"] = "Default Inventory Group"; switch (csvRow["UnitType"].ToString()) { case "WEIGHT": csvRow["Unit_Weight"] = csvRow["UnitOfMeasureName"]; break; case "VOLUME": csvRow["Unit_Volume"] = csvRow["UnitOfMeasureName"]; break; case "EACH": csvRow["Unit_Each"] = csvRow["UnitOfMeasureName"]; break; } csvRow["ConvFactBase"] = 1; csvRow["ConvFactExp"] = 0; csvRow["Rolename"] = "cispro_general"; } // Overwrite the existing CSV FileStream fs2 = new FileStream(FullPathName, FileMode.Truncate); StreamWriter sw2 = new StreamWriter(fs2, System.Text.Encoding.Default); sw2.Write(CswDataTable.ToCsv(CsvData)); sw2.Flush(); sw2.Close(); String EmailMessageSubject = "Your ChemSW Rapid Loader import is available for download"; String EmailMessageBody = String.Format( _EmailBodyTemplate, _CswNbtResources.CurrentNbtUser.Username, _makeLink(TempFileName) ); if (false == String.IsNullOrEmpty(Request.EmailAddress)) { _sendEmail(_CswNbtResources.CurrentNbtUser.Username, Request.EmailAddress, EmailMessageSubject, EmailMessageBody); } _sendEmail(_CswNbtResources.CurrentNbtUser.Username, _CswNbtResources.SetupVbls[CswEnumSetupVariableNames.SupportEmail], EmailMessageSubject, EmailMessageBody); }