<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="24" zv="Cache for Windows (x86-64) 2010.1 (Build 413U)" ts="2011-06-28 00:36:42">
<Document name="AllianceDist.AlertRules.RUL"><routingRule host="AllianceDist" name="AlertRules" effectiveBeginDateTime="" effectiveEndDateTime="" context="EnsLib.MsgRouter.RoutingEngine" doAll="false" source="" msgClass="" docName="" docCategory="" docType="">
  <description></description>
  <reportGroup></reportGroup>
  <reportName></reportName>
  <shortDescription></shortDescription>
  <rule source="" msgClass="" docName="" docCategory="" docType="">
    <action type="send" target="EmailAlert" transform=""></action>
  </rule>
</routingRule>
</Document>

<Class name="AllianceDist.AllianceDist">
<ProcedureBlock>1</ProcedureBlock>
<Super>Ens.Production</Super>
<TimeChanged>62264,60296.399481</TimeChanged>
<TimeCreated>62263,32590.040043</TimeCreated>

<XData name="ProductionDefinition">
<Data><![CDATA[
<Production Name="AllianceDist.AllianceDist" TestingEnabled="true" LogGeneralTraceEvents="false">
  <Description></Description>
  <ActorPoolSize>2</ActorPoolSize>
  <Item Name="Proxy" Category="" ClassName="EnsLib.EDI.EDIFACT.Service.FileService" PoolSize="1" Enabled="true" Foreground="false" InactivityTimeout="0" Comment="" LogTraceEvents="false" Schedule="">
    <Setting Target="Host" Name="TargetConfigNames">Router</Setting>
    <Setting Target="Host" Name="DocSchemaCategory">D96A</Setting>
    <Setting Target="Host" Name="Validation">dm</Setting>
    <Setting Target="Host" Name="BatchHandling">Indiv</Setting>
    <Setting Target="Host" Name="AlertOnError">1</Setting>
    <Setting Target="Adapter" Name="FilePath">D:\EnsembleTest\EDI\proxy_in</Setting>
    <Setting Target="Adapter" Name="FileSpec">*</Setting>
    <Setting Target="Adapter" Name="ArchivePath">D:\EnsembleTest\EDI\proxy_archive</Setting>
    <Setting Target="Adapter" Name="WorkPath">D:\EnsembleTest\EDI\proxy_work</Setting>
  </Item>
  <Item Name="AllianceOst" Category="" ClassName="AllianceDist.EDI.EDIFACT.FileOperationFixed" PoolSize="1" Enabled="true" Foreground="false" InactivityTimeout="0" Comment="" LogTraceEvents="false" Schedule="">
    <Setting Target="Host" Name="AutoBatchParentSegs">1</Setting>
    <Setting Target="Host" Name="Validation">dm</Setting>
    <Setting Target="Host" Name="AlertOnError">1</Setting>
    <Setting Target="Adapter" Name="FilePath">D:\EnsembleTest\EDI\inAllianceOst</Setting>
  </Item>
  <Item Name="AllianceMitte" Category="" ClassName="AllianceDist.EDI.EDIFACT.FileOperationFixed" PoolSize="1" Enabled="true" Foreground="false" InactivityTimeout="0" Comment="" LogTraceEvents="false" Schedule="">
    <Setting Target="Host" Name="AutoBatchParentSegs">1</Setting>
    <Setting Target="Host" Name="Validation">dm</Setting>
    <Setting Target="Host" Name="AlertOnError">1</Setting>
    <Setting Target="Adapter" Name="FilePath">D:\EnsembleTest\EDI\inAllianceMitte</Setting>
  </Item>
  <Item Name="Router" Category="" ClassName="EnsLib.MsgRouter.VDocRoutingEngine" PoolSize="0" Enabled="true" Foreground="false" InactivityTimeout="0" Comment="" LogTraceEvents="false" Schedule="">
    <Setting Target="Host" Name="Validation">dm</Setting>
    <Setting Target="Host" Name="BusinessRuleName">AllianceDist.Rules</Setting>
    <Setting Target="Host" Name="AlertOnError">1</Setting>
  </Item>
  <Item Name="BadDocument" Category="" ClassName="AllianceDist.EDI.EDIFACT.FileOperationFixed" PoolSize="1" Enabled="true" Foreground="false" InactivityTimeout="0" Comment="" LogTraceEvents="false" Schedule="">
    <Setting Target="Host" Name="AlertOnError">1</Setting>
    <Setting Target="Adapter" Name="FilePath">D:\EnsembleTest\EDI\proxy_bad</Setting>
  </Item>
  <Item Name="EmailAlert" Category="" ClassName="EnsLib.EMail.AlertOperation" PoolSize="1" Enabled="true" Foreground="false" InactivityTimeout="0" Comment="" LogTraceEvents="false" Schedule="">
    <Setting Target="Adapter" Name="SMTPServer">10.10.1.100</Setting>
    <Setting Target="Adapter" Name="SMTPPort">25</Setting>
    <Setting Target="Adapter" Name="Credentials"></Setting>
    <Setting Target="Adapter" Name="Recipient">roger.zaugg@cbt.ch</Setting>
    <Setting Target="Adapter" Name="From">alliance-ost@cbt.ch</Setting>
  </Item>
  <Item Name="Ens.Alert" Category="" ClassName="EnsLib.MsgRouter.RoutingEngine" PoolSize="0" Enabled="true" Foreground="false" InactivityTimeout="0" Comment="" LogTraceEvents="false" Schedule="">
    <Setting Target="Host" Name="BusinessRuleName">AllianceDist.AlertRules</Setting>
  </Item>
  <Item Name="ErrorHandler" Category="" ClassName="AllianceDist.ErrorHandling" PoolSize="0" Enabled="true" Foreground="false" InactivityTimeout="0" Comment="" LogTraceEvents="false" Schedule="">
  </Item>
</Production>
]]></Data>
</XData>
</Class>


