using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace digioz
{
    public class ContactInfoManagement
    {
        private static PortalSettings coPortalSettings;

        public static ContactInfo GetContactInfo()
        {
            ContactInfo loContactInfo = new ContactInfo();
            digioz.Hashtable loConfigTable = new digioz.Hashtable();
            ConfigurationList loConfigurationList = ConfigurationManagement.GetConfigurationList();
            coPortalSettings = PortalSettingsManagement.GetPortalSettings();

            foreach (digioz.Configuration loConfig in loConfigurationList)
            {
                loConfigTable.AddToTable(loConfig.KeyName, loConfig.KeyValue);
            }

            loContactInfo.ContactName = (string)(loConfigTable.GetValue("Contact Name"));
            loContactInfo.ContactEMail = (string)(loConfigTable.GetValue("Contact Email"));
            loContactInfo.SMTPServer = (string)(loConfigTable.GetValue("SMTP Server"));
            loContactInfo.SMTPUsername = (string)(loConfigTable.GetValue("SMTP Username"));
            loContactInfo.SMTPPassword = (string)(loConfigTable.GetValue("SMTP Password"));

            //Create Class Object For Password Decryption
            RijndaelEnhanced rijndaelKey = new RijndaelEnhanced(coPortalSettings.EncryptionKey, coPortalSettings.EncryptionVector);
            string lsCipherText;
            try
            {
                lsCipherText = rijndaelKey.Decrypt(loContactInfo.SMTPPassword);
            }
            catch
            {
                lsCipherText = String.Empty;
            }

            loContactInfo.SMTPPassword = lsCipherText;

            return loContactInfo;
        }
    }
}

