示例#1
0
        public void SearchForCiscoIPPhone(string directory)
        {
            CicsoIPPhoneInputType input = new CicsoIPPhoneInputType();

            try
            {
                input.Prompt = "Entrer un critère de recherche";
                input.Title  = "Recherche répertoire";

                input.InputItem = new CiscoIPPhoneInputItemType[3];

                input.InputItem[1] = new CiscoIPPhoneInputItemType();
                input.InputItem[1].DefaultValue     = " ";
                input.InputItem[1].DisplayName      = "Prénom";
                input.InputItem[1].InputFlags       = "A";
                input.InputItem[1].QueryStringParam = "givenName";

                input.InputItem[0] = new CiscoIPPhoneInputItemType();
                input.InputItem[0].DefaultValue     = " ";
                input.InputItem[0].DisplayName      = "Nom";
                input.InputItem[0].InputFlags       = "A";
                input.InputItem[0].QueryStringParam = "sn";

                input.InputItem[2] = new CiscoIPPhoneInputItemType();
                input.InputItem[2].DefaultValue     = " ";
                input.InputItem[2].DisplayName      = "Numéro de tél";
                input.InputItem[2].InputFlags       = "T";
                input.InputItem[2].QueryStringParam = "telephonenumber";

                input.URL = this.Context.Request.Url.AbsoluteUri.Substring(0, this.Context.Request.Url.AbsoluteUri.LastIndexOf("/") + 1) + "GetResultsForCiscoIPPhone?directory=" + System.Web.HttpUtility.UrlEncode(directory) + "&pos=0";
                //return input;
                CicsoIPPhoneInputTypeSerializer xml      = new CicsoIPPhoneInputTypeSerializer();
                System.Xml.XmlWriterSettings    settings = new System.Xml.XmlWriterSettings();;
                settings.Encoding = System.Text.Encoding.UTF8;
                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                System.Xml.XmlWriter   xw = System.Xml.XmlWriter.Create(ms, settings);
                System.Xml.Serialization.XmlSerializerNamespaces xmlnsEmpty = new System.Xml.Serialization.XmlSerializerNamespaces();
                xmlnsEmpty.Add("", "");
                xml.Serialize(xw, input, xmlnsEmpty);
                ms.Position = 0;
                this.Context.Response.ContentType     = "text/xml";
                this.Context.Response.ContentEncoding = System.Text.Encoding.UTF8;
                this.Context.Response.Write(GetStringFromStream(ms));
                //ms.Flush();
                //ms.Close();
            }
            catch (Exception e)
            {
                log.Error("Unable to build Cisco Ipphone Input Type: " + e.Message);
                this.Context.Response.Redirect(this.Context.Request.Url.AbsoluteUri.Substring(0, this.Context.Request.Url.AbsoluteUri.LastIndexOf("/") + 1) + "Error?error=" + System.Web.HttpUtility.UrlEncode(e.Message), false);
                //return input;
            }
        }
 void Write19_CicsoIPPhoneInputType(string n, string ns, CicsoIPPhoneInputType o, bool isNullable, bool needType) {
     if ((object)o == null) {
         if (isNullable) WriteNullTagLiteral(n, ns);
         return;
     }
     if (!needType) {
         System.Type t = o.GetType();
         if (t == typeof(CicsoIPPhoneInputType)) {
         }
         else {
             throw CreateUnknownTypeException(o);
         }
     }
     WriteStartElement(n, ns, o, false, null);
     if (needType) WriteXsiType(@"CicsoIPPhoneInputType", @"");
     WriteNullableStringLiteral(@"Title", @"", ((global::System.String)o.@Title));
     WriteNullableStringLiteral(@"Prompt", @"", ((global::System.String)o.@Prompt));
     WriteNullableStringLiteral(@"URL", @"", ((global::System.String)o.@URL));
     {
         CiscoIPPhoneInputItemType[] a = (CiscoIPPhoneInputItemType[])o.@InputItem;
         if (a != null) {
             for (int ia = 0; ia < a.Length; ia++) {
                 Write7_CiscoIPPhoneInputItemType(@"InputItem", @"", ((CiscoIPPhoneInputItemType)a[ia]), false, false);
             }
         }
     }
     {
         CiscoIPPhoneSoftKeyType[] a = (CiscoIPPhoneSoftKeyType[])o.@SoftKeyItem;
         if (a != null) {
             for (int ia = 0; ia < a.Length; ia++) {
                 Write3_CiscoIPPhoneSoftKeyType(@"SoftKeyItem", @"", ((CiscoIPPhoneSoftKeyType)a[ia]), false, false);
             }
         }
     }
     WriteEndElement(o);
 }
 CicsoIPPhoneInputType Read19_CicsoIPPhoneInputType(bool isNullable, bool checkType) {
     System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null;
     bool isNull = false;
     if (isNullable) isNull = ReadNull();
     if (checkType) {
     if (xsiType == null || ((object) ((System.Xml.XmlQualifiedName)xsiType).Name == (object)id49_CicsoIPPhoneInputType && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) {
     }
     else
         throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType);
     }
     if (isNull) return null;
     CicsoIPPhoneInputType o;
     o = new CicsoIPPhoneInputType();
     CiscoIPPhoneInputItemType[] a_3 = null;
     int ca_3 = 0;
     CiscoIPPhoneSoftKeyType[] a_4 = null;
     int ca_4 = 0;
     bool[] paramsRead = new bool[5];
     while (Reader.MoveToNextAttribute()) {
         if (!IsXmlnsAttribute(Reader.Name)) {
             UnknownNode((object)o);
         }
     }
     Reader.MoveToElement();
     if (Reader.IsEmptyElement) {
         Reader.Skip();
         o.@InputItem = (CiscoIPPhoneInputItemType[])ShrinkArray(a_3, ca_3, typeof(CiscoIPPhoneInputItemType), true);
         o.@SoftKeyItem = (CiscoIPPhoneSoftKeyType[])ShrinkArray(a_4, ca_4, typeof(CiscoIPPhoneSoftKeyType), true);
         return o;
     }
     Reader.ReadStartElement();
     Reader.MoveToContent();
     int whileIterations8 = 0;
     int readerCount8 = ReaderCount;
     while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) {
         if (Reader.NodeType == System.Xml.XmlNodeType.Element) {
             if (!paramsRead[0] && ((object) Reader.LocalName == (object)id43_Title && (object) Reader.NamespaceURI == (object)id2_Item)) {
                 if (ReadNull()) {
                     o.@Title = null;
                 }
                 else {
                     o.@Title = Reader.ReadElementString();
                 }
                 paramsRead[0] = true;
             }
             else if (!paramsRead[1] && ((object) Reader.LocalName == (object)id44_Prompt && (object) Reader.NamespaceURI == (object)id2_Item)) {
                 if (ReadNull()) {
                     o.@Prompt = null;
                 }
                 else {
                     o.@Prompt = Reader.ReadElementString();
                 }
                 paramsRead[1] = true;
             }
             else if (!paramsRead[2] && ((object) Reader.LocalName == (object)id38_URL && (object) Reader.NamespaceURI == (object)id2_Item)) {
                 if (ReadNull()) {
                     o.@URL = null;
                 }
                 else {
                     o.@URL = Reader.ReadElementString();
                 }
                 paramsRead[2] = true;
             }
             else if (((object) Reader.LocalName == (object)id50_InputItem && (object) Reader.NamespaceURI == (object)id2_Item)) {
                 a_3 = (CiscoIPPhoneInputItemType[])EnsureArrayIndex(a_3, ca_3, typeof(CiscoIPPhoneInputItemType));a_3[ca_3++] = Read7_CiscoIPPhoneInputItemType(false, true);
             }
             else if (((object) Reader.LocalName == (object)id51_SoftKeyItem && (object) Reader.NamespaceURI == (object)id2_Item)) {
                 a_4 = (CiscoIPPhoneSoftKeyType[])EnsureArrayIndex(a_4, ca_4, typeof(CiscoIPPhoneSoftKeyType));a_4[ca_4++] = Read3_CiscoIPPhoneSoftKeyType(false, true);
             }
             else {
                 UnknownNode((object)o, @":Title, :Prompt, :URL, :InputItem, :SoftKeyItem");
             }
         }
         else {
             UnknownNode((object)o, @":Title, :Prompt, :URL, :InputItem, :SoftKeyItem");
         }
         Reader.MoveToContent();
         CheckReaderCount(ref whileIterations8, ref readerCount8);
     }
     o.@InputItem = (CiscoIPPhoneInputItemType[])ShrinkArray(a_3, ca_3, typeof(CiscoIPPhoneInputItemType), true);
     o.@SoftKeyItem = (CiscoIPPhoneSoftKeyType[])ShrinkArray(a_4, ca_4, typeof(CiscoIPPhoneSoftKeyType), true);
     ReadEndElement();
     return o;
 }