Exemple #1
0
        private DirectoryType InitCiscoDirectory()
        {
            DirectoryType dir = new DirectoryType();

            dir.name = tbDirectoryName.Text;
            CiscoDatasourceType cdt = new CiscoDatasourceType();

            cdt.server     = tbCiscoServer.Text;
            cdt.axluser    = tbAXLUser.Text;
            cdt.axluserpwd = tbAXLUserPassword.Text;
            dir.Item       = cdt;
            return(dir);
        }
Exemple #2
0
        public static DataSet Search(DirectoryType dir)
        {
            DataSet             results = new DataSet();
            DataTable           dt      = results.Tables.Add();
            CiscoDatasourceType ldt     = (CiscoDatasourceType)dir.Item;

            try
            {
                Init(ldt.server, ldt.axluser, ldt.axluserpwd);
                ExecuteSQLQueryReq query = new ExecuteSQLQueryReq();
                query.sql = "select firstname, lastname, telephonenumber, department from enduser";
                ExecuteSQLQueryRes response = _axl.executeSQLQuery(query);
                dt.Columns.Add("firstname");
                dt.Columns.Add("lastname");
                dt.Columns.Add("telephonenumber");
                dt.Columns.Add("department");
                if (response != null && response.@return != null && [email protected] > 0)
                {
                    foreach (object o in response.@return)
                    {
                        List <object> values = new List <object>();
                        values.Add(((XmlNode[])o)[0].InnerText);
                        values.Add(((XmlNode[])o)[1].InnerText);
                        values.Add(((XmlNode[])o)[2].InnerText);
                        values.Add(((XmlNode[])o)[3].InnerText);
                        dt.Rows.Add(values.ToArray());
                    }
                }
                else
                {
                    log.Error("No result retreive from AXL Server");
                }
                return(results);
            }
            catch (Exception e)
            {
                log.Error(e.Message);
                return(results);
            }
        }
Exemple #3
0
 private DirectoryType InitCiscoDirectory()
 {
     DirectoryType dir = new DirectoryType();
     dir.name = tbDirectoryName.Text;
     CiscoDatasourceType cdt = new CiscoDatasourceType();
     cdt.server = tbCiscoServer.Text;
     cdt.axluser = tbAXLUser.Text;
     cdt.axluserpwd = tbAXLUserPassword.Text;
     dir.Item = cdt;
     return dir;
 }
