Ejemplo n.º 1
0
    private void LoadIndexes()
    {
        if ((_Indexes == null) || (_Indexes.Count == 0))
        {
            IRepository <IIndexDefinition> rep = EntityFactory.GetRepository <IIndexDefinition>();
            IQueryable         qry             = (IQueryable)rep;
            IExpressionFactory ef        = qry.GetExpressionFactory();
            ICriteria          crit      = qry.CreateCriteria();
            IExpression        accessExp = ef.Le("UserAccess", _UserType);
            crit.Add(ef.And(accessExp, ef.Eq("Enabled", true)));
            crit.AddOrder(ef.Asc("IndexName"));
            IList <IIndexDefinition> tempIndexes = crit.List <IIndexDefinition>();

            //c.Add(NHibernate.Expression.Expression.Eq("Enabled", true));
            //c.Add(Expression.Le("UserAccess", _UserType));
            //c.AddOrder(Order.Asc("IndexName"));
            //List<IndexDefinition> tempIndexes = (List<IndexDefinition>)c.List<IndexDefinition>();

            Assembly interfaceAsm = Assembly.GetAssembly(typeof(IIndexDefinition));
            Type[]   types        = interfaceAsm.GetTypes();
            _TablesEntities = new Dictionary <string, Type>();
            foreach (Type entity in types)
            {
                AttributeCollection attrs = TypeDescriptor.GetAttributes(entity);
                foreach (Attribute attr in attrs)
                {
                    ActiveRecordAttribute activeRecord = attr as ActiveRecordAttribute;
                    if (activeRecord != null)
                    {
                        _TablesEntities.Add(activeRecord.Table.ToUpper(), entity);
                    }
                }
            }
            _Indexes = new List <IIndexDefinition>();
            foreach (IIndexDefinition index in tempIndexes)
            {
                if (index.Type == 1) // database index
                {
                    DBIndexDefinition dbid = DBIndexDefinition.SetFromString(index.MetaData);
                    if (_TablesEntities.ContainsKey(dbid.MainTable.ToUpper()))
                    {
                        _Indexes.Add(index);
                    }
                }
                else
                {
                    _Indexes.Add(index);
                }
            }
        }
    }
Ejemplo n.º 2
0
    private void LoadIndexes()
    {
        if ((_indexes == null) || (_indexes.Count == 0))
        {
            var rep       = EntityFactory.GetRepository <IIndexDefinition>();
            var qry       = (IQueryable)rep;
            var ef        = qry.GetExpressionFactory();
            var crit      = qry.CreateCriteria();
            var accessExp = ef.Le("UserAccess", _userType);
            crit.Add(ef.And(accessExp, ef.Eq("Enabled", true)));
            crit.AddOrder(ef.Asc("IndexName"));
            var tempIndexes = crit.List <IIndexDefinition>();

            var interfaceAsm = Assembly.GetAssembly(typeof(IIndexDefinition));
            var types        = interfaceAsm.GetTypes();
            _tablesEntities = new Dictionary <string, Type>();
            foreach (var entity in types)
            {
                var attrs = TypeDescriptor.GetAttributes(entity);
                foreach (var activeRecord in Enumerable.OfType <ActiveRecordAttribute>(attrs))
                {
                    _tablesEntities.Add(activeRecord.Table.ToUpper(), entity);
                }
            }
            _indexes = new List <IIndexDefinition>();
            foreach (var index in tempIndexes)
            {
                if (index.Type == 1) // database index
                {
                    var dbid = DBIndexDefinition.SetFromString(index.MetaData);
                    if (_tablesEntities.ContainsKey(dbid.MainTable.ToUpper()))
                    {
                        _indexes.Add(index);
                    }
                }
                else
                {
                    _indexes.Add(index);
                }
            }
        }
    }
