private DataFim SetDeviceData(DataFim df, EndPoint ds, DataFims listData)
        {
            df.EndPoint = ds.EndPointName;

            df = ProcessParents(df, listData, ds.EndPointName, ds.ListParents);
            return(df);
        }
        /// <summary>
        /// Starts the process for placing the retrieved device information into list that will be displayed in the grid.
        /// DataFims is the list displayed in the grid.
        /// </summary>
        /// <param name="listDs">DeviceSettings</param>
        /// <param name="listDat">DataFims</param>
        private void LoadDataFim(DeviceSettings listDs, DataFims listDat)
        {
            DataFim df = new DataFim();

            foreach (EndPoint ds in listDs)
            {
                if (ds.HasValues)
                {
                    df = SetDeviceData(df, ds, listDat);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Reads data from file and re-inserts back into lists and grid.
        /// </summary>
        /// <returns>bool: true on success</returns>
        public bool LoadDeviceData()
        {
            FileStream fs = null;

            try
            {
                fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);
                using (StreamReader sr = new StreamReader(fs))
                {
                    GetDeviceInfo(sr);
                    while (sr.Peek() >= 0)
                    {
                        string   line   = sr.ReadLine();
                        string[] buffer = line.Split(',');

                        DataFim df = new DataFim();

                        df.EndPoint  = buffer[0];
                        df.Parent    = buffer[1];
                        df.Element   = buffer[2];
                        df.ValueOrig = buffer[3];
                        df.ValueNew  = buffer[4];
                        df.SameValue = GetSameValue(buffer[5]);

                        ListDeviceSettings.Add(df);
                    }
                }
            }
            catch (FileNotFoundException fe) { ErrorMessage = fe.Message; }
            catch (DirectoryNotFoundException fe) { ErrorMessage = fe.Message; }
            catch (IOException e) { ErrorMessage = e.Message; }
            finally
            {
                if (fs != null)
                {
                    fs.Dispose();
                }
            }
            return(!IsError);
        }
        private DataFim ProcessParents(DataFim df, DataFims listData, string endpoint, Parents listParents)
        {
            foreach (Parent p in listParents)
            {
                df.Parent = p.ParentName;
                foreach (PairedValue pv in p.ListPairedValues)
                {
                    df.Element   = pv.IdentName;
                    df.ValueOrig = pv.IdentValue;

                    listData.Add(df);

                    df          = new DataFim();
                    df.EndPoint = endpoint;
                    df.Parent   = p.ParentName;
                }
                if (p.ListParents.Count > 0)
                {
                    df = ProcessParents(df, listData, endpoint, p.ListParents);
                }
            }
            return(df);
        }