Esempio n. 1
0
        public List <IObjectTemplate> GetTemplatesByDataset(string datasetName)
        {
            List <IObjectTemplate> templates = new List <IObjectTemplate>();
            ITable pTemplateTable            = _workspace.OpenTable("YT_TEMPLATE_FEATURECLASS");


            IQueryFilter pFilter1 = new QueryFilter();

            pFilter1.WhereClause = "Dataset='" + datasetName + "'";

            ICursor pCursor = pTemplateTable.Search(pFilter1, false);

            int[]        fieldIndexes = new int[6];
            IRow         pRow         = pCursor.NextRow();
            IQueryFilter pQueryFilter = new QueryFilter();

            IObjectTemplate oneTemplate = null;

            while (pRow != null)
            {
                oneTemplate = new ObjectTemplate(pRow);
                templates.Add(oneTemplate);
                pRow = pCursor.NextRow();
            }
            ComReleaser.ReleaseCOMObject(pFilter1);
            ComReleaser.ReleaseCOMObject(pCursor);
            ComReleaser.ReleaseCOMObject(pTemplateTable);
            return(templates);
        }
Esempio n. 2
0
        //public void LoadTemplates()
        //{
        //    if (_workspace == null)
        //    {
        //        Connect();
        //    }
        //    if (_templates!=null)
        //        _templates.Clear();
        //   else
        //        _templates=new List<IObjectTemplate>();
        //    ITable pTemplateTable = _workspace.OpenTable("YT_TEMPLATE_FEATURECLASS");
        //    ITable pTemplateFields= _workspace.OpenTable("YT_TEMPLATE_FIELD");

        //    ITableSort tableSort = new TableSort();
        //    tableSort.Table = pTemplateTable;
        //    tableSort.Fields = "TemplateName";
        //    tableSort.Sort(null);

        //    ICursor pCursor = tableSort.Rows;
        //    int[] fieldIndexes = new int[6];
        //    IRow pRow = pCursor.NextRow();
        //    IQueryFilter pQueryFilter = new QueryFilter();

        //    IObjectTemplate oneTemplate = null;
        //    while (pRow != null)
        //    {
        //        oneTemplate = new ObjectTemplate(pRow);
        //        pQueryFilter.WhereClause = "TemplateName='" + oneTemplate.Name+"'";
        //        ICursor pCursor1 = pTemplateFields.Search(pQueryFilter, false);
        //        IRow fieldRow = pCursor1.NextRow();
        //        while (fieldRow != null)
        //        {
        //            YTField ytField=new YTField(fieldRow);
        //            oneTemplate.Fields.Add(ytField);
        //            fieldRow = pCursor1.NextRow();
        //        }
        //        ComReleaser.ReleaseCOMObject(pCursor1);
        //        oneTemplate.Database = this;
        //        _templates.Add(oneTemplate);
        //        pRow = pCursor.NextRow();
        //    }
        //    ComReleaser.ReleaseCOMObject(pCursor);
        //    ComReleaser.ReleaseCOMObject(pTemplateTable);
        //    ComReleaser.ReleaseCOMObject(pTemplateFields);
        //}


        public void LoadTemplates()
        {
            if (_workspace == null)
            {
                Connect();
            }
            if (_templates != null)
            {
                _templates.Clear();
            }
            else
            {
                _templates = new List <IObjectTemplate>();
            }
            ITable pTemplateTable = _workspace.OpenTable("YT_TEMPLATE_FEATURECLASS");


            ITableSort tableSort = new TableSort();

            tableSort.Table  = pTemplateTable;
            tableSort.Fields = "TemplateName";
            tableSort.Sort(null);

            ICursor pCursor = tableSort.Rows;

            int[]        fieldIndexes = new int[6];
            IRow         pRow         = pCursor.NextRow();
            IQueryFilter pQueryFilter = new QueryFilter();

            IObjectTemplate oneTemplate = null;

            while (pRow != null)
            {
                oneTemplate          = new ObjectTemplate(pRow);
                oneTemplate.Database = this;
                _templates.Add(oneTemplate);
                pRow = pCursor.NextRow();
            }
            ComReleaser.ReleaseCOMObject(pCursor);
            ComReleaser.ReleaseCOMObject(pTemplateTable);
        }