Exemplo n.º 1
0
        void UpdateAllDirtySubnetworks(UtilityNetwork utilityNetwork, Tier tier, MapView mapView)
        {
            #region Update all dirty subnetworks in a tier

            using (SubnetworkManager subnetworkManager = utilityNetwork.GetSubnetworkManager())
            {
                subnetworkManager.UpdateAllSubnetworks(tier, true);

                mapView.Redraw(true);
            }



            #endregion
        }
Exemplo n.º 2
0
        /// <summary>
        /// Run the toggle switches process, it can be cancel
        /// </summary>
        /// <param name="cps">Cancelable Progressor Source to show the progression</param>
        /// <param name="mapExtent">Map Extent to zomm to the precedent extent</param>
        /// <returns>An error comment if needed, empty of no error</returns>
        internal static async Task <string> RunCancelableToggleSwwitches(CancelableProgressorSource cps, Envelope mapExtent)
        {
            string status = "";
            await QueuedTask.Run(() =>
            {
                cps.Progressor.Max = 6;

                cps.Progressor.Value  += 1;
                cps.Progressor.Status  = (cps.Progressor.Value * 100 / cps.Progressor.Max) + @" % Completed";
                cps.Progressor.Message = "Step 1 – Toggle switch status";

                // change selected switches attributes
                status = ToggleSwitchesExecute();
            }, cps.Progressor);

            await QueuedTask.Run(() =>
            {
                if (String.IsNullOrEmpty(status) && !cps.Progressor.CancellationToken.IsCancellationRequested)
                {
                    cps.Progressor.Value  += 1;
                    cps.Progressor.Status  = (cps.Progressor.Value * 100 / cps.Progressor.Max) + @" % Completed";
                    cps.Progressor.Message = "Step 2 –  Validate and save edits";

                    // ValidateNetworkTopology need an Edit Operation if there are some editions not saved
                    Project.Current.SaveEditsAsync();
                    GlobalUtilityNetwork.ValidateNetworkTopology();
                    // ValidateNetworkTopology create an edit operation which must be saved
                    Project.Current.SaveEditsAsync();

                    cps.Progressor.Value  += 1;
                    cps.Progressor.Status  = (cps.Progressor.Value * 100 / cps.Progressor.Max) + @" % Completed";
                    cps.Progressor.Message = "Step 3 – Update the dirty subnetwork(s)";

                    UtilityNetworkDefinition unDef = GlobalUtilityNetwork.GetDefinition();
                    Tier tier = unDef.GetDomainNetwork(cDomainNetworkName).GetTier(cTierName);

                    SubnetworkManager subManager = GlobalUtilityNetwork.GetSubnetworkManager();

                    // Update subnetwork
                    try
                    { subManager.UpdateAllSubnetworks(tier, true); }
                    catch (Exception ex)
                    { status = ExceptionFormat(ex); }
                }
            }, cps.Progressor);

            await QueuedTask.Run(() =>
            {
                if (String.IsNullOrEmpty(status) && !cps.Progressor.CancellationToken.IsCancellationRequested)
                {
                    cps.Progressor.Value  += 1;
                    cps.Progressor.Status  = (cps.Progressor.Value * 100 / cps.Progressor.Max) + @" % Completed";
                    cps.Progressor.Message = "Step 4 – Color the diagram edges per subnetwork";
                    ColorEdges.ExecuteReductionEdgeColorBySubnetwork(GetDiagramLayerFromMap(MapView.Active.Map));

                    cps.Progressor.Value  += 1;
                    cps.Progressor.Status  = (cps.Progressor.Value * 100 / cps.Progressor.Max) + @" % Completed";
                    cps.Progressor.Message = "Step 5 – Redraw the Network Diagram";

                    MapView.Active.Redraw(true);
                    MapView.Active.ZoomTo(mapExtent);

                    // re set the selection
                    if (GlobalMapSelection != null)
                    {
                        MapView.Active.Map.ClearSelection();
                        MapView.Active.Map.SetSelection(GlobalMapSelection);
                    }
                }
            }, cps.Progressor);

            await QueuedTask.Run(() =>
            {
                CleanModule();
            });

            return(status);
        }