本文整理汇总了C#中System.Data.OleDb.OleDbDataReader.SafeString方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbDataReader.SafeString方法的具体用法?C# OleDbDataReader.SafeString怎么用?C# OleDbDataReader.SafeString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.OleDb.OleDbDataReader
的用法示例。
在下文中一共展示了OleDbDataReader.SafeString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComponentTestingPropertyDataAdapter
public ComponentTestingPropertyDataAdapter(OleDbDataReader dr, IList<string> dynamicList, int startColumn)
{
ControlSystemName = "";
ComponentName = "";
ControlSystemName = dr.SafeString((int) TestingPropertyColumn.ControlSystemName).Trim();
ComponentName = dr.SafeString((int) TestingPropertyColumn.ComponentName).Trim();
DynamicProperties = new List<DynamicProperty>();
if (dynamicList != null && dynamicList.Any())
{
for (var d = 0; d < dynamicList.Count(); d++)
{
var p = dynamicList[d];
var property = new DynamicProperty
{
PropertyName = p,
PropertyValue = dr.SafeString(startColumn + d)
};
DynamicProperties.Add(property);
}
}
}
示例2: ElectricalDataAdapter
public ElectricalDataAdapter(OleDbDataReader dr, string workSheetName, int rowNumber, CommonUtils.ImportType importType)
{
RowNumber = rowNumber;
WorkSheetName = workSheetName;
Tag = dr.SafeString((int) EquipmentColumn.Tag).Trim();
EquipmentType = dr.SafeString((int) EquipmentColumn.Type).Trim();
Description = dr.SafeString((int) EquipmentColumn.Description).Trim();
Notes = dr.SafeString((int) EquipmentColumn.Notes);
AreaNumber = dr.SafeString((int)EquipmentColumn.Area).Trim();
Specification = dr.SafeString((int)EquipmentColumn.Spec).Trim();
PandID = dr.SafeString((int)EquipmentColumn.PID).Trim();
MaintSysId = dr.SafeString((int)EquipmentColumn.MaintSysId);
string classifiedString = dr.SafeString((int)EquipmentColumn.Classified);
bool classified;
if (bool.TryParse(classifiedString, out classified))
{
Classified = classified;
}
string isActiveString = dr.SafeString((int)EquipmentColumn.IsActive);
bool isActive;
if (bool.TryParse(isActiveString, out isActive))
{
IsActive = isActive;
}
Validate(importType==CommonUtils.ImportType.CreateElectrical);
}
示例3: EngineeringPropertyDataAdapter
public EngineeringPropertyDataAdapter(OleDbDataReader dr, IList<string> dynamicList, int startColumn)
{
ControlSystemName = "";
ComponentName = "";
ControlSystemName = dr.SafeString((int)EngineeringPropertyColumn.ControlSystemName).Trim();
ComponentName = dr.SafeString((int)EngineeringPropertyColumn.ComponentName).Trim();
DynamicProperties = new List<DynamicProperty>();
if (dynamicList != null && dynamicList.Any())
{
for (int d = 0; d < dynamicList.Count(); d++)
{
string p = dynamicList[d];
DynamicProperty property = new DynamicProperty();
property.PropertyName = p;
property.PropertyValue = dr.SafeString(startColumn + d);
DynamicProperties.Add(property);
}
}
}
示例4: VendorDataAdapter
public VendorDataAdapter(OleDbDataReader dr, int rowNumber)
{
ErrorMessages = new List<string>();
//Name
Name = dr.SafeString((int)VendorColumn.VendorName);
if (String.IsNullOrEmpty(Name))
{
ErrorMessages.Add(string.Format("{0} returned null, please check the format of this cell in Excel (set to Text). Row number '{1}'. Skipping ", VendorColumn.VendorName, rowNumber));
}
//Number
string numberString = string.Empty;
numberString = dr.SafeString((int)VendorColumn.VendorNumber);
int number;
if (int.TryParse(numberString, out number))
{
Number = number;
}
else
{
ErrorMessages.Add(string.Format("Could not convert {0} '{1}' to number. Rown number '{2}'. Skipping ", VendorColumn.VendorNumber, numberString, rowNumber));
}
//City
City = dr.SafeString((int)VendorColumn.VendorCity);
if (String.IsNullOrEmpty(City))
{
ErrorMessages.Add(string.Format("{0} returned null, please check the format of this cell in Excel (set to Text). Row number '{1}'. Skipping ", VendorColumn.VendorCity, rowNumber));
}
}
示例5: InterlockPropertyDataAdapter
public InterlockPropertyDataAdapter(OleDbDataReader dr)
{
ControlSystemName = string.Empty;
InterlockTypeName = string.Empty;
ControlSystemName = dr.SafeString((int)InterlockPropertyColumn.ControlSystemName).Trim();
InterlockTypeName = dr.SafeString((int)InterlockPropertyColumn.InterlockType).Trim();
}
示例6: RelatedDocumentDataAdapter
public RelatedDocumentDataAdapter(OleDbDataReader dr)
{
EquipmentName = string.Empty;
DocumentName = string.Empty;
EquipmentName = dr.SafeString((int)CommonColumn.EquipmentName).Trim();
DocumentName = dr.SafeString((int)CommonColumn.DocumentName).Trim();
}
示例7: DocumentLocationDataAdapter
public DocumentLocationDataAdapter(OleDbDataReader dr, int rowNumber, IEnumerable<DocumentLocation> documentLocations, IEnumerable<CmsWebService.Document> documents)
{
DocumentName = string.Empty;
LocationName = string.Empty;
RowNumber = rowNumber;
//DOCUMENT
DocumentName = dr.SafeString((int)DocumentLocationColumn.DocumentName).Trim();
if (string.IsNullOrEmpty(DocumentName))
{
ErrorMessages.Add(string.Format("The DocumentName column is empty in the excel document for Excel row {0}.", rowNumber));
return;
}
CmsWebService.Document document = (from x in documents where string.Compare(x.Name, DocumentName, true, CultureInfo.CurrentCulture) == 0 select x).FirstOrDefault();
if (document == null)
{
ErrorMessages.Add(string.Format("Excel Row {1}. Cannot find a Document with the Name {0} - skipping...", DocumentName, rowNumber));
return;
}
if (!document.IsActive)
{
ErrorMessages.Add(string.Format("Excel Row {1}. The Document {0} is not Active - skipping...", DocumentName, rowNumber));
return;
}
DocumentId = document.Id;
//LOCATION
LocationName = dr.SafeString((int)DocumentLocationColumn.LocationName).Trim();
if (string.IsNullOrEmpty(LocationName))
{
ErrorMessages.Add(string.Format("The LocaitonName column is empty in the excel document for Excel row {0}.", rowNumber));
return;
}
DocumentLocation documentLocation = (from x in documentLocations where string.Compare(x.Name, LocationName, true, CultureInfo.CurrentCulture) == 0 select x).FirstOrDefault();
if (documentLocation == null)
{
ErrorMessages.Add(string.Format("Excel Row {1}. Cannot find an Document Location using Name {0}. - skipping...", LocationName, rowNumber));
return;
}
if (!documentLocation.IsActive)
{
ErrorMessages.Add(string.Format("Excel Row {1}. The DocumentLocation {0} is not Active - skipping...", LocationName, rowNumber));
return;
}
LocationId = documentLocation.Id;
}
示例8: AttachmentDataAdapter
public AttachmentDataAdapter(OleDbDataReader dr, int rowNumber)
{
AttachmentDto = new BaseAttachmentDto();
AttachmentDto.Tag = dr.SafeString((int)AttachmentColumn.Tag).Trim();
AttachmentDto.Type = dr.SafeString((int)AttachmentColumn.Type).Trim();
AttachmentDto.AttachmentType = dr.SafeString((int)AttachmentColumn.AttachmentType).Trim();
AttachmentDto.Filename = dr.SafeString((int)AttachmentColumn.Filename).Trim();
AttachmentDto.Description = dr.SafeString((int)AttachmentColumn.Description).Trim();
CheckType(rowNumber);
}
示例9: DocumentEquipmentDataAdapter
public DocumentEquipmentDataAdapter(OleDbDataReader dr, int rowNumber, CommonUtils.ImportType importType)
{
DocumentName = string.Empty;
EquipmentTypeName = string.Empty;
RowNumber = rowNumber;
mImportType = importType;
DocumentName = dr.SafeString((int)DocumentEquipmentColumn.DocumentName).Trim();
EquipmentTypeName = dr.SafeString((int)DocumentEquipmentColumn.EquipmentType).Trim();
Tag = dr.SafeString((int)DocumentEquipmentColumn.Tag).Trim();
this.Validate(rowNumber, importType == CommonUtils.ImportType.LinkRelatedEquipmentDocument);
}
示例10: InstrumentComponentDataAdapter
public InstrumentComponentDataAdapter(OleDbDataReader dr, List<InstrumentProperty> existingInstrumentProperties,
IList<string> spreadSheetComponentPropertyNames, int rowNumber, bool canCreateProperties, CommonUtils.ImportType importType)
{
base.PopulateCommonProperties(dr);
RowNumber = rowNumber;
mImportType = importType;
int k = 0;
const int StartColumnIndex = (int)BaseComponentColumn.Model + 1;
for (int i = StartColumnIndex; i < StartColumnIndex + spreadSheetComponentPropertyNames.Count; i++)
{
if (string.IsNullOrEmpty(dr.SafeString(i)))
{
continue;
}
string propertyName = spreadSheetComponentPropertyNames[k];
k++;
InstrumentProperty property = (from x in existingInstrumentProperties where x.Name.ToLower() == propertyName.ToLower() select x).FirstOrDefault();
if (property != null)
{
PropertyValues.Add(property.Name, dr.SafeValueToString(i));
}
else
{
if (canCreateProperties)
{
if (!PropertyValues.ContainsValue(dr.SafeString(i)))
{
PropertyValues.Add(propertyName, dr.SafeString(i));
}
}
else
{
ErrorMessages.Add(RaiseMissingPropertyMessage(ComponentName, rowNumber, propertyName));
break;
}
}
}
base.Validate(rowNumber, mImportType==CommonUtils.ImportType.CreateInstrumentComponent);
}
示例11: SystemReferenceDataAdapter
public SystemReferenceDataAdapter(OleDbDataReader dr, string workSheetName, int rowNumber)
{
RowNumber = rowNumber;
WorkSheetName = workSheetName;
ProjectCode = dr.SafeString((int)ProjectWbsColumn.ProjectCode).Trim();
WbsElement = dr.SafeString((int)ProjectWbsColumn.WbsElement).Trim();
WbsElementDescription = dr.SafeString((int)ProjectWbsColumn.WbsElementDescription).Trim();
SpendClassification = dr.SafeString((int)ProjectWbsColumn.SpendClassification).Trim();
var statusString = dr.SafeString((int)ProjectWbsColumn.WbsStatus).Trim();
if (!String.IsNullOrEmpty(statusString))
{
//Status in Excel will be Either Open (write 1 to table) or Closed (write 0 to table).
Status = statusString.ToLower() == "open" ? true : false;
}
string actualsString = dr.SafeString((int)ProjectWbsColumn.Actuals).Trim();
if (String.IsNullOrEmpty(actualsString))
{
Actuals = null;
}
else
{
decimal number;
if (Decimal.TryParse(actualsString, NumberStyles.Any, null, out number))
{
Actuals = number;
}
else
{
Errors.Add(String.Format("Could not parse Actual '{0}' on Line number {1} to decimal. Skipping...",
actualsString, rowNumber));
}
}
string wbsBudgetString = dr.SafeString((int)ProjectWbsColumn.WbsBudget).Trim();
if (String.IsNullOrEmpty(wbsBudgetString))
{
WbsBudget = null;
}
else
{
decimal number2;
if (Decimal.TryParse(wbsBudgetString, NumberStyles.Any, null, out number2))
{
WbsBudget = number2;
}
else
{
Errors.Add(String.Format("Could not parse Actual '{0}' on Line number {1} to decimal. Skipping...",
actualsString, rowNumber));
}
}
}
示例12: InterlockDataAdapter
public InterlockDataAdapter(OleDbDataReader dr ,IList<string> dynamicList, int startColumn)
{
ControlSystemName = string.Empty;
InterlockTypeName =
Number = string.Empty;
Cause = string.Empty;
Description = string.Empty;
ControlSystemName = dr.SafeString((int)InterlockColumn.ControlSystemName).Trim();
InterlockTypeName = dr.SafeString((int)InterlockColumn.InterlockType).Trim();
Number = dr.SafeString((int)InterlockColumn.Number).Trim();
Cause = dr.SafeString((int)InterlockColumn.Cause).Trim();
Description = dr.SafeString((int)InterlockColumn.Description).Trim();
DynamicProperties = new List<DynamicProperty>();
if (dynamicList != null && dynamicList.Any())
{
for (int d = 0; d < dynamicList.Count(); d++)
{
string p = dynamicList[d];
DynamicProperty property = new DynamicProperty();
property.PropertyName = p;
property.PropertyValue = dr.SafeString(startColumn + d);
DynamicProperties.Add(property);
}
}
}
示例13: MechanicalDataAdapter
public MechanicalDataAdapter(OleDbDataReader dr, string workSheetName, int rowNumber)
{
RowNumber = rowNumber;
WorkSheetName = workSheetName;
Tag = dr.SafeString((int)EquipmentColumn.Tag);
EquipmentType = dr.SafeString((int)EquipmentColumn.Type).Trim();
Description = dr.SafeString((int)EquipmentColumn.Description).Trim();
Notes = dr.SafeString((int)EquipmentColumn.Notes).Trim();
AreaNumber = dr.SafeString((int)EquipmentColumn.Area).Trim();
Specification = dr.SafeString((int)EquipmentColumn.Spec).Trim();
PandID = dr.SafeString((int)EquipmentColumn.PID).Trim();
MaintSysId = dr.SafeString((int)EquipmentColumn.MaintSysId);
Classified = dr.SafeNullableBool((int)EquipmentColumn.Classified);
IsActive = dr.SafeNullableBool((int)EquipmentColumn.IsActive);
}
示例14: ControlDataAdapter
public ControlDataAdapter(OleDbDataReader dr)
{
ControlSystemName = string.Empty;
ControlSytemTypeName = string.Empty;
AreaNumber = string.Empty;
GraphicName = string.Empty;
Description = string.Empty;
UpperEquipmentName = string.Empty;
PIDName = string.Empty;
SpecificationName = string.Empty;
Notes = string.Empty;
Classified = string.Empty;
ControlSystemName = dr.SafeString((int)ControlColumn.ControlSystemName).Trim();
ControlSytemTypeName = dr.SafeString((int)ControlColumn.ControlSystemTypeName).Trim();
AreaNumber = dr.SafeString((int)ControlColumn.AreaNumber).Trim();
GraphicName = dr.SafeString((int)ControlColumn.GraphicName).Trim();
Description = dr.SafeString((int)ControlColumn.Description).Trim();
UpperEquipmentName = dr.SafeString((int)ControlColumn.UpperEquipmentName).Trim();
PIDName = dr.SafeString((int)ControlColumn.PIDName).Trim();
SpecificationName = dr.SafeString((int)ControlColumn.SpecificationName).Trim();
Notes = dr.SafeString((int)ControlColumn.Notes).Trim();
Classified = dr.SafeString((int)ControlColumn.Classified).Trim();
}
示例15: InstrumentDataAdapter
public InstrumentDataAdapter(OleDbDataReader dr, string workSheetName, int rowNumber, CommonUtils.ImportType importType)
{
RowNumber = rowNumber;
WorkSheetName = workSheetName;
ErrorMessages = new List<string>();
Tag = dr.SafeString((int)InstrumentColumn.Tag).Trim();
EquipmentType = dr.SafeString((int)InstrumentColumn.Type).Trim();
Description = dr.SafeString((int)InstrumentColumn.Description).Trim();
Notes = dr.SafeString((int)InstrumentColumn.Notes).Trim();
AreaNumber = dr.SafeString((int)InstrumentColumn.Area).Trim();
Specification = dr.SafeString((int)InstrumentColumn.Spec).Trim();
PandID = dr.SafeString((int)InstrumentColumn.PID).Trim();
MaintSysId = dr.SafeString((int)InstrumentColumn.MaintSysId);
Classified = dr.SafeNullableBool((int) InstrumentColumn.Classified);
VerificationFrequency = dr.SafeString((int)InstrumentColumn.VerificationFrequency);
IsActive = dr.SafeNullableBool((int) InstrumentColumn.IsActive);
Validate(importType==CommonUtils.ImportType.CreateInstrument);
}