Exemplo n.º 1
0
        public string ProcessRequest(string query)
        {
            request = TJson.Parse <DataRequest>(query);
            result  = new DataResponse();
            LogManager.OnLogEvent += new LogEvent(LogManager_OnLogEvent);
            ServiceContext serviceContext = null;

            try
            {
                SetCulture(request);
                result.ServiceName = request.ServiceName;
                serviceContext     = new ServiceContext(request, result, DataSource, HttpContext.Current);
                DoProcess(serviceContext);

                if (result.Result != ReturnCode.Fail)
                {
                    result.Result = ReturnCode.Success;
                }
            }
            catch (Exception ex)
            {
                result.Result = ReturnCode.Error;
                Exception logException = ex;
                while (logException.InnerException != null)
                {
                    logException = logException.InnerException;
                }

                try
                {
                    if (request != null)
                    {
                        new UtilOP(request.LogIn).LogError(result.ServiceName, logException);
                    }
                }
                catch
                {
                }

                if (request.LogIn != null && request.LogIn.IsDebug)
                {
                    result.Message    = logException.Message;
                    result.StackTrace = logException.ToString();
                }
                else
                {
                    result.Message    = logException.Message;
                    result.StackTrace = "";
                }
            }

            result.DebugInfo       = sbDebug.ToString();
            sbDebug                = null;
            LogManager.OnLogEvent -= new LogEvent(LogManager_OnLogEvent);
            return(result.ToJson());
        }
Exemplo n.º 2
0
        //protected DataProvider EAP_DataSource
        //{
        //    get
        //    {
        //        if (null == _DataSource)
        //            _DataSource = DataProvider.GetEAP_Provider();

        //        return _DataSource;
        //    }
        //}

        public void ProcessRequest(HttpContext context)
        {
            Context = context;
            string method = context.Request.HttpMethod;

            result = new DataResponse();

            //ClientMessage();

            LogManager.OnLogEvent += new LogEvent(LogManager_OnLogEvent);

            if (method.ToLower() == "post")
            {
                context.Response.ContentType = "application/x-base64";

                BinaryReader requestDataReader = new BinaryReader(context.Request.InputStream, Encoding.UTF8);
                byte[]       buffer            = new byte[context.Request.InputStream.Length];
                context.Request.InputStream.Read(buffer, 0, buffer.Length);

                string requestString = HttpUtility.UrlDecode(DESEncrypt.ConvertToString(buffer));
                requestString = requestString.Substring(requestString.IndexOf('=') + 1);


                ServiceContext serviceContext = null;
                try
                {
                    request = TJson.Parse <DataRequest>(requestString);
                    SetCulture(request);
                    //  request.Category = ServiceCategoryName;
                    result.ServiceName = request.ServiceName;

                    serviceContext = new ServiceContext(request, result, DataSource, context);
                    DoProcess(serviceContext);
                    //    scope.Complete();
                    //}

                    if (result.Result != ReturnCode.Fail)
                    {
                        result.Result = ReturnCode.Success;
                    }
                }
                catch (Exception ex)
                {
                    result.Result = ReturnCode.Error;
                    Exception logException = ex;
                    while (logException.InnerException != null)
                    {
                        logException = logException.InnerException;
                    }
                    //Exception logException = tempEx != null ? tempEx : ex;

                    try
                    {
                        if (request != null)
                        {
                            new UtilOP(request.LogIn).LogError(result.ServiceName, logException);
                        }
                    }
                    catch
                    {
                    }

                    if (request.LogIn != null && request.LogIn.IsDebug)
                    {
                        result.Message    = logException.Message;
                        result.StackTrace = logException.ToString();
                    }
                    else
                    {
                        result.Message    = logException.Message;
                        result.StackTrace = "";
                    }
                }

                result.DebugInfo       = sbDebug.ToString();
                sbDebug                = null;
                LogManager.OnLogEvent -= new LogEvent(LogManager_OnLogEvent);
                if (!serviceContext.IsCustomerResponse)
                {
                    string sendData = HttpUtility.UrlEncode(result.ToJson());
                    context.Response.BinaryWrite(DESEncrypt.ConvertToByteArray(sendData));
                }
            }
        }