<Class name="AllianceDist.EDI.EDIFACT.FileOperationFixed">
<ClassType/>
<ProcedureBlock>1</ProcedureBlock>
<Super>EnsLib.EDI.EDIFACT.Operation.BatchStandard</Super>
<System>4</System>
<TimeChanged>62264,56818.819488</TimeChanged>
<TimeCreated>59318,79308.949</TimeCreated>

<Parameter name="ADAPTER">
<Default>EnsLib.File.OutboundAdapter</Default>
</Parameter>

<Method name="outputDocument">
<FormalSpec>pFilename:%String,pDocument:EnsLib.EDI.EDIFACT.Document,pSeparators:%String</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
    //
    //
    // Change: UNZ Interchange segment is missing and is not written to the file!!!
    //
    // Created by DL, ISC Switzerland
    //
    // Date: 22.06.2011
    //

    // Start of Change 
    if ('pDocument.Attachments.Next()) {
        // Write header and message
        do ..Adapter.PutStream(pFilename,pDocument,pSeparators)
        // Write trailer
        quit ..Adapter.PutStream(pFilename,pDocument.ParentTrailerSeg,pSeparators)
    }
    // 
    // Original Code!!!
    //
    #; No Attachments - write it out directly
    //Quit:'pDocument.Attachments.Next() ..Adapter.PutStream(pFilename,pDocument,pSeparators) 
    
    // End of Change

    #; Has attachments - must go out as MIME
    Set tStream=##class(%FileCharacterStream).%New()
    Set tSC=pDocument.OutputToLibraryStream(tStream,pSeparators)
    Set tEDIFACTPart=##class(%Net.MIMEPart).%New(tStream)
    Set tMIME=##class(%Net.MIMEPart).%New()
    Set tSC=tMIME.Parts.Insert(tEDIFACTPart) Quit:$$$ISERR(tSC) tSC

    Set k=""  For { Set tAttachment=pDocument.Attachments.GetNext(.k)  Quit:""=k
        Set tAttachmentPart=##class(%Net.MIMEPart).%New(tAttachment.Stream)
        Set tAttachmentPart.ContentType=tAttachmentPart.ContentType_"; filename="""_##class(%File).GetFilename(tAttachment.Filename)_""""
        Set tSC=tMIME.Parts.Insert(tAttachmentPart) Quit:$$$ISERR(tSC)
    }
    Quit:$$$ISERR(tSC) tSC
    
    $$$TRACE("Writing interchange "_pDocument_"/"_pDocument.%Id()_" as MIME to file "_pFilename)
    Quit ..Adapter.PutMIME(pFilename,tMIME,0)
]]></Implementation>
</Method>

