예제 #1
0
        // GET: Search
        public ActionResult Search(string value)
        {
            string response = "";

            if (!string.IsNullOrEmpty(value))
            {
                string[] values = value.Split(new char[] { '/' });

                TrainingWCFService.WCFInvoker invoker = new TrainingWCFService.WCFInvoker(ConfigurationManager.AppSettings["WCFServiceAddress"]);
                invoker.LogOperation(values);

                string operation = invoker.GetOperation(values);
                string result    = new BusinessLogic.SearchProvider(ConfigurationManager.AppSettings["Datasource"]).GetValue(operation);
                if (result != null)
                {
                    response = result;
                }
                else
                {
                    invoker.RegisterOperation(values);
                    result   = new BusinessLogic.SearchProvider(ConfigurationManager.AppSettings["Datasource"]).GetValue(operation);
                    response = result;
                }
            }
            else
            {
                Thread.Sleep(999);
                response = "Can't call this page directly";
            }

            return(Content(response));
        }
        private async Task <string> PerformOperation(string[] values)
        {
            TrainingWCFService.WCFInvoker invoker = new TrainingWCFService.WCFInvoker(ConfigurationManager.AppSettings["WCFServiceAddress"]);

            string operation = await Task.Factory.StartNew <string>(() => { return(invoker.GetOperation(values)); });

            bool result = await Task.Factory.StartNew <bool>(() => { return(invoker.CheckOperation(values)); });

            return(string.Format("'{0}' - {1}", operation, result));
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Initialize cache client
            string cacheHost = ConfigurationManager.AppSettings["cacheHost"];
            int    cachePort = int.Parse(ConfigurationManager.AppSettings["cachePort"]);

            CacheLib.Client client = new CacheLib.Client(cachePort, cacheHost);

            client.Get("test");

            TrainingWCFService.WCFInvoker invoker = new TrainingWCFService.WCFInvoker(ConfigurationManager.AppSettings["WCFServiceAddress"]);
            invoker.HealthCheck();
        }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var task = Task.Factory.StartNew(() =>
            {
                TrainingWCFService.WCFInvoker invoker = new TrainingWCFService.WCFInvoker(ConfigurationManager.AppSettings["WCFServiceAddress"]);
                invoker.HealthCheck();
            });

            while (!task.IsCompleted)
            {
                Thread.Sleep(10);
            }

            string error;

            if (task.Exception != null)
            {
                error = task.Exception.ToString();
            }
        }
예제 #5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBoxSearch.Text != null && TextBoxSearch.Text.Length > 0)
            {
                string   s      = TextBoxSearch.Text.Trim();
                string[] values = s.Split(' ');

                if (values.Length > 0)
                {
                    TrainingWCFService.WCFInvoker invoker = new TrainingWCFService.WCFInvoker(ConfigurationManager.AppSettings["WCFServiceAddress"]);
                    invoker.LogOperation(values);

                    string operation = invoker.GetOperation(values);

                    // Initialize cache client
                    string          cacheHost = ConfigurationManager.AppSettings["cacheHost"];
                    int             cachePort = int.Parse(ConfigurationManager.AppSettings["cachePort"]);
                    CacheLib.Client client    = new CacheLib.Client(cachePort, cacheHost);

                    client.Get(operation);

                    string result = new BusinessLogic.SearchProvider(ConfigurationManager.AppSettings["Datasource"]).GetValue(operation);
                    if (result != null)
                    {
                        Response.Write(result);
                    }
                    else
                    {
                        invoker.RegisterOperation(values);
                        result = new BusinessLogic.SearchProvider(ConfigurationManager.AppSettings["Datasource"]).GetValue(operation);
                        Response.Write(result);

                        client.Put(operation, result);
                    }
                }
            }
        }
예제 #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     TrainingWCFService.WCFInvoker invoker = new TrainingWCFService.WCFInvoker(ConfigurationManager.AppSettings["WCFServiceAddress"]);
     invoker.HealthCheck();
 }
        private async Task LogOperation(string[] values)
        {
            TrainingWCFService.WCFInvoker invoker = new TrainingWCFService.WCFInvoker(ConfigurationManager.AppSettings["WCFServiceAddress"]);

            await Task.Factory.StartNew(() => { invoker.LogOperation(values); });
        }