2012-10-29 82 views
0

我得到EDI文件如下所示,我需要处理它,并且我需要维护主键,外键也。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  *(no value) 20091015 1045  p  * (novalue) ~~ 

为* 7564 * ACME药学到另一台,依此类推。

,因为我不能有XML文件

任何帮助,我无法使用第三方工具?

好的。

这里是我的vb.net代码

公共枚举段 TH PHA PAT IS1 结束枚举

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

“有帮助吗?”是你在整篇文章中提出的唯一问题,这不是一个可以回答的问题。请编辑您的问题,先将其改进为可回答的问题,然后再添加一些代码格式以使其更具可读性。 –

+0

我需要的方法来处理这个文件,而无需使用任何第三方工具 – user1783579

+1

那么你有什么尝试?解析文件非常简单;您只需抓住每对分隔符('*')之间的部分,并在到达'〜'时停止每个“行”(分段)。 NCPDP EDI药店索赔文件是最简单的解析文件之一,但您在此处未展示任何努力。而且你需要**编辑**你的问题来实际询问一个问题,正如我之前要求你做的那样。 –

回答

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任务进行验证和回填数据。

需要更多的细节?编辑你的问题,并提供一些你自己。我们很乐意提供建议和指导,但我们不在您的立方体中,并且不了解您的需求。

+0

我正在使用源组件作为trnasform,并且我正在通过eachand每个stage.but我的脚本组件只是运行indefinetly。 – user1783579

+0

这里是我的源代码 – user1783579

+0

我如何在这里上传文件或图片 – user1783579

相关问题