示例#1
0
        public static void ClearApplicationInternalErrorLog()
        {
            //Obtaining the data source
            MeasurementsDataContext dbEventLog = new MeasurementsDataContext();

            // Remove all Internal errors
            dbEventLog.InternalErrors.DeleteAllOnSubmit(dbEventLog.InternalErrors);

            dbEventLog.SubmitChanges();
        }
示例#2
0
        public static void FillUnitListsTable()
        {
            //Obtaining the data source
            MeasurementsDataContext dbEventLog = new MeasurementsDataContext();

            List <string> FavoritUnitStrings = new List <string> {
                "m/s", "Km/h", "ml", "l/h"
            };

            //Create compiled query
            var fnUnitIdFromName = CompiledQuery.Compile((MeasurementsDataContext dbEventLog1, string UnitName) =>
                                                         from u in dbEventLog.Units
                                                         where u.Name == UnitName
                                                         select u.Id);

            // Execute the query
            // Remove all unit lists from dbEventLog.UnitLists
            dbEventLog.UnitLists.DeleteAllOnSubmit(dbEventLog.UnitLists);

            dbEventLog.SubmitChanges();

            // Fill named derived units into dbEventLog.Units
            int UnitListId = UnitListBaseNumber;

            int UnitListElementIndex = 0;

            foreach (string unitStr in FavoritUnitStrings)
            {
                // IPhysicalUnit pu = PhysicalMeasure.PhysicalUnit.Parse(unitStr);
                // IPhysicalQuantity pq = pu.ConvertToSystemUnit();

                var q = fnUnitIdFromName(dbEventLog, unitStr);

                int UnitListElementUnitId = q.ElementAtOrDefault(0);
                Debug.Assert(UnitListElementUnitId != 0);

                if (UnitListElementUnitId != 0)
                {
                    UnitList_LINQ ul_element = new UnitList_LINQ()
                    {
                        Id = UnitListElementBaseNumber + UnitListElementIndex, UnitId = UnitListElementUnitId, ListId = UnitListId
                    };
                    //UnitList ul_element = new UnitList() { UnitId = UnitListElementUnitId, ListId = UnitListId };
                    dbEventLog.UnitLists.InsertOnSubmit(ul_element);
                }
                else
                {
                    InternalError_LINQ.ApplicationInternalErrorLog("Error when adding '" + unitStr + "' as favorite unit. Found no unit named '" + unitStr + "'");
                }

                UnitListElementIndex++;
            }

            dbEventLog.SubmitChanges();
        }
示例#3
0
        // ApplicationInternalErrorLog("Error when adding '" + unitStr + " as favorite unit");
        public static void ApplicationInternalErrorLog(string errorMessage)
        {
            //Obtaining the data source
            MeasurementsDataContext dbEventLog = new MeasurementsDataContext();

            int nextId            = dbEventLog.InternalErrors.Count() + 1;
            InternalError_LINQ ie = new InternalError_LINQ()
            {
                Id = nextId, LogTime = System.DateTime.Now, EventTime = System.DateTime.Now, ErrorMessage = errorMessage
            };

            dbEventLog.InternalErrors.InsertOnSubmit(ie);

            dbEventLog.SubmitChanges();
        }