Exemple #4
0
 private void InitDirectory(DirectoryType dir)
 {
     tbDirectoryName.Text = dir.name;
     if (dir.Item is SqlDatasourceType)
     {
         rblDirectoryType.Items.FindByValue("SQL").Selected = true;
         SqlDatasourceType sdt = (SqlDatasourceType)dir.Item;
         tbSqlDsn.Text     = sdt.dsn;
         tbSqlUid.Text     = sdt.uid;
         tbSqlPwd.Text     = sdt.pwd;
         tbSqlCommand.Text = sdt.command;
         tbSqlFilter.Text  = sdt.sqlFilter;
         foreach (FieldFormatter ffs in sdt.fieldFormatters)
         {
             lbSQLFieldFormatters.Items.Add(new ListItem(ffs.fieldName, ffs.value + "#" + ffs.fieldType.ToString()));
         }
         if (sdt.ipphonefilter != null)
         {
             tbSQLFirstNameFilterMap.Text       = sdt.ipphonefilter.firstnamemap;
             tbSQLLastNameFilterMap.Text        = sdt.ipphonefilter.lastnamemap;
             tbSQLTelephoneNumberFilterMap.Text = sdt.ipphonefilter.telephonenumbermap;
         }
         ShowSQL();
     }
     else if (dir.Item is LdapDatasourceType)
     {
         rblDirectoryType.Items.FindByValue("LDAP").Selected = true;
         LdapDatasourceType ldt = (LdapDatasourceType)dir.Item;
         tbLdapServer.Text = ldt.server;
         ddlLdapAuthentication.Items.FindByText(ldt.authenticationType).Selected = true;
         tbLdapUser.Text         = ldt.user;
         tbLdapUserPassword.Text = ldt.userPassword;
         tbLdapTargetOu.Text     = ldt.targetOU;
         tbLdapFilter.Text       = ldt.ldapFilter;
         tbLdapPageSize.Text     = ldt.pageSize.ToString();
         tbLdapNbPages.Text      = ldt.nbPages.ToString();
         foreach (string attribut in ldt.ldapAttributes)
         {
             lbLdapAttribute.Items.Add(new ListItem(attribut, attribut));
         }
         foreach (FieldFormatter ffl in ldt.fieldFormatters)
         {
             lbLdapFieldFormatters.Items.Add(new ListItem(ffl.fieldName, ffl.value + "#" + ffl.fieldType.ToString()));
         }
         if (ldt.ipphonefilter != null)
         {
             tbLdapFirstNameFilterMap.Text       = ldt.ipphonefilter.firstnamemap;
             tbLdapLastNameFilterMap.Text        = ldt.ipphonefilter.lastnamemap;
             tbLdapTelephoneNumberFilterMap.Text = ldt.ipphonefilter.telephonenumbermap;
         }
         ShowLdap();
     }
     else if (dir.Item is CiscoDatasourceType)
     {
         rblDirectoryType.Items.FindByValue("CISCO").Selected = true;
         CiscoDatasourceType ldt = (CiscoDatasourceType)dir.Item;
         tbCiscoServer.Text     = ldt.server;
         tbAXLUser.Text         = ldt.axluser;
         tbAXLUserPassword.Text = ldt.axluserpwd;
         foreach (FieldFormatter ffc in ldt.fieldFormatters)
         {
             lbCiscoFieldFormatters.Items.Add(new ListItem(ffc.fieldName, ffc.value + "#" + ffc.fieldType.ToString()));
         }
         if (ldt.ipphonefilter != null)
         {
             tbFirstNameFilterMap.Text       = ldt.ipphonefilter.firstnamemap;
             tbLastNameFilterMap.Text        = ldt.ipphonefilter.lastnamemap;
             tbTelephoneNumberFilterMap.Text = ldt.ipphonefilter.telephonenumbermap;
         }
         ShowCisco();
     }
     else
     {
         log.Error("Datasource type unknown...cannot load " + dir.name);
     }
 }
