public IActionResult Index()
        {
            var page = new TestPage();
            var view = new ElementResult(page.GetOouiElement(), title: "FooBar", disposeAfterSession: false);

            return(view);
        }
示例#2
0
        public static List <ElementResult> SelectDropdowns(this ElementResult elementRef, string option)
        {
            var ele = new ElementObject {
                Action = ElementAction.Dropdown, Text = option
            };

            return(elementRef.ExecuteActions(ele));
        }
示例#3
0
        public static ElementResult MultiDropdown(this ElementResult elementRef, string option)
        {
            var ele = new ElementObject {
                Action = ElementAction.MultiDropdown, Text = option
            };

            return(elementRef.ExecuteAction(ele));
        }
示例#4
0
        public static ElementResult GetProperty(this ElementResult elementRef)
        {
            var ele = new ElementObject {
                Action = ElementAction.GetProperty
            };

            return(elementRef.ExecuteAction(ele));
        }
示例#5
0
        public static ElementResult RadioBtn(this ElementResult elementRef, bool selected = true)
        {
            var ele = new ElementObject {
                Action = ElementAction.RadioBtn, Text = selected.ToString()
            };

            return(elementRef.ExecuteAction(ele));
        }
示例#6
0
        public static ElementResult EnterText(this ElementResult elementRef, string text)
        {
            var ele = new ElementObject {
                Action = ElementAction.EnterText, Text = text
            };

            return(elementRef.ExecuteAction(ele));
        }
示例#7
0
        public static List <ElementResult> WaitForAll(this ElementResult elementRef, string text)
        {
            var ele = new ElementObject {
                Action = ElementAction.Wait, Text = text
            };

            return(elementRef.ExecuteActions(ele));
        }
示例#8
0
        public static List <ElementResult> GetProperties(this ElementResult elementRef)
        {
            var ele = new ElementObject {
                Action = ElementAction.GetProperty
            };

            return(elementRef.ExecuteActions(ele));
        }
示例#9
0
        public static ElementResult DropdownIndex(this ElementResult elementRef, int index)
        {
            var ele = new ElementObject {
                Action = ElementAction.DropdownIndex, Text = index.ToString()
            };

            return(elementRef.ExecuteAction(ele));
        }
示例#10
0
 public static List <ElementResult> WaitForAll(this ElementResult elementRef, ElementObject ele = null)
 {
     if (ele == null)
     {
         ele = new ElementObject();
     }
     ele.Action = ElementAction.Wait;
     return(elementRef.ExecuteActions(ele));
 }
示例#11
0
 public static List <ElementResult> DropdownIndexes(this ElementResult elementRef, ElementObject ele = null)
 {
     if (ele == null)
     {
         ele = new ElementObject();
     }
     ele.Action = ElementAction.DropdownIndex;
     return(elementRef.ExecuteActions(ele));
 }
示例#12
0
 public static ElementResult EnterText(this ElementResult elementRef, ElementObject ele = null)
 {
     if (ele == null)
     {
         ele = new ElementObject();
     }
     ele.Action = ElementAction.EnterText;
     return(elementRef.ExecuteAction(ele));
 }
示例#13
0
 public static ElementResult RadioBtn(this ElementResult elementRef, ElementObject ele = null)
 {
     if (ele == null)
     {
         ele = new ElementObject();
     }
     ele.Action = ElementAction.RadioBtn;
     return(elementRef.ExecuteAction(ele));
 }
示例#14
0
        public static ElementResult GetDropdown(this ElementResult elementRef, Enum ele)
        {
            var element = new ElementObject(ele)
            {
                Action = ElementAction.GetDropdown
            };

            return(elementRef.ExecuteAction(element));
        }
示例#15
0
        public static ElementResult GetAttribute(this ElementResult elementRef, string attribute)
        {
            var ele = new ElementObject()
            {
                Text = attribute, Action = ElementAction.GetAttribute
            };

            return(elementRef.ExecuteAction(ele));
        }
示例#16
0
        public static List <ElementResult> GetTexts(this ElementResult elementRef, Enum ele)
        {
            var element = new ElementObject(ele)
            {
                Action = ElementAction.GetText
            };

            return(elementRef.ExecuteActions(element));
        }
示例#17
0
 public static ElementResult MultiDropdown(this ElementResult elementRef, ElementObject ele = null)
 {
     if (ele == null)
     {
         ele = new ElementObject();
     }
     ele.Action = ElementAction.MultiDropdown;
     return(elementRef.ExecuteAction(ele));
 }