示例#4
0
        //protected UnitKind _kindofUnit = UnitKind.BaseUnit;

        //public UnitKind KindOfUnit { get { return _kindofUnit; } }
        //public override string Text { get { return Name + "  " + (!string.IsNullOrWhiteSpace(Symbol) ? Symbol : ExponentsText); } set { /* Name = value; */ } }

        /*
         * public string GetUnitItemText(UnitItemViewKind UnitViewKind)
         * {
         *  string  str ="";
         *
         *  if ((UnitViewKind & UnitItemViewKind.DBId) != 0)
         *  {
         *      str += "[" + Id.ToString() + "]";
         *  }
         *
         *  if ((UnitViewKind & UnitItemViewKind.Name) != 0)
         *  {
         *      if (!string.IsNullOrWhiteSpace(str))
         *      {
         *          str += " ";
         *      }
         *      str += Name;
         *  }
         *
         *  if ((UnitViewKind & UnitItemViewKind.Symbol) != 0)
         *  {
         *      if (!string.IsNullOrWhiteSpace(str))
         *      {
         *          str += " ";
         *      }
         *      str += Symbol;
         *  }
         *
         *  if (   (((UnitViewKind & UnitItemViewKind.Symbol) != 0) && string.IsNullOrWhiteSpace(Symbol))
         || ((UnitViewKind & UnitItemViewKind.BaseUnits) != 0))
         || {
         ||     if (!string.IsNullOrWhiteSpace(str))
         ||     {
         ||         str += " ";
         ||     }
         ||     str += ExponentsText;
         || }
         ||
         || return str;
         ||}
         ||
         ||
         ||// string.Format();
         ||//public string ExponentsText { get { return PhysicalUnit.MakePhysicalUnit(DimensionExponents.Exponents(Exponents.ToArray()), ConvertionFactor ?? 1.0).ToString(); } set { /*  Name = value; * /  } }
         ||//public string ExponentsText { get { return PhysicalUnit.MakePhysicalUnit(DimensionExponents.Exponents(Exponents.ToArray()), 1.0).ToString(); } set { /*  Name = value; * /  } }
         ||//public string ExponentsText { get { return PhysicalUnit.MakePhysicalUnit(DimensionExponents.Exponents(Exponents.ToArray()), ConversionFactor ?? 1.0, ConversionOffset ?? 0.0).ToString(); } set { /*  Name = value; * /  } }
         ||public string ExponentsText
         ||{
         || get
         || {
         ||     if (!ConversionOffset.HasValue || ConversionOffset.Value == 0)
         ||     {
         ||         return PhysicalUnit.MakePhysicalUnit(Exponents.ToArray().ToSBytes(), ConversionFactor ?? 1.0, ConversionOffset ?? 0.0).ToString();
         ||     }
         ||     else
         ||     {
         ||         return PhysicalUnit.MakePhysicalUnit(Exponents.ToArray().ToSBytes(), ConversionFactor ?? 1.0, ConversionOffset ?? 0.0).ToString();
         ||     }
         || }
         || set { / *  Name = value; * /  }
         ||}
         **/

        /*
         * // Define FillUnitsTable base numbers and class sizes
         * public const int BaseUnitBaseNumber = 1;
         * public const int BaseUnitsClassSize = 16;
         * public const int NamedDerivedUnitBaseNumber = BaseUnitBaseNumber + BaseUnitsClassSize;
         * public const int NamedDerivedUnitsClassSize = 32;
         * public const int NamedConvertibleUnitBaseNumber = NamedDerivedUnitBaseNumber + NamedDerivedUnitsClassSize;
         * public const int NamedConvertibleClassSize = 16;
         * public const int OtherDerivedUnitBaseNumber = NamedConvertibleUnitBaseNumber + NamedConvertibleClassSize;
         *
         * public static List<string> OtherDerivedUnitStrings = new List<string> { "m/s", "Km/h", "Kg/h", "l/h" , "KWh"};
         *
         * public static int OtherDerivedUnitClassSize = OtherDerivedUnitStrings.Count;
         ***/

        public static void FillUnitsTable()
        {
            //Obtaining the data source
            MeasurementsDataContext dbEventLog = new MeasurementsDataContext();

            //List<string> OtherDerivedUnitStrings = new List<string> { "m/s", "Km/h", "Kg/h", "l/h" };

            int OtherDerivedUnitClassSize = OtherDerivedUnitStrings.Count;

            //int DeleteClassSize = BaseUnitsClassSize + NamedDerivedUnitsClassSize + OtherDerivedUnitClassSize;
            int DeleteClassSize = OtherDerivedUnitBaseNumber + OtherDerivedUnitClassSize;

            // Remove all units from dbEventLog.Units
            //dbEventLog.Units.DeleteAllOnSubmit(dbEventLog.Units);
            //dbEventLog.SubmitChanges();

            //Create compiled query
            var fnUnitsOfClass = CompiledQuery.Compile((MeasurementsDataContext dbEventLog1, int UnitClass, int ClassSize) =>
                                                       from c in dbEventLog1.Units
                                                       where c.Id >= UnitClass
                                                       where c.Id < (UnitClass + ClassSize)
                                                       select c);

            // Execute the query
            // Remove all units from dbEventLog.Units
            // foreach (Unit u in dbEventLog.Units)
            ////foreach (Unit u in fnUnitsOfClass(dbEventLog, BaseUnitBaseNumber - 1, DeleteClassSize))
            ////{
            ////    dbEventLog.Units.DeleteOnSubmit(u);
            ////}
            // Remove all unit lists from dbEventLog.Units
            dbEventLog.Units.DeleteAllOnSubmit(dbEventLog.Units);


            // Fill base units into dbEventLog.Units
            foreach (PhysicalMeasure.BaseUnit pu in PhysicalMeasure.Physics.SI_Units.BaseUnits)
            {
                Unit_LINQ u = new Unit_LINQ()
                {
                    Id = BaseUnitBaseNumber + pu.BaseUnitNumber, Name = pu.Name, Symbol = pu.Symbol, Exponents = pu.Exponents
                };
                dbEventLog.Units.InsertOnSubmit(u);
            }


            // Fill named derived units into dbEventLog.Units
            int NamedDerivedUnitIndex = 0;

            foreach (PhysicalMeasure.NamedDerivedUnit pu in PhysicalMeasure.Physics.SI_Units.NamedDerivedUnits)
            {
                Unit_LINQ u = new Unit_LINQ()
                {
                    Id = NamedDerivedUnitBaseNumber + NamedDerivedUnitIndex, Name = pu.Name, Symbol = pu.Symbol, Exponents = pu.Exponents
                };
                dbEventLog.Units.InsertOnSubmit(u);

                NamedDerivedUnitIndex++;
            }


            // Fill Convertible units into dbEventLog.Units
            int NamedConvertibleUnitIndex = 0;

            foreach (PhysicalMeasure.ConvertibleUnit pu in PhysicalMeasure.Physics.SI_Units.ConvertibleUnits)
            {
                //Unit u = new Unit() { Id = NamedDerivedUnitBaseNumber + NamedDerivedUnitIndex + NamedConvertibleUnitIndex, Name = pu.Name, Symbol = pu.Symbol, Exponents = pu.UnsignedExponents, ConvertionFactor = 1 / pu.ConvertToPrimaryUnit().Value };
                //Unit u = new Unit() { Id = NamedConvertibleUnitBaseNumber + NamedConvertibleUnitIndex, Name = pu.Name, Symbol = pu.Symbol, Exponents = pu.UnsignedExponents, ConvertionFactor = 1 / pu.ConvertToPrimaryUnit().Value, ConvertionOffset =  };
                Unit_LINQ u = new Unit_LINQ()
                {
                    Id = NamedConvertibleUnitBaseNumber + NamedConvertibleUnitIndex, Name = pu.Name, Symbol = pu.Symbol, Exponents = pu.Exponents, ConversionFactor = pu.Conversion.LinearScale, ConversionOffset = pu.Conversion.LinearOffset
                };
                dbEventLog.Units.InsertOnSubmit(u);

                NamedConvertibleUnitIndex++;
            }


            // Fill named derived units into dbEventLog.Units
            int OtherDerivedUnitIndex = 0;

            foreach (string unitStr in OtherDerivedUnitStrings)
            {
                PhysicalUnit     pu = PhysicalUnit.Parse(unitStr);
                PhysicalQuantity pq = pu.ConvertToSystemUnit().ConvertToDerivedUnit();

                //Unit u = new Unit() { Id = OtherDerivedUnitBaseNumber + OtherDerivedUnitIndex, Name = pu.ToPrintString(), Exponents = pu.UnsignedExponents};
                Unit_LINQ u = new Unit_LINQ()
                {
                    Id = OtherDerivedUnitBaseNumber + OtherDerivedUnitIndex, Name = pu.ToPrintString(), Exponents = pq.Unit.Exponents, ConversionFactor = 1 / pq.Value
                };
                dbEventLog.Units.InsertOnSubmit(u);

                OtherDerivedUnitIndex++;
            }

            dbEventLog.SubmitChanges();
        }
        public void Load_Data()
        {
            //Obtaining the data source
#if USE_DB_MAPPING_LINQ_TO_SQL
            MeasurementsDataContext dbEventLog = new MeasurementsDataContext();
#elif USE_DB_MAPPING_LINQ_TO_ENTITY_FRAMEWORK
            MeasurementsDataContext dbEventLog = new MeasurementsDataContext();
#elif USE_DB_MAPPING_LINQ_TO_ENTITY_FRAMEWORK_CORE
            // MEASUREMENTSDataSet dbEventLog = new MEASUREMENTSDataSet();
            LoggingContext dbEventLog = new LoggingContext();
#endif
            // Display a wait cursor while the TreeNodes are being created.
            //Cursor.Current = new Cursor("MyWait.cur");

            // Suppress repainting the TreeView until all the objects have been created.
            itemsTreeView.BeginUpdate();

            // Clear the TreeView each time the method is called.
            itemsTreeView.Nodes.Clear();

            try
            {
                Stack <TreeNodeCollection> TreeNodeStack = new Stack <TreeNodeCollection>();
                TreeNodeStack.Push(itemsTreeView.Nodes);
                TreeNodeCollection TNC = TreeNodeStack.Peek();

                int TopViewClassCounts = 0;
                if ((ViewClass & ListViewClass.Unit) != 0)
                {
                    TopViewClassCounts++;
                }
                if ((ViewClass & ListViewClass.Measurement) != 0)
                {
                    TopViewClassCounts++;
                }
                if ((ViewClass & ListViewClass.InternalError) != 0)
                {
                    TopViewClassCounts++;
                }

                if (TopViewClassCounts > 1)
                {   // Place top view class nodes under AllRoot when more than one
                    TreeNode AllRootNode = new GroupItemTreeNode(ListViewClassMethodes.GetClassName(ListViewClass.All), ListViewClassIconIndexes.II_FolderAll, itemsTreeView);


                    TNC.Add(AllRootNode);

                    TreeNodeStack.Push(AllRootNode.Nodes);
                    TNC = TreeNodeStack.Peek();
                }

                if ((ViewClass & (ListViewClass.Unit | ListViewClass.FavoriteUnit)) != 0)
                {   // Some units to show
                    /***
                     * // Create the query
                     * var queryAllItems = from u in dbEventLog.Units select u;
                     ***/

#if USE_DB_MAPPING_LINQ_TO_SQL
                    //Create compiled query
                    var fnUnitsOfClass = CompiledQuery.Compile((MeasurementsDataContext dbEventLog1, int UnitClass, int ClassSize) =>
                                                               from u in dbEventLog1.Units
                                                               where u.Id >= UnitClass
                                                               where u.Id < (UnitClass + ClassSize)
                                                               select u);
#elif USE_DB_MAPPING_LINQ_TO_ENTITY_FRAMEWORK
                    //Create compiled query
                    var fnUnitsOfClass = CompiledQuery.Compile((MeasurementsDataContext dbEventLog1, int UnitClass, int ClassSize) =>
                                                               from u in dbEventLog1.Units
                                                               where u.Id >= UnitClass
                                                               where u.Id < (UnitClass + ClassSize)
                                                               select u);
#elif USE_DB_MAPPING_LINQ_TO_ENTITY_FRAMEWORK_CORE
                    /*
                     * //Create compiled query
                     * var fnUnitsOfClass = CompiledQuery.Compile((LoggingContext dbEventLog1, int UnitClass, int ClassSize) =>
                     * from u in dbEventLog1.Units
                     * where u.Id >= UnitClass
                     * where u.Id < (UnitClass + ClassSize)
                     * select u);
                     */

                    List <UnitDBItem> fnUnitsOfClass(LoggingContext dbEventLog1, int UnitClass, int ClassSize)
                    {
                        var temp = from u in dbEventLog1.Units
                                   where u.Id >= UnitClass
                                   where u.Id < (UnitClass + ClassSize)
                                   select u;

                        return(temp.ToList());
                    }
#endif

                    TreeNode UnitRootNode = null;
                    if ((((ViewClass & ListViewClass.Unit) != 0) && (ViewClass != ListViewClass.Unit ||
                                                                     (ViewKind & ItemViewKind.FixedLabels) != 0)) ||
                        (ViewClass & ListViewClass.FavoriteUnit) != 0 && ViewClass != ListViewClass.FavoriteUnit)
                    {
                        UnitRootNode = new UnitItemGroupTreeNode(ListViewClassMethodes.GetClassName(ListViewClass.Unit), itemsTreeView);
                        TNC.Add(UnitRootNode);
                        TreeNodeStack.Push(UnitRootNode.Nodes);
                        TNC = TreeNodeStack.Peek();
                    }

                    if ((ViewClass & ListViewClass.Unit) != 0)
                    {
                        TreeNode subnode1 = null;
                        if (ViewClass != ListViewClass.Unit || (ViewKind & ItemViewKind.FixedLabels) != 0)
                        {
                            subnode1 = new UnitItemGroupTreeNode(ListViewClassMethodes.GetClassName(ListViewClass.BaseUnit), itemsTreeView);
                            TNC.Add(subnode1);

                            TreeNodeStack.Push(subnode1.Nodes);
                            TNC = TreeNodeStack.Peek();
                        }

                        // Execute the query for base units
                        foreach (Unit u in fnUnitsOfClass(dbEventLog, Unit.BaseUnitBaseNumber, Unit.BaseUnitsClassSize))
                        {
                            //TreeNode subnode2 = new TreeNode(u.GetUnitItemText(((UnitItemViewKind)ViewKind) & (UnitItemViewKind.DBId | UnitItemViewKind.Name | UnitItemViewKind.Symbol)));
                            TreeNode subnode2 = new BaseUnitItemTreeNode((UnitItemViewKind)ViewKind, u, itemsTreeView);

                            TNC.Add(subnode2);
                        }

                        if (ViewClass != ListViewClass.Unit || (ViewKind & ItemViewKind.FixedLabels) != 0)
                        {
                            TreeNodeStack.Pop();
                            TNC = TreeNodeStack.Peek();

                            subnode1 = new UnitItemGroupTreeNode(ListViewClassMethodes.GetClassName(ListViewClass.NamedDerivedUnit), itemsTreeView);
                            TNC.Add(subnode1);

                            TreeNodeStack.Push(subnode1.Nodes);
                            TNC = TreeNodeStack.Peek();
                        }

                        // Execute the query named derivated units
                        foreach (Unit u in fnUnitsOfClass(dbEventLog, Unit.NamedDerivedUnitBaseNumber, Unit.NamedDerivedUnitsClassSize))
                        {
                            // TreeNode subnode2 = new TreeNode(u.GetUnitItemText(((UnitItemViewKind)ViewKind) & (UnitItemViewKind.DBId | UnitItemViewKind.Name | UnitItemViewKind.Symbol)));
                            TreeNode subnode2 = new NamedDerivatedUnitItemTreeNode((UnitItemViewKind)ViewKind, u, itemsTreeView);
                            TNC.Add(subnode2);
                        }

                        if (ViewClass != ListViewClass.Unit || (ViewKind & ItemViewKind.FixedLabels) != 0)
                        {
                            TreeNodeStack.Pop();
                            TNC = TreeNodeStack.Peek();

                            subnode1 = new UnitItemGroupTreeNode(ListViewClassMethodes.GetClassName(ListViewClass.ConvertedUnit), itemsTreeView);
                            TNC.Add(subnode1);

                            TreeNodeStack.Push(subnode1.Nodes);
                            TNC = TreeNodeStack.Peek();
                        }

                        // Execute the query named convertible units
                        foreach (Unit u in fnUnitsOfClass(dbEventLog, Unit.NamedConvertibleUnitBaseNumber, Unit.NamedConvertibleClassSize))
                        {
                            //TreeNode subnode2 = new TreeNode(u.GetUnitItemText(((UnitItemViewKind)ViewKind) & (UnitItemViewKind.DBId | UnitItemViewKind.Name | UnitItemViewKind.Symbol | UnitItemViewKind.BaseUnits)));
                            TreeNode subnode2 = new ConvertibleUnitItemTreeNode((UnitItemViewKind)ViewKind, u, itemsTreeView);
                            TNC.Add(subnode2);
                        }

                        if (ViewClass != ListViewClass.Unit || (((UnitItemViewKind)ViewKind) & UnitItemViewKind.FixedLabels) != 0)
                        {
                            TreeNodeStack.Pop();
                            TNC = TreeNodeStack.Peek();

                            subnode1 = new UnitItemGroupTreeNode(ListViewClassMethodes.GetClassName(ListViewClass.DerivedUnit), itemsTreeView);
                            TNC.Add(subnode1);

                            TreeNodeStack.Push(subnode1.Nodes);
                            TNC = TreeNodeStack.Peek();
                        }
                        // Execute the query for other derivated units
                        foreach (Unit u in fnUnitsOfClass(dbEventLog, Unit.OtherDerivedUnitBaseNumber, int.MaxValue - 256))
                        {
                            //TreeNode subnode2 = new TreeNode(u.GetUnitItemText(((UnitItemViewKind)ViewKind) & (UnitItemViewKind.DBId | UnitItemViewKind.Name | UnitItemViewKind.BaseUnits)));
                            TreeNode subnode2 = new DerivatedUnitItemTreeNode((UnitItemViewKind)ViewKind, u, itemsTreeView);
                            TNC.Add(subnode2);
                        }

                        if (ViewClass != ListViewClass.Unit || (((UnitItemViewKind)ViewKind) & UnitItemViewKind.FixedLabels) != 0)
                        {
                            TreeNodeStack.Pop();
                            TNC = TreeNodeStack.Peek();
                        }
                    }


                    if ((ViewClass & ListViewClass.FavoriteUnit) != 0)
                    {
                        TreeNode subnode1 = null;
                        if (ViewClass != ListViewClass.FavoriteUnit || (((UnitItemViewKind)ViewKind) & UnitItemViewKind.FixedLabels) != 0)
                        {
                            subnode1 = new UnitItemGroupTreeNode(ListViewClassMethodes.GetClassName(ListViewClass.FavoriteUnit), itemsTreeView);
                            TNC.Add(subnode1);
                            TreeNodeStack.Push(subnode1.Nodes);
                            TNC = TreeNodeStack.Peek();
                        }


#if USE_DB_MAPPING_LINQ_TO_SQL
                        //Create compiled query
                        var fnUnitsFromFavoritList = CompiledQuery.Compile((MeasurementsDataContext dbEventLog1, int FavoritUnitListID) =>
                                                                           from fu in dbEventLog1.UnitLists
                                                                           where fu.ListId == FavoritUnitListID
                                                                           select fu.Unit);
#elif USE_DB_MAPPING_LINQ_TO_ENTITY_FRAMEWORK
                        //Create compiled query
                        var fnUnitsFromFavoritList = CompiledQuery.Compile((MeasurementsDataContext dbEventLog1, int FavoritUnitListID) =>
                                                                           from fu in dbEventLog1.UnitLists
                                                                           where fu.ListId == FavoritUnitListID
                                                                           select fu.Unit);
#elif USE_DB_MAPPING_LINQ_TO_ENTITY_FRAMEWORK_CORE
                        Unit fnUnitsOfUnitDbItem(UnitDBItem udbi)
                        {
                            return(udbi as Unit);
                        }

                        //Create compiled query
                        List <Unit> fnUnitsFromFavoritList(LoggingContext dbEventLog1, int FavoritUnitListID)
                        {
                            /** */
                            var temp = from fu in dbEventLog1.UnitListElements
                                       join u in dbEventLog1.Units on fu.UnitId equals u.Id
                                       where fu.ListId == FavoritUnitListID
                                       orderby fu.ElementIndex
                                       // select (u as Unit);
                                       select u;

                            return(temp.ToList().Select(ui => fnUnitsOfUnitDbItem(ui)).ToList());
                        }
#endif
                        List <Unit> favoritUnits = fnUnitsFromFavoritList(dbEventLog, FavoriteUnitListID);
                        // Execute the query favorite units
                        foreach (Unit u in favoritUnits)
                        {
                            TreeNode subnode2 = new FavoriteUnitItemTreeNode((UnitItemViewKind)ViewKind, u, itemsTreeView);
                            TNC.Add(subnode2);
                        }

                        if (ViewClass != ListViewClass.FavoriteUnit || (((UnitItemViewKind)ViewKind) & UnitItemViewKind.FixedLabels) != 0)
                        {
                            TreeNodeStack.Pop();
                            TNC = TreeNodeStack.Peek();
                        }
                    }

                    if (UnitRootNode != null)
                    {
                        TreeNodeStack.Pop();
                        TNC = TreeNodeStack.Peek();
                    }
                }

                if ((ViewClass & ListViewClass.Measurement) != 0)
                {
                    /***
                     * // Create the query
                     * queryAllItems = null;
                     * var queryAllItems2 = from m in dbEventLog.Measurements select m;
                     ***/


                    if (ViewClass != ListViewClass.Measurement || (ViewKind & ItemViewKind.FixedLabels) != 0)
                    {
                        TreeNode node = new TreeNode(ListViewClassMethodes.GetClassName(ListViewClass.Measurement));
                        TNC.Add(node);
                        TreeNodeStack.Push(node.Nodes);
                        TNC = TreeNodeStack.Peek();
                    }

                    // Execute the query
                    //foreach (var m in queryAllItems2)
                    foreach (MeasurementDBItem m in dbEventLog.Measurements)
                    {
                        // ItemsListView.Items.Add(u.Name);
                        TreeNode subnode = new MeasurementItemTreeNode((MeasurementItemViewKind)ViewKind, m, itemsTreeView);
                        TNC.Add(subnode);
                    }

                    if (ViewClass != ListViewClass.Measurement || (ViewKind & ItemViewKind.FixedLabels) != 0)
                    {
                        TreeNodeStack.Pop();
                        TNC = TreeNodeStack.Peek();
                    }
                }

                if ((ViewClass & ListViewClass.InternalError) != 0)
                {
                    /***
                     * // Create the query
                     * queryAllItems = null;
                     * var queryAllItems2 = from m in dbEventLog.Measurements select m;
                     ***/

                    if (ViewClass != ListViewClass.InternalError || (ViewKind & ItemViewKind.FixedLabels) != 0)
                    {
                        TreeNode node = new TreeNode(ListViewClassMethodes.GetClassName(ListViewClass.InternalError));
                        TNC.Add(node);
                        TreeNodeStack.Push(node.Nodes);
                        TNC = TreeNodeStack.Peek();
                    }

                    // Execute the query
                    //foreach (var m in queryAllItems2)
                    foreach (var ie in dbEventLog.InternalErrors)
                    {
                        // ItemsListView.Items.Add(u.Name);
                        TreeNode subnode = new TreeNode(ie.GetErrorItemText(((ErrorItemViewKind)ViewKind)));
                        TNC.Add(subnode);
                    }

                    if (ViewClass != ListViewClass.InternalError || (ViewKind & ItemViewKind.FixedLabels) != 0)
                    {
                        TreeNodeStack.Pop();
                        TNC = TreeNodeStack.Peek();
                    }
                }
            }
            finally
            {
                itemsTreeView.ExpandAll();

                // Reset the cursor to the default for all controls.
                //Cursor.Current = Cursors.Default;

                // Begin repainting the TreeView.
                itemsTreeView.EndUpdate();
            }
        }