示例#1
0
        /// <summary>
        /// trace the subnetwork and return the number of features
        /// </summary>
        /// <returns></returns>
        public long Trace()
        {
            string      response    = "";
            UNWorkspace unworkspace = UNWorkspace.getWorkspace();

            try
            {
                unworkspace.onProgressDelegate(0, ("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] Trace Subnetwork " + Name + " In Tier " + TierName + " Domain " + DomainNetworkName), 0);

                Dictionary <string, string> ps = new Dictionary <string, string>();
                ps.Add("sessionId", unworkspace.SessionID);
                ps.Add("gdbVersion", unworkspace.CurrentVersion.Name);
                ps.Add("moment", unworkspace.CurrentVersion.Moment.ToString());
                ps.Add("domainNetworkName", DomainNetworkName);
                ps.Add("traceType", "subnetwork");
                ps.Add("traceLocations", "[]");
                JObject tierdef = this.Tier.SubnetworkTraceConfiguraiton;
                tierdef["subnetworkName"] = Name;
                ps.Add("traceConfiguration", tierdef.ToString());
                response        = unworkspace.Request(unworkspace.UNSServiceURL + "/trace", ps);
                ResponseMessage = response;
                JObject subnetworktrace = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(response);
                JArray  features        = subnetworktrace["traceResults"]["elements"] as JArray;
                //unworkspace.onProgressDelegate(0, ("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] Trace Subnetwork " + Name + " returned " + features.Count + " features"), 0);

                FeatureCount = features.Count;

                //compare the subnetwork with the gold
                List <SubnetworkName> thesub = unworkspace.GoldSubnetworks.Where(t => t.Name == this.Name).ToList();
                if (thesub.Count > 0)
                {
                    if (thesub[0].TraceCount != FeatureCount)
                    {
                        unworkspace.onProgressDelegate(0, ("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] [TRACE TEST FAILED] Subnetwork " + Name + " returned different # of features. Expected [" + thesub[0].TraceCount + "] Returned [" + features.Count + "] "), 0);
                    }
                    else
                    {
                        unworkspace.onProgressDelegate(0, ("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] [TRACE TEST PASSED] Subnetwork " + Name + " returned same      # of features. Expected [" + thesub[0].TraceCount + "] Returned [" + features.Count + "] "), 0);
                    }
                }
                return(features.Count);
            }
            catch (Exception ex)
            {
                Success         = false;
                ResponseMessage = response + " - " + ex.Message;
                unworkspace.onProgressDelegate(0, "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] [Failed] Trace Subnetwork " + Name + " In Tier " + TierName + " Domain " + DomainNetworkName + "[" + ResponseMessage + "]", 0);
                return(0);
            }
        }
示例#2
0
        /// <summary>
        /// Update subnetwork
        /// </summary>
        public void Update()
        {
            string response = "";

            try
            {
                if (isDirty == false)
                {
                    UNWorkspace unworkspace = UNWorkspace.getWorkspace();
                    unworkspace.onProgressDelegate(0, ("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] Update Subnetwork " + Name + " In Tier " + TierName + " Domain " + DomainNetworkName), 0);

                    Dictionary <string, string> ps = new Dictionary <string, string>();
                    ps.Add("sessionId", unworkspace.SessionID);
                    ps.Add("gdbVersion", unworkspace.CurrentVersion.Name);
                    ps.Add("moment", unworkspace.CurrentVersion.Moment.ToString());
                    ps.Add("domainNetworkName", DomainNetworkName);
                    ps.Add("tierName", TierName);
                    ps.Add("subnetworkName", Name);
                    ps.Add("allSubnetworksInTier", "false");
                    ps.Add("traceConfiguration", "{}");
                    response        = unworkspace.Request(unworkspace.UNSServiceURL + "/updateSubnetwork", ps);
                    ResponseMessage = response;
                    JObject subnetworkresponse = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(response);

                    if (subnetworkresponse["success"].ToString().ToLower() == "false")
                    {
                        Success = false;
                        string failedmessage = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] [Failed] Update Subnetwork " + Name + " In Tier " + TierName + " Domain " + DomainNetworkName + "[" + ResponseMessage + "]";
                        unworkspace.onProgressDelegate(0, failedmessage, 0);
                    }

                    else
                    {
                        //refresh version after each successful subnetwork to get the new moement
                        unworkspace.RefreshVersion();
                        Success = true;
                    }
                }
                else //clean subnetworks does not request updating.. just succeed
                {
                    Success = true;
                }
            }
            catch (Exception ex)
            {
                Success         = false;
                ResponseMessage = response + " - " + ex.Message;
                Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] [Failed] Update Subnetwork " + Name + " In Tier " + TierName + " Domain " + DomainNetworkName + "[" + ResponseMessage + "]");
            }
        }
示例#3
0
        public void UpdateIsConnected()
        {
            Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] Update Is Connected ");
            UNWorkspace unworkspace        = UNWorkspace.getWorkspace();
            Dictionary <string, string> ps = new Dictionary <string, string>();


            string  response           = unworkspace.Request(unworkspace.UNSServiceURL + "/updateIsConnected", ps);
            JObject subnetworkresponse = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(response);

            if (subnetworkresponse["success"].ToString() == "false")
            {
                Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] [Failed] Update Is Connected");
            }

            else
            {
                Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] [Done] Update Is Connected");
            }
        }
示例#4
0
        /// <summary>
        /// Query and populates all subnetworks
        /// </summary>
        public void PopulateSubnetworks()
        {
            _subnetworks = new List <RestSDK.Subnetwork>();
            UNWorkspace unworkspace        = UNWorkspace.getWorkspace();
            Dictionary <string, string> ps = new Dictionary <string, string>();

            ps.Add("outFields", "SUBNETWORKNAME,domainnetworkname,tiername");
            ps.Add("gdbVersion", CurrentVersion.Name);
            ps.Add("where", "1=1");
            ps.Add("returnDistinctValues", "true");
            string  response  = unworkspace.Request(unworkspace.FeatureServiceURL + "/" + unworkspace.SubnetworksTable + "/query", ps);
            JObject jResponse = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(response);

            JArray features = (JArray)jResponse["features"];

            foreach (JObject f in features)
            {
                Subnetwork s = new Subnetwork();
                s.DomainNetworkName = getVal(f["attributes"], "domainnetworkname");
                s.TierName          = getVal(f["attributes"], "tiername"); // f["attributes"]["tiername"].ToString();
                s.Name = getVal(f["attributes"], "subnetworkname");        //f["attributes"]["subnetworkname"].ToString();
                _subnetworks.Add(s);
            }


            foreach (DomainNetwork d in DomainNetworks)
            {
                foreach (Tier t in d.Tiers)
                {
                    t.Subnetworks = _subnetworks.Where(s => s.TierName == t.Name && s.DomainNetworkName == t.DomainNetworkName).ToList <Subnetwork>();
                    foreach (Subnetwork s in t.Subnetworks)
                    {
                        s.Tier = t;
                    }
                }
            }
        }
示例#5
0
        /// <summary>
        /// validate the full extents of the utility network
        /// </summary>
        /// <returns></returns>
        public string ValidateNetworkTopology(string extent)
        {
            Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] Validate Network Topology ");
            UNWorkspace unworkspace        = UNWorkspace.getWorkspace();
            Dictionary <string, string> ps = new Dictionary <string, string>();

            string fullExtent = extent;

            ps.Add("validateArea", fullExtent);
            string  response           = unworkspace.Request(unworkspace.UNSServiceURL + "/validateNetworkTopology", ps);
            JObject subnetworkresponse = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(response);

            if (subnetworkresponse["success"].ToString() == "false")
            {
                Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] [Failed] Validate Network Topology");
            }

            else
            {
                Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] [Done] Validate Network Topology");
            }

            return(response);
        }