public string GetDefaultWebBrowserByAccountDB(AccountD account)
        {
            string url = string.Empty;
            HostType hostType = account.HostType;
            switch (hostType)
            {
                case HostType.TYPE_GMAIL:
                    url = new GoogleDownloadController().LOGIN_URL;
                    break;
                case HostType.TYPE_YAHOO:
                    url = new YahooDownloadController().LOGIN_URL;
                    break;
                case HostType.TYPE_LIVE_HOTMAIL:
                    url = new LiveHotmailDownloadController().LOGIN_URL;
                    break;
            }

            //DownloadController downloadController;
            //int len = listDownloadController.Count();

            //for (int j = 0; j < len; j++)
            //{
            //    downloadController = listDownloadController[j];
            //    return downloadController.Browser;
            //}

            return url;
        }
        public void DownloadContacts(AccountDB acc, AccountDownloadListener notify)
        {
            HostType hostType = acc.HostType;
            DownloadController hostDownload = null;

            // remove old DownloadController first
            string username = acc.Username;
            int accTypeId = acc.AccountTypeId;
            DownloadController downloadController;
            AccountDB acc2;

            int len = listDownloadController.Count();
            for (int i = 0; i < len; i++)
            {
                downloadController = listDownloadController[i];
                acc2 = downloadController.Account;
                if (acc.SameWith(acc2))
                {
                    listDownloadController.RemoveAt(i);
                    break;
                }
            }

            switch (hostType)
            {
                case HostType.TYPE_GMAIL:
                    hostDownload = new GoogleDownloadController(acc, notify);
                    break;
                case HostType.TYPE_YAHOO:
                    hostDownload = new YahooDownloadController(acc, notify);
                    break;
                case HostType.TYPE_LIVE_HOTMAIL:
                    hostDownload = new LiveHotmailDownloadController(acc, notify);
                    break;
                case HostType.TYPE_ICLOUD:
                    hostDownload = new ICloudDownloadController(acc, notify);
                    break;
                case HostType.TYPE_OUTLOOK:
                    hostDownload = new OutlookDownloadController(acc, notify);
                    break;
                case HostType.TYPE_EXCHANGE_SERVER:
                    hostDownload = new ExchangeDownloadController(acc, notify);
                    break;
                case HostType.TYPE_OFFICE_365:
                    hostDownload = new Office365DownloadController(acc, notify);
                    break;
            }

            if (hostDownload != null)
            {
                listDownloadController.Add(hostDownload);
                hostDownload.DownloadContacts();
            }
        }
        public WebBrowser GetDefaultWebBrowserByAccountDB(AccountDB account, AccountDownloadListener notify)
        {
            //AccountDB acc;
            DownloadController downloadController;
            HostType hostType = account.HostType;
            //var googleDownloadController = new GoogleDownloadController();

            //int len = listDownloadController.Count();
            //for (int j = 0; j < len; j++)
            //{
            //    downloadController = listDownloadController[j];
            //    acc = downloadController.Account;
            //    if (acc.SameWith(account) && downloadController.IsDownloadGotUnexpectedPage())
            //    {
            //        return downloadController.Browser;
            //    }
            //    else if (acc.SameWith(account))
            //    {
            //        return downloadController.Browser;
            //    }
            //}

            switch (hostType)
            {
                case HostType.TYPE_GMAIL:
                    downloadController = new GoogleDownloadController(account, notify);
                    browser = downloadController.Browser;
                    ClearCookies.SuppressWininetBehavior();
                    DeleteUrlCacheEntry("https://accounts.google.com/AccountChooser?continue=https%3A%2F%2Faccounts.google.com%2FManageAccount&hl=en");
                    browser.Navigate("javascript:void((function(){var a,b,c,e,f;f=0;a=document.cookie.split('; ');for(e=0;e<    a.length&&a[e];e++){f++;for(b='.'+location.host;b;b=b.replace(/^(?:%5C.|[^%5C.]+)/,'')){for(    c=location.pathname;c;c=c.replace(/.$/,'')){document.cookie=(a[e]+'; domain='+b+'; path='+c+'; expires='+new Date((    new Date()).getTime()-1e11).toGMTString());}}}})())");
                    browser.Navigate(new Uri("https://accounts.google.com/AccountChooser?continue=https%3A%2F%2Faccounts.google.com%2FManageAccount&hl=en"));
                    break;
                case HostType.TYPE_YAHOO:
                    downloadController = new YahooDownloadController(account, notify);
                    browser = downloadController.Browser;
                    ClearCookies.SuppressWininetBehavior();
                    DeleteUrlCacheEntry("https://login.yahoo.com/");
                    browser.Navigate("javascript:void((function(){var a,b,c,e,f;f=0;a=document.cookie.split('; ');for(e=0;e<    a.length&&a[e];e++){f++;for(b='.'+location.host;b;b=b.replace(/^(?:%5C.|[^%5C.]+)/,'')){for(    c=location.pathname;c;c=c.replace(/.$/,'')){document.cookie=(a[e]+'; domain='+b+'; path='+c+'; expires='+new Date((    new Date()).getTime()-1e11).toGMTString());}}}})())");
                    browser.Navigate(new Uri("https://login.yahoo.com/"));
                    break;
                case HostType.TYPE_LIVE_HOTMAIL:
                    downloadController = new LiveHotmailDownloadController(account, notify);
                    browser = downloadController.Browser;
                    ClearCookies.SuppressWininetBehavior();
                    DeleteUrlCacheEntry("https://login.live.com/");
                    browser.Navigate("javascript:void((function(){var a,b,c,e,f;f=0;a=document.cookie.split('; ');for(e=0;e<    a.length&&a[e];e++){f++;for(b='.'+location.host;b;b=b.replace(/^(?:%5C.|[^%5C.]+)/,'')){for(    c=location.pathname;c;c=c.replace(/.$/,'')){document.cookie=(a[e]+'; domain='+b+'; path='+c+'; expires='+new Date((    new Date()).getTime()-1e11).toGMTString());}}}})())");
                    browser.Navigate(new Uri("https://login.live.com/"));
                    break;
            }

            return browser;
        }