Skip to main content

Posts

Showing posts from June, 2017

T SQL : Filename with date string derivation with simple logic

DECLARE  @Filename varchar(100)  ,@FilenameSmall varchar(100)  ,@BatchNameType varchar(50) SET @BatchNameType = SPACE(0) SET @Filename = '05 May 2017_FP.xlsx' SET @Filename = '05 May 2017_FW.xlsx' SET @Filename = '05 May 2017_HA.xlsx' SET @Filename = '05 May 2017_WHO.xlsx' SET @Filename = 'GENERICS-20170531_152713.xlsx' SET @FilenameSmall = LOWER(@Filename) SET @BatchNameType += CASE WHEN PATINDEX('%_fw.xlsx', @FilenameSmall) > 0 THEN 'FINALWAY-' ELSE SPACE(0) END SET @BatchNameType += CASE WHEN PATINDEX('%_fp.xlsx', @FilenameSmall) > 0 THEN 'FINALWAY-' ELSE SPACE(0) END SET @BatchNameType += CASE WHEN PATINDEX('%_ha.xlsx', @FilenameSmall) > 0 THEN 'HOMEALONE-' ELSE SPACE(0) END SET @BatchNameType += CASE WHEN PATINDEX('%_who.xlsx', @FilenameSmall) > 0 THEN 'WHO-' ELSE SPACE(0) END IF( LEN(@BatchNameType) > 0)  BEGIN   SELECT [@Filename] = @Filename, [@FilenameSmall] =...

BizTalk 2010 : Sample pipeline with filename extraction

public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg) {     VirtualStream inboundStream = new VirtualStream(pInMsg.BodyPart.GetOriginalDataStream());     VirtualStream outboundStream = new VirtualStream(VirtualStream.MemoryFlag.AutoOverFlowToDisk);     string sBatchName = Path.GetFileNameWithoutExtension(pInMsg.Context.Read("ReceivedFileName", " http://schemas.microsoft.com/BizTalk/2003/file-properties ").ToString());     AccountingEntriesExcelCreator ExcelCreator = new AccountingEntriesExcelCreator();     outboundStream = ExcelCreator.CreateExcel(inboundStream, sBatchName);     if (outboundStream != null)     {         if (outboundStream.Length > 0)         {             outboundStream.Position = 0;             pInMsg.BodyPart.Data = outboundStream;             pContext.ResourceTracker.AddResource(inboundStream);             pContext.ResourceTracker.AddResource(outboundStream);         }         else         {             pInMsg = null;    ...

BizTalk 2010 : Use Code Page = UTF-8 (65001) to preserved special characters (Unicode) when converting flatfile to xml form

T SQL : String manipulation and DataTime extraction from string

SET @XmlFilename = 'JCA_RB_SP-20170531_152713.txt' SELECT @IndexOfDash = CHARINDEX ( '-' , @XmlFilename ) SELECT @BatchName = LEFT( @XmlFilename , CHARINDEX ( '-' , @XmlFilename ) - 1 ) SELECT @BatchDateStringRaw = SUBSTRING ( @XmlFilename , CHARINDEX ( '-' , @XmlFilename ) + 1 , 15 ) SELECT @BatchDateString = SUBSTRING ( @BatchDateStringRaw , 1 , 4 ) + '-' + SUBSTRING ( @BatchDateStringRaw , 5 , 2 ) + '-' + SUBSTRING ( @BatchDateStringRaw , 7 , 2 ) + ' ' + SUBSTRING ( @BatchDateStringRaw , 10 , 2 ) + ':' + SUBSTRING ( @BatchDateStringRaw , 12 , 2 ) + ':' + SUBSTRING ( @BatchDateStringRaw , 14 , 2 ) SELECT [@XmlFilename] = @XmlFilename , [@IndexOfDash] = @IndexOfDash , [@BatchName] = @BatchName , [@BatchDateStringRaw] = @BatchDateStringRaw , [@BatchDateString] = @BatchDateString , CAST ( @BatchDateString ...