private string ExpressionToString(UtilityTraceConditionalExpression expression) { if (expression is UtilityCategoryComparison categoryComparison) { return($"`{categoryComparison.Category.Name}` {categoryComparison.ComparisonOperator}"); } else if (expression is UtilityNetworkAttributeComparison attributeComparison) { // Check if attribute domain is a coded value domain. if (attributeComparison.NetworkAttribute.Domain is CodedValueDomain domain) { // Get the coded value using the the attribute comparison value and attribute data type. UtilityNetworkAttributeDataType dataType = attributeComparison.NetworkAttribute.DataType; object attributeValue = ConvertToDataType(attributeComparison.Value, attributeComparison.NetworkAttribute.DataType); CodedValue codedValue = domain.CodedValues.FirstOrDefault(value => ConvertToDataType(value.Code, dataType).Equals(attributeValue)); return($"`{attributeComparison.NetworkAttribute.Name}` {attributeComparison.ComparisonOperator} `{codedValue?.Name}`"); } else { return($"`{attributeComparison.NetworkAttribute.Name}` {attributeComparison.ComparisonOperator} `{attributeComparison.OtherNetworkAttribute?.Name ?? attributeComparison.Value}`"); } } else if (expression is UtilityTraceAndCondition andCondition) { return($"({ExpressionToString(andCondition.LeftExpression)}) AND\n ({ExpressionToString(andCondition.RightExpression)})"); } else if (expression is UtilityTraceOrCondition orCondition) { return($"({ExpressionToString(orCondition.LeftExpression)}) OR\n ({ExpressionToString(orCondition.RightExpression)})"); } else { return(null); } }
private async void Initialize() { try { Configuration.IsEnabled = false; // Create and load the utility network. _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl)); // Build the choice lists for network attribute comparison. Attributes.ItemsSource = _utilityNetwork.Definition.NetworkAttributes.Where(netattr => !netattr.IsSystemDefined); Operators.ItemsSource = Enum.GetValues(typeof(UtilityAttributeComparisonOperator)); // Create a default starting location. UtilityNetworkSource networkSource = _utilityNetwork.Definition.GetNetworkSource(DeviceTableName); UtilityAssetGroup assetGroup = networkSource.GetAssetGroup(AssetGroupName); UtilityAssetType assetType = assetGroup.GetAssetType(AssetTypeName); Guid globalId = Guid.Parse(GlobalId); _startingLocation = _utilityNetwork.CreateElement(assetType, globalId); // Set the terminal for this location. (For our case, we use the 'Load' terminal.) _startingLocation.Terminal = _startingLocation.AssetType.TerminalConfiguration?.Terminals.FirstOrDefault(term => term.Name == "Load"); // Get a default trace configuration from a tier to update the UI. UtilityDomainNetwork domainNetwork = _utilityNetwork.Definition.GetDomainNetwork(DomainNetworkName); UtilityTier sourceTier = domainNetwork.GetTier(TierName); // Set the trace configuration. _configuration = sourceTier.TraceConfiguration; // Set the default expression (if provided). if (sourceTier.TraceConfiguration.Traversability.Barriers is UtilityTraceConditionalExpression expression) { ConditionBarrierExpression.Text = ExpressionToString(expression); _initialExpression = expression; } // Setting DataContext will resolve the data-binding in XAML. Configuration.DataContext = _configuration; // Set the traversability scope. sourceTier.TraceConfiguration.Traversability.Scope = UtilityTraversabilityScope.Junctions; } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Message.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error); } finally { Configuration.IsEnabled = true; } }
private async void Initialize() { try { // Disable interaction until the data is loaded. _mainView.Visibility = ViewStates.Gone; // Create and load the utility network. _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl)); // Getthe attributes in the utility network. _attributes = _utilityNetwork.Definition.NetworkAttributes.Where(netattr => !netattr.IsSystemDefined); // Create a default starting location. UtilityNetworkSource networkSource = _utilityNetwork.Definition.GetNetworkSource(DeviceTableName); UtilityAssetGroup assetGroup = networkSource.GetAssetGroup(AssetGroupName); UtilityAssetType assetType = assetGroup.GetAssetType(AssetTypeName); Guid globalId = Guid.Parse(GlobalId); _startingLocation = _utilityNetwork.CreateElement(assetType, globalId); // Set the terminal for this location. (For our case, we use the 'Load' terminal.) _startingLocation.Terminal = _startingLocation.AssetType.TerminalConfiguration?.Terminals.FirstOrDefault(term => term.Name == "Load"); // Get a default trace configuration from a tier to update the UI. UtilityDomainNetwork domainNetwork = _utilityNetwork.Definition.GetDomainNetwork(DomainNetworkName); _sourceTier = domainNetwork.GetTier(TierName); // Set the trace configuration. _configuration = _sourceTier.TraceConfiguration; // Set the default expression (if provided). if (_sourceTier.TraceConfiguration.Traversability.Barriers is UtilityTraceConditionalExpression expression) { _initialExpression = expression; _expressionLabel.Text = ExpressionToString(_initialExpression); } // Set the traversability scope. _sourceTier.TraceConfiguration.Traversability.Scope = UtilityTraversabilityScope.Junctions; } catch (Exception ex) { new AlertDialog.Builder(this).SetMessage(ex.Message).SetTitle(ex.GetType().Name).Show(); } finally { _mainView.Visibility = ViewStates.Visible; } }
private async void Initialize() { try { // Disable interaction until the data is loaded. View.UserInteractionEnabled = false; // Create and load the utility network. _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl)); // Create a default starting location. UtilityNetworkSource networkSource = _utilityNetwork.Definition.GetNetworkSource(DeviceTableName); UtilityAssetGroup assetGroup = networkSource.GetAssetGroup(AssetGroupName); UtilityAssetType assetType = assetGroup.GetAssetType(AssetTypeName); Guid globalId = Guid.Parse(GlobalId); _startingLocation = _utilityNetwork.CreateElement(assetType, globalId); // Set the terminal for this location. (For our case, we use the 'Load' terminal.) _startingLocation.Terminal = _startingLocation.AssetType.TerminalConfiguration?.Terminals.FirstOrDefault(term => term.Name == "Load"); // Get a default trace configuration from a tier to update the UI. UtilityDomainNetwork domainNetwork = _utilityNetwork.Definition.GetDomainNetwork(DomainNetworkName); _sourceTier = domainNetwork.GetTier(TierName); // Set the trace configuration. _configuration = _sourceTier.TraceConfiguration; // Set the default expression (if provided). if (_sourceTier.TraceConfiguration.Traversability.Barriers is UtilityTraceConditionalExpression expression) { _expressionLabel.Text = ExpressionToString(expression); _initialExpression = expression; } // Set the traversability scope. _sourceTier.TraceConfiguration.Traversability.Scope = UtilityTraversabilityScope.Junctions; } catch (Exception ex) { new UIAlertView(ex.GetType().Name, ex.Message, (IUIAlertViewDelegate)null, "Error loading network", null).Show(); } finally { View.UserInteractionEnabled = true; } }
private async void Initialize() { try { ConfigureTable.IsEnabled = false; // Create and load the utility network. _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl)); // Build the choice lists for network attribute comparison. Attributes.ItemsSource = _utilityNetwork.Definition.NetworkAttributes.Where(i => i.IsSystemDefined == false).ToList(); Operators.ItemsSource = Enum.GetValues(typeof(UtilityAttributeComparisonOperator)); // Create a default starting location. UtilityNetworkSource networkSource = _utilityNetwork.Definition.GetNetworkSource(DeviceTableName); UtilityAssetGroup assetGroup = networkSource.GetAssetGroup(AssetGroupName); UtilityAssetType assetType = assetGroup.GetAssetType(AssetTypeName); Guid globalId = Guid.Parse(GlobalId); _startingLocation = _utilityNetwork.CreateElement(assetType, globalId); // Set the terminal for this location. (For our case, we use the 'Load' terminal.) _startingLocation.Terminal = _startingLocation.AssetType.TerminalConfiguration?.Terminals.FirstOrDefault(term => term.Name == "Load"); // Get a default trace configuration from a tier to update the UI. UtilityDomainNetwork domainNetwork = _utilityNetwork.Definition.GetDomainNetwork(DomainNetworkName); _sourceTier = domainNetwork.GetTier(TierName); if (_sourceTier.TraceConfiguration.Traversability.Barriers is UtilityTraceConditionalExpression expression) { ConditionBarrierExpression.Text = ExpressionToString(expression); _initialExpression = expression; } // Set the traversability scope. _sourceTier.TraceConfiguration.Traversability.Scope = UtilityTraversabilityScope.Junctions; } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "OK"); } finally { ConfigureTable.IsEnabled = true; } }
private async void Initialize() { // As of ArcGIS Enterprise 10.8.1, using utility network functionality requires a licensed user. The following login for the sample server is licensed to perform utility network operations. AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(async(info) => { try { // WARNING: Never hardcode login information in a production application. This is done solely for the sake of the sample. string sampleServer7User = "******"; string sampleServer7Pass = "******"; return(await AuthenticationManager.Current.GenerateCredentialAsync(info.ServiceUri, sampleServer7User, sampleServer7Pass)); } catch (Exception ex) { Debug.WriteLine(ex.Message); return(null); } }); try { Configuration.IsEnabled = false; // Create and load the utility network. _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl)); // Build the choice lists for network attribute comparison. Attributes.ItemsSource = _utilityNetwork.Definition.NetworkAttributes.Where(netattr => !netattr.IsSystemDefined); Operators.ItemsSource = Enum.GetValues(typeof(UtilityAttributeComparisonOperator)); // Create a default starting location. UtilityNetworkSource networkSource = _utilityNetwork.Definition.GetNetworkSource(DeviceTableName); UtilityAssetGroup assetGroup = networkSource.GetAssetGroup(AssetGroupName); UtilityAssetType assetType = assetGroup.GetAssetType(AssetTypeName); Guid globalId = Guid.Parse(GlobalId); _startingLocation = _utilityNetwork.CreateElement(assetType, globalId); // Set the terminal for this location. (For our case, we use the 'Load' terminal.) _startingLocation.Terminal = _startingLocation.AssetType.TerminalConfiguration?.Terminals.FirstOrDefault(term => term.Name == "Load"); // Get a default trace configuration from a tier to update the UI. UtilityDomainNetwork domainNetwork = _utilityNetwork.Definition.GetDomainNetwork(DomainNetworkName); UtilityTier sourceTier = domainNetwork.GetTier(TierName); // Set the trace configuration. _configuration = sourceTier.TraceConfiguration; // Set the default expression (if provided). if (sourceTier.TraceConfiguration.Traversability.Barriers is UtilityTraceConditionalExpression expression) { ConditionBarrierExpression.Text = ExpressionToString(expression); _initialExpression = expression; } // Setting DataContext will resolve the data-binding in XAML. Configuration.DataContext = _configuration; // Set the traversability scope. sourceTier.TraceConfiguration.Traversability.Scope = UtilityTraversabilityScope.Junctions; } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Message.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error); } finally { Configuration.IsEnabled = true; } }
private async void Initialize() { // As of ArcGIS Enterprise 10.8.1, using utility network functionality requires a licensed user. The following login for the sample server is licensed to perform utility network operations. AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(async(info) => { try { // WARNING: Never hardcode login information in a production application. This is done solely for the sake of the sample. string sampleServer7User = "******"; string sampleServer7Pass = "******"; return(await AuthenticationManager.Current.GenerateCredentialAsync(info.ServiceUri, sampleServer7User, sampleServer7Pass)); } catch (Exception ex) { Debug.WriteLine(ex.Message); return(null); } }); try { // Disable interaction until the data is loaded. View.UserInteractionEnabled = false; // Create and load the utility network. _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl)); // Create a default starting location. UtilityNetworkSource networkSource = _utilityNetwork.Definition.GetNetworkSource(DeviceTableName); UtilityAssetGroup assetGroup = networkSource.GetAssetGroup(AssetGroupName); UtilityAssetType assetType = assetGroup.GetAssetType(AssetTypeName); Guid globalId = Guid.Parse(GlobalId); _startingLocation = _utilityNetwork.CreateElement(assetType, globalId); // Set the terminal for this location. (For our case, we use the 'Load' terminal.) _startingLocation.Terminal = _startingLocation.AssetType.TerminalConfiguration?.Terminals.FirstOrDefault(term => term.Name == "Load"); // Get a default trace configuration from a tier to update the UI. UtilityDomainNetwork domainNetwork = _utilityNetwork.Definition.GetDomainNetwork(DomainNetworkName); _sourceTier = domainNetwork.GetTier(TierName); // Set the trace configuration. _configuration = _sourceTier.TraceConfiguration; // Set the default expression (if provided). if (_sourceTier.TraceConfiguration.Traversability.Barriers is UtilityTraceConditionalExpression expression) { _expressionLabel.Text = ExpressionToString(expression); _initialExpression = expression; } // Set the traversability scope. _sourceTier.TraceConfiguration.Traversability.Scope = UtilityTraversabilityScope.Junctions; } catch (Exception ex) { new UIAlertView(ex.GetType().Name, ex.Message, (IUIAlertViewDelegate)null, "Error loading network", null).Show(); } finally { View.UserInteractionEnabled = true; } }