Example #1
0
        private static ModelCode InputModelCode()
        {
            CommonTrace.WriteTrace(CommonTrace.TraceVerbose, "Entering Model Code started.");

            try
            {
                Console.Write("Enter Model Code: ");
                string    userModelCode = Console.ReadLine();
                ModelCode modelCode     = 0;

                if (!ModelCodeHelper.GetModelCodeFromString(userModelCode, out modelCode))
                {
                    if (userModelCode.StartsWith("0x", StringComparison.Ordinal))
                    {
                        modelCode = (ModelCode)long.Parse(userModelCode.Substring(2), System.Globalization.NumberStyles.HexNumber);
                    }
                    else
                    {
                        modelCode = (ModelCode)long.Parse(userModelCode);
                    }
                }

                return(modelCode);
            }
            catch (Exception ex)
            {
                string message = string.Format("Entering Model Code failed. {0}", ex);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
                Console.WriteLine(message);
                throw ex;
            }
        }
        private void FindPropertyModelCode(ModelCode property)
        {
            string[] props = (property.ToString()).Split('_');

            props[1] = props[1].TrimEnd('S');
            DMSType propertyCode = ModelResourcesDesc.GetTypeFromModelCode(property);
            // DMSType propertyCode = ModelCodeHelper.GetDMSTypeFromString(property);

            ModelCode mc;

            ModelCodeHelper.GetModelCodeFromString(propertyCode.ToString(), out mc);

            foreach (ModelCode modelCode in Enum.GetValues(typeof(ModelCode)))
            {
                if ((String.Compare(modelCode.ToString(), mc.ToString()) != 0) && (String.Compare(property.ToString(), modelCode.ToString()) != 0) && (String.Compare(props[1], modelCode.ToString())) == 0)
                {
                    DMSType type = ModelCodeHelper.GetTypeFromModelCode(modelCode);
                    if (type == 0)
                    {
                        FindChildren(modelCode);
                    }
                    else
                    {
                        childrenType = new List <ModelCode>();
                        childrenType.Add(modelCode);
                    }
                }
            }
        }