<Method name="outputSegment">
<FormalSpec>pFilename:%String,pSegObj:EnsLib.EDI.EDIFACT.Segment,pSeparators:%String,pCount:%Integer</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
    //If $Case(pSegObj.Name,"GE":1,"IEA":1,:0) Set pSegObj=pSegObj.%ConstructClone()  Do pSegObj.SetValueAt(pCount,1)
    Quit ..Adapter.PutStream(pFilename,pSegObj,pSeparators)
]]></Implementation>
</Method>
</Class>


<Class name="AllianceDist.ErrorHandling">
<ClassType>persistent</ClassType>
<ProcedureBlock>1</ProcedureBlock>
<Super>Ens.BusinessProcess</Super>
<TimeChanged>62264,65155.992999</TimeChanged>
<TimeCreated>62263,80169.079337</TimeCreated>

<Method name="OnRequest">
<FormalSpec>pRequest:EnsLib.EDI.EDIFACT.Document,*pResponse:Ens.Response</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
	#dim tSC As %Status
    #dim alertRequest As Ens.AlertRequest

    set tSC = $$$OK
    
    set alertMessage = "Datei konnte nicht bearbeitet werden, da die Identifizierung der Bestellung fehlgeschlagen ist!!! Message Session ID:"_..%SessionId
    
    // Set Ens.AlertRequest Properties (used to be processed correctly with generic email operation!)
    set alertRequest = ##class(Ens.AlertRequest).%New()
    set alertRequest.SourceConfigName = "Router" 
    set alertRequest.AlertText = alertMessage
    //set alertRequest.AlertDestination = "Email-Empfänger"
	
    // Send AlertRequest to generic Email-Operation
    set tSC = ..SendRequestAsync("EmailAlert", alertRequest)

    // Write to Event Log in EMP
    $$$LOGERROR(alertMessage)

    Quit tSC
]]></Implementation>
</Method>

<Method name="OnResponse">
<Description>
Handle a 'Response'</Description>
<FormalSpec><![CDATA[request:%Library.Persistent,&response:%Library.Persistent,callrequest:%Library.Persistent,callresponse:%Library.Persistent,pCompletionKey:%String]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
    // Subclass responsibility
    Quit $$$OK
]]></Implementation>
</Method>

<Storage name="Default">
<Type>%Library.CacheStorage</Type>
</Storage>
</Class>


<Project name="AllianceDist" LastModified="2011-06-22 16:42:13">
  <Items>
    <ProjectItem name="AllianceDist.AlertRules.RUL" type="RUL"/>
    <ProjectItem name="AllianceDist.AllianceDist" type="CLS"/>
    <ProjectItem name="AllianceDist.EDI.EDIFACT.FileOperationFixed" type="CLS"/>
    <ProjectItem name="AllianceDist.ErrorHandling" type="CLS"/>
    <ProjectItem name="AllianceDist.Rules.RUL" type="RUL"/>
  </Items>
</Project>


<Document name="AllianceDist.Rules.RUL"><routingRule host="AllianceDist" name="Rules" effectiveBeginDateTime="" effectiveEndDateTime="" context="EnsLib.MsgRouter.VDocRoutingEngine" doAll="false" source="" msgClass="" docName="" docCategory="" docType="">
  <description></description>
  <reportGroup></reportGroup>
  <reportName></reportName>
  <shortDescription></shortDescription>
  <rule source="Proxy" msgClass="EnsLib.EDI.EDIFACT.Document" docName="" docCategory="" docType="D96A:ORDERS">
    <condition join="AND" operator="=" op1="Document.{SegmentGroup2(2).NAD-12:C082(1).3039}" op2="&quot;7640146110008&quot;"></condition>
    <action type="send" target="AllianceOst" transform=""></action>
  </rule>
  <rule source="Proxy" msgClass="EnsLib.EDI.EDIFACT.Document" docName="" docCategory="" docType="D96A:ORDERS">
    <condition join="AND" operator="=" op1="Document.{SegmentGroup2(2).NAD-12:C082(1).3039}" op2="&quot;7609999037214&quot;"></condition>
    <action type="send" target="AllianceMitte" transform=""></action>
  </rule>
  <rule source="Proxy" msgClass="" docName="" docCategory="" docType="">
    <action type="send" target="BadDocument,ErrorHandler" transform=""></action>
  </rule>
</routingRule>
</Document></Export>
