Example #1
0
        private void TestCisco()
        {
            DirectoryType dir = InitCiscoDirectory();

            try
            {
                DataSet ds = CiscoDataSource.Search(dir);
                lblResult.Text = ds.Tables[0].Rows.Count.ToString() + " results retreived";
            }
            catch (Exception e)
            {
                lblResult.Text = e.Message + " - " + e.InnerException.Message;
            }
        }
Example #2
0
        private static void InitDirectoryCache()
        {
            if (directoryConfiguration != null)
            {
                foreach (DirectoryType dt in directoryConfiguration)
                {
                    log.Debug("DirectoryType: " + dt.ToString());
                    try
                    {
                        DataSet          ds  = null;
                        FieldFormatter[] ffs = null;
                        if (dt.Item is SqlDatasourceType)
                        {
                            ds = SQL.Search(dt);

                            ffs = ((SqlDatasourceType)dt.Item).fieldFormatters;
                        }
                        else if (dt.Item is LdapDatasourceType)
                        {
                            ds  = LDAP.Search(dt);
                            ffs = ((LdapDatasourceType)dt.Item).fieldFormatters;
                        }
                        else if (dt.Item is CiscoDatasourceType)
                        {
                            ds  = CiscoDataSource.Search(dt);
                            ffs = ((CiscoDatasourceType)dt.Item).fieldFormatters;
                        }
                        //HttpRuntime.Cache.Insert(dt.name, ds, null, DateTime.Now.AddHours(10), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, OnCacheSuppress);
                        HttpRuntime.Cache.Insert(dt.name, ds, null, DateTime.Now.AddMinutes(Double.Parse(System.Web.Configuration.WebConfigurationManager.AppSettings.Get("DMDRefreshTimer"))), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, OnCacheSuppress);
                        if (ds != null && ds.Tables.Count > 0)
                        {
                            log.Debug("Result dataset contains " + ds.Tables.Count.ToString() + " table: " + ds.Tables[0].TableName);
                            DataTable calcTable = ds.Tables[0];

                            List <string> cols = new List <string>();

                            foreach (FieldFormatter ff in ffs)
                            {
                                cols.Add(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[0];
                            }
                            calcTable = sortedView.ToTable("Results", false, cols.ToArray());
                            //HttpRuntime.Cache.Insert(dt.name + "_formated", calcTable, null, DateTime.Now.AddHours(10), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, OnCacheSuppress);
                            HttpRuntime.Cache.Insert(dt.name + "_formated", calcTable, null, DateTime.Now.AddMinutes(Double.Parse(System.Web.Configuration.WebConfigurationManager.AppSettings.Get("DMDRefreshTimer"))), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, OnCacheSuppress);
                        }
                    }
                    catch (Exception e)
                    {
                        log.Error("Unable to search the directory " + dt.name + ": " + e.Message);
                    }
                }
            }
            else
            {
                log.Error("Configuration file is empty or does not exist");
            }
        }