Exemple #5
0
        public void GetResultsForCiscoIPPhone(string directory, string givenName, string sn, string telephonenumber, string pos)
        {
            string gn     = "givenName";
            string name   = "sn";
            string tel    = "telephonenumber";
            string filter = "";
            CiscoIPPhoneDirectoryType             dir   = new CiscoIPPhoneDirectoryType();
            List <CiscoIPPhoneDirectoryEntryType> entry = new List <CiscoIPPhoneDirectoryEntryType>();

            try
            {
                dir.Title = "Recherche répertoire";
                foreach (DirectoryType dt in Global.directoryConfiguration)
                {
                    if (dt.name == directory)
                    {
                        if (dt.Item is SqlDatasourceType)
                        {
                            SqlDatasourceType sdt = dt.Item as SqlDatasourceType;
                            if (sdt.ipphonefilter != null)
                            {
                                gn   = sdt.ipphonefilter.firstnamemap;
                                name = sdt.ipphonefilter.lastnamemap;
                                tel  = sdt.ipphonefilter.telephonenumbermap;
                            }
                        }
                        else if (dt.Item is LdapDatasourceType)
                        {
                            LdapDatasourceType ldt = dt.Item as LdapDatasourceType;
                            if (ldt.ipphonefilter != null)
                            {
                                gn   = ldt.ipphonefilter.firstnamemap;
                                name = ldt.ipphonefilter.lastnamemap;
                                tel  = ldt.ipphonefilter.telephonenumbermap;
                            }
                        }
                        else if (dt.Item is CiscoDatasourceType)
                        {
                            CiscoDatasourceType cdt = dt.Item as CiscoDatasourceType;
                            if (cdt.ipphonefilter != null)
                            {
                                gn   = cdt.ipphonefilter.firstnamemap;
                                name = cdt.ipphonefilter.lastnamemap;
                                tel  = cdt.ipphonefilter.telephonenumbermap;
                            }
                        }
                        filter = gn + " LIKE '" + givenName.Trim() + "*' AND " + name + " LIKE '" + sn.Trim() + "*' AND " + tel + " LIKE '" + telephonenumber.Trim() + "*'";
                    }
                }

                DataTable results      = null;
                int       identityCol  = 0;
                int       telephoneCol = 0;
                foreach (DirectoryType dt in Global.directoryConfiguration)
                {
                    if (dt.name == directory)
                    {
                        FieldFormatter[] ffs = null;
                        if (dt.Item is SqlDatasourceType)
                        {
                            ffs = ((SqlDatasourceType)dt.Item).fieldFormatters;
                        }
                        else if (dt.Item is LdapDatasourceType)
                        {
                            ffs = ((LdapDatasourceType)dt.Item).fieldFormatters;
                        }
                        else if (dt.Item is CiscoDatasourceType)
                        {
                            ffs = ((CiscoDatasourceType)dt.Item).fieldFormatters;
                        }
                        int cpt = 0;
                        foreach (FieldFormatter ff in ffs)
                        {
                            if (ff.fieldType == FieldType.Identity)
                            {
                                identityCol = cpt;
                            }
                            if (ff.fieldType == FieldType.Telephone)
                            {
                                telephoneCol = cpt;
                            }

                            cpt++;
                        }

                        break;
                    }
                }
                if (HttpRuntime.Cache.Get(directory + "_" + filter) != null)
                {
                    results = (DataTable)HttpRuntime.Cache.Get(directory + "_" + filter);
                }
                else
                {
                    if (HttpRuntime.Cache.Get(directory) != null)
                    {
                        DataSet  fromCache = (DataSet)HttpRuntime.Cache.Get(directory);
                        DataView dv        = null;
                        try
                        {
                            if (fromCache != null)
                            {
                                dv           = fromCache.Tables[0].AsDataView();
                                dv.RowFilter = filter;
                                DataTable calcTable = dv.ToTable("CalcTable");
                                foreach (DirectoryType dt in Global.directoryConfiguration)
                                {
                                    if (dt.name == directory)
                                    {
                                        FieldFormatter[] ffs  = null;
                                        List <string>    cols = new List <string>();
                                        if (dt.Item is SqlDatasourceType)
                                        {
                                            ffs = ((SqlDatasourceType)dt.Item).fieldFormatters;
                                        }
                                        else if (dt.Item is LdapDatasourceType)
                                        {
                                            ffs = ((LdapDatasourceType)dt.Item).fieldFormatters;
                                        }
                                        else if (dt.Item is CiscoDatasourceType)
                                        {
                                            ffs = ((CiscoDatasourceType)dt.Item).fieldFormatters;
                                        }

                                        foreach (FieldFormatter ff in ffs)
                                        {
                                            cols.Add(ff.fieldName);
                                            if (!calcTable.Columns.Contains(ff.fieldName))
                                            {
                                                DataColumn dc = new DataColumn();
                                                dc.DataType   = typeof(string);
                                                dc.ColumnName = ff.fieldName;
                                                dc.Expression = ff.value;
                                                calcTable.Columns.Add(dc);
                                            }
                                        }
                                        DataView sortedView = calcTable.AsDataView();
                                        if (cols.Count > 0)
                                        {
                                            sortedView.Sort = cols[identityCol];
                                        }
                                        results      = sortedView.ToTable("Results", false, cols.ToArray());
                                        dv           = results.AsDataView();
                                        dv.RowFilter = results.Columns[telephoneCol].ColumnName + " <> ''";
                                        results      = dv.ToTable();
                                        HttpRuntime.Cache.Insert(directory + "_" + filter, results, null, DateTime.Now.AddMinutes(Double.Parse(System.Web.Configuration.WebConfigurationManager.AppSettings.Get("DMDRefreshTimer"))), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                log.Debug("Cache is null, no data to retreive...");
                            }
                        }
                        catch (Exception e)
                        {
                            log.Error("Error while searching: " + e.Message);
                        }
                    }
                }
                if (results.Rows.Count > 0)
                {
                    if ((Int32.Parse(pos) + 32) >= results.Rows.Count)
                    {
                        dir.Prompt  = "Enreg. " + (Int32.Parse(pos) + 1).ToString() + " à " + results.Rows.Count.ToString() + " sur " + results.Rows.Count.ToString();
                        dir.SoftKey = new CiscoIPPhoneSoftKeyType[4];

                        dir.SoftKey[0]                  = new CiscoIPPhoneSoftKeyType();
                        dir.SoftKey[0].Name             = "Compos.";
                        dir.SoftKey[0].URL              = "SoftKey:Dial";
                        dir.SoftKey[0].URLDown          = "";
                        dir.SoftKey[0].Postion          = 1;
                        dir.SoftKey[0].PostionSpecified = true;

                        dir.SoftKey[1]                  = new CiscoIPPhoneSoftKeyType();
                        dir.SoftKey[1].Name             = "EditNum.";
                        dir.SoftKey[1].URL              = "SoftKey:EditDial";
                        dir.SoftKey[1].URLDown          = "";
                        dir.SoftKey[1].Postion          = 2;
                        dir.SoftKey[1].PostionSpecified = true;


                        dir.SoftKey[2]                  = new CiscoIPPhoneSoftKeyType();
                        dir.SoftKey[2].Name             = "Quitter";
                        dir.SoftKey[2].URL              = "SoftKey:Exit";
                        dir.SoftKey[2].URLDown          = "";
                        dir.SoftKey[2].Postion          = 3;
                        dir.SoftKey[2].PostionSpecified = true;

                        dir.SoftKey[3]                  = new CiscoIPPhoneSoftKeyType();
                        dir.SoftKey[3].Name             = "Recher.";
                        dir.SoftKey[3].URL              = this.Context.Request.Url.AbsoluteUri.Substring(0, this.Context.Request.Url.AbsoluteUri.LastIndexOf("/") + 1) + "SearchForCiscoIPPhone?directory=" + System.Web.HttpUtility.UrlEncode(directory);
                        dir.SoftKey[3].URLDown          = "";
                        dir.SoftKey[3].Postion          = 4;
                        dir.SoftKey[3].PostionSpecified = true;
                    }
                    else
                    {
                        dir.Prompt = "Enreg. " + (Int32.Parse(pos) + 1).ToString() + " à " + (Int32.Parse(pos) + 32).ToString() + " sur " + results.Rows.Count.ToString();
                        this.Context.Response.AddHeader("Refresh", ";url=" + this.Context.Request.Url.AbsoluteUri.Substring(0, this.Context.Request.Url.AbsoluteUri.LastIndexOf("/") + 1) + "GetResultsForCiscoIPPhone?directory=" + System.Web.HttpUtility.UrlEncode(directory) + "&givenName=" + System.Web.HttpUtility.UrlEncode(givenName) + "&sn=" + System.Web.HttpUtility.UrlEncode(sn) + "&telephonenumber=" + System.Web.HttpUtility.UrlEncode(telephonenumber) + "&pos=" + System.Web.HttpUtility.UrlEncode((Int32.Parse(pos) + 32).ToString()));
                        dir.SoftKey = new CiscoIPPhoneSoftKeyType[5];

                        dir.SoftKey[0]                  = new CiscoIPPhoneSoftKeyType();
                        dir.SoftKey[0].Name             = "Compos.";
                        dir.SoftKey[0].URL              = "SoftKey:Dial";
                        dir.SoftKey[0].URLDown          = "";
                        dir.SoftKey[0].Postion          = 1;
                        dir.SoftKey[0].PostionSpecified = true;

                        dir.SoftKey[1]                  = new CiscoIPPhoneSoftKeyType();
                        dir.SoftKey[1].Name             = "EditNum.";
                        dir.SoftKey[1].URL              = "SoftKey:EditDial";
                        dir.SoftKey[1].URLDown          = "";
                        dir.SoftKey[1].Postion          = 2;
                        dir.SoftKey[1].PostionSpecified = true;

                        dir.SoftKey[2]                  = new CiscoIPPhoneSoftKeyType();
                        dir.SoftKey[2].Name             = "Quitter";
                        dir.SoftKey[2].URL              = "SoftKey:Exit";
                        dir.SoftKey[2].URLDown          = "";
                        dir.SoftKey[2].Postion          = 3;
                        dir.SoftKey[2].PostionSpecified = true;

                        dir.SoftKey[3]                  = new CiscoIPPhoneSoftKeyType();
                        dir.SoftKey[3].Name             = "Suivant";
                        dir.SoftKey[3].URL              = "SoftKey:Update";
                        dir.SoftKey[3].URLDown          = "";
                        dir.SoftKey[3].Postion          = 4;
                        dir.SoftKey[3].PostionSpecified = true;

                        dir.SoftKey[4]                  = new CiscoIPPhoneSoftKeyType();
                        dir.SoftKey[4].Name             = "Recher.";
                        dir.SoftKey[4].URL              = this.Context.Request.Url.AbsoluteUri.Substring(0, this.Context.Request.Url.AbsoluteUri.LastIndexOf("/") + 1) + "SearchForCiscoIPPhone?directory=" + System.Web.HttpUtility.UrlEncode(directory);
                        dir.SoftKey[4].URLDown          = "";
                        dir.SoftKey[4].Postion          = 5;
                        dir.SoftKey[4].PostionSpecified = true;
                    }
                    for (int cptRow = Int32.Parse(pos); cptRow <= Int32.Parse(pos) + 31; cptRow++)
                    {
                        if (cptRow < results.Rows.Count)
                        {
                            CiscoIPPhoneDirectoryEntryType dirEntry = new CiscoIPPhoneDirectoryEntryType();
                            dirEntry.Name      = (string)results.Rows[cptRow][identityCol];
                            dirEntry.Telephone = (string)results.Rows[cptRow][telephoneCol];
                            entry.Add(dirEntry);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    dir.Prompt  = "Pas d'enregistrement trouvé";
                    dir.SoftKey = new CiscoIPPhoneSoftKeyType[2];

                    dir.SoftKey[0]                  = new CiscoIPPhoneSoftKeyType();
                    dir.SoftKey[0].Name             = "Quitter";
                    dir.SoftKey[0].URL              = "SoftKey:Exit";
                    dir.SoftKey[0].URLDown          = "";
                    dir.SoftKey[0].Postion          = 3;
                    dir.SoftKey[0].PostionSpecified = true;

                    dir.SoftKey[1]                  = new CiscoIPPhoneSoftKeyType();
                    dir.SoftKey[1].Name             = "Recher.";
                    dir.SoftKey[1].URL              = this.Context.Request.Url.AbsoluteUri.Substring(0, this.Context.Request.Url.AbsoluteUri.LastIndexOf("/") + 1) + "SearchForCiscoIPPhone?directory=" + System.Web.HttpUtility.UrlEncode(directory);
                    dir.SoftKey[1].URLDown          = "";
                    dir.SoftKey[1].Postion          = 1;
                    dir.SoftKey[1].PostionSpecified = true;
                }

                dir.DirectoryEntry = entry.ToArray();

                //return dir;
                CiscoIPPhoneDirectoryTypeSerializer xml      = new CiscoIPPhoneDirectoryTypeSerializer();
                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, dir, xmlnsEmpty);
                ms.Position = 0;
                this.Context.Response.ContentType     = "text/xml";
                this.Context.Response.ContentEncoding = System.Text.Encoding.UTF8;
                this.Context.Response.Write(GetStringFromStream(ms));
            }
            catch (Exception e)
            {
                log.Error("Unable to build Cisco Ipphone Directory 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 dir;
            }
        }
Exemple #6
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;
            }
        }