Class to measure time elapsed between instantiation to disposal
Inheritance: IDisposable
Exemplo n.º 1
0
        void CreateSchemaNodes(TreeNode connNode)
        {
            Action <TimeSpan> act  = (ts) => LoggingService.Info("Connection " + connNode.Name + ": Schema population completed in " + ts.TotalMilliseconds + "ms");
            FdoConnection     conn = _connMgr.GetConnection(connNode.Name);

            if (conn != null)
            {
                using (FdoFeatureService service = conn.CreateFeatureService())
                {
                    if (service.SupportsPartialSchemaDiscovery())
                    {
                        using (var measure = new TimeMeasurement(act))
                        {
                            List <string> schemaNames = service.GetSchemaNames();

                            //Pre-sort
                            SortedList <string, string> sorted = new SortedList <string, string>();
                            foreach (string name in schemaNames)
                            {
                                sorted.Add(name, name);
                            }

                            foreach (string name in schemaNames)
                            {
                                TreeNode schemaNode = CreateSchemaNode(name, true);
                                connNode.Nodes.Add(schemaNode);
                                schemaNode.Nodes.Add(ResourceService.GetString("TEXT_LOADING"));
                            }
                        }
                    }
                    else
                    {
                        using (var measure = new TimeMeasurement(act))
                        {
                            FeatureSchemaCollection schemas = service.DescribeSchema();

                            //Pre-sort
                            SortedList <string, FeatureSchema> sorted = new SortedList <string, FeatureSchema>();
                            foreach (FeatureSchema schema in schemas)
                            {
                                sorted.Add(schema.Name, schema);
                            }

                            foreach (FeatureSchema schema in schemas)
                            {
                                TreeNode schemaNode = CreateSchemaNode(schema.Name, false);
                                GetClassNodesFull(schema, schemaNode);
                                connNode.Nodes.Add(schemaNode);
                                schemaNode.Expand();
                            }
                        }
                    }
                }
            }
        }
        void CreateSchemaNodes(TreeNode connNode)
        {
            Action<TimeSpan> act = (ts) => LoggingService.Info("Connection " + connNode.Name + ": Schema population completed in " + ts.TotalMilliseconds + "ms");
            FdoConnection conn = _connMgr.GetConnection(connNode.Name);
            if (conn != null)
            {
                using (FdoFeatureService service = conn.CreateFeatureService())
                {
                    if (service.SupportsPartialSchemaDiscovery())
                    {
                        using (var measure = new TimeMeasurement(act))
                        {
                            List<string> schemaNames = service.GetSchemaNames();

                            //Pre-sort
                            SortedList<string, string> sorted = new SortedList<string, string>();
                            foreach (string name in schemaNames)
                                sorted.Add(name, name);

                            foreach (string name in schemaNames)
                            {
                                TreeNode schemaNode = CreateSchemaNode(name, true);
                                connNode.Nodes.Add(schemaNode);
                                schemaNode.Nodes.Add(ResourceService.GetString("TEXT_LOADING"));
                            }
                        }
                    }
                    else
                    {
                        using (var measure = new TimeMeasurement(act))
                        {
                            FeatureSchemaCollection schemas = service.DescribeSchema();

                            //Pre-sort
                            SortedList<string, FeatureSchema> sorted = new SortedList<string, FeatureSchema>();
                            foreach (FeatureSchema schema in schemas)
                                sorted.Add(schema.Name, schema);

                            foreach (FeatureSchema schema in schemas)
                            {
                                TreeNode schemaNode = CreateSchemaNode(schema.Name, false);
                                GetClassNodesFull(schema, schemaNode);
                                connNode.Nodes.Add(schemaNode);
                                schemaNode.Expand();
                            }
                        }
                    }
                }
            }
        }