CiscoIPPhoneMenuItemType Read2_CiscoIPPhoneMenuItemType(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)id3_CiscoIPPhoneMenuItemType && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) {
     }
     else
         throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType);
     }
     if (isNull) return null;
     CiscoIPPhoneMenuItemType o;
     o = new CiscoIPPhoneMenuItemType();
     bool[] paramsRead = new bool[2];
     while (Reader.MoveToNextAttribute()) {
         if (!IsXmlnsAttribute(Reader.Name)) {
             UnknownNode((object)o);
         }
     }
     Reader.MoveToElement();
     if (Reader.IsEmptyElement) {
         Reader.Skip();
         return o;
     }
     Reader.ReadStartElement();
     Reader.MoveToContent();
     int whileIterations14 = 0;
     int readerCount14 = 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)id46_Name && (object) Reader.NamespaceURI == (object)id2_Item)) {
                 if (ReadNull()) {
                     o.@Name = null;
                 }
                 else {
                     o.@Name = Reader.ReadElementString();
                 }
                 paramsRead[0] = true;
             }
             else if (!paramsRead[1] && ((object) Reader.LocalName == (object)id38_URL && (object) Reader.NamespaceURI == (object)id2_Item)) {
                 if (ReadNull()) {
                     o.@URL = null;
                 }
                 else {
                     o.@URL = Reader.ReadElementString();
                 }
                 paramsRead[1] = true;
             }
             else {
                 UnknownNode((object)o, @":Name, :URL");
             }
         }
         else {
             UnknownNode((object)o, @":Name, :URL");
         }
         Reader.MoveToContent();
         CheckReaderCount(ref whileIterations14, ref readerCount14);
     }
     ReadEndElement();
     return o;
 }
 void Write2_CiscoIPPhoneMenuItemType(string n, string ns, CiscoIPPhoneMenuItemType 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(CiscoIPPhoneMenuItemType)) {
         }
         else {
             throw CreateUnknownTypeException(o);
         }
     }
     WriteStartElement(n, ns, o, false, null);
     if (needType) WriteXsiType(@"CiscoIPPhoneMenuItemType", @"");
     WriteNullableStringLiteral(@"Name", @"", ((global::System.String)o.@Name));
     WriteNullableStringLiteral(@"URL", @"", ((global::System.String)o.@URL));
     WriteEndElement(o);
 }
Exemple #3
0
        public void GetDirectoriesForCiscoIPPhone()
        {
            CiscoIPPhoneMenuType menu = new CiscoIPPhoneMenuType();

            menu.Prompt = "Sélectionner un répertoire";
            menu.Title  = "Répertoires";
            try
            {
                List <CiscoIPPhoneMenuItemType> menus = new List <CiscoIPPhoneMenuItemType>();

                foreach (DirectoryType dt in Global.directoryConfiguration)
                {
                    CiscoIPPhoneMenuItemType menuitem = null;
                    bool isIPPhoneCompliant           = false;
                    if (dt.Item is SqlDatasourceType)
                    {
                        SqlDatasourceType sdt = dt.Item as SqlDatasourceType;
                        if (sdt.ipphonefilter != null)
                        {
                            isIPPhoneCompliant = true;
                        }
                    }
                    else if (dt.Item is LdapDatasourceType)
                    {
                        LdapDatasourceType ldt = dt.Item as LdapDatasourceType;
                        if (ldt.ipphonefilter != null)
                        {
                            isIPPhoneCompliant = true;
                        }
                    }
                    else if (dt.Item is CiscoDatasourceType)
                    {
                        CiscoDatasourceType cdt = dt.Item as CiscoDatasourceType;
                        if (cdt.ipphonefilter != null)
                        {
                            isIPPhoneCompliant = true;
                        }
                    }
                    if (isIPPhoneCompliant)
                    {
                        menuitem      = new CiscoIPPhoneMenuItemType();
                        menuitem.Name = dt.name;
                        menuitem.URL  = this.Context.Request.Url.AbsoluteUri.Substring(0, this.Context.Request.Url.AbsoluteUri.LastIndexOf("/") + 1) + "SearchForCiscoIPPhone?directory=" + System.Web.HttpUtility.UrlEncode(dt.name);
                        menus.Add(menuitem);
                    }
                }
                if (menus.Count > 0)
                {
                    menu.MenuItem = menus.ToArray();
                }
                else
                {
                    this.Context.Response.Redirect(this.Context.Request.Url.AbsoluteUri.Substring(0, this.Context.Request.Url.AbsoluteUri.LastIndexOf("/") + 1) + "Error?error=" + System.Web.HttpUtility.UrlEncode("No ipphone directories finded"), false);
                    //return menu;
                }
                //return menu;
                CiscoIPPhoneMenuTypeSerializer xml      = new CiscoIPPhoneMenuTypeSerializer();
                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, menu, xmlnsEmpty);
                ms.Position = 0;
                this.Context.Response.ContentType     = "text/xml";
                this.Context.Response.ContentEncoding = System.Text.Encoding.UTF8;
                this.Context.Response.Write(GetStringFromStream(ms));
                //xw.Flush();
                //xw.Close();
            }
            catch (Exception e)
            {
                log.Error("Unable get directories: " + 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 menu;
            }
        }