コード例 #1
0
        private List <AddmlFlatFileDefinition> GetAddmlFlatFileDefinitions()
        {
            List <AddmlFlatFileDefinition> addmlFlatFileDefinitions = new List <AddmlFlatFileDefinition>();

            flatFileDefinition[] flatFileDefinitions = GetFlatFileDefinitions();
            foreach (flatFileDefinition flatFileDefinition in flatFileDefinitions)
            {
                string              name            = flatFileDefinition.name;
                string              recordSeparator = GetRecordSeparator(flatFileDefinition.typeReference);
                string              fieldSeparator  = GetFieldSeparator(flatFileDefinition.typeReference);
                string              fileName        = GetFileName(flatFileDefinition.name);
                FileInfo            fileInfo        = _workingDirectory.Content().WithFile(fileName);
                string              charset         = GetCharset(flatFileDefinition.typeReference);
                string              recordDefinitionFieldIdentifier = flatFileDefinition.recordDefinitionFieldIdentifier;
                int?                numberOfRecords   = GetNumberOfRecords(flatFileDefinition.name);
                Checksum            checksum          = GetChecksum(flatFileDefinition.name);
                AddmlFlatFileFormat format            = GetFlatFileFormat(flatFileDefinition.typeReference);
                List <string>       flatFileProcesses = GetFlatFileProcessNames(flatFileDefinition.name);

                AddmlFlatFileDefinition addmlFlatFileDefinition =
                    new AddmlFlatFileDefinition(name, fileName, fileInfo, recordSeparator, fieldSeparator, charset,
                                                recordDefinitionFieldIdentifier, numberOfRecords, checksum, format, flatFileProcesses);

                AddAddmlFieldDefinitions(addmlFlatFileDefinition, flatFileDefinition);

                addmlFlatFileDefinitions.Add(addmlFlatFileDefinition);
            }

            SetForeignKeyReferences(addmlFlatFileDefinitions);

            return(addmlFlatFileDefinitions);
        }
コード例 #2
0
 public AddmlRecordDefinition(AddmlFlatFileDefinition addmlFlatFileDefinition,
                              string name,
                              int?recordLength,
                              string recordDefinitionFieldValue,
                              List <AddmlForeignKey> foreignKeys,
                              List <string> processes)
 {
     AddmlFlatFileDefinition = addmlFlatFileDefinition;
     Name         = name;
     RecordLength = recordLength;
     RecordDefinitionFieldValue = recordDefinitionFieldValue;
     ForeignKeys           = foreignKeys;
     AddmlFieldDefinitions = new List <AddmlFieldDefinition>();
     Processes             = processes;
 }
コード例 #3
0
        private void AddAddmlFieldDefinitions(AddmlFlatFileDefinition addmlFlatFileDefinition,
                                              flatFileDefinition flatFileDefinition)
        {
            List <recordDefinition> recordDefinitions = GetRecordDefinitions(flatFileDefinition);

            foreach (recordDefinition recordDefinition in recordDefinitions)
            {
                string        recordDefinitionName       = recordDefinition.name;
                int?          recordLength               = GetRecordLength(recordDefinition);
                string        recordDefinitionFieldValue = recordDefinition.recordDefinitionFieldValue;
                List <string> recordProcesses            = GetRecordProcessNames(addmlFlatFileDefinition.Name, recordDefinition.name);

                List <AddmlForeignKey> foreignKeys = GetForeignKeysForRecord(flatFileDefinition, recordDefinition);

                AddmlRecordDefinition addmlRecordDefinition =
                    addmlFlatFileDefinition.AddAddmlRecordDefinition(recordDefinitionName, recordLength, recordDefinitionFieldValue, foreignKeys, recordProcesses);

                List <fieldDefinition> fieldDefinitions = GetFieldDefinitions(recordDefinition);
                foreach (fieldDefinition fieldDefinition in fieldDefinitions)
                {
                    string        name               = fieldDefinition.name;
                    int?          startPosition      = GetStartPosition(fieldDefinition);
                    int?          endPosition        = GetEndPosition(fieldDefinition); // Henter slutt-posisjon med ny funksjon
                    DataType      dataType           = GetFieldType(fieldDefinition.typeReference);
                    bool          isPartOfPrimaryKey = IsPartOfPrimaryKey(recordDefinition, fieldDefinition);
                    bool          isUnique           = IsUnique(fieldDefinition);
                    bool          isNullable         = IsNullable(fieldDefinition);
                    int?          minLength          = GetMinLength(fieldDefinition);
                    int?          maxLength          = GetMaxLength(fieldDefinition);
                    int?          fixedLength        = GetFixedLength(fieldDefinition) ?? endPosition - startPosition + 1;
                    List <string> processes          = GetFieldProcessNames(flatFileDefinition.name, recordDefinition.name,
                                                                            fieldDefinition.name);
                    List <AddmlCode> addmlCodes = GetCodes(fieldDefinition);

                    AddmlFieldDefinition addAddmlFieldDefinition = addmlRecordDefinition.AddAddmlFieldDefinition(
                        name, startPosition, fixedLength, dataType, isUnique, isNullable, minLength,
                        maxLength, processes, addmlCodes, isPartOfPrimaryKey);

                    FieldIndex fieldIndex = new FieldIndex(flatFileDefinition, recordDefinition, fieldDefinition);
                    if (_allFieldDefinitions.ContainsKey(fieldIndex))
                    {
                        throw new AddmlDefinitionParseException("ADDML file already contains a field definition with same index: " + fieldIndex);
                    }
                    _allFieldDefinitions.Add(fieldIndex, addAddmlFieldDefinition);
                }
            }
        }
コード例 #4
0
ファイル: AddmlDefinition.cs プロジェクト: reftel/arkade5
 /// <summary>
 /// The ControlForeignKey ADDML process requires a list of all existing primary keys in order to function correct.
 /// But the process it self is only defined on the foreign key record. This method makes sure that the CollectPrimaryKey process,
 /// is inserted into all primary key field definitions that are referenced from a foreign key field definition,
 /// where the ControlForeignKey process is defined.
 /// </summary>
 private void InsertCollectPrimaryKeyProcessInDefinitionsReferencedFromAForeignKeyWithControlProcess()
 {
     AddmlFlatFileDefinition.InsertCollectPrimaryKeyProcessInDefinitionsReferencedFromAForeignKeyWithControlProcess(AddmlFlatFileDefinitions);
 }