示例#18
0
        public static ElementResult WaitFor(this ElementResult elementRef, Enum ele)
        {
            var element = new ElementObject(ele)
            {
                Action = ElementAction.Wait
            };

            return(elementRef.ExecuteAction(element));
        }
示例#19
0
 public static ElementResult GetAttribute(this ElementResult elementRef, ElementObject ele = null)
 {
     if (ele == null)
     {
         ele = new ElementObject();
     }
     ele.Action = ElementAction.GetAttribute;
     return(elementRef.ExecuteAction(ele));
 }
示例#20
0
        /// <summary>
        /// Validates the ContentFilter.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>The result of validation.</returns>
        public Result Validate(FilterContext context)
        {
            Result result = new Result(null);

            // check for empty filter.
            if (m_elements == null || m_elements.Count == 0)
            {
                return(result);
            }

            bool error = false;

            for (int ii = 0; ii < m_elements.Count; ii++)
            {
                ContentFilterElement element = m_elements[ii];

                // check for null.
                if (element == null)
                {
                    ServiceResult nullResult = ServiceResult.Create(
                        StatusCodes.BadStructureMissing,
                        "ContentFilterElement is null (Index={0}).",
                        ii);

                    result.ElementResults.Add(new ElementResult(nullResult));
                    error = true;
                    continue;
                }

                element.Parent = this;

                // validate element.
                ElementResult elementResult = element.Validate(context, ii);

                if (ServiceResult.IsBad(elementResult.Status))
                {
                    result.ElementResults.Add(elementResult);
                    error = true;
                    continue;
                }

                result.ElementResults.Add(null);
            }

            // ensure the global error code.
            if (error)
            {
                result.Status = StatusCodes.BadContentFilterInvalid;
            }
            else
            {
                result.ElementResults.Clear();
            }

            return(result);
        }
示例#21
0
 public static ElementResult GetCheckbox(this ElementResult elementRef, ElementObject ele = null)
 {
     if (ele == null)
     {
         ele = new ElementObject {
             Action = ElementAction.GetCheckbox
         };
     }
     return(elementRef.ExecuteAction(ele));
 }
示例#22
0
        public static ElementResult ExecuteAction(this ElementResult elementRef, ElementObject ele)
        {
            if (ele == null)
            {
                ele = new ElementObject();
            }
            var ea = new ElementActions(elementRef.TE);

            return(ea.ExecuteAction(ele, elementRef));
        }
示例#23
0
 public static List <ElementResult> GetTexts(this ElementResult elementRef, ElementObject ele = null)
 {
     if (ele == null)
     {
         ele = new ElementObject();
     }
     ele.Action = ElementAction.GetText;
     //var ele = new ElementObject { Action = ElementAction.GetText };
     return(elementRef.ExecuteActions(ele));
 }
示例#24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="elementRef"></param>
        /// <param name="location">'start' 'center' 'end' or 'nearest'</param>
        public static void ScrollTo(this ElementResult elementRef, string location = "center")
        {
            IJavaScriptExecutor js = elementRef.TE.RawSeleniumWebDriver_AvoidCallingDirectly as IJavaScriptExecutor;

            if (string.IsNullOrEmpty(location))
            {
                js.ExecuteScript($"arguments[0].scrollIntoView(true);", elementRef.RawEle);
                return;
            }

            js.ExecuteScript($"arguments[0].scrollIntoView({{block: \"{location}\"}});", elementRef.RawEle);
        }
