Converts a DataSet to and from JSON.
Inheritance: JsonConverter
Exemplo n.º 1
0
    //get DOTD CID Contact Information
    public string GetCommunityContact(string CID)
    {
        gov.la.dotd.floods.CommunityContacts ws = new gov.la.dotd.floods.CommunityContacts();
        string result = null; //need to substantiate a null return value

        //TODO: now that you have the connection to the service, use a try/catch and make the call to the DOTD web servcie
        try
        {
            //TODO: Create XML Doc Variable, and Call the DOTD Service with the CID parameter passed from the javascript call to populate it
            Newtonsoft.Json.Converters.DataSetConverter ds = new Newtonsoft.Json.Converters.DataSetConverter();
            JsonSerializerSettings settings = new JsonSerializerSettings();
            settings.Converters.Add(ds);
            result = JsonConvert.SerializeObject(ws.GetCommunityInfo(CID), Newtonsoft.Json.Formatting.None, settings);
        }
        catch (Exception e)
        {
            result = "Service is Unavailable"; //TODO: return error
        }
        return(result);
    }
Exemplo n.º 2
0
    public string GetCommunityContacts(string CID)
    {
        string result = null;

        using (var client = new DOTDCommunityContacts.CommunityContactsSoapClient("CommunityContactsSoap"))
        {
            Newtonsoft.Json.Converters.DataSetConverter ds = new Newtonsoft.Json.Converters.DataSetConverter();
            JsonSerializerSettings settings = new JsonSerializerSettings();
            settings.Converters.Add(ds);

            result = "not null";
            try
            {
                result = JsonConvert.SerializeObject(client.GetCommunityInfo(CID), Newtonsoft.Json.Formatting.None, settings);
                return(result);
            }
            catch (Exception e)
            {
                result = "Service is Unavailable";
                return(result);
            }
        }
    }