Esempio n. 1
0
        private static ErrorStatus ReadCode(System.Xml.XmlReader reader)
        {
            ErrorStatus status = new ErrorStatus();

            reader.MoveToContent();
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case "name":
                    reader.ReadAttributeValue();
                    status.Name = reader.ReadContentAsString(); break;

                case "value":
                    reader.ReadAttributeValue();
                    var val = reader.ReadContentAsString();
                    status.Value = Convert.ToInt32(val, 16); break;

                case "comment":
                    reader.ReadAttributeValue();
                    status.Comment = reader.ReadContentAsString(); break;

                default:
                    reader.ReadAttributeValue(); break;
                }
            }
            return(status);
        }
Esempio n. 2
0
        protected string ReceiveXmlMessage(System.Xml.XmlReader reader)
        {
            string strCommand = "";

            if (reader.ReadToFollowing("Command"))
            //if (reader.Name == "Command")
            {
                strCommand = reader.GetAttribute("Type");
                Dictionary <string, string> parameterList = new Dictionary <string, string>();

                if (reader.ReadToDescendant("Parameter"))
                {
                    do
                    {
                        string strParameterName  = reader.GetAttribute("Name");
                        string strParameterValue = reader.ReadElementString();

                        parameterList.Add(strParameterName, strParameterValue);
                    } while (reader.ReadToNextSibling("Parameter"));
                }

                switch (strCommand)
                {
                case Commands.Configuration.Command:
                    //load saved configuration values
                    LoadingConfigValues(parameterList);
                    return("");

                case Commands.GetConfiguration.Command:
                    return(ReturnConfiguration());

                //break;

                case Commands.GetSupportedFeatures.Command: // "GetSupportedFeatures":
                    //e.g. Worklist, CurveData, Attachment_Type, Attachment_Path
                    return(ReturnSupportedFeatures());

                //break;
                case Commands.SearchPatients.Command: // "SearchPatient":
                    //list of patients
                    return(ReturnSearchPatientResult(parameterList));

                case Commands.TestResult.Command: // "TestResult":
                    //Do nothing. Results are read from output file.
                    return("");

                default:
                    return(@"
              <ndd>
                <Command Type=""Error"">
                  <Parameter Name=""Message"">Command not supported</Parameter>
                  <Parameter Name=""Details"">" + strCommand + @"</Parameter>
                </Command>
              </ndd>");
                }
            }

            while (reader.Read())
            {
                if (reader.Name == "Patients")
                {
                    System.Xml.XmlReader patientReader = reader.ReadSubtree();
                    while (patientReader.ReadToFollowing("Patient"))
                    {
                        if (patientReader.ReadAttributeValue() && patientReader.AttributeCount > 0)
                        {
                            string strPatientID   = patientReader.GetAttribute("ID");
                            string strPatientNone = patientReader.GetAttribute("NotAvailable");
                        }

                        while (patientReader.Read())
                        {
                            if (patientReader.Name == "FirstName")
                            {
                                string strName = patientReader.ReadString();
                            }
                        }
                    }
                    if (reader.ReadToFollowing("Patient"))
                    {
                    }
                }
            }

            Console.Beep();

            return("");
        }
        public static ThirdPartyDescriptor DescriptorFromClientSideExtrnalCampaign(string content)
        {
            string start = "<external_campaign";
            string end   = "</external_campaign>";

            int startIndex = content.IndexOf(start);
            int endIndex   = content.IndexOf(end, startIndex);

            if ((startIndex == -1) || (endIndex == -1))
            {
                return(null);
            }

            ThirdPartyDescriptor thirdPartyDescriptor = new ThirdPartyDescriptor();

            int length = endIndex - startIndex + end.Length;

            content = content.Substring(startIndex, length);

            System.IO.StringReader stringReader = new System.IO.StringReader(content);

            System.Xml.XmlReaderSettings readerSettings = new System.Xml.XmlReaderSettings();
            readerSettings.IgnoreWhitespace             = true;
            readerSettings.IgnoreComments               = true;
            readerSettings.IgnoreProcessingInstructions = true;

            System.Xml.XmlReader reader = System.Xml.XmlReader.Create(stringReader, readerSettings);

            Stack <string> elementStack = new Stack <string>();

            Dictionary <string, string> elementAttributes = new Dictionary <string, string>();
            string elementContent = null;

            reader.ReadToDescendant("external_campaign");

            while (reader.Read())
            {
                System.Xml.XmlNodeType nodeType = reader.NodeType;
                switch (nodeType)
                {
                case System.Xml.XmlNodeType.Element:
                    elementStack.Push(reader.Name);
                    elementAttributes.Clear();
                    elementContent = null;

                    if (reader.HasAttributes)
                    {
                        for (int i = 0, c = reader.AttributeCount; i < c; ++i)
                        {
                            reader.MoveToAttribute(i);
                            string attributeName = reader.Name;
                            if (reader.ReadAttributeValue())
                            {
                                string attributeValue = reader.Value;
                                if (attributeValue != null)
                                {
                                    elementAttributes[attributeName] = attributeValue;
                                }
                            }
                        }
                    }
                    break;

                case System.Xml.XmlNodeType.EndElement:
                    if (elementStack.Count == 0)
                    {
                        break;
                    }

                    string key = elementStack.Pop();

                    if (elementContent != null)
                    {
                        if (key == "param")
                        {
                            if (elementAttributes.TryGetValue("name", out key))
                            {
                                thirdPartyDescriptor.campaignParams[key] = elementContent;
                            }
                        }
                        else
                        {
                            thirdPartyDescriptor.properties[key] = elementContent;
                        }
                    }

                    elementAttributes.Clear();
                    elementContent = null;
                    break;

                case System.Xml.XmlNodeType.Text:
                case System.Xml.XmlNodeType.CDATA:
                    elementContent = reader.Value;
                    break;
                }
            }

            return(thirdPartyDescriptor);
        }