示例#25
0
        public static List <ElementResult> ExecuteActions(this ElementResult elementRef, ElementObject ele)
        {
            if (!elementRef.Success)
            {
                return(new List <ElementResult>()
                {
                    new ElementResult(elementRef.TE)
                });
            }

            if (ele == null)
            {
                ele = new ElementObject();
            }
            var ea = new ElementActions(elementRef.TE);

            return(ea.ExecuteActions(ele, elementRef));
        }
        private static void ExecuteTrace(Guid traceStartGuid, string geodatabasePath)
        {
            using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(geodatabasePath))))
            {
                IReadOnlyList <UtilityNetworkDefinition> utilityNetworkDefinitions = geodatabase.GetDefinitions <UtilityNetworkDefinition>();

                string utilityNetworkName = string.Empty;

                if (utilityNetworkDefinitions.Count < 0 || utilityNetworkDefinitions.Count > 1)
                {
                    return;
                }

                // Get utility network name from the dataset
                foreach (UtilityNetworkDefinition definition in utilityNetworkDefinitions)
                {
                    utilityNetworkName = definition.GetName();

                    Console.WriteLine($"Utility network name: {utilityNetworkName}");
                    definition.Dispose();
                }

                // Open utility network
                using (UtilityNetwork utilityNetwork = geodatabase.OpenDataset <UtilityNetwork>(utilityNetworkName))
                    using (UtilityNetworkDefinition utilityNetworkDefinition = utilityNetwork.GetDefinition())
                    {
                        using (NetworkSource networkSource = utilityNetworkDefinition.GetNetworkSource("ElectricDevice"))
                            using (AssetGroup assetGroup = networkSource.GetAssetGroup("Medium Voltage Transformer"))
                                using (AssetType assetType = assetGroup.GetAssetType("Overhead Single Phase"))
                                {
                                    DomainNetwork      domainNetwork      = utilityNetworkDefinition.GetDomainNetwork("Electric");
                                    Tier               sourceTier         = domainNetwork.GetTier("Electric Distribution");
                                    TraceConfiguration traceConfiguration = sourceTier.GetTraceConfiguration();

                                    // Get downstream side of the terminal
                                    Terminal terminal = null;
                                    if (assetType.IsTerminalConfigurationSupported())
                                    {
                                        TerminalConfiguration    terminalConfiguration = assetType.GetTerminalConfiguration();
                                        IReadOnlyList <Terminal> terminals             = terminalConfiguration.Terminals;
                                        terminal = terminals.First(t => !t.IsUpstreamTerminal);
                                    }

                                    // Create an element to begin a trace
                                    Element startingPointElement = utilityNetwork.CreateElement(assetType, traceStartGuid, terminal);

                                    List <Element> startingPoints = new List <Element>();
                                    startingPoints.Add(startingPointElement);


                                    // Get trace manager
                                    using (TraceManager traceManager = utilityNetwork.GetTraceManager())
                                    {
                                        // Set trace configurations
                                        TraceArgument traceArgument = new TraceArgument(startingPoints);
                                        traceArgument.Configuration = traceConfiguration;

                                        // Get downstream tracer
                                        Tracer tracer = traceManager.GetTracer <DownstreamTracer>();

                                        // Execuate downstream trace
                                        IReadOnlyList <Result> traceResults = tracer.Trace(traceArgument);

                                        // Display trace results in console
                                        foreach (Result result in traceResults)
                                        {
                                            if (result is ElementResult)
                                            {
                                                ElementResult           elementResult = result as ElementResult;
                                                IReadOnlyList <Element> elements      = elementResult.Elements;

                                                Console.WriteLine("Trace result elements:");
                                                foreach (Element element in elements)
                                                {
                                                    Console.WriteLine($"\t OID: {element.ObjectID}, Name:{element.AssetType.Name}");
                                                }
                                            }
                                            else if (result is FunctionOutputResult)
                                            {
                                                FunctionOutputResult           functionResult  = result as FunctionOutputResult;
                                                IReadOnlyList <FunctionOutput> functionOutputs = functionResult.FunctionOutputs;

                                                Console.WriteLine("Trace result function outputs:");
                                                foreach (FunctionOutput functionOut in functionOutputs)
                                                {
                                                    Console.WriteLine($"\t Function result:{functionOut.Value}, name: {functionOut.Function}");
                                                }
                                            }
                                            else if (result is AggregatedGeometryResult)
                                            {
                                                AggregatedGeometryResult aggResults = result as AggregatedGeometryResult;
                                                Polyline   aggregatedLine           = aggResults.Line as Polyline;
                                                Multipoint aggregatedPoint          = aggResults.Point as Multipoint;
                                                Polygon    aggregatedPolygon        = aggResults.Polygon as Polygon;
                                            }
                                        }
                                    }
                                }
                    }
            }
        }
