Exemple #1
0
        public List <long> GetExtentValues(ModelCode modelCodeType, List <ModelCode> properties, StringBuilder sb)
        {
            var message = "Getting extent values method started.";

            CommonTrace.WriteTrace(CommonTrace.TraceError, message);

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

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

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

                    foreach (var rd in rds)
                    {
                        if (rd == null)
                        {
                            continue;
                        }
                        tempSb.Append($"\nEntity with gid: 0x{rd.Id:X16}" + Environment.NewLine);

                        foreach (var property in rd.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;

                            case PropertyType.Enum:
                                StringAppender.AppendEnum(tempSb, property);
                                break;

                            case PropertyType.DateTime:
                                StringAppender.AppendDateTime(tempSb, property);
                                break;

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

                        ids.Add(rd.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);
        }
Exemple #2
0
        private void Button_Click_GetValues(object sender, RoutedEventArgs e)
        {
            if (selectedGID == -1)
            {
                return;
            }

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

            foreach (var child in Properties.Children)
            {
                if (!(child is CheckBox checkBox))
                {
                    continue;
                }
                if (!checkBox.IsChecked.Value)
                {
                    continue;
                }

                foreach (KeyValuePair <ModelCode, string> keyValuePair in propertiesDesc)
                {
                    if (keyValuePair.Value.Equals(checkBox.Content))
                    {
                        selectedProperties.Add(keyValuePair.Key);
                    }
                }
            }

            ResourceDescription rd = null;

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

            if (rd == null)
            {
                return;
            }

            var 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;

                case PropertyType.DateTime:
                    StringAppender.AppendDateTime(sb, property);
                    break;

                case PropertyType.Enum:
                    StringAppender.AppendEnum(sb, property);
                    break;

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

            Values.Clear();
            Values.AppendText(sb.ToString());
        }
Exemple #3
0
        public List <long> GetRelatedValues(long sourceGlobalId, List <ModelCode> properties, Association association, StringBuilder sb)
        {
            var message = "Getting related values method started.";

            CommonTrace.WriteTrace(CommonTrace.TraceError, message);

            int iteratorId        = 0;
            int resourcesLeft     = 0;
            int numberOfResources = 500;
            var resultIds         = new List <long>();
            var tempSb            = new StringBuilder();

            try
            {
                iteratorId    = GdaQueryProxy.GetRelatedValues(sourceGlobalId, properties, association);
                resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);

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

                    foreach (var rd in rds)
                    {
                        if (rd == null)
                        {
                            continue;
                        }
                        tempSb.Append($"\nEntity with gid: 0x{rd.Id:X16}" + Environment.NewLine);

                        foreach (Property property in rd.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;

                            case PropertyType.Enum:
                                StringAppender.AppendEnum(tempSb, property);
                                break;

                            case PropertyType.DateTime:
                                StringAppender.AppendDateTime(tempSb, property);
                                break;

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

                        resultIds.Add(rd.Id);
                    }

                    resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);
                }

                GdaQueryProxy.IteratorClose(iteratorId);

                message = "Getting related values method successfully finished.";
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }
            catch (Exception e)
            {
                message =
                    $"Getting related values method  failed for sourceGlobalId = {sourceGlobalId} and association (propertyId = {association.PropertyId}, type = {association.Type}). Reason: {e.Message}";
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }

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

            return(resultIds);
        }