|
using System;
using System.Diagnostics;
using System.Threading;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Contexts;
using System.Data;
using System.IO;
//
using RKiss.WebServiceRemoting;
namespace MyRemoteObject
{
public class RemoteObject : MarshalByRefObject, IWSDimeRemoting
{
public RemoteObject()
{
Trace.WriteLine("RemoteObject ctor");
}
//IMyInterface
public string Echo(int id, string msg)
{
string response = "";
int filesize = 0;
AttachmentTicket at = null;
//exception test
if(msg.IndexOf("throw") >= 0)
throw new Exception("This is an Exception test");
//Attachment
try
{
at = new AttachmentTicket();
if(at.Items.Contains("UploadFile"))
{
filesize = at.Detach("UploadFile", "UploadedFile.bin");
}
response = string.Format("Echo: id={0}, msg={1}; upload[{2}bytes]", id, msg, filesize);
}
catch(Exception ex)
{
response = string.Format("Echo: id={0}, msg={1}", id, msg);
}
//request to download file
if(msg.IndexOf("download") >= 0)
{
if(at == null)
{
at = new AttachmentTicket(Guid.NewGuid().ToString(), "RemoteObject");
}
at.Attach("DownloadFile", "FileToDownload.bin");
}
Console.WriteLine(response);
return response;
}
[OneWay]
public void EchoOneWay(int id, string msg)
{
int filesize = 0;
//exception test
if(msg == "throw")
throw new Exception("This is an Exception test");
//Atatchment
AttachmentTicket at = new AttachmentTicket();
if(at.Items.Contains("UploadFile"))
{
filesize = at.Detach("UploadFile", "UploadedFile.bin");
}
string response = string.Format("Echo: id={0}, msg={1}, upload[{2}bytes]", id, msg, filesize);
Console.WriteLine(response);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.