예제 #1
0
        private string FeaturesUploadRequest()
        {
            int vectorsCount;
            // nacitanie vektorov
            XmlDocument xmlVectors = new XmlDocument();

            xmlVectors.Load(string.Format("{0}/{1}", _biosandboxHome, _tmpDbXml));

            // nove xml pre request
            XmlDocument request     = new XmlDocument();
            XmlNode     requestRoot = request.AppendChild(request.CreateElement("Upload"));

            //  sparsovanie a vytvorenie noveho pre jedneho cloveka s vektormi
            XmlNode requestPerson = requestRoot.AppendChild(request.CreateElement("Person"));

            // pridanie elementu datas
            XmlNode      requestDatas     = requestPerson.AppendChild(request.CreateElement("Datas"));
            XmlAttribute requestDatasSize = requestDatas.Attributes.Append(request.CreateAttribute("size"));

            vectorsCount = xmlVectors.GetElementsByTagName("data").Count - 1;
            requestDatasSize.InnerText = vectorsCount.ToString();    // minus 1 preto, lebo jeden element data je pouzity v inom kontexte ako data trenovacieho vektoru

            // pridanie noveho mena
            XmlNode      requestName      = requestPerson.AppendChild(request.CreateElement("Name"));
            XmlAttribute requestNameValue = requestName.Attributes.Append(request.CreateAttribute("value"));

            requestNameValue.InnerText = _trainName;

            // pridanie vektorov
            for (int i = 0; i < vectorsCount; i++)
            {
                XmlNode vector       = xmlVectors.GetElementsByTagName(string.Format("features_{0}", i)).Item(0);
                string  personVector = Tools.CleanVectorString(vector.LastChild.InnerText);

                // pridanie vektoru
                XmlNode requestData = requestDatas.AppendChild(request.CreateElement("Data"));
                requestData.InnerText = personVector;
            }

            string requestString = request.OuterXml;

            ServiceReference3.recognitionwsdlPortType client = new ServiceReference3.recognitionwsdlPortTypeClient();
            return(client.uploadAndTest("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + requestString));
        }
예제 #2
0
        private string FeaturesUploadRequest(bool isUdfFca1Checked)
        {
            int vectorsCount;
            // nacitanie vektorov
            XmlDocument xmlVectors = new XmlDocument();

            xmlVectors.Load(string.Format("{0}/{1}", _biosandboxHome, _tmpDbXml));

            // nove xml pre request
            XmlDocument request     = new XmlDocument();
            XmlNode     requestRoot = request.AppendChild(request.CreateElement("Test"));

            // pridanie elementu datas
            // minus 1 preto, lebo jeden element data je pouzity v inom kontexte ako data trenovacieho vektoru
            vectorsCount = xmlVectors.GetElementsByTagName("data").Count - 1;

            // pridanie vektorov
            for (int i = 0; i < vectorsCount; i++)
            {
                XmlNode vector       = xmlVectors.GetElementsByTagName(string.Format("features_{0}", i)).Item(0);
                string  personVector = Tools.CleanVectorString(vector.LastChild.InnerText);

                // pridanie vektoru
                XmlNode requestData = requestRoot.AppendChild(request.CreateElement("Vector"));
                requestData.InnerText = personVector;
                XmlAttribute id = requestData.Attributes.Append(request.CreateAttribute("id"));
                id.InnerText = i.ToString();
            }

            string requestString = request.OuterXml;

            ServiceReference3.recognitionwsdlPortType client = new ServiceReference3.recognitionwsdlPortTypeClient();
            //_textBox.Text += Tools.GetLogMessage("Start sending content to server");
            if (isUdfFca1Checked)
            {
                return(client.udfRecognitionTest("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + requestString));
            }
            else
            {
                return(client.udfRecognitionTest2("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + requestString));
            }
        }