Example #3
0
        public override void Execute(object parameter)
        {
            if (parameter == null || !(parameter is Object[]))
            {
                MessageBox.Show("All fields are required.");
                return;
            }

            long             globalId;
            List <ModelCode> m = new List <ModelCode>();

            try
            {
                Object[] parameters = parameter as Object[];
                globalId = (long)parameters[0];

                IList i          = (IList)parameters[1];
                var   properties = i.Cast <ModelCodeWrapper>();

                foreach (var item in properties)
                {
                    ModelCode mc1;
                    ModelCodeHelper.GetModelCodeFromString((item.ModelCode).ToString(), out mc1);
                    m.Add(mc1);
                }
            }
            catch
            {
                MessageBox.Show("All fields are required.");
                return;
            }

            ObservableCollection <ResourceDescriptionWrapper> ocRd = new ObservableCollection <ResourceDescriptionWrapper>();

            try
            {
                ResourceDescription rd = Connection.Connection.Instance().GetValues(globalId, m);

                var modelCodeString = ((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(rd.Id)).ToString();

                ModelCode modelCode;
                ModelCodeHelper.GetModelCodeFromString(modelCodeString, out modelCode);
                string temp = String.Format("0x{0:x16}", (rd.Id));
                ResourceDescriptionWrapper rdw = new ResourceDescriptionWrapper(modelCodeString, temp);
                ocRd.Add(rdw);

                foreach (var prop in rd.Properties)
                {
                    ResourceDescriptionWrapper rdw1 = new ResourceDescriptionWrapper((prop.Id).ToString(), prop.ToString());
                    ocRd.Add(rdw1);
                }
            }
            catch
            {
                MessageBox.Show("Service host is not started.");
            }

            vm.ResourceDescription = ocRd;
        }
Example #4
0
        private static Association InputAssociation()
        {
            CommonTrace.WriteTrace(CommonTrace.TraceVerbose, "Entering association started.");
            Association association = new Association();

            try
            {
                Console.Write("Entering  association\n");

                Console.Write("Enter propertyId: ");

                string    userModelCode = Console.ReadLine();
                ModelCode modelCode     = 0;

                if (!ModelCodeHelper.GetModelCodeFromString(userModelCode, out modelCode))
                {
                    if (userModelCode.StartsWith("0x", StringComparison.Ordinal))
                    {
                        modelCode = (ModelCode)long.Parse(userModelCode.Substring(2), System.Globalization.NumberStyles.HexNumber);
                    }
                    else
                    {
                        modelCode = (ModelCode)long.Parse(userModelCode);
                    }
                }

                association.PropertyId = modelCode;

                Console.Write("Enter type: ");

                userModelCode = Console.ReadLine();
                modelCode     = 0;

                if (!ModelCodeHelper.GetModelCodeFromString(userModelCode, out modelCode))
                {
                    if (userModelCode.StartsWith("0x", StringComparison.Ordinal))
                    {
                        modelCode = (ModelCode)long.Parse(userModelCode.Substring(2), System.Globalization.NumberStyles.HexNumber);
                    }
                    else
                    {
                        modelCode = (ModelCode)long.Parse(userModelCode);
                    }
                }

                association.Type = modelCode;

                return(association);
            }
            catch (Exception ex)
            {
                string message = string.Format("Entering association failed. {0}", ex);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
                Console.WriteLine(message);
                throw ex;
            }
        }
        private void comboBoxSourceReference3_SelectedIndexChanged(object sender, EventArgs e)
        {
            buttonQuery3.Enabled = false;
            listBoxProperties3.Items.Clear();
            comboBoxTargetType3.Items.Clear();
            comboBoxTargetType3.Enabled = false;
            ModelCodeHelper.GetModelCodeFromString(comboBoxSourceReference3.SelectedItem.ToString(), out ModelCode modelCode);
            List <DMSType> types = new List <DMSType>();

            switch (modelCode)
            {
            case ModelCode.CONDUCTINGEQUIPMENT_TERMINALS:
                types.Add(DMSType.TERMINAL);
                break;

            case ModelCode.CONTROL_REGULATINGCONDEQ:
                types.AddRange(modelResourcesDesc.GetLeaves(ModelCode.REGULATINGCONDEQ));
                break;

            case ModelCode.CURVEDATA_CURVE:
                types.AddRange(modelResourcesDesc.GetLeaves(ModelCode.CURVE));
                break;

            case ModelCode.CURVE_CURVEDATAS:
                types.Add(DMSType.CURVEDATA);
                break;

            case ModelCode.REACTIVECAPABILITYCURVE_SYNCHRONOUSMACHINES:
                types.Add(DMSType.SYNCHRONOUSMACHINE);
                break;

            case ModelCode.REGULATINGCONDEQ_CONTROLS:
                types.Add(DMSType.CONTROL);
                break;

            case ModelCode.REGULATINGCONTROL_TERMINAL:
                types.Add(DMSType.TERMINAL);
                break;

            case ModelCode.SYNCHRONOUSMACHINE_REACTIVECAPABILITYCURVES:
                types.Add(DMSType.REACTIVECAPABILITYCURVE);
                break;

            case ModelCode.TERMINAL_CONDUCTINGEQUIPMENT:
                types.AddRange(modelResourcesDesc.GetLeaves(ModelCode.CONDUCTINGEQUIPMENT));
                break;

            case ModelCode.TERMINAL_REGULATINGCONTROL:
                types.Add(DMSType.REGULATINGCONTROL);
                break;
            }
            object[] typeCollection = types.Select(t => (object)t).ToArray();
            comboBoxTargetType3.Items.Add("ANY");
            comboBoxTargetType3.Items.AddRange(typeCollection);
            comboBoxTargetType3.Enabled = true;
        }
Example #6
0
        private void comboBoxTargetType2_SelectedIndexChanged(object sender, EventArgs e)
        {
            listBoxProperties2.Items.Clear();
            ModelCodeHelper.GetModelCodeFromString(comboBoxTargetType2.SelectedItem.ToString(), out ModelCode modelCode);
            List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds(modelCode);

            object[] propertyCollection = properties.Select(p => (object)p).ToArray();
            listBoxProperties2.Items.AddRange(propertyCollection);
            buttonQuery2.Enabled = true;
        }
        private void buttonQuery3_Click(object sender, EventArgs e)
        {
            richTextBoxOutput.Text = string.Empty;
            long        source      = Convert.ToInt64(textBoxSourceGID3.Text, 16);
            Association association = new Association();

            ModelCodeHelper.GetModelCodeFromString(comboBoxSourceReference3.SelectedItem.ToString(), out ModelCode propertyID);
            association.PropertyId = propertyID;
            if (comboBoxTargetType3.SelectedItem.ToString() == "ANY")
            {
                association.Type = 0;
            }
            else
            {
                ModelCodeHelper.GetModelCodeFromString(comboBoxTargetType3.SelectedItem.ToString(), out ModelCode type);
                association.Type = type;
            }
            List <ModelCode> propertyIDs = new List <ModelCode>();

            foreach (object selectedItem in listBoxProperties3.SelectedItems)
            {
                ModelCodeHelper.GetModelCodeFromString(selectedItem.ToString(), out ModelCode modelCode);
                propertyIDs.Add(modelCode);
            }
            try
            {
                NetworkModelGDAProxy networkModelGDAProxy = new NetworkModelGDAProxy("NetworkModelGDAEndpoint");
                int iteratorID    = networkModelGDAProxy.GetRelatedValues(source, propertyIDs, association);
                int resourcesLeft = networkModelGDAProxy.IteratorResourcesLeft(iteratorID);
                List <ResourceDescription> resourceDescriptions = null;
                using (StringWriter stringWriter = new StringWriter())
                    using (XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter))
                    {
                        xmlTextWriter.Formatting = Formatting.Indented;
                        while (resourcesLeft > 0)
                        {
                            resourceDescriptions = networkModelGDAProxy.IteratorNext(numberOfResources, iteratorID);
                            foreach (ResourceDescription resourceDescription in resourceDescriptions)
                            {
                                resourceDescription.ExportToXml(xmlTextWriter);
                                stringWriter.Write(stringWriter.NewLine);
                            }
                            resourcesLeft = networkModelGDAProxy.IteratorResourcesLeft(iteratorID);
                        }
                        richTextBoxOutput.Text = stringWriter.ToString();
                    }
                networkModelGDAProxy.IteratorClose(iteratorID);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Get Related Values - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #8
0
        public List <long> FindIds(DMSType chosenDMSType)
        {
            ModelCode mc;

            ModelCodeHelper.GetModelCodeFromString(chosenDMSType.ToString(), out mc);
            List <ModelCode>           properties = Connection.Connection.Instance().ModelResourceDesc.GetAllPropertyIds(chosenDMSType);
            List <ResourceDescription> rds        = Connection.Connection.Instance().GetExtentValues(mc, properties);

            List <long> ids = new List <long>();

            foreach (ResourceDescription rd in rds)
            {
                ids.Add(rd.Id);
            }

            return(ids);
        }
Example #9
0
        public override void Execute(object parameter)
        {
            if (parameter == null || !(parameter is Object[]))
            {
                return;
            }

            Object[] parameters = parameter as Object[];

            if (parameters == null || parameters[0] == null || parameters[1] == null)
            {
                return;
            }

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

            System.Collections.IList i = (System.Collections.IList)parameters[1];
            var       propertyModels   = i.Cast <PropertyModel>();
            ModelCode modelCode;

            if (!ModelCodeHelper.GetModelCodeFromString(parameters[0].ToString(), out modelCode))
            {
                return;
            }

            foreach (var propertyModel in propertyModels)
            {
                properties.Add(propertyModel.ModelCode);
            }

            List <ResourceDescription> resourceDescritions = GetExtentValues(modelCode, properties);

            List <PropertyView> propertyViews = new List <PropertyView>();

            foreach (ResourceDescription rd in resourceDescritions)
            {
                string gidString = String.Format("GID: 0x{0:x16}", rd.Id);
                propertyViews.Add(new PropertyView(modelCode, gidString));
                foreach (Property p  in rd.Properties)
                {
                    propertyViews.Add(new PropertyView(p.Id, p.ToString()));
                }
                propertyViews.Add(new PropertyView());
            }
            viewModel.ObjectValue = new ObservableCollection <PropertyView>(propertyViews); //
        }
        public void Load()
        {
            PropertiesView.Clear();
            //model code bude npr system.controls.combobox.nesto: protswitch, pa zato moramo da parsiramo
            try
            {
                var parsedString = ModelCode.Split(':');
                ModelCode = parsedString[1];
            }
            catch (Exception)
            {
                MessageBox.Show("Choose valid Model Code from list first", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            mc = 0;
            try
            {
                if (!ModelCodeHelper.GetModelCodeFromString(ModelCode, out mc))
                {
                    if (ModelCode.StartsWith("0x", StringComparison.Ordinal))
                    {
                        mc = (ModelCode)long.Parse(ModelCode.Substring(2), System.Globalization.NumberStyles.HexNumber);
                    }
                    else
                    {
                        mc = (ModelCode)long.Parse(ModelCode);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Chosen Model Code is not valid", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                getExtendedValuesView.tbModelCode.Focus();
                return;
            }

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

            foreach (var item in properties)
            {
                PropertiesView.Add(new PopertyView(item.ToString(), true));
            }
        }
Example #11
0
        private List <ModelCode> NadjiTipove(ModelCode kodProp)
        {
            ModelResourcesDesc modResDes = new ModelResourcesDesc();

            //List<DMSType> tip = new List<DMSType>();

            string[] props = (kodProp.ToString()).Split('_');
            props[1] = props[1].TrimEnd('S');

            DMSType propertyCode = ModelResourcesDesc.GetTypeFromModelCode(kodProp);


            ModelCode mc;

            ModelCodeHelper.GetModelCodeFromString(propertyCode.ToString(), out mc);

            foreach (ModelCode modelCode in Enum.GetValues(typeof(ModelCode)))
            {
                if (String.Compare(props[1], modelCode.ToString()) == 0)
                {
                    DMSType type = ModelCodeHelper.GetTypeFromModelCode(modelCode);
                    if (type == 0)
                    {
                        tipovi = new List <ModelCode>();
                        List <DMSType> r = modResDes.GetLeaves(modelCode);
                        foreach (DMSType ff in r)
                        {
                            tipovi.Add(modResDes.GetModelCodeFromType(ff));
                        }
                    }
                    else
                    {
                        tipovi = new List <ModelCode>();
                        tipovi.Add(modelCode);
                    }
                }
            }


            return(new List <ModelCode>());
        }
Example #12
0
        private void buttonQuery2_Click(object sender, EventArgs e)
        {
            richTextBoxOutput.Text = string.Empty;
            ModelCodeHelper.GetModelCodeFromString(comboBoxTargetType2.SelectedItem.ToString(), out ModelCode entityType);
            List <ModelCode> propertyIDs = new List <ModelCode>();

            foreach (object selectedItem in listBoxProperties2.SelectedItems)
            {
                ModelCodeHelper.GetModelCodeFromString(selectedItem.ToString(), out ModelCode modelCode);
                propertyIDs.Add(modelCode);
            }
            try
            {
                NetworkModelGDAProxy networkModelGDAProxy = new NetworkModelGDAProxy("NetworkModelGDAEndpoint");
                int iteratorID    = networkModelGDAProxy.GetExtentValues(entityType, propertyIDs);
                int resourcesLeft = networkModelGDAProxy.IteratorResourcesLeft(iteratorID);
                List <ResourceDescription> resourceDescriptions = null;
                using (StringWriter stringWriter = new StringWriter())
                    using (XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter))
                    {
                        xmlTextWriter.Formatting = Formatting.Indented;
                        while (resourcesLeft > 0)
                        {
                            resourceDescriptions = networkModelGDAProxy.IteratorNext(numberOfResources, iteratorID);
                            foreach (ResourceDescription resourceDescription in resourceDescriptions)
                            {
                                resourceDescription.ExportToXml(xmlTextWriter);
                            }
                            resourcesLeft = networkModelGDAProxy.IteratorResourcesLeft(iteratorID);
                        }
                        richTextBoxOutput.Text = stringWriter.ToString();
                    }
                networkModelGDAProxy.IteratorClose(iteratorID);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Get Extent Values - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #13
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            if (cb3.SelectedIndex == -1 || cb32.SelectedIndex == -1)
            {
                tb.Text = "Error";
            }
            else
            {
                KeyValuePair <long, ModelCode> kvp = (KeyValuePair <long, ModelCode>)cb3.SelectedValue;

                Association a = new Association();
                a.PropertyId = (ModelCode)cb32.SelectedValue;
                ModelCode mc;
                ModelCodeHelper.GetModelCodeFromString(cb33.Text, out mc);
                a.Type = mc;

                if (izabraniProperty.Count == 0)
                {
                    izabraniProperty = Program.t.GetAllProperty(mc);
                    Program.t.GetRelatedValues(kvp.Key, a, izabraniProperty);
                }
                else
                {
                    Program.t.GetRelatedValues(kvp.Key, a, izabraniProperty);
                }

                tb.Text = File.ReadAllText(Config.Instance.ResultDirecotry + "\\GetRelatedValues_Results.xml");
            }

            izabraniProperty  = new List <ModelCode>();
            cb3.SelectedValue = null;
            cb32.ItemsSource  = null;
            lb3.ItemsSource   = null;
            cb32.IsEnabled    = false;
            tb3.Text          = "";
        }
        private void comboBoxTargetType3_SelectedIndexChanged(object sender, EventArgs e)
        {
            buttonQuery3.Enabled = false;
            listBoxProperties3.Items.Clear();
            List <ModelCode> properties = new List <ModelCode>();

            if (comboBoxTargetType3.SelectedItem.ToString() == "ANY")
            {
                ModelCodeHelper.GetModelCodeFromString(comboBoxSourceReference3.SelectedItem.ToString(), out ModelCode modelCode);
                switch (modelCode)
                {
                case ModelCode.CONDUCTINGEQUIPMENT_TERMINALS:
                    modelCode = ModelCode.TERMINAL;
                    break;

                case ModelCode.CONTROL_REGULATINGCONDEQ:
                    modelCode = ModelCode.REGULATINGCONDEQ;
                    break;

                case ModelCode.CURVEDATA_CURVE:
                    modelCode = ModelCode.CURVE;
                    break;

                case ModelCode.CURVE_CURVEDATAS:
                    modelCode = ModelCode.CURVEDATA;
                    break;

                case ModelCode.REACTIVECAPABILITYCURVE_SYNCHRONOUSMACHINES:
                    modelCode = ModelCode.SYNCHRONOUSMACHINE;
                    break;

                case ModelCode.REGULATINGCONDEQ_CONTROLS:
                    modelCode = ModelCode.CONTROL;
                    break;

                case ModelCode.REGULATINGCONTROL_TERMINAL:
                    modelCode = ModelCode.TERMINAL;
                    break;

                case ModelCode.SYNCHRONOUSMACHINE_REACTIVECAPABILITYCURVES:
                    modelCode = ModelCode.REACTIVECAPABILITYCURVE;
                    break;

                case ModelCode.TERMINAL_CONDUCTINGEQUIPMENT:
                    modelCode = ModelCode.CONDUCTINGEQUIPMENT;
                    break;

                case ModelCode.TERMINAL_REGULATINGCONTROL:
                    modelCode = ModelCode.REGULATINGCONTROL;
                    break;
                }
                List <DMSType> types = modelResourcesDesc.GetLeaves(modelCode);
                Dictionary <ModelCode, int> propertyCount = new Dictionary <ModelCode, int>();
                foreach (DMSType type in types)
                {
                    List <ModelCode> typeProperties = modelResourcesDesc.GetAllPropertyIds(type);
                    foreach (ModelCode property in typeProperties)
                    {
                        if (!propertyCount.ContainsKey(property))
                        {
                            propertyCount.Add(property, 0);
                        }
                        propertyCount[property]++;
                        if (propertyCount[property] == types.Count)
                        {
                            properties.Add(property);
                        }
                    }
                }
            }
            else
            {
                ModelCodeHelper.GetModelCodeFromString(comboBoxTargetType3.SelectedItem.ToString(), out ModelCode modelCode);
                properties.AddRange(modelResourcesDesc.GetAllPropertyIds(modelCode));
            }
            object[] propertyCollection = properties.Select(p => (object)p).ToArray();
            listBoxProperties3.Items.AddRange(propertyCollection);
            buttonQuery3.Enabled = true;
        }
        public override void Execute(object parameter)
        {
            if (parameter == null || !(parameter is Object[]))
            {
                MessageBox.Show("All fields are required.");
                return;
            }

            ModelCode        sourceModelCode;
            long             sourceGid;
            ModelCode        referenceModelCode;
            ModelCode        childrenModelCode;
            List <ModelCode> m = new List <ModelCode>(); //propeetiji

            try
            {
                Object[] parameters = parameter as Object[];

                ModelCodeHelper.GetModelCodeFromString(parameters[0].ToString(), out sourceModelCode);

                sourceGid = (long)(parameters[1]);

                ModelCodeHelper.GetModelCodeFromString(parameters[2].ToString(), out referenceModelCode);

                ModelCodeHelper.GetModelCodeFromString(parameters[3].ToString(), out childrenModelCode);

                IList i          = (IList)parameters[4];
                var   properties = i.Cast <ModelCodeWrapper>();

                foreach (var item in properties)
                {
                    ModelCode mc1;
                    ModelCodeHelper.GetModelCodeFromString((item.ModelCode).ToString(), out mc1);
                    m.Add(mc1);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("All fields are required.");
                return;
            }

            Association association = new Association();

            association.PropertyId = referenceModelCode;
            association.Type       = childrenModelCode;

            List <ResourceDescription> retVal = new List <ResourceDescription>();
            ObservableCollection <ResourceDescriptionWrapper> ocRd = new ObservableCollection <ResourceDescriptionWrapper>();

            try
            {
                retVal = Connection.Connection.Instance().GetRelatedValues(sourceGid, m, association);
                //ocRd = new ObservableCollection<ResourceDescriptionWrapper>();

                foreach (var item in retVal)
                {
                    var modelCodeString = ((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(item.Id)).ToString();

                    ModelCode modelCode;
                    ModelCodeHelper.GetModelCodeFromString(modelCodeString, out modelCode);
                    string temp = String.Format("0x{0:x16}", (item.Id));
                    ResourceDescriptionWrapper rdw = new ResourceDescriptionWrapper(modelCodeString, temp);
                    ocRd.Add(rdw);

                    foreach (var prop in item.Properties)
                    {
                        string s = prop.ToString();
                        ResourceDescriptionWrapper rdw1 = new ResourceDescriptionWrapper((prop.Id).ToString(), s);
                        ocRd.Add(rdw1);
                    }
                    ResourceDescriptionWrapper empty = new ResourceDescriptionWrapper();
                    ocRd.Add(empty);
                }
            }
            catch
            {
                MessageBox.Show("Service host is not started.");
            }

            vm.ResourceDescriptions = ocRd;
        }