Esempio n. 1
0
        public void Restore()
        {
            Serialization  sAgent       = new Serialization("serialization_sctrl" + this.id + ".dat");
            SCtrlSavedData restoredData = new SCtrlSavedData();

            try
            {
                restoredData = sAgent.Restore(restoredData);

                if (restoredData.Controls != null)
                {
                    foreach (KeyValuePair <string, ButtonState> restoredItem in restoredData.Controls)
                    {
                        if (this.StationControls.ContainsKey(restoredItem.Key))
                        {
                            if (restoredItem.Value == ButtonState.On)
                            {
                                (this.StationControls[restoredItem.Key] as Button).Push();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.myLog.LogAlert(AlertType.Error, this.line.Id.ToString(), this.GetType().ToString(), "Restore()", ex.ToString(), "system");
                Console.WriteLine(DateTime.Now + " " + ex.TargetSite.ToString(), ex.Source, ex.ToString());
            }
        }
Esempio n. 2
0
        public void Backup()
        {
            SCtrlSavedData dataToSave = new SCtrlSavedData();

            dataToSave.Controls = new SerializableDictionary <string, ButtonState>();

            try
            {
                foreach (KeyValuePair <string, Button> item in this.StationControls)
                {
                    dataToSave.Controls.Add(item.Key, (item.Value as Button).TState);
                }

                Serialization sAgent = new Serialization("serialization_sctrl" + this.id + ".dat");
                sAgent.Backup(dataToSave);
            }
            catch (Exception ex)
            {
                this.myLog.LogAlert(AlertType.Error, this.line.Id.ToString(), this.GetType().ToString(), "Backup()", ex.ToString(), "system");
                Console.WriteLine(DateTime.Now + " " + ex.TargetSite.ToString(), ex.Source, ex.ToString());
            }
        }