Ejemplo n.º 3
0
    private void CreateIndexControls()
    {
        if (_Indexes != null)
        {
            Literal outerDiv = new Literal();
            outerDiv.Text = "<div style='border:inset 1px;overflow-y:scroll;height:160px;'>";
            PlaceHolder1.Controls.Add(outerDiv);

            int itemCount = 0;
            foreach (IIndexDefinition id in _Indexes)
            {
                if (id.Type == 1)
                {
                    DBIndexDefinition dbid = DBIndexDefinition.SetFromString(id.MetaData);
                    _DBIndexDefs.Add(dbid);
                    foreach (SlxFieldDefinition fd in dbid.FilterFields)
                    {
                        fd.IndexType = 1;
                        SlxFieldDefinition temp;
                        if (_SearchFilters.ContainsKey(fd.DisplayName))
                        {
                            _SearchFilters.TryGetValue(fd.DisplayName, out temp);
                            temp.CommonIndexes += "," + id.IndexName;
                            _SearchFilters.Remove(fd.DisplayName);
                        }
                        else
                        {
                            temp = SlxFieldDefinition.SetFromString(fd.GetAsString());
                            temp.CommonIndexes = id.IndexName;
                        }
                        _SearchFilters.Add(temp.DisplayName, temp);
                    }
                }
                else
                {
                    if (!_SearchFilters.ContainsKey("File Name"))
                    {
                        SlxFieldDefinition fd = new SlxFieldDefinition();
                        fd.DisplayName = "name";
                        fd.FieldType   = 1;
                        fd.IndexType   = 0;
                        _SearchFilters.Add("File Name", fd);
                    }
                    if (!_SearchFilters.ContainsKey("File Last Modified"))
                    {
                        SlxFieldDefinition fd = new SlxFieldDefinition();
                        fd.DisplayName = "date";
                        fd.FieldType   = 11;
                        fd.IndexType   = 0;
                        _SearchFilters.Add("File Last Modified", fd);
                    }
                    if (!_SearchFilters.ContainsKey("File Date Created"))
                    {
                        SlxFieldDefinition fd = new SlxFieldDefinition();
                        fd.DisplayName = "created";
                        fd.FieldType   = 11;
                        fd.IndexType   = 0;
                        _SearchFilters.Add("File Date Created", fd);
                    }
                }
                Literal rowDiv = new Literal();
                rowDiv.Text = "<div>";
                PlaceHolder1.Controls.Add(rowDiv);

                CheckBox cb = new CheckBox();
                cb.ID   = "Index" + itemCount.ToString();
                cb.Text = Localize(IndexDefinitionToResourceKey(id), id.IndexName);
                cb.LabelAttributes.Add("id", "lblIndex" + itemCount.ToString());
                cb.Checked  = true;
                cb.CssClass = "slxlabel";
                cb.Style.Add(HtmlTextWriterStyle.MarginLeft, "5px");
                cb.ForeColor = Color.Navy;
                PlaceHolder1.Controls.Add(cb);

                Literal endRowDiv = new Literal();
                endRowDiv.Text = "</div>";
                PlaceHolder1.Controls.Add(endRowDiv);
                itemCount++;
            }
            Literal endouterDiv = new Literal();
            endouterDiv.Text = "</div>";
            PlaceHolder1.Controls.Add(endouterDiv);
        }
        CreateFilterControls();
    }
Ejemplo n.º 4
0
    private void CreateIndexControls()
    {
        if (_indexes != null)
        {
            var outerDiv = new Literal {
                Text = "<div style='border:solid 1px #cccccc;overflow-y:scroll;height:160px;'>"
            };
            PlaceHolder1.Controls.Add(outerDiv);

            var itemCount = 0;
            foreach (var id in _indexes)
            {
                if (id.Type == 1)
                {
                    var dbid = DBIndexDefinition.SetFromString(id.MetaData);
                    _dbIndexDefs.Add(dbid);
                    foreach (var fd in dbid.FilterFields)
                    {
                        fd.IndexType = 1;
                        SlxFieldDefinition temp;
                        if (_searchFilters.ContainsKey(fd.DisplayName))
                        {
                            _searchFilters.TryGetValue(fd.DisplayName, out temp);
                            temp.CommonIndexes += "," + id.IndexName;
                            _searchFilters.Remove(fd.DisplayName);
                        }
                        else
                        {
                            temp = SlxFieldDefinition.SetFromString(fd.GetAsString());
                            temp.CommonIndexes = id.IndexName;
                        }
                        _searchFilters.Add(temp.DisplayName, temp);
                    }
                }
                else
                {
                    if (!_searchFilters.ContainsKey("File Name"))
                    {
                        var fd = new SlxFieldDefinition {
                            DisplayName = "filename", FieldType = 1, IndexType = 0
                        };
                        _searchFilters.Add("File Name", fd);
                    }
                    if (!_searchFilters.ContainsKey("File Last Modified"))
                    {
                        var fd = new SlxFieldDefinition {
                            DisplayName = "date", FieldType = 11, IndexType = 0
                        };
                        _searchFilters.Add("File Last Modified", fd);
                    }
                    if (!_searchFilters.ContainsKey("File Date Created"))
                    {
                        var fd = new SlxFieldDefinition {
                            DisplayName = "created", FieldType = 11, IndexType = 0
                        };
                        _searchFilters.Add("File Date Created", fd);
                    }
                }
                var rowDiv = new Literal {
                    Text = "<div>"
                };
                PlaceHolder1.Controls.Add(rowDiv);

                var cb = new CheckBox
                {
                    ID   = "Index" + itemCount,
                    Text = Localize(IndexDefinitionToResourceKey(id), id.IndexName)
                };
                cb.LabelAttributes.Add("id", "lblIndex" + itemCount);
                cb.Checked = true;
                cb.Style.Add(HtmlTextWriterStyle.MarginLeft, "5px");
                cb.CssClass = "inforAspCheckBox";
                PlaceHolder1.Controls.Add(cb);

                var endRowDiv = new Literal {
                    Text = "</div>"
                };
                PlaceHolder1.Controls.Add(endRowDiv);
                itemCount++;
            }
            var endouterDiv = new Literal {
                Text = "</div>"
            };
            PlaceHolder1.Controls.Add(endouterDiv);
        }
        CreateFilterControls();
    }