示例#27
0
        /// <summary>
        /// GenerateReport
        ///
        /// This routine takes a feature layer that references a feature class that participates in a utility network.
        /// It returns a set of data to display on the UI thread.
        ///
        ///
        /// </summary>

        public LoadTraceResults GenerateReport(Layer selectedLayer)
        {
            // Create a new results object.  We use this class to pass back a set of data from the worker thread to the UI thread

            LoadTraceResults results = new LoadTraceResults();

            // Initialize a number of geodatabase objects

            using (UtilityNetwork utilityNetwork = UtilityNetworkUtils.GetUtilityNetworkFromLayer(selectedLayer))
            {
                if (utilityNetwork == null)
                {
                    results.Message = "Please select a utility network layer.";
                    results.Success = false;
                }
                else
                {
                    using (Geodatabase utilityNetworkGeodatabase = utilityNetwork.GetDatastore() as Geodatabase)
                        using (UtilityNetworkDefinition utilityNetworkDefinition = utilityNetwork.GetDefinition())
                            using (Geodatabase defaultGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(Project.Current.DefaultGeodatabasePath))))
                                using (TraceManager traceManager = utilityNetwork.GetTraceManager())
                                {
                                    // First check to make sure we have a feature service workspace.  Utility Network functionality requires this.
                                    if (utilityNetworkGeodatabase.GetGeodatabaseType() != GeodatabaseType.Service)
                                    {
                                        results.Message = "A feature service workspace connection is required.";
                                        results.Success = false;
                                        return(results);
                                    }

                                    // Get a row from the starting points table in the default project workspace.  This table is created the first time the user creates a starting point
                                    // If the table is missing or empty, a null row is returned

                                    using (Row startingPointRow = GetStartingPointRow(defaultGeodatabase, ref results))
                                    {
                                        if (startingPointRow != null)
                                        {
                                            // Convert starting point row into network element

                                            Element startingPointElement = GetElementFromPointRow(startingPointRow, utilityNetwork, utilityNetworkDefinition);

                                            // Obtain a tracer object

                                            DownstreamTracer downstreamTracer = traceManager.GetTracer <DownstreamTracer>();

                                            // Get the network attributes that we will use in our trace

                                            using (NetworkAttribute phasesNetworkAttribute = GetAttribute(utilityNetworkDefinition, PhaseAttributeNames))
                                                using (NetworkAttribute loadNetworkAttribute = GetAttribute(utilityNetworkDefinition, LoadAttributeNames))
                                                    using (NetworkAttribute deviceStatusNetworkAttribute = GetAttribute(utilityNetworkDefinition, DeviceStatusAttributeNames))
                                                    {
                                                        if (phasesNetworkAttribute == null || loadNetworkAttribute == null || deviceStatusNetworkAttribute == null)
                                                        {
                                                            results.Success = false;
                                                            results.Message = "This add-in requires network attributes for phase, service load, and device status.\n";
                                                            return(results);
                                                        }


                                                        // Get the Tier for Medium Voltage Radial

                                                        DomainNetwork electricDomainNetwork = utilityNetworkDefinition.GetDomainNetwork(ElectricDomainNetwork);
                                                        Tier          mediumVoltageTier     = electricDomainNetwork.GetTier(MediumVoltageTier);


                                                        // Set up the trace configuration

                                                        TraceConfiguration traceConfiguration = new TraceConfiguration();

                                                        // Configure the trace to use the electric domain network

                                                        traceConfiguration.DomainNetwork = electricDomainNetwork;

                                                        // Take the default TraceConfiguration from the Tier for Traversability

                                                        Traversability tierTraceTraversability = mediumVoltageTier.TraceConfiguration.Traversability;
                                                        traceConfiguration.Traversability.FunctionBarriers = tierTraceTraversability.FunctionBarriers;
                                                        traceConfiguration.IncludeBarriersWithResults      = mediumVoltageTier.TraceConfiguration.IncludeBarriersWithResults;
                                                        traceConfiguration.Traversability.Scope            = tierTraceTraversability.Scope;
                                                        ConditionalExpression baseCondition = tierTraceTraversability.Barriers as ConditionalExpression;

                                                        // Create a condition to only return features that have the service point category

                                                        ConditionalExpression servicePointCategoryCondition = new CategoryComparison(CategoryOperator.IsEqual, ServicePointCategory);

                                                        // Create function to sum loads on service points where phase = A

                                                        ConditionalExpression aPhaseCondition = new NetworkAttributeComparison(phasesNetworkAttribute, Operator.DoesNotIncludeTheValues, APhase);
                                                        Add aPhaseLoad = new Add(loadNetworkAttribute, servicePointCategoryCondition);


                                                        // Create function to sum loads on service points where phase = B

                                                        ConditionalExpression bPhaseCondition = new NetworkAttributeComparison(phasesNetworkAttribute, Operator.DoesNotIncludeTheValues, BPhase);
                                                        Add bPhaseLoad = new Add(loadNetworkAttribute, servicePointCategoryCondition);

                                                        // Create function to sum loads on service points where phase = C

                                                        ConditionalExpression cPhaseCondition = new NetworkAttributeComparison(phasesNetworkAttribute, Operator.DoesNotIncludeTheValues, CPhase);
                                                        Add cPhaseLoad = new Add(loadNetworkAttribute, servicePointCategoryCondition);

                                                        // Set the output condition to only return features that have the service point category

                                                        traceConfiguration.OutputCondition = servicePointCategoryCondition;

                                                        // Create starting point list and trace argument object

                                                        List <Element> startingPointList = new List <Element>()
                                                        {
                                                            startingPointElement
                                                        };
                                                        TraceArgument traceArgument = new TraceArgument(startingPointList);
                                                        traceArgument.Configuration = traceConfiguration;

                                                        // Trace on the A phase

                                                        traceConfiguration.Traversability.Barriers = new Or(baseCondition, aPhaseCondition);
                                                        traceConfiguration.Functions = new List <Function>()
                                                        {
                                                            aPhaseLoad
                                                        };
                                                        traceArgument.Configuration = traceConfiguration;

                                                        try
                                                        {
                                                            IReadOnlyList <Result> resultsA = downstreamTracer.Trace(traceArgument);

                                                            ElementResult elementResult = resultsA.OfType <ElementResult>().First();
                                                            results.NumberServicePointsA = elementResult.Elements.Count;

                                                            FunctionOutputResult functionOutputResult = resultsA.OfType <FunctionOutputResult>().First();
                                                            results.TotalLoadA = (double)functionOutputResult.FunctionOutputs.First().Value;
                                                        }
                                                        catch (ArcGIS.Core.Data.GeodatabaseUtilityNetworkException e)
                                                        {
                                                            //No A phase connectivity to source
                                                            if (!e.Message.Equals("No subnetwork source was discovered."))
                                                            {
                                                                results.Success  = false;
                                                                results.Message += e.Message;
                                                            }
                                                        }

                                                        // Trace on the B phase

                                                        traceConfiguration.Traversability.Barriers = new Or(baseCondition, bPhaseCondition);
                                                        traceConfiguration.Functions = new List <Function>()
                                                        {
                                                            bPhaseLoad
                                                        };
                                                        traceArgument.Configuration = traceConfiguration;

                                                        try
                                                        {
                                                            IReadOnlyList <Result> resultsB = downstreamTracer.Trace(traceArgument);

                                                            ElementResult elementResult = resultsB.OfType <ElementResult>().First();
                                                            results.NumberServicePointsB = elementResult.Elements.Count;

                                                            FunctionOutputResult functionOutputResult = resultsB.OfType <FunctionOutputResult>().First();
                                                            results.TotalLoadB = (double)functionOutputResult.FunctionOutputs.First().Value;
                                                        }
                                                        catch (ArcGIS.Core.Data.GeodatabaseUtilityNetworkException e)
                                                        {
                                                            // No B phase connectivity to source
                                                            if (!e.Message.Equals("No subnetwork source was discovered."))
                                                            {
                                                                results.Success  = false;
                                                                results.Message += e.Message;
                                                            }
                                                        }

                                                        // Trace on the C phase
                                                        traceConfiguration.Traversability.Barriers = new Or(baseCondition, cPhaseCondition);
                                                        traceConfiguration.Functions = new List <Function>()
                                                        {
                                                            cPhaseLoad
                                                        };
                                                        traceArgument.Configuration = traceConfiguration;

                                                        try
                                                        {
                                                            IReadOnlyList <Result> resultsC = downstreamTracer.Trace(traceArgument);

                                                            ElementResult elementResult = resultsC.OfType <ElementResult>().First();
                                                            results.NumberServicePointsC = elementResult.Elements.Count;

                                                            FunctionOutputResult functionOutputResult = resultsC.OfType <FunctionOutputResult>().First();
                                                            results.TotalLoadC = (double)functionOutputResult.FunctionOutputs.First().Value;
                                                        }
                                                        catch (ArcGIS.Core.Data.GeodatabaseUtilityNetworkException e)
                                                        {
                                                            // No C phase connectivity to source
                                                            if (!e.Message.Equals("No subnetwork source was discovered."))
                                                            {
                                                                results.Success  = false;
                                                                results.Message += e.Message;
                                                            }
                                                        }
                                                    }

                                            // append success message to the output string

                                            results.Message += "Trace successful.";
                                            results.Success  = true;
                                        }
                                    }
                                }
                }
            }
            return(results);
        }
示例#28
0
 public static ElementResult DropdownIndex(this ElementResult elementRef, ElementObject ele = null)
 {
     ele.Action = ElementAction.DropdownIndex;
     return(elementRef.ExecuteAction(ele));
 }