public static Cookie GetFedAuthCookie(string hostWeb, HttpCookie fedAuth)
        {
            //if (WebConfigurationManager.AppSettings["TestMode"] == "1")
            //{
            //    fedAuth = new HttpCookie("FedAuth");
            //    fedAuth.Value = WebConfigurationManager.AppSettings["FedAuthCookie"];
            //}

            string domainCookie;

            if (string.IsNullOrEmpty(WebConfigure.GetLoginDomainForCookie()))
            {
                var httpReq = (HttpWebRequest)WebRequest.Create(hostWeb);
                domainCookie = httpReq.RequestUri.Host;
            }
            else
            {
                domainCookie = WebConfigure.GetLoginDomainForCookie();
            }

            // Make Cookie from fedAuth
            var fedAuthCookie = new Cookie()
            {
                Domain  = domainCookie,
                Expires = fedAuth.Expires,
                Name    = fedAuth.Name,
                Path    = fedAuth.Path,
                Secure  = fedAuth.Secure,
                Value   = String.IsNullOrEmpty(fedAuth.Value) ? "" : fedAuth.Value.Replace(' ', '+').Replace("%2B", "+"),
            };

            return(fedAuthCookie);
        }
        public static XDocument GetXDoc(string requestUrl, string acceptHeader, List <Cookie> cookies)
        {
            // prepare HttpWebRequest to execute REST API call
            var httpReq = (HttpWebRequest)WebRequest.Create(requestUrl);

            // add access token string as Authorization header
            httpReq.Accept = acceptHeader;

            var domainCookie = string.IsNullOrEmpty(WebConfigure.GetLoginDomainForCookie()) ? httpReq.RequestUri.Host : WebConfigure.GetLoginDomainForCookie();

            httpReq.CookieContainer = new CookieContainer();
            foreach (var cookie in cookies)
            {
                cookie.Domain = domainCookie;
                httpReq.CookieContainer.Add(cookie);
            }
            httpReq.UseDefaultCredentials = true;

            // execute REST API call and inspect response
            HttpWebResponse responseForUser = (HttpWebResponse)httpReq.GetResponse();
            StreamReader    readerUser      = new StreamReader(responseForUser.GetResponseStream());
            var             xdoc            = XDocument.Load(readerUser);

            readerUser.Close();
            readerUser.Dispose();

            return(xdoc);
        }
        public static Dictionary <string, string> PushConf()
        {
            Dictionary <string, string> val = new Dictionary <string, string>();

            val["primaindb"]   = WebConfigure.GetMainConnectionString();
            val["secdbempmst"] = WebConfigure.GetSecondaryEmpMasterConnectionString();
            val["kymobauto"]   = WebConfigure.GetMobileAuthorization();
            val["kylgadm"]     = WebConfigure.GetLoginManualXupj();
            val["kydmn"]       = WebConfigure.GetDomain();
            val["kydmnch"]     = WebConfigure.GetLoginDomainForCookie();
            val["kyurlml"]     = WebConfigure.GetUrlSendEmail();
            val["kyhst"]       = WebConfigure.GetLoginHost();
            return(val);
        }