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


C# OleDbDataReader.SafeValueToString方法代码示例

本文整理汇总了C#中System.Data.OleDb.OleDbDataReader.SafeValueToString方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbDataReader.SafeValueToString方法的具体用法?C# OleDbDataReader.SafeValueToString怎么用?C# OleDbDataReader.SafeValueToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.OleDb.OleDbDataReader的用法示例。


在下文中一共展示了OleDbDataReader.SafeValueToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FinancialDataAdapter

        public FinancialDataAdapter(OleDbDataReader dr, List<DateTime> dates, int rowNumber)
        {
            ErrorMessages = new List<string>();
            int issueId;
            string issueIdString = dr.SafeValueToString((int) FinancialColumn.IssueId);
            DateValue = new Dictionary<DateTime, decimal>();

            if (Int32.TryParse(issueIdString, out issueId))
            {
                IssueId = issueId;
            }
            else
            {
                ErrorMessages.Add(string.Format("Could not convert Issue id '{0}' to Int. Rown number '{1}'. Skipping ", issueIdString, rowNumber));
            }

            var financeTypeString = dr.SafeValueToString((int) FinancialColumn.FinanceType).Trim();

            if (financeTypeString == FinanceType.Baseline.ToString()) FinanceType = FinanceType.Baseline;
            else if (financeTypeString == FinanceType.Budget.ToString()) FinanceType = FinanceType.Budget;
            else if (financeTypeString == FinanceType.Forecast.ToString()) FinanceType = FinanceType.Forecast;
            else if (financeTypeString == FinanceType.ForecastV1.ToString()) FinanceType = FinanceType.ForecastV1;
            else if (financeTypeString == FinanceType.ForecastV2.ToString()) FinanceType = FinanceType.ForecastV2;
            else if (financeTypeString == FinanceType.ForecastV3.ToString()) FinanceType = FinanceType.ForecastV3;
            else
            {
                ErrorMessages.Add(string.Format("Could not recognise FinancialType '{0}'. Rown number '{1}'. Skipping ", financeTypeString, rowNumber));
            } //add error msg

            int dateIndex = 0;
            for (int i = (int) FinancialColumn.FinanceType + 1; i < dr.FieldCount; i++)
            {
                DateTime date = dates[dateIndex];
                dateIndex++;
                string dateStringValue = dr.SafeValueToString(i);
                dateStringValue = dateStringValue.Replace("$","");
                if (string.IsNullOrEmpty(dateStringValue)) {continue;} //Import only data that has value

                decimal dateValue;

                if (Decimal.TryParse(dateStringValue, out dateValue))
                {
                    DateValue.Add(date, Math.Round(dateValue,2));
                }
                else
                {
                    ErrorMessages.Add(string.Format("Could not convert value '{0}' for '{1}'. Rown number '{2}'. Skipping ", dateStringValue,date, rowNumber));
                }
            }
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:50,代码来源:FinancialDataAdapter.cs

示例2: 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

示例3: Cji5DataAdapter

        public Cji5DataAdapter(OleDbDataReader dr, int rowNumber)
        {
            ErrorMessages = new List<string>();
            PoNumber = dr.SafeValueToString((int) PurchaseColumn.RefDocumentNumber);
            ProjectDefinition = dr.SafeValueToString((int)PurchaseColumn.ProjectDefinition);

            if (String.IsNullOrEmpty(ProjectDefinition))
            {
                ErrorMessages.Add(string.Format("{0} returned null, please check the format of this cell in Excel (set to Text). Row number '{1}'. Skipping ", PurchaseColumn.ProjectDefinition,  rowNumber));
            }

            VendorNumber = dr.SafeValueToString((int)PurchaseColumn.Vendor);
            Description = dr.SafeValueToString((int)PurchaseColumn.Name);

            decimal totalAmountValue;
            string totalAmountString = dr.SafeValueToString((int)PurchaseColumn.PlanObjectCur);

            if (Decimal.TryParse(totalAmountString, out totalAmountValue))
            {
                TotalAmount = totalAmountValue;
            }
            else
            {
                ErrorMessages.Add(string.Format("Could not convert {0} '{1}' to decimal. Row number '{2}'. Skipping ", PurchaseColumn.PlanObjectCur, totalAmountString, rowNumber));
            }

            decimal valueInObjCrcyValue;
            string valueInObjCrcyString = dr.SafeValueToString((int)PurchaseColumn.ValueInObjCrcy);

            if (Decimal.TryParse(valueInObjCrcyString, out valueInObjCrcyValue))
            {
                ValueInObjCrcy = valueInObjCrcyValue;
            }
            else
            {
                ErrorMessages.Add(string.Format("Could not convert {0} '{1}' to decimal. Row number '{2}'. Skipping ", PurchaseColumn.ValueInObjCrcy, valueInObjCrcyString, rowNumber));
            }

            WbsElement = dr.SafeValueToString((int)PurchaseColumn.WbsElement);

            if (String.IsNullOrEmpty(WbsElement))
            {
                ErrorMessages.Add(string.Format("{0} returned null, please check the format of this cell in Excel (set to Text). Row number '{1}'. Skipping ", PurchaseColumn.WbsElement, rowNumber));
            }

            int costElementValue;
            string costElementString = dr.SafeValueToString((int)PurchaseColumn.CostElement);

            if (int.TryParse(costElementString, out costElementValue))
            {
                CostElement = costElementValue;
            }
            else
            {
                ErrorMessages.Add(string.Format("Could not convert {0} '{1}' to decimal. Row number '{2}'. Skipping ", PurchaseColumn.CostElement, costElementString, rowNumber));
            }

            int referenceItemValue;
            string referenceItemString = dr.SafeValueToString((int)PurchaseColumn.ReferenceItem);

            if (int.TryParse(referenceItemString, out referenceItemValue))
            {
                ReferenceItem = referenceItemValue;
            }
            else
            {
                ErrorMessages.Add(string.Format("Could not convert {0} '{1}' to decimal. Row number '{2}'. Skipping ", PurchaseColumn.ReferenceItem, referenceItemString, rowNumber));
            }

            ReferenceDocType = dr.SafeValueToString((int)PurchaseColumn.ReferenceDocType);

            DateTime dateValue;
            string dateStringValue = dr.SafeValueToString((int)PurchaseColumn.DocumentDate);
            if (DateTime.TryParse(dateStringValue, out dateValue))
            {
                Date = dateValue;
            }
            else
            {
                ErrorMessages.Add(string.Format("Could not convert {0} '{1}' to Date. Row number '{2}'. Skipping ", PurchaseColumn.DocumentDate, dateStringValue, rowNumber));
            }
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:82,代码来源:Cji5DataAdapter.cs

示例4: Cji3DataAdapter

        public Cji3DataAdapter(OleDbDataReader dr, int rowNumber)
        {
            ErrorMessages = new List<string>();

            //FiscalYear
            string fiscalYearString = string.Empty;
            fiscalYearString = dr.SafeValueToString((int)Cij3Column.FiscalYear);
            int fiscalYear;

            if (int.TryParse(fiscalYearString, out fiscalYear))
            {
                FiscalYear = fiscalYear;
            }
            else
            {
                ErrorMessages.Add(string.Format("Could not convert {0} '{1}' to integer. Rown number '{2}'. Skipping ", Cij3Column.FiscalYear, fiscalYearString, rowNumber));
            }

            //Period
            string periodString = string.Empty;
            periodString = dr.SafeValueToString((int)Cij3Column.Period);
            int period;

            if (int.TryParse(periodString, out period))
            {
                Period = period;
            }
            else
            {
                ErrorMessages.Add(string.Format("Could not convert {0} '{1}' to decimal. Rown number '{2}'. Skipping ", Cij3Column.Period, periodString, rowNumber));
            }

            //Date
            Date = new DateTime(fiscalYear,period,1);

            //Project Definition
            ProjectDefinition = dr.SafeValueToString((int)Cij3Column.ProjectDefinition);
            if (String.IsNullOrEmpty(ProjectDefinition))
            {
                ErrorMessages.Add(string.Format("{0} returned null, please check the format of this cell in Excel (set to Text). Row number '{1}'. Skipping ", Cij3Column.ProjectDefinition, rowNumber));
            }

            //WBS Element
            WbsElement = dr.SafeValueToString((int)Cij3Column.WbsElement);
            if (String.IsNullOrEmpty(WbsElement))
            {
                ErrorMessages.Add(string.Format("{0} returned null, please check the format of this cell in Excel (set to Text). Row number '{1}'. Skipping ", Cij3Column.WbsElement, rowNumber));
            }

            //Purchasing Document
            PurchasingDocument = dr.SafeValueToString((int)Cij3Column.PurchasingDocument);

            //Purchase Order Text
            PurchaseOrderText = dr.SafeValueToString((int)Cij3Column.PurchaseOrderText);

            //Name
            Name = dr.SafeValueToString((int)Cij3Column.Name);

            //PartnerObject
            PartnerObject = dr.SafeValueToString((int)Cij3Column.PartnerObject);

            //CoPartnerObject
            CoPartnerObjectName = dr.SafeValueToString((int)Cij3Column.CoPartnerObjectName);

            //Posting Date
            DateTime postingDate;
            string postingDateString = dr.SafeValueToString((int)Cij3Column.PostingDate);
            if (DateTime.TryParse(postingDateString, out postingDate))
            {
                PostingDate = postingDate;
            }
            else
            {
                ErrorMessages.Add(string.Format("Could not convert {0} '{1}' to Date. Rown number '{2}'. Skipping ", Cij3Column.PostingDate, postingDateString, rowNumber));
            }

            //Value in Object Currency
            string valueCurrencyString = string.Empty;
            valueCurrencyString = dr.SafeValueToString((int)Cij3Column.ValueInObjCrcy);
            decimal valueCurrency;

            if (decimal.TryParse(valueCurrencyString, out valueCurrency))
            {
                ValueInObjectCurrency = valueCurrency;
            }
            else
            {
                ErrorMessages.Add(string.Format("Could not convert {0} '{1}' to decimal. Rown number '{2}'. Skipping ", Cij3Column.ValueInObjCrcy, valueCurrencyString, rowNumber));
            }
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:90,代码来源:Cji3DataAdapter.cs


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