Пример #1
0
        public void ProcessRequest(HttpContext context)
        {
            //cache the results
            if (HttpContext.Current.Cache["personCol"] == null)
            {
                ReferenceServiceClient client = new ReferenceServiceClient();

                HttpContext.Current.Cache["personColCache"] = client.GetAllPersons();
            }

            //get the JSON string which
            //from the UI and convert it to lower case
            //for filtering
            String personName = context.Request.Form[0].ToLower();

            //casting it to our collection
            Collection<Entities.PersonBE> personCol = (Collection<Entities.PersonBE>)HttpContext.Current.Cache["personColCache"];

            //don't do any filtering if char lenght less than two
            //if (personName.Length > 2)
            //{
            personCol = personCol.Where(p => p.name.ToLower().Contains(personName)).ToCollection();
            //}

            JavaScriptSerializer jsSerializer = new JavaScriptSerializer();

            String jsonString = jsonString = jsSerializer.Serialize(personCol);

            //set the response type to be JSON
            context.Response.ContentType = "application/json; charset=utf-8";

            context.Response.Write(jsonString);
        }
Пример #2
0
 /// <summary>
 /// Constructor for the ClientProxy class.
 /// Allocates an instance of the real web service client.
 /// </summary>
 /// <param name="webService">Web service proxy.</param>
 /// <param name="operationTimeoutMinutes">Operation timeout to set in the client. Unit is minutes.</param>
 /// <param name="operationTimeoutSeconds">Operation timeout to set in the client. Unit is seconds.</param>
 public ClientProxy(ReferenceServiceProxy webService,
                    Int32 operationTimeoutMinutes,
                    Int32 operationTimeoutSeconds = 0)
 {
     _operationTimeout = (operationTimeoutMinutes * 60) + operationTimeoutSeconds;
     _webService       = webService;
     _client           = (ReferenceServiceClient)(_webService.PopClient(_operationTimeout));
     _webService.SetTimeout(Client.Endpoint.Binding, _operationTimeout);
 }
Пример #3
0
            /// <summary>
            /// Implementation of the IDisposable interface.
            /// Recycle the client instance.
            /// </summary>
            public void Dispose()
            {
                if ((_client.State != CommunicationState.Opened) ||
                    (!_webService.PushClient(_client, _operationTimeout)))
                {
                    // Client is not in state open or
                    // was not added to the client pool.
                    // Release resources.
                    _client.Close();
                }

                _client = null;
            }
Пример #4
0
        /// <summary>
        /// Create a web service client.
        /// </summary>
        /// <returns>A web service client.</returns>
        protected override Object CreateClient()
        {
            ReferenceServiceClient client;

            client = new ReferenceServiceClient(GetBinding(),
                                                GetEndpointAddress());

            // Increase data size for all methods that
            // sends or receives a lot of data.
            IncreaseDataSize("GetLog", client.Endpoint);
            IncreaseDataSize("GetReferences", client.Endpoint);
            IncreaseDataSize("GetReferencesByIds", client.Endpoint);
            IncreaseDataSize("GetReferencesBySearchCriteria", client.Endpoint);

            return(client);
        }