JayRockTest.ashx.cs :  » Content-Management-Systems-CMS » mojoPortal » SiteOffice » ExternalMail » Services » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Content Management Systems CMS » mojoPortal 
mojoPortal » SiteOffice » ExternalMail » Services » JayRockTest.ashx.cs
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Globalization;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using Jayrock.Json;
using Jayrock.JsonRpc;
using Jayrock.JsonRpc.Web;
using mojoPortal.Business;
using mojoPortal.Web;

namespace SiteOffice.ExternalMail.Services{
    /// <summary>
    /// Summary description for $codebehindclassname$
    /// </summary>
    [JsonRpcHelp("This is a JSON-RPC service that demonstrates the basic features of the Jayrock library.")]
    public class JayRockTest : JsonRpcHandler
    {
        #region mojo stuff

        //[JsonRpcMethod("GetCurrentUser", Idempotent = true)]
        //[JsonRpcHelp("Returns the current user")]
        //public SiteUser GetCurrentUser()
        //{
        //    return SiteUtils.GetCurrentSiteUser();
        //}


        #endregion


        [JsonRpcMethod("echo", Idempotent = true)]
        [JsonRpcHelp("Echoes back the text sent as input.")]
        public string Echo(string text)
        {
            return text;
        }



        [JsonRpcMethod("echoObject", Idempotent = true)]
        [JsonRpcHelp("Echoes back the object sent as input.")]
        public object EchoOject(object o)
        {
            return o;
        }

        [JsonRpcMethod("echoArgs", Idempotent = true)]
        [JsonRpcHelp("Echoes back the arguments sent as input. This method demonstrates variable number of arguments.")]
        public object EchoArgs(params object[] args)
        {
            return args;
        }

        [JsonRpcMethod("echoAsStrings", Idempotent = true)]
        [JsonRpcHelp("Echoes back the arguments as an array of strings. This method demonstrates working with variable number of arguments.")]
        public object EchoAsStrings(params object[] args)
        {
            string[] strings = new string[args.Length];

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i] != null)
                    strings[i] = args[i].ToString();
            }

            return strings;
        }

        //[JsonRpcMethod("echoGuid", Idempotent = true)]
        //[JsonRpcHelp("Echoes back the given GUID. This method demonstrates working with an argument typed as System.Guid.")]
        //public Guid EchoGuid(Guid id)
        //{
        //    return id;
        //}

        //[JsonRpcMethod("sum", Idempotent = true)]
        //[JsonRpcHelp("Return the sum of two integers.")]
        //[JsonRpcObsolete("Use the total method instead.")]
        //public int Sum(int a, int b)
        //{
        //    return a + b;
        //}

        //[JsonRpcMethod("getStringArray", Idempotent = true)]
        //[JsonRpcHelp("Returns an array of city names. Demonstrates returning a strongly-typed array.")]
        //public string[] GetCities()
        //{
        //    return new string[] { "London", "Zurich", "Paris", "New York" };
        //}

        [JsonRpcMethod("ServerTimeZone", Idempotent = true)]
        [JsonRpcHelp("Returns the time zone of the server.")]
        public string ServerTimeZone()
        {
            return TimeZone.CurrentTimeZone.DaylightName;
        }

        [JsonRpcMethod("ServerGMTOffset", Idempotent = true)]
        [JsonRpcHelp("Returns the time zone of the server.")]
        public string ServerGMTOffset()
        {
            return TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).ToString();
        }

        [JsonRpcMethod("ServerLocalTime", Idempotent = true)]
        [JsonRpcHelp("Returns the local time on the server. Demonstrates how DateTime is returned simply as a string using the ISO 8601 format.")]
        public DateTime ServerLocalTime()
        {
            return DateTime.Now;
        }

        [JsonRpcMethod("newGuid", Idempotent = true)]
        [JsonRpcHelp("Generates and returns a GUID as a string.")]
        public Guid NewGuid()
        {
            return Guid.NewGuid();
        }

        [JsonRpcMethod("cookies", Idempotent = true)]
        [JsonRpcHelp("Returns the cookie names seen by the server.")]
        public HttpCookieCollection Cookies()
        {
            return Request.Cookies;
        }

        [JsonRpcMethod("serverVariables", Idempotent = true)]
        [JsonRpcHelp("Returns the server variables collection at the server. Demonstrates returning NameValueCollection.")]
        public NameValueCollection ServerVariables()
        {
            return Request.ServerVariables;
        }

        //[JsonRpcMethod("getAuthor", Idempotent = true)]
        //[JsonRpcHelp("Returns information about the author. Demonstrates how a Hashtable from the server is automatically converted into an object on the client-side.")]
        //public IDictionary GetAuthor()
        //{
        //    Hashtable author = new Hashtable();
        //    author["FirstName"] = "Atif";
        //    author["LastName"] = "Aziz";
        //    return author;
        //}

        //[JsonRpcMethod("sleep", Idempotent = true)]
        //[JsonRpcHelp("Blocks the request for the specified number of milliseconds (maximum 7 seconds).")]
        //public void Sleep(int milliseconds)
        //{
        //    System.Threading.Thread.Sleep(Math.Min(7000, milliseconds));
        //}

        [JsonRpcMethod("format", Idempotent = true)]
        [JsonRpcHelp("Formats placeholders in a format specification with supplied replacements. This method demonstrates fixed and variable arguments.")]
        public string Format(string format, params object[] args)
        {
            return string.Format(format, args);
        }

        [JsonRpcMethod("encode", Idempotent = true)]
        [JsonRpcHelp("Returns the bytes of a string in a given encoding that are transmitted as a Base64 string.")]
        public byte[] EncodeBytes(string s, string encoding)
        {
            return System.Text.Encoding.GetEncoding(encoding).GetBytes(s);
        }

        [JsonRpcMethod("decode", Idempotent = true)]
        [JsonRpcHelp("Returns the string from encoded bytes (transmitted as a Base64 string).")]
        public string DecodeString(byte[] bytes, string encoding)
        {
            return System.Text.Encoding.GetEncoding(encoding).GetString(bytes);
        }

        //[JsonRpcMethod("stypeof", Idempotent = true)]
        //[JsonRpcHelp("Returns the CLR type that a given value converted to on the server.")]
        //public string GetObjectType(object o)
        //{
        //    return o != null ? o.GetType().FullName : null;
        //}

        [JsonRpcMethod("echoTime", Idempotent = true)]
        [JsonRpcHelp("Echoes back the date/time sent as parameter.")]
        public DateTime EchoTime(DateTime time)
        {
            return time;
        }


        //[JsonRpcMethod("getCouple", Idempotent = true)]
        //[JsonRpcHelp("Returns a server-typed object representing a couple. Demonstrates to returning server-typed objects.")]
        //public Marriage GetCouple()
        //{
        //    return new Marriage(
        //        new Person("Mickey", "Mouse"),
        //        new Person("Minnie", "Mouse"));
        //}

        //[JsonRpcMethod("swapNames", Idempotent = true)]
        //[JsonRpcHelp("Swaps first and last name of person. Demonstrates receiving and returning a server-typed object.")]
        //public Person SwapPersonNames(Person p)
        //{
        //    return p == null ? new Person() : new Person(p.LastName, p.FirstName);
        //}

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.