using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace TANFWorkSearch { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { var ws = new TANFWorkSearchWSD.TANFWorkSearch(); TANFWorkSearchWSD.WorkSearchOut wsInput = new TANFWorkSearchWSD.WorkSearchOut(); DateTime dateTime = DateTime.Now; TANFWorkSearchWSD.SGData sgData = new TANFWorkSearchWSD.SGData(); sgData.RequestEnvironment = TANFWorkSearchWSD.RequestEnvironment.C; sgData.RequestTimeStamp = dateTime; sgData.Caller = TANFWorkSearchWSD.Caller.C; sgData.ServiceVersion = "serviceVersionPlaceHolder"; TANFWorkSearchWSD.BusinessData businessData = new TANFWorkSearchWSD.BusinessData(); TANFWorkSearchWSD.Individual individual = new TANFWorkSearchWSD.Individual(); double recID=12.30; individual.RecipientID = recID.ToString(); individual.FirstName = "firstName"; individual.LastName = "lastName"; individual.MiddleInitial = "Middle"; individual.DOB =dateTime; individual.SSN = "1234"; individual.BeginDate = dateTime; individual.EndDate = dateTime; individual.UserID = "1234"; individual.ParticipantID = "1234"; ws.GetWorkSearchInfo(wsInput); } } }
Tuesday, December 11, 2012
Consuming webMethods WSD in C#.
Labels:
C#,
Development
Expertise in creating custom solutions using IBM webMethods product suite to meet various customer needs.
Search String in text file and return line number.
Inputs:
searchString
fileName
outputs:
exists
lineNum
error
Imports:
searchString
fileName
outputs:
exists
lineNum
error
Code:
IDataCursor pipelineCursor = pipeline.getCursor(); String searchString = IDataUtil.getString( pipelineCursor, "searchString" ); String fileName = IDataUtil.getString( pipelineCursor, "fileName" ); pipelineCursor.destroy(); File file=new File(fileName); int lineNum = 0; try { Scanner in = new Scanner(new FileReader(file)); while (in.hasNext()) { String inString = in.nextLine().toLowerCase(); if( inString.indexOf( searchString ) >= 0) { IDataUtil.put( pipelineCursor, "lineNum", Integer.toString(lineNum)); IDataUtil.put( pipelineCursor, "exists", "true"); break; } else{ IDataUtil.put( pipelineCursor, "exists", "false"); } lineNum++; } } catch (FileNotFoundException e) { IDataUtil.put( pipelineCursor, "error", e.toString()); } pipelineCursor.destroy();
Code:
import java.io.FileReader; import java.util.Scanner; import java.io.File;
Labels:
Development
Expertise in creating custom solutions using IBM webMethods product suite to meet various customer needs.
Split one large file to multiple small files based on break length - Large file handling.
Inputs:
fileName: Absolute File Name path to be split.
lineBreak: number of lines when the break needs to happen.
outFileNamePrefix: output file name prefix, absolute path.
Code:
fileName: Absolute File Name path to be split.
lineBreak: number of lines when the break needs to happen.
outFileNamePrefix: output file name prefix, absolute path.
Code:
IDataCursor pipelineCursor = pipeline.getCursor(); String fileName = IDataUtil.getString( pipelineCursor, "fileName" ); String lineBreak = IDataUtil.getString( pipelineCursor, "lineBreak" ); String outFileNamePrefix = IDataUtil.getString( pipelineCursor, "outFileNamePrefix" ); pipelineCursor.destroy(); int breakLenInt=Integer.parseInt(lineBreak); int count=0; int currentLineNumber=0; String line=null; FileInputStream inputStream; FileWriter fstream; try { inputStream = new FileInputStream(new File(fileName)); InputStreamReader streamReader = new InputStreamReader(inputStream, "UTF-8"); BufferedReader reader = new BufferedReader(streamReader); while ((line=reader.readLine())!=null){ if(currentLineNumber<breakLenInt){ String outFile=outFileNamePrefix+"_"+count+".txt"; fstream = new FileWriter(outFile,true); BufferedWriter bw=new BufferedWriter(fstream); bw.write(line); bw.newLine(); bw.close(); currentLineNumber++; } else{ breakLenInt=breakLenInt+Integer.parseInt(lineBreak); count++; } } reader.close(); streamReader.close(); IDataUtil.put( pipelineCursor, "result", "Success" ); } catch (FileNotFoundException e) { IDataUtil.put( pipelineCursor, "result", e.toString() ); } catch (UnsupportedEncodingException e) { IDataUtil.put( pipelineCursor, "result", e.toString() ); } catch (IOException e) { IDataUtil.put( pipelineCursor, "result", e.toString() ); }
Labels:
Development
Expertise in creating custom solutions using IBM webMethods product suite to meet various customer needs.
Subscribe to:
Posts (Atom)