/// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public PressureLossReportFormats getAllFormats(bool bCheckDomain = true)
        {
            XmlSerializer             serializer = new XmlSerializer(typeof(PressureLossReportFormats));
            PressureLossReportFormats formats    = new PressureLossReportFormats();

            if (!File.Exists(formatFileName))
            {
                return(null);
            }

            using (TextReader reader = new StreamReader(formatFileName))
            {
                try
                {
                    PressureLossReportHelper  helper     = PressureLossReportHelper.instance;
                    PressureLossReportFormats allformats = serializer.Deserialize(reader) as PressureLossReportFormats;
                    if (allformats != null)
                    {
                        foreach (PressureLossReportData data in allformats)
                        {
                            if ((bCheckDomain && data.Domain == helper.Domain) || !bCheckDomain)
                            {
                                formats.Add(data);
                            }
                        }
                    }

                    return(formats);
                }
                catch (System.InvalidOperationException)
                {
                    return(formats);
                }
            }
        }
        /// <summary>
        /// save the data to the xml file, please catch InvalidOperationException to
        /// identify the existing file is broken.
        /// </summary>
        /// <param name="data">format data</param>
        public void save(PressureLossReportData data)
        {
            try
            {
                XmlSerializer             serializer = new XmlSerializer(typeof(PressureLossReportFormats));
                PressureLossReportFormats formats    = new PressureLossReportFormats();
                if (File.Exists(formatFileName))
                {
                    formats = getAllFormats(false);
                    //formats can't been null, it may throw exception.
                    //this format exists
                    if (formats != null && formats.Contains(data))
                    {
                        formats.Remove(data);
                    }
                }

                formats.Add(data);
                using (TextWriter writer = new StreamWriter(formatFileName))
                {
                    serializer.Serialize(writer, formats);
                }
            }
            catch
            {
                //do nothing
            }
        }
        /// <summary>
        /// save the data to the xml file, please catch InvalidOperationException to 
        /// identify the existing file is broken.
        /// </summary>
        /// <param name="data">format data</param>
        public void save(PressureLossReportData data)
        {
            try
             {
            XmlSerializer serializer = new XmlSerializer(typeof(PressureLossReportFormats));
            PressureLossReportFormats formats = new PressureLossReportFormats();
            if (File.Exists(formatFileName))
            {
               formats = getAllFormats(false);
               //formats can't been null, it may throw exception.
               //this format exists
               if (formats != null && formats.Contains(data))
               {
                  formats.Remove(data);
               }
            }

            formats.Add(data);
            using (TextWriter writer = new StreamWriter(formatFileName))
            {
               serializer.Serialize(writer, formats);
            }
             }
             catch
             {
            //do nothing
             }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public PressureLossReportFormats getAllFormats(bool bCheckDomain = true)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(PressureLossReportFormats));
             PressureLossReportFormats formats = new PressureLossReportFormats();
             if (!File.Exists(formatFileName))
            return null;

             using (TextReader reader = new StreamReader(formatFileName))
             {
            try
            {
               PressureLossReportHelper helper = PressureLossReportHelper.instance;
               PressureLossReportFormats allformats = serializer.Deserialize(reader) as PressureLossReportFormats;
               if (allformats != null)
               {
                  foreach (PressureLossReportData data in allformats)
                  {
                     if ((bCheckDomain && data.Domain == helper.Domain) || !bCheckDomain)
                        formats.Add(data);

                  }
               }

               return formats;
            }
            catch (System.InvalidOperationException)
            {
               return formats;
            }
             }
        }