using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Configuration;
using System.Web.Configuration;

/// <summary>
/// Summary description for Decrypter
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class Decrypter : System.Web.Services.WebService {

    public Decrypter () 
    {
        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }


    [WebMethod]
    public string DecryptTest()
    {
        string ret = DecryptConnString();
        return ret;
    }

    private string DecryptConnString()
    {
        try
        {
            Configuration objConfig = WebConfigurationManager.OpenWebConfiguration("~");

            ConnectionStringsSection objAppsettings = (ConnectionStringsSection)objConfig.GetSection("connectionStrings");

            if (objAppsettings.SectionInformation.IsProtected)
            {

                objAppsettings.SectionInformation.UnprotectSection();
                return objAppsettings.ConnectionStrings["ConnString"].ConnectionString;
            }
            else
            {
                return objAppsettings.ConnectionStrings["ConnString"].ConnectionString;
            }
        }
        catch (Exception exNapaka)
        {
            return "NAPAKA:" + exNapaka.Message;
        }
    }
}



