Esempio n. 1
0
        private void DeserializeObject(string fileName)
        {
            FileStream fStream = null;

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(structSerializeObject));
                fStream = new FileStream(fileName, FileMode.Open);
                if (fStream.Length > 0)
                {
                    stSerOb = (structSerializeObject)serializer.Deserialize(fStream);
                }
            }
            catch
            {
            }
            finally
            {
                if (fStream != null)
                {
                    fStream.Close();
                }
                stSerOb.RemotePath = ((stSerOb.RemotePath == null) || (stSerOb.RemotePath.Equals(""))) ? "" : stSerOb.RemotePath;

                DateTime dateStart = DateTime.Today.AddDays(-1);
                dateTimeRange.start = (stSerOb.DateTimeRangeStart.Year == 1) ? new DateTime(dateStart.Year, dateStart.Month, dateStart.Day, 00, 00, 0) : stSerOb.DateTimeRangeStart;
                dateTimeRange.end   = DateTime.Now;

                stSerOb.Detectors = ((stSerOb.Detectors == null) || (stSerOb.Detectors.Count <Int16>() == 0)) ? new Int16[] { 1, 2, 0, 0 } : stSerOb.Detectors;
                for (Int16 i = 0; i < stSerOb.Detectors.Length; i++)
                {
                    detectors.Add(new Detector(i, stSerOb.Detectors[i].ToString()));
                }

                setTimerInterval(stSerOb.TimerInterval);
            }
        }
Esempio n. 2
0
        private void DeserializeObject(string fileName)
        {
            FileStream fStream = null;

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(structSerializeObject));
                fStream = new FileStream(fileName, FileMode.Open);
                if (fStream.Length > 0)
                {
                    stSerOb = (structSerializeObject)serializer.Deserialize(fStream);
                }
            }
            catch
            {
            }
            finally
            {
                if (fStream != null)
                {
                    fStream.Close();
                }

                DateTime dateStart = DateTime.Today.AddDays(-1);
                dateTimeRange.start = (stSerOb.DateTimeRangeStart.Year == 1) ? new DateTime(dateStart.Year, dateStart.Month, dateStart.Day, 00, 00, 0) : stSerOb.DateTimeRangeStart;
                dateTimeRange.end   = DateTime.Now;
                stSerOb.Detectors   = ((stSerOb.Detectors == null) || (stSerOb.Detectors.Count <Int16>() == 0)) ? new Int16[] { 1, 2, 0, 0 } : stSerOb.Detectors;
                if ((stSerOb.Thresholds == null) || (stSerOb.Thresholds.Count <float>() == 0))
                {
                    Threshold.Thresholds = new float[] { 0.01F, 0.02F, 0.03F, 0.04F };
                }
                else
                {
                    stSerOb.Thresholds.CopyTo(Threshold.Thresholds, 0);
                }
            }
        }