From db2ca04e7a888289ac0f59537dcb6833cb7341da Mon Sep 17 00:00:00 2001 From: Arnaud Simon Date: Wed, 12 Nov 2008 14:25:03 +0000 Subject: Qpid-1146: Added doc + samples git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@713378 13f79535-47bb-0310-9956-ffa450edef68 --- .../client-010/addins/ExcelAddIn/Excel.exe.config | 2 + dotnet/client-010/addins/ExcelAddIn/ExcelAddIn.cs | 3 +- .../client-010/addins/ExcelAddIn/ExcelAddIn.csproj | 11 ++++- .../addins/ExcelAddIn/Properties/AssemblyInfo.cs | 8 +-- .../ExcelAddInMessageProcessor.csproj | 57 ++++++++++++++++++++++ .../addins/ExcelAddInMessageProcessor/Processor.cs | 44 +++++++++++++++++ .../Properties/AssemblyInfo.cs | 35 +++++++++++++ .../ExcelAddInProducer/ExcelAddInProducer.csproj | 1 + .../ExcelAddInProducer/Properties/AssemblyInfo.cs | 8 +-- dotnet/client-010/addins/README.txt | 29 +++++++++++ 10 files changed, 187 insertions(+), 11 deletions(-) create mode 100644 dotnet/client-010/addins/ExcelAddInMessageProcessor/ExcelAddInMessageProcessor.csproj create mode 100644 dotnet/client-010/addins/ExcelAddInMessageProcessor/Processor.cs create mode 100644 dotnet/client-010/addins/ExcelAddInMessageProcessor/Properties/AssemblyInfo.cs create mode 100644 dotnet/client-010/addins/README.txt (limited to 'dotnet') diff --git a/dotnet/client-010/addins/ExcelAddIn/Excel.exe.config b/dotnet/client-010/addins/ExcelAddIn/Excel.exe.config index 0a49da465f..69e5bc36d6 100644 --- a/dotnet/client-010/addins/ExcelAddIn/Excel.exe.config +++ b/dotnet/client-010/addins/ExcelAddIn/Excel.exe.config @@ -6,5 +6,7 @@ + \ No newline at end of file diff --git a/dotnet/client-010/addins/ExcelAddIn/ExcelAddIn.cs b/dotnet/client-010/addins/ExcelAddIn/ExcelAddIn.cs index baed00b03a..d77f3761a8 100644 --- a/dotnet/client-010/addins/ExcelAddIn/ExcelAddIn.cs +++ b/dotnet/client-010/addins/ExcelAddIn/ExcelAddIn.cs @@ -250,8 +250,7 @@ namespace ExcelAddIn byte[] body = new byte[m.Body.Length - m.Body.Position]; reader.Read(body, 0, body.Length); ASCIIEncoding enc = new ASCIIEncoding(); - res = enc.GetString(body); - res = res + " price: " + m.ApplicationHeaders["price"]; + res = enc.GetString(body); return res; } diff --git a/dotnet/client-010/addins/ExcelAddIn/ExcelAddIn.csproj b/dotnet/client-010/addins/ExcelAddIn/ExcelAddIn.csproj index e6f1bd020b..048b0ab6ec 100644 --- a/dotnet/client-010/addins/ExcelAddIn/ExcelAddIn.csproj +++ b/dotnet/client-010/addins/ExcelAddIn/ExcelAddIn.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -11,6 +11,11 @@ Qpid Excel AddIn + + + + + 2.0 true @@ -21,6 +26,7 @@ prompt 4 true + bin\Debug\Qpid Excel AddIn.XML pdbonly @@ -48,6 +54,9 @@ Client + + + + \ No newline at end of file diff --git a/dotnet/client-010/addins/ExcelAddInMessageProcessor/Processor.cs b/dotnet/client-010/addins/ExcelAddInMessageProcessor/Processor.cs new file mode 100644 index 0000000000..0b2d27519f --- /dev/null +++ b/dotnet/client-010/addins/ExcelAddInMessageProcessor/Processor.cs @@ -0,0 +1,44 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +using System.IO; +using System.Text; +using org.apache.qpid.client; + +namespace ExcelAddInMessageProcessor +{ + class Processor : ExcelAddIn.MessageProcessor + { + public string ProcessMessage(IMessage m) + { + BinaryReader reader = new BinaryReader(m.Body, Encoding.UTF8); + byte[] body = new byte[m.Body.Length - m.Body.Position]; + reader.Read(body, 0, body.Length); + ASCIIEncoding enc = new ASCIIEncoding(); + string res = enc.GetString(body); + if (m.ApplicationHeaders.ContainsKey("price")) + { + res = res + ": price: " + m.ApplicationHeaders["price"]; + } + return res; + } + } +} \ No newline at end of file diff --git a/dotnet/client-010/addins/ExcelAddInMessageProcessor/Properties/AssemblyInfo.cs b/dotnet/client-010/addins/ExcelAddInMessageProcessor/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..1279348645 --- /dev/null +++ b/dotnet/client-010/addins/ExcelAddInMessageProcessor/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ExcelAddInMessageProcessor")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Apache Software Foundation")] +[assembly: AssemblyProduct("ExcelAddInMessageProcessor")] +[assembly: AssemblyCopyright("Copyright Apache Software Foundation 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d20b2d75-7b8b-4f7d-8a81-40a4cce94195")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/dotnet/client-010/addins/ExcelAddInProducer/ExcelAddInProducer.csproj b/dotnet/client-010/addins/ExcelAddInProducer/ExcelAddInProducer.csproj index 1d6863332a..d60a63451b 100644 --- a/dotnet/client-010/addins/ExcelAddInProducer/ExcelAddInProducer.csproj +++ b/dotnet/client-010/addins/ExcelAddInProducer/ExcelAddInProducer.csproj @@ -33,6 +33,7 @@ + diff --git a/dotnet/client-010/addins/ExcelAddInProducer/Properties/AssemblyInfo.cs b/dotnet/client-010/addins/ExcelAddInProducer/Properties/AssemblyInfo.cs index 226709ca0b..f83025483c 100644 --- a/dotnet/client-010/addins/ExcelAddInProducer/Properties/AssemblyInfo.cs +++ b/dotnet/client-010/addins/ExcelAddInProducer/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -6,11 +6,11 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Qpid Excel AddIn Producer")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyDescription("Built from svn revision number: ")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Apache Software Foundation")] [assembly: AssemblyProduct("Qpid Excel AddIn Producer")] -[assembly: AssemblyCopyright("Copyright © Apache Software Foundation 2008")] +[assembly: AssemblyCopyright("Apache Software Foundation")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyVersion("0.10.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/dotnet/client-010/addins/README.txt b/dotnet/client-010/addins/README.txt new file mode 100644 index 0000000000..486a708910 --- /dev/null +++ b/dotnet/client-010/addins/README.txt @@ -0,0 +1,29 @@ +This project contains three sub-projects: +- The RTD excell Addin +- A sample client sending messages to queue1 +- A ample message processor + +RDT AddIn +Excel provides a function called RTD (real-time data) that lets you specify a COM server via its ProgId here "Qpid" so that you can push qpid messages into Excel. +For using the Qpid RTD follows those steps: + +1) Copy the configuration Excel.exe.config into C:\Program Files\Microsoft Office\Office12 +2) Edit Excel.exe.xml and set the targeted Qpid broker host, port number +3) Select the cell or cell range to contain the information +4) enter the following formula =rtd("Qpid",,"myQueue") Where MyQueue is the queue from which you wish to receive messages from + +Note: The Qpid RTD is a COM-AddIn that must be registered with Excel. This is done automatically when compiling the Addin with visual studio. + +The default behavior of the RDT AddIn is to display the message payload. This could be altered by specifying your own message processor. +A Message processor is a class that implements the API ExcelAddIn.MessageProcessor. For example, the provided processor in client-010\addins\ExcelAddInMessageProcessor displays the message body and the the header price when specified. + +To use you own message processor follows those steps: +1) Write your own message processor that extends ExcelAddIn.MessageProcessor +2) Edit Excel.exe.config and uncomment the entries: + + +- ProcessorAssembly is the path on the Assembly that contains your processor class +- ProcessorClass is your processor class name +3) run excel and define a rtd function + +Note: the provided ExcelAddInProducer can be used for testing the provided message processor. As messages are sent to queue1 the following rtd fucntion should be used =rtd("Qpiud",,"queue1") \ No newline at end of file -- cgit v1.2.1