コード例 #1
0
 private void PrepareSectionStaticValues(DataRow uploadedSheetRow, DataSheetSettings settings)
 {
     foreach (DataSheetColumn column in SectionValues)
     {
         column.StaticValue = column.FormattedColumnValue(uploadedSheetRow, settings);
     }
 }
コード例 #2
0
        public string FormattedColumnValue(DataRow dataSheetRow, DataSheetSettings settings)
        {
            string result = _StaticValue;

            if (_Index > -1)
            {
                result = dataSheetRow[_Index].ToString().Trim();
            }
            if (_StringOperations.Count > 0)
            {
                result = _StringOperations.PerformOperations(result);
            }
            if (IsNumeric && !Utilities.Data.Utilities.IsNumeric(result))
            {
                result = "0";
            }
            if (_Calculations.Count > 0)
            {
                result = _Calculations.PerformCalculations(double.Parse(result), dataSheetRow, settings).ToString();
            }
            if (ConditionalOperation.ConditionType != ConditionalOperation.ConditionTypes.None)
            {
                result = ConditionalOperation.PerformOperation(result, dataSheetRow);
            }
            result = HandleDateParsing(result);
            if (result != null)
            {
                result = _PreText + result + _PostText;
            }
            return(result);
        }
コード例 #3
0
        public void CheckForNewSection(DataRow uploadedSheetRow, DataSheetSettings settings)
        {
            object separatorColumnValue = uploadedSheetRow[SeparatorIndex];

            if (separatorColumnValue == null || separatorColumnValue.ToString().IndexOf(Separator) == -1)
            {
                return;
            }
            PrepareSectionStaticValues(uploadedSheetRow, settings);
        }
コード例 #4
0
 public void ApplySectionValues(DataTable formattedTable, DataRow newRow, DataSheetSettings settings)
 {
     foreach (DataSheetColumn column in SectionValues)
     {
         if (string.IsNullOrEmpty(column.StaticValue))
         {
             continue;
         }
         newRow[column.Name] = newRow[column.Name] + column.StaticValue;
     }
 }
コード例 #5
0
 public void AppendToRow(DataRow existingRow, DataRow uploadedSheetRow, DataSheetSettings settings)
 {
     if (!settings.MultiRowsPerRecordOptions.Columns.IsValidRow(uploadedSheetRow, settings))
     {
         return;
     }
     foreach (DataSheetColumn column in this)
     {
         AddColumnValueToRow(existingRow, column, uploadedSheetRow, settings);
     }
 }
コード例 #6
0
        public DataRow NewRow(DataTable formattedTable, DataRow uploadedSheetRow, DataSheetSettings settings)
        {
            DataRow row = formattedTable.NewRow();

            foreach (DataSheetColumn column in this)
            {
                AddColumnValueToRow(row, column, uploadedSheetRow, settings);
            }

            //Set any static section-values that need to apply to each row
            settings.DataSheetSection.ApplySectionValues(formattedTable, row, settings);

            return(row);
        }
コード例 #7
0
 public bool IsValidRow(DataRow dataSheetRow, DataSheetSettings settings)
 {
     foreach (DataSheetColumn dataSheetColumn in this)
     {
         if (!dataSheetColumn.IsPartOfCurrentGroup(settings))
         {
             continue;
         }
         if (!dataSheetColumn.IsValidRow(dataSheetRow))
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #8
0
        private void AddColumnValueToRow(DataRow rowToPopulate, DataSheetColumn column, DataRow uploadedSheetRow, DataSheetSettings settings)
        {
            if (string.IsNullOrEmpty(column.Name))
            {
                return;
            }
            if (!column.IsPartOfCurrentGroup(settings))
            {
                return;
            }
            string columnValue = column.FormattedColumnValue(uploadedSheetRow, settings);

            if (columnValue == null)
            {
                return;
            }
            if (column.IsNumeric && rowToPopulate.Table.Columns[column.Name].DataType == typeof(System.Int32))
            {
                rowToPopulate[column.Name] = (int)double.Parse(rowToPopulate[column.Name].ToString() == "" ? "0" : rowToPopulate[column.Name].ToString()) + (int)double.Parse(columnValue);
            }
            else if (column.IsNumeric && !string.IsNullOrEmpty(rowToPopulate[column.Name].ToString()))
            {
                rowToPopulate[column.Name] = double.Parse(rowToPopulate[column.Name].ToString()) + double.Parse(columnValue);
            }
            else if (rowToPopulate.Table.Columns[column.Name].DataType == typeof(DateTime))
            {
                rowToPopulate[column.Name] = rowToPopulate[column.Name].ToString() == "" ? columnValue : DateTime.Parse(rowToPopulate[column.Name].ToString()).ToShortDateString() + " " + columnValue;
            }
            else
            {
                rowToPopulate[column.Name] = rowToPopulate[column.Name] + column.FormattedColumnValue(uploadedSheetRow, settings);
            }
        }
コード例 #9
0
 public void SetPropertiesOfObject(object objectToSet, DataRow uploadedSheetRow, DataSheetSettings settings)
 {
     foreach (DataSheetColumn dataSheetColumn in this)
     {
         Utilities.Data.PropertySetter.SetPropertyValue(objectToSet, dataSheetColumn.Name,
                                                        dataSheetColumn.FormattedColumnValue(uploadedSheetRow, settings));
     }
 }
コード例 #10
0
 public bool IsPartOfCurrentGroup(DataSheetSettings settings)
 {
     return(Group == 0 || Group == settings.MultiRecordsPerRowOptions.CurrentGroup);
 }