示例#1
0
        public Refreshing()
        {
            NetTcpBinding binding = new NetTcpBinding();
            ChannelFactory <IRefreshData> factory = new ChannelFactory <IRefreshData>(binding, new EndpointAddress("net.tcp://localhost:7100/RefreshDataProvider"));

            proxyRefresh = factory.CreateChannel();
        }
示例#2
0
        public void OnStart()
        {
            // TODO: This can be improved if the service was made stateful.
            // Get the entire database entries and send it via WCF.
            var db_utils  = new DatabaseUtils();
            var schemas   = db_utils.GetAllAppointments();
            var customers = schemas.Select(x => new Customer(x)).ToList();

            while (true)
            {
                IRefreshData channel = null;
                try {
                    Log.WriteLog("----- OnStart: COUNT {0} -----", customers.Count());
                    channel = _client.CreateChannel();
                    channel.RefreshDatabase(customers);
                    break;
                } catch (Exception ex) {
                    Log.WriteLog("Error connecting to cloud vm ", ex);
                    // TODO: This can be improved using a two way WCF contract.
                    Thread.Sleep(1000);
                } finally {
                    if (channel != null)
                    {
                        ((ICommunicationObject)channel).Close();
                    }
                }
            }

            // Start a timer to Flush data periodically.
            _timer = new System.Timers.Timer(_periodInMsecs)
            {
                AutoReset = false
            };
            _timer.Elapsed += Flush;
            _timer.Start();
        }