private void ButtonGetValues_Click(object sender, RoutedEventArgs e)
        {
            if (SelectedGID == null)
            {
                return;
            }

            List <ModelCode> selectedProperties = new List <ModelCode>();

            foreach (var child in Properties.Children)
            {
                if (child is CheckBox checkBox)
                {
                    if (checkBox.IsChecked.Value)
                    {
                        foreach (KeyValuePair <ModelCode, string> keyValuePair in propertiesDesc)
                        {
                            if (keyValuePair.Value.Equals(checkBox.Content))
                            {
                                selectedProperties.Add(keyValuePair.Key);
                            }
                        }
                    }
                }
            }
            ResourceDescription rd = null;

            try
            {
                rd = tgda.GetValues(SelectedGID.GID, selectedProperties);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "GetValues", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            if (rd != null)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("Returned entity" + Environment.NewLine + Environment.NewLine);
                sb.Append($"Entity with gid: 0x{rd.Id:X16}" + Environment.NewLine);

                foreach (Property property in rd.Properties)
                {
                    switch (property.Type)
                    {
                    case PropertyType.Int64:
                        StringAppender.AppendLong(sb, property);
                        break;

                    case PropertyType.Float:
                        StringAppender.AppendFloat(sb, property);
                        break;

                    case PropertyType.String:
                        StringAppender.AppendString(sb, property);
                        break;

                    case PropertyType.Reference:
                        StringAppender.AppendReference(sb, property);
                        break;

                    case PropertyType.ReferenceVector:
                        StringAppender.AppendReferenceVector(sb, property);
                        break;

                    default:
                        sb.Append($"{property.Id}: {property.PropertyValue.LongValue}{Environment.NewLine}");
                        break;
                    }
                }

                Values.Document.Blocks.Clear();
                Values.AppendText(sb.ToString());
            }
        }
Beispiel #2
0
        public async Task <List <long> > GetExtentValues(ModelCode modelCodeType, List <ModelCode> properties, StringBuilder sb)
        {
            string message = "Getting extent values method started.";

            Logger.LogInformation(message);

            int           iteratorId;
            int           resourcesLeft;
            int           numberOfResources = 300;
            List <long>   ids    = new List <long>();
            StringBuilder tempSb = new StringBuilder();

            try
            {
                var nmsClient = NetworkModelGdaClient.CreateClient();

                if (nmsClient == null)
                {
                    string errMsg = "NetworkModelGdaClient is null.";
                    Logger.LogWarning(errMsg);
                    throw new NullReferenceException(errMsg);
                }

                iteratorId = await nmsClient.GetExtentValues(modelCodeType, properties);

                resourcesLeft = await nmsClient.IteratorResourcesLeft(iteratorId);

                while (resourcesLeft > 0)
                {
                    List <ResourceDescription> rds = await nmsClient.IteratorNext(numberOfResources, iteratorId);

                    for (int i = 0; i < rds.Count; i++)
                    {
                        if (rds[i] == null)
                        {
                            continue;
                        }

                        tempSb.Append($"Entity with gid: 0x{rds[i].Id:X16}" + Environment.NewLine);

                        foreach (Property property in rds[i].Properties)
                        {
                            switch (property.Type)
                            {
                            case PropertyType.Int64:
                                StringAppender.AppendLong(tempSb, property);
                                break;

                            case PropertyType.Float:
                                StringAppender.AppendFloat(tempSb, property);
                                break;

                            case PropertyType.String:
                                StringAppender.AppendString(tempSb, property);
                                break;

                            case PropertyType.Reference:
                                StringAppender.AppendReference(tempSb, property);
                                break;

                            case PropertyType.ReferenceVector:
                                StringAppender.AppendReferenceVector(tempSb, property);
                                break;

                            default:
                                tempSb.Append($"{property.Id}: {property.PropertyValue.LongValue}{Environment.NewLine}");
                                break;
                            }
                        }

                        ids.Add(rds[i].Id);
                    }

                    resourcesLeft = await nmsClient.IteratorResourcesLeft(iteratorId);
                }

                await nmsClient.IteratorClose(iteratorId);

                message = "Getting extent values method SUCCESSFULLY finished.";
                Logger.LogInformation(message);
            }
            catch (Exception e)
            {
                message = string.Format("Getting extent values method failed for {0}.\n\t{1}", modelCodeType, e.Message);
                Logger.LogError(message);
            }

            if (sb != null)
            {
                sb.Append(tempSb.ToString());
            }

            return(ids);
        }
Beispiel #3
0
        public List <long> GetExtentValues(ModelCode modelCodeType, List <ModelCode> properties, StringBuilder sb)
        {
            string message = "Getting extent values method started.";

            Logger.LogInfo(message);

            int           iteratorId;
            int           resourcesLeft;
            int           numberOfResources = 300;
            List <long>   ids    = new List <long>();
            StringBuilder tempSb = new StringBuilder();

            try
            {
                using (NetworkModelGDAProxy gdaQueryProxy = proxyFactory.CreateProxy <NetworkModelGDAProxy, INetworkModelGDAContract>(EndpointNames.NetworkModelGDAEndpoint))
                {
                    if (gdaQueryProxy == null)
                    {
                        string errMsg = "NetworkModelGDAProxy is null.";
                        Logger.LogWarn(errMsg);
                        throw new NullReferenceException(errMsg);
                    }

                    iteratorId    = gdaQueryProxy.GetExtentValues(modelCodeType, properties);
                    resourcesLeft = gdaQueryProxy.IteratorResourcesLeft(iteratorId);

                    while (resourcesLeft > 0)
                    {
                        List <ResourceDescription> rds = gdaQueryProxy.IteratorNext(numberOfResources, iteratorId);

                        for (int i = 0; i < rds.Count; i++)
                        {
                            if (rds[i] != null)
                            {
                                tempSb.Append($"Entity with gid: 0x{rds[i].Id:X16}" + Environment.NewLine);

                                foreach (Property property in rds[i].Properties)
                                {
                                    switch (property.Type)
                                    {
                                    case PropertyType.Int64:
                                        StringAppender.AppendLong(tempSb, property);
                                        break;

                                    case PropertyType.Float:
                                        StringAppender.AppendFloat(tempSb, property);
                                        break;

                                    case PropertyType.String:
                                        StringAppender.AppendString(tempSb, property);
                                        break;

                                    case PropertyType.Reference:
                                        StringAppender.AppendReference(tempSb, property);
                                        break;

                                    case PropertyType.ReferenceVector:
                                        StringAppender.AppendReferenceVector(tempSb, property);
                                        break;

                                    default:
                                        tempSb.Append($"{property.Id}: {property.PropertyValue.LongValue}{Environment.NewLine}");
                                        break;
                                    }
                                }
                            }
                            ids.Add(rds[i].Id);
                        }
                        resourcesLeft = gdaQueryProxy.IteratorResourcesLeft(iteratorId);
                    }

                    gdaQueryProxy.IteratorClose(iteratorId);

                    message = "Getting extent values method successfully finished.";
                    Logger.LogInfo(message);
                }
            }
            catch (Exception e)
            {
                message = string.Format("Getting extent values method failed for {0}.\n\t{1}", modelCodeType, e.Message);
                Logger.LogError(message);
            }

            if (sb != null)
            {
                sb.Append(tempSb.ToString());
            }

            return(ids);
        }
Beispiel #4
0
        public List <long> GetExtentValues(ModelCode modelCodeType, List <ModelCode> properties, StringBuilder sb)
        {
            string message = "Getting extent values method started.";

            CommonTrace.WriteTrace(CommonTrace.TraceError, message);

            int           iteratorId        = 0;
            int           resourcesLeft     = 0;
            int           numberOfResources = 300;
            List <long>   ids    = new List <long>();
            StringBuilder tempSb = new StringBuilder();

            try
            {
                iteratorId    = GdaQueryProxy.GetExtentValues(modelCodeType, properties);
                resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);

                while (resourcesLeft > 0)
                {
                    List <ResourceDescription> rds = GdaQueryProxy.IteratorNext(numberOfResources, iteratorId);

                    for (int i = 0; i < rds.Count; i++)
                    {
                        if (rds[i] != null)
                        {
                            tempSb.Append($"Entity with gid: 0x{rds[i].Id:X16}" + Environment.NewLine);

                            foreach (Property property in rds[i].Properties)
                            {
                                switch (property.Type)
                                {
                                case PropertyType.Int64:
                                    StringAppender.AppendLong(tempSb, property);
                                    break;

                                case PropertyType.Float:
                                    StringAppender.AppendFloat(tempSb, property);
                                    break;

                                case PropertyType.String:
                                    StringAppender.AppendString(tempSb, property);
                                    break;

                                case PropertyType.Reference:
                                    StringAppender.AppendReference(tempSb, property);
                                    break;

                                case PropertyType.ReferenceVector:
                                    StringAppender.AppendReferenceVector(tempSb, property);
                                    break;

                                default:
                                    tempSb.Append($"{property.Id}: {property.PropertyValue.LongValue}{Environment.NewLine}");
                                    break;
                                }
                            }
                        }
                        ids.Add(rds[i].Id);
                    }
                    resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);
                }
                GdaQueryProxy.IteratorClose(iteratorId);

                message = "Getting extent values method successfully finished.";
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }
            catch (Exception e)
            {
                message = string.Format("Getting extent values method failed for {0}.\n\t{1}", modelCodeType, e.Message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }

            if (sb != null)
            {
                sb.Append(tempSb.ToString());
            }

            return(ids);
        }