예제 #1
0
        //klik na dugme kod Get Extended Values
        private void button1_Click(object sender, EventArgs e)
        {
            ispis1.Text = string.Empty;
            tekst       = "";
            if (comboBox8.SelectedItem != null)
            {
                try
                {
                    string tip = (string)comboBox8.SelectedItem;

                    ModelCode tip2 = modelRD.GetModelCodeFromModelCodeName(tip);
                    List <ResourceDescription> rd = new List <ResourceDescription>();
                    foreach (long mc in pomocna)
                    {
                        rd.Add(gda.GetValues(mc));
                    }

                    foreach (ResourceDescription r in rd)
                    {
                        for (int i = 0; i < r.Properties.Count(); i++)
                        {
                            if (r.Properties[i].Id == tip2)
                            {
                                if (r.Properties[i].Type == PropertyType.ReferenceVector)
                                {
                                    if (r.Properties[i].AsLongs().Count > 0)
                                    {
                                        sb = new StringBuilder(100);
                                        for (int jj = 0; jj < r.Properties[i].AsLongs().Count; jj++)
                                        {
                                            sb.Append(String.Format("0x{0:x16}", r.Properties[i].AsLongs()[jj])).Append(", ");
                                        }

                                        ispis1.Text += sb.ToString(0, sb.Length - 2) + "\n";
                                    }
                                    else
                                    {
                                        ispis1.Text += "Empty reference vector" + "\n";
                                    }
                                }
                                else
                                {
                                    ispis1.Text += "Value:" + (r.Properties[i].GetValue() + "\n").ToString();
                                }
                            }
                        }
                    }
                    rd.Clear();
                    listaString.Clear();
                    distinct.Clear();
                }
                catch
                {
                    ispis1.Text = "ERROR";
                }
            }
        }
        private void GetResult()
        {
            var path = Directory.GetCurrentDirectory();

            path = Path.GetFullPath(Path.Combine(path, @"..\..\..\Results\"));

            //napravi XML fajl
            List <ModelCode> properties = new List <ModelCode>();

            foreach (var item in PropertiesView)
            {
                if (item.IsChecked)
                {
                    properties.Add(modelResourcesDesc.GetModelCodeFromModelCodeName(item.Name));
                }
            }

            try
            {
                //provera da li je validan gid
                short type = ModelCodeHelper.ExtractTypeFromGlobalId(g);

                var rd = GdaQueryProxy.GetValues(g, properties);
                if (rd != null)
                {
                    var xmlWriter = new XmlTextWriter(path + "GetValues_Results.xml", Encoding.Unicode);
                    xmlWriter.Formatting = Formatting.Indented;
                    rd.ExportToXml(xmlWriter);
                    xmlWriter.Flush();
                    xmlWriter.Close();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    string.IsNullOrEmpty(Gid)
                        ? "Please enter valid GID first"
                        : "Entered GID does't exists", "Warning",
                    MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            try
            {
                using (var reader = new StreamReader(path + "GetValues_Results.xml"))
                {
                    Result = reader.ReadToEnd();
                    return;
                }
            }
            catch (IOException)
            {
                MessageBox.Show("IO Exception");
                Result = "File not found";
                return;
            }
        }
        private void GetResult()
        {
            if (string.IsNullOrEmpty(ModelCode))
            {
                MessageBox.Show("You first have to load element!", "Warrning", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
            else
            {
                int         iteratorId = 0;
                List <long> ids        = new List <long>();

                int numberOfResources = 2;
                int resourcesLeft     = 0;

                if (mc == 0)
                {
                    MessageBox.Show("You didn't load element", "Warning", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds(mc);

                foreach (var item in PropertiesView)
                {
                    if (!item.IsChecked)
                    {
                        properties.Remove(modelResourcesDesc.GetModelCodeFromModelCodeName(item.Name));
                    }
                }

                iteratorId    = GdaQueryProxy.GetExtentValues(mc, properties);
                resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);

                var path = Directory.GetCurrentDirectory();
                path = Path.GetFullPath(Path.Combine(path, @"..\..\..\Results\"));

                var xmlWriter = new XmlTextWriter(path + "GetExtentValues_Results.xml", Encoding.Unicode);
                xmlWriter.Formatting = Formatting.Indented;

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

                    foreach (var t in rds)
                    {
                        ids.Add(t.Id);
                        t.ExportToXml(xmlWriter);
                        xmlWriter.Flush();
                    }

                    resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);
                }

                GdaQueryProxy.IteratorClose(iteratorId);
                xmlWriter.Close();

                try
                {
                    using (var reader = new StreamReader(path + "GetExtentValues_Results.xml"))
                    {
                        Result = reader.ReadToEnd();
                    }
                }
                catch (IOException)
                {
                    MessageBox.Show("IO Exception");
                    Result = "File was not found";
                    return;
                }
            }
        }