示例#1
0
 public void PageInit()
 {
     if (HttpContext.Current.Session["OptimflexPortalUserData"] != null)
     {
         CSession mySession   = new CSession();
         var      varUserData = mySession.getCurrentUserData();
         if (varUserData.USR_ISENABLED_2FA == 1)
         {
             if (varUserData.USR_ISVERIFIED_2FA == 0)
             {
                 HttpContext.Current.Response.Redirect("~/Verify2FA");
             }
         }
     }
     else
     {
         HttpContext.Current.Response.Redirect("~/Login");
     }
 }
示例#2
0
        public JsonRequestData DiverseJsonRequest(string pFuncName, object[] pData, bool isLogin = false)
        {
            object[] objArr;
            if (isLogin)
            {
                objArr    = new object[1];
                objArr[0] = (new JavaScriptSerializer().Serialize(pData));
            }
            else
            {
                CMain myMainClass = new CMain();
                objArr = new object[pData.Length + 1];
                UserData currentUserData = new UserData();
                CSession mySession       = new CSession();
                currentUserData = mySession.getCurrentUserData();
                objArr[0]       = myMainClass.getJsonHeader(currentUserData.USR_USERNAME, mySession.Decrypt(currentUserData.USR_PASSWORD));
                if (pData.Length > 0)
                {
                    for (int i = 0; i < pData.Length; i++)
                    {
                        objArr[i + 1] = pData[i];
                    }
                }
            }
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(ConfigurationManager.AppSettings["DiverseWebServiceUrl"]);

            httpWebRequest.Method      = "POST";
            httpWebRequest.ContentType = "application/json; charset=utf-8";
            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                streamWriter.Write("{\"pFuncName\": \"" + pFuncName + "\",\"pParams\": " + (new JavaScriptSerializer().Serialize(objArr)) + "}");
                streamWriter.Flush();
                streamWriter.Close();
            }
            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                string strRetData = streamReader.ReadToEnd().ToString();
                return(JsonConvert.DeserializeObject <JsonRequestData>(strRetData));
            }
        }