0

以下に示すようにEDIファイルを取得しています。それを処理する必要があり、主キー、外部キーも維持する必要があります。

TH*4.2*857463*01**20091015*1045*P**~~IS*7564*ACME 
PHARMACY~PHA*1234567890~PAT*MA*06*987544****SMITH*JOHN****1234 MAIN 
ST**SOMEWHERE*MA*54356**19500101*M*01*01*INDIA**BURGER~

ここで、列の区切りは * で、値が指定されていない場合も * を入力します。

フィールドを保存する必要があります

TH*4.2*857463*01**20091015*1045*P**~~

フィールドを区切って1つのテーブルに。

だからそうなるだろう

th01 th02 th03 th04 th05 th06 th07 th08 th09 th10
TH 4.2 857163 01 *(値なし) 20091015 1045 p * (値なし) ~~

IS*7564*ACME PHARMACY を別のテーブルに、など。

xml ファイルを使用できないため、サードパーティのツールを使用できません

何か助けはありますか?

わかった。

ここに私のvb.netコードがあります

Public Enum セグメント TH PHA PAT IS1 End Enum

Dim arrLine As String()
Dim segmentcode As String
Dim counter As Integer
Dim linenumber As Integer = 1
Dim segmenetsequence As Hashtable = New Hashtable()
Dim setid As Guid = Guid.NewGuid()






Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

    arrLine = Row.LineText.Split("*"c)

    segmentcode = SegmentValue(arrLine, 0)
    Row.LineNumber = linenumber


    Row.Setid = setid

    counter = arrLine.Length
    linenumber += 1

    Select Case (segmentcode.ToUpper())

        Case Segments.TH.ToString.ToUpper()
            Row.TH01 = SegmentValue(arrLine, 1)
            Row.TH02 = SegmentValue(arrLine, 2)
            Row.TH03 = Convert.ToInt32(SegmentValue(arrLine, 3))
            Row.TH04 = SegmentValue(arrLine, 4)
            Row.TH05 = Convert.ToDateTime(SegmentValue(arrLine, 5))
            Row.TH06 = SegmentValue(arrLine, 6)
            Row.TH07 = SegmentValue(arrLine, 7)
            Row.TH08 = Convert.ToInt32(SegmentValue(arrLine, 8))
            Row.TH09 = SegmentValue(arrLine, 9)

        Case Segments.IS1.ToString.ToUpper()
            Row.IS01 = SegmentValue(arrLine, 1)
            Row.IS02 = SegmentValue(arrLine, 2)
            Row.IS03 = SegmentValue(arrLine, 3)

        Case Segments.PHA.ToString.ToUpper()

            Row.PHA01 = SegmentValue(arrLine, 1)
            Row.PHA02 = SegmentValue(arrLine, 2)
            Row.PHA03 = SegmentValue(arrLine, 3)
            Row.PHA04 = SegmentValue(arrLine, 4)
            Row.PHA05 = SegmentValue(arrLine, 5)
            Row.PHA06 = SegmentValue(arrLine, 6)
            Row.PHA07 = SegmentValue(arrLine, 7)
            Row.PHA08 = SegmentValue(arrLine, 8)
            Row.PHA09 = SegmentValue(arrLine, 9)
            Row.PHA10 = SegmentValue(arrLine, 10)
            Row.PHA11 = SegmentValue(arrLine, 11)
            Row.PHA12 = SegmentValue(arrLine, 12)


        Case Segments.PAT.ToString.ToUpper()

            Row.PAT01 = SegmentValue(arrLine, 1)
            Row.PAT02 = SegmentValue(arrLine, 2)
            Row.PAT03 = SegmentValue(arrLine, 3)
            Row.PAT04 = SegmentValue(arrLine, 4)
            Row.PAT05 = Convert.ToInt32(SegmentValue(arrLine, 5))
            Row.PAT06 = SegmentValue(arrLine, 6)
            Row.PAT07 = SegmentValue(arrLine, 7)
            Row.PAT08 = SegmentValue(arrLine, 8)
            Row.PAT09 = SegmentValue(arrLine, 9)
            Row.PAT10 = SegmentValue(arrLine, 10)
            Row.PAT11 = SegmentValue(arrLine, 11)
            Row.PAT12 = SegmentValue(arrLine, 12)
            Row.PAT13 = SegmentValue(arrLine, 13)
            Row.PAT14 = SegmentValue(arrLine, 14)
            Row.PAT15 = SegmentValue(arrLine, 15)
            Row.PAT16 = SegmentValue(arrLine, 16)
            Row.PAT17 = SegmentValue(arrLine, 17)
            Row.PAT18 = Convert.ToDateTime(SegmentValue(arrLine, 18))
            Row.PAT19 = SegmentValue(arrLine, 19)
            Row.PAT20 = Convert.ToInt32(SegmentValue(arrLine, 20))
            Row.PAT21 = Convert.ToInt32(SegmentValue(arrLine, 21))
            Row.PAT22 = SegmentValue(arrLine, 22)
            Row.PAT23 = SegmentValue(arrLine, 23)
            Row.PAT24 = SegmentValue(arrLine, 24)




    End Select



End Sub

Public Function SegmentValue(ByRef LineArray As String(), ByVal Counter As Integer) As String
    Throw New NotImplementedException

    If LineArray.Length > Counter Then
        Return LineArray(Counter).ToString().Trim()

    End If
    Return String.Empty

End Function

クラス終了

4

1 に答える 1

0

大まかに言えば、スクリプトコンポーネントをソースとして使用することを検討します。ファイルに含めることができる「もの」ごとに出力コレクションがあります。あなたの例では、上Output 0の行を説明するのに十分な列がありthます。次に、データセットを説明するOutput 1コレクションが作成されます。ISまた、データを追跡するために、ソースコンポーネント内で生成された代理キーなど、すべてのキーを考慮する必要があります。

コレクション内のすべての列を定義したら、C#/VB.NETで解析ロジックを作成するだけです。解析したら、それらのコレクションに値を割り当てるだけです。

    Output0Buffer.AddRow();
    // use this to assign a value
    Output0Buffer.MyColumn = parsedValue;
    // Use this for handling a null value
    Output0Buffer.MyColumn_IsNull = true;

これで、パッケージを実行し、解析されたデータフローをストリームに流すことができます。

満たすべき外部キーと生成される代理値があるようです。その場合は、すべてではないにしてもほとんどのデータをさまざまなステージングテーブルに書き込み、データフロータスクにチェーンされたSQL実行タスクを介して繰り返しクエリを実行してデータの検証と埋め戻しを続行します。

詳細が必要ですか?質問を編集して、自分で提供してください。私たちは皆、アドバイスと指示を喜んで提供しますが、私たちはあなたのキューブに参加しておらず、あなたのニーズを理解していません。

于 2012-10-29T21:18:41.070 に答える