Beispiel #1
0
        //----------------------------------------------------------------------------------------------------
        public static void AjaxReturnMethod_AES(AjaxRequest ajaxRequest, string ajaxResponseString, string aesIndex)
        {
            var ajaxSender = Security.AjaxSender.GetObj();

            ajaxResponseString = Security.AESLogic.DecryptClient(ajaxSender.Get_AESKey(), ajaxResponseString);
            AjaxReturnMethod(ajaxRequest, ajaxResponseString);
        }
Beispiel #2
0
        public static AjaxRequest New_ServerSide(string remoteMethod, int parameterCount)
        {
            var rtn = new AjaxRequest();

            rtn.RemoteMethod = remoteMethod;
            rtn.Parameters   = new object[parameterCount];
            rtn.AjaxUrl      = ASPdatabaseNET.Config.SystemProperties.wwwASPdatabaseURL;
            return(rtn);
        }
Beispiel #3
0
        //----------------------------------------------------------------------------------------------------
        public Exception Send()
        {
            var ajaxRequest_This   = this;
            var ajaxRequest_ToSend = new AjaxRequest();

            try
            {
                ajaxRequest_ToSend.AjaxUrl      = this.AjaxUrl;
                ajaxRequest_ToSend.RemoteMethod = this.RemoteMethod;
                ajaxRequest_ToSend.Parameters   = this.Parameters;

                var ajaxSender = ASPdb.Security.AjaxSender.GetObj();
                if (this.DoEncryption)
                {
                    if (!ajaxSender.IsReady)
                    {
                        alert("Required Ajax Encryption could not be established."); return(null);
                    }

                    string json = "";
                    eval("json = $.toJSON(ajaxRequest_ToSend);");
                    json = Security.AESLogic.EncryptClient(ajaxSender.Get_AESKey(), json);
                    var aesIndex = ajaxSender.AESIndex;
                    eval(@"
                        var jsonRequestMap = { AjaxRequest: json, AESIndex: aesIndex };
                        $.post(
                            this.AjaxUrl, 
                            jsonRequestMap, 
                            function (responseString) 
                            { 
                                ASPdb.Ajax.AjaxRequest.AjaxReturnMethod_AES(ajaxRequest_This, responseString, aesIndex); 
                            });
                        ");
                }
                else
                {
                    eval(@"
                        var jsonRequestMap = { AjaxRequest: $.toJSON(ajaxRequest_ToSend) };
                        $.post(
                            this.AjaxUrl, 
                            jsonRequestMap, 
                            function (responseString) 
                            { 
                                ASPdb.Ajax.AjaxRequest.AjaxReturnMethod(ajaxRequest_This, responseString); 
                            });
                        ");
                }
                return(null);
            }
            catch (Exception exc)
            {
                alert("Error in AjaxRequest.Send()");
                console.log("AjaxRequest.Send() -- Exception: " + exc);
                return(exc);
            }
        }
Beispiel #4
0
        //----------------------------------------------------------------------------------------------------
        public static AjaxRequest New(string ajaxUrl, string remoteMethod, AjaxReturnInfo returnInfo)
        {
            var rtn = new AjaxRequest();

            rtn.AjaxUrl      = ajaxUrl;
            rtn.RemoteMethod = remoteMethod;
            rtn.ReturnInfo   = returnInfo;

            rtn.Parameters = new object[0];

            return(rtn);
        }
Beispiel #5
0
        //----------------------------------------------------------------------------------------------------
        public static void AjaxReturnMethod(AjaxRequest ajaxRequest, string ajaxResponseString)
        {
            if (ajaxRequest.ReturnInfo != null)
            {
                var ajaxResponse = AjaxResponse.GetFromJson(ajaxResponseString);
                ajaxResponse.AjaxRequest = ajaxRequest;

                if (ajaxRequest.ReturnInfo.Callback_Object != null)
                {
                    var objToCallOn = ajaxRequest.ReturnInfo.Callback_Object;
                    eval("objToCallOn." + ajaxRequest.ReturnInfo.Callback_Method + "(ajaxResponse);");
                }
                else
                {
                    eval(ajaxRequest.ReturnInfo.Callback_Method + "(ajaxResponse);");
                }
            }
        }
Beispiel #6
0
        public void GatewayEntry_Run(Type childType, bool userNotLoggedIn, string[] publicMethods)
        {
            this.IsClientCode = false;
            AjaxRequest request = null;

            string aesIndex = AjaxRequest.GetFromHttp_AESIndex();

            if (aesIndex == null)
            {
                request = AjaxRequest.GetFromHttpRequest();
            }
            else
            {
                request = AjaxRequest.GetFromHttpRequest_AndDecrypt();
            }

            var response = new AjaxResponse();

            try
            {
                if (publicMethods == null)
                {
                    publicMethods = new string[0];
                }
                if (!publicMethods.Contains(request.RemoteMethod))
                {
                    if (userNotLoggedIn)
                    {
                        throw new Exception("User Session Expired");
                    }
                }

                this.aj.Parameters = request.Parameters;
                var method = childType.GetMethod(request.RemoteMethod); // reflection
                if (method != null)
                {
                    var paremetersList = new List <object>();
                    foreach (var reflectionParam in method.GetParameters())
                    {
                        switch (reflectionParam.ParameterType.Name)
                        {
                        case "Int32":
                            paremetersList.Add(aj._Int32);
                            break;

                        case "Boolean":
                            paremetersList.Add(aj._Boolean);
                            break;

                        case "DateTime":
                            paremetersList.Add(aj._DateTime);
                            break;

                        case "String":
                            paremetersList.Add(aj._String);
                            break;

                        default:
                            //paremetersList.Add(aj._Json2(reflectionParam.ParameterType.FullName));

                            string fullTypeName = reflectionParam.ParameterType.FullName;
                            var    obj          = aj._Json2(fullTypeName);
                            paremetersList.Add(obj);
                            break;
                        }
                    }
                    object[] paramArr = paremetersList.ToArray();
                    if (paramArr.Length < 1)
                    {
                        paramArr = null;
                    }
                    response.ReturnObj = method.Invoke(this, paramArr);
                }
            }
            catch (Exception exc)
            {
                if (exc.InnerException != null)
                {
                    exc = exc.InnerException;
                }

                if (exc.Message == "User Session Expired")
                {
                    response.SetException(exc);
                    response.DoLogout = true;
                }
                else
                {
                    ASPdb.Framework.Debug.RecordException(exc);
                    response.SetException(exc);
                }
            }

            if (aesIndex == null)
            {
                response.Send();
            }
            else
            {
                response.Send_AES(aesIndex);
            }
        }
Beispiel #7
0
 //----------------------------------------------------------------------------------------------------
 public void SetCallback(object callback_Object, string callback_Method, object callback_DataObj)
 {
     this.Ajax = AjaxRequest.New2(this.AjaxUrl, "", callback_Object, callback_Method);
     this.Ajax.ReturnInfo.DataObj = callback_DataObj;
 }