示例#1
0
        private void ChangeSettingCallBack(object sender, FileSystemEventArgs e)
        {
            bool accessed = false;

            while (!accessed)
            {
                try
                {
                    this.infoLog.Info("Setting file was changed");
                    XmlSerializer  f         = new XmlSerializer(typeof(StateModelData));
                    StateModelData stateData = null;
                    using (FileStream fs = new FileStream(this.settingsDir + "\\" + ConfigurationManager.AppSettings["settings"], FileMode.OpenOrCreate))
                    {
                        stateData = (StateModelData)f.Deserialize(fs);
                    }

                    var client = TopicClient.Create(ConfigurationManager.AppSettings["topic"]);
                    client.Send(new BrokeredMessage(stateData));
                    client.Close();
                    this.infoLog.Info("New setting was sent to all subscribers");
                    accessed = true;
                }
                catch (IOException ex)
                {
                    this.errorLog.Error(ex, "Cannot read setting file");
                    Task.Delay(2000);
                }
            }
        }
        private void TimerCallBackMethod(object obj)
        {
            try
            {
                string queueName = ConfigurationManager.AppSettings["centralQueue"];

                var client = QueueClient.Create(queueName);
                var state  = new StateModelData()
                {
                    Status          = this.status,
                    CurrentSettings = new Settings()
                    {
                        Timeout      = int.Parse(ConfigurationManager.AppSettings["timeout"]),
                        BarcodeValue = this.barcodeSeparator
                    }
                };

                client.Send(new BrokeredMessage(state));
                client.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#3
0
        public void SendSharedModelTest()
        {
            var model = new StateModelData()
            {
                CurrentSettings = new Settings()
                {
                    BarcodeValue = "testBarcode",
                    Timeout      = 1000
                },
                Status = Status.Waiting
            };


            var client = QueueClient.Create("customqueue");

            client.Send(new BrokeredMessage(model));
            client.Close();
        }