当前位置: 首页>>代码示例>>C#>>正文


C# OleDbDataReader.SafeString方法代码示例

本文整理汇总了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);
                }
            }
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:26,代码来源:ComponentTestingPropertyDataAdapter.cs

示例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);
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:30,代码来源:ElectricalDataAdapter.cs

示例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);
                }
            }
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:25,代码来源:EngineeringPropertyDataAdapter.cs

示例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));
            }
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:32,代码来源:VendorDataAdapter.cs

示例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();
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:8,代码来源:InterlockPropertyDataAdapter.cs

示例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();
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:8,代码来源:RelatedDocumentDataAdapter.cs

示例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;
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:56,代码来源:DocumentLocationDataAdapter.cs

示例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);
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:12,代码来源:AttachmentDataAdapter.cs

示例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);
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:12,代码来源:DocumentEquipmentDataAdapter.cs

示例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);
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:47,代码来源:InstrumentComponentDataAdapter.cs

示例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));
                }
            }
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:59,代码来源:SystemReferenceDataAdapter.cs

示例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);
                }
            }
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:31,代码来源:InterlockDataAdapter.cs

示例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);
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:17,代码来源:MechanicalDataAdapter.cs

示例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();
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:24,代码来源:ControlDataAdapter.cs

示例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);
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:23,代码来源:InstrumentDataAdapter.cs


注:本文中的System.Data.OleDb.OleDbDataReader